Пример #1
0
def run(oldpath, newpath):
    """
    Runs the 14th basic test suite. Tests:

    Importing time sequential ascii
    """
    inputASCII = os.path.join(oldpath, INPUT_ASCII)
    info = generic.getLidarFileInfo(inputASCII)

    importedSPD = os.path.join(newpath, IMPORTED_SPD)
    translate(info, inputASCII, importedSPD, COLTYPES, constCols=CONST_COLS)
    utils.compareLiDARFiles(os.path.join(oldpath, IMPORTED_SPD), importedSPD)
Пример #2
0
def run(oldpath, newpath):
    """
    Runs the 20th basic test suite. Tests:

    Importing an LVIS ASCII file
    """
    inputASC = os.path.join(oldpath, INPUT_ASCII)
    info = generic.getLidarFileInfo(inputASC)

    importedSPD = os.path.join(newpath, IMPORTED_SPD)
    translate(info,
              inputASC,
              importedSPD,
              colTypes=COLTYPES,
              pulseCols=PULSECOLS,
              scaling=SCALING)
    utils.compareLiDARFiles(os.path.join(oldpath, IMPORTED_SPD), importedSPD)
Пример #3
0
def run():
    """
    Main function. Looks at the command line arguments
    and calls the appropiate translation function.
    """
    cmdargs = getCmdargs()
    wktStr = None
    if cmdargs.wktfile is not None:
        wktStr = open(cmdargs.wktfile).read()

    # first determine the format of the input file
    # I'm not sure this is possible in all situations, but assume it is for now
    info = generic.getLidarFileInfo(cmdargs.input)
    inFormat = info.getDriverName()

    if inFormat == 'LAS' and cmdargs.format == 'SPDV4':
        las2spdv4.translate(info, cmdargs.input, cmdargs.output, cmdargs.range,
                            cmdargs.spatial, cmdargs.extent, cmdargs.scaling,
                            cmdargs.epsg, cmdargs.binsize, cmdargs.buildpulses,
                            cmdargs.pulseindex, cmdargs.null, cmdargs.constcol,
                            cmdargs.lasscalings)

    elif inFormat == 'SPDV3' and cmdargs.format == 'SPDV4':
        spdv32spdv4.translate(info, cmdargs.input, cmdargs.output,
                              cmdargs.range, cmdargs.spatial, cmdargs.extent,
                              cmdargs.scaling, cmdargs.null, cmdargs.constcol)

    elif inFormat == 'riegl RXP' and cmdargs.format == 'SPDV4':
        rieglrxp2spdv4.translate(info,
                                 cmdargs.input,
                                 cmdargs.output,
                                 cmdargs.range,
                                 cmdargs.scaling,
                                 cmdargs.internalrotation,
                                 cmdargs.magneticdeclination,
                                 cmdargs.externalrotationfn,
                                 cmdargs.null,
                                 cmdargs.constcol,
                                 epsg=cmdargs.epsg,
                                 wkt=wktStr)

    elif inFormat == 'riegl RDB' and cmdargs.format == 'SPDV4':
        rieglrdb2spdv4.translate(info,
                                 cmdargs.input,
                                 cmdargs.output,
                                 cmdargs.range,
                                 cmdargs.scaling,
                                 cmdargs.null,
                                 cmdargs.constcol,
                                 epsg=cmdargs.epsg,
                                 wkt=wktStr)

    elif inFormat == 'SPDV4' and cmdargs.format == 'LAS':
        spdv42las.translate(info, cmdargs.input, cmdargs.output,
                            cmdargs.spatial, cmdargs.extent)

    elif inFormat == 'ASCII' and cmdargs.format == 'SPDV4':

        if cmdargs.coltype is None:
            msg = "must pass --coltypes parameter"
            raise generic.LiDARInvalidSetting(msg)

        if cmdargs.pulsecols is not None:
            pulsecols = cmdargs.pulsecols.split(',')
        else:
            pulsecols = None

        classtrans = None
        if cmdargs.classtrans is not None:
            # translate strings to codes
            for internalCode, strLasCode in cmdargs.classtrans:
                internalCode = int(internalCode)
                strLasCodeFull = "CLASSIFICATION_%s" % strLasCode
                try:
                    lasCode = getattr(lidarprocessor, strLasCodeFull)
                except AttributeError:
                    msg = 'class %s not understood' % strLasCode
                    raise generic.LiDARInvalidSetting(msg)

                if classtrans is None:
                    classtrans = []
                classtrans.append((internalCode, lasCode))

        ascii2spdv4.translate(info, cmdargs.input, cmdargs.output,
                              cmdargs.coltype, pulsecols, cmdargs.range,
                              cmdargs.scaling, classtrans, cmdargs.null,
                              cmdargs.constcol)

    elif inFormat == 'LVIS Binary' and cmdargs.format == 'SPDV4':

        lvisbin2spdv4.translate(info, cmdargs.input, cmdargs.output,
                                cmdargs.range, cmdargs.scaling, cmdargs.null,
                                cmdargs.constcol)

    elif inFormat == 'LVIS HDF5' and cmdargs.format == 'SPDV4':

        lvishdf52spdv4.translate(info, cmdargs.input, cmdargs.output,
                                 cmdargs.range, cmdargs.scaling, cmdargs.null,
                                 cmdargs.constcol)

    elif inFormat == 'PulseWaves' and cmdargs.format == 'SPDV4':

        pulsewaves2spdv4.translate(info, cmdargs.input, cmdargs.output,
                                   cmdargs.range, cmdargs.scaling,
                                   cmdargs.null, cmdargs.constcol)

    elif inFormat == 'SPDV4' and cmdargs.format == 'PULSEWAVES':
        spdv42pulsewaves.translate(info, cmdargs.input, cmdargs.output)

    else:
        msg = 'Cannot convert between formats %s and %s'
        msg = msg % (inFormat, cmdargs.format)
        raise generic.LiDARFunctionUnsupported(msg)