예제 #1
0
    for proj4Standard, srid in Session.execute('SELECT proj4text, srid FROM spatial_ref_sys'):
        # Skip empty proj4s
        if not proj4Standard.strip():
            continue
        # If we have a match,
        if simplifyProj4(proj4Standard) == proj4Simplified:
            return srid
    # If we have no matches, raise exception
    raise model.GeoRegistryError('Could not recognize proj4 spatial reference')


# If we are running standalone,
if __name__ == '__main__':
    # Parse
    optionParser = script_process.buildOptionParser()
    options, arguments = optionParser.parse_args()
    # Load countryPackByAlpha3
    countryPackByAlpha3 = {}
    countryPath = store.expandBasePath('utilities/countries.csv')
    for countryName, countryAlpha2, countryAlpha3 in csv.reader(open(countryPath, 'rt')):
        countryPackByAlpha3[countryAlpha3.upper()] = countryName, countryAlpha2.upper()
    # Initialize
    script_process.initialize(options)
    person = Session.query(model.Person).filter_by(username='******').first()
    personID = person.id
    folderPath = arguments[0] if arguments else ''
    # For each filePath,
    for filePath in sorted(glob.glob(os.path.join(folderPath, '*.shp'))):
        # Run
        print run(filePath)
예제 #2
0
def buildOptionParser():
    'Return default optionParser'
    optionParser = optparse.OptionParser()
    optionParser.add_option('-c', '--configurationPath', dest='configurationPath', help='use the specified configuration file', metavar='PATH', default=store.expandBasePath('development.ini'))
    return optionParser