def load_geom(source): geom = None # source is a wkt file if os.path.exists(os.path.abspath(source)): data = None with open(os.path.abspath(source), 'r') as fp: data = fp.read(50) # load WKT geometry and remove leading whitespaces if data.lower().lstrip().startswith(('polygon', 'multipolygon')): geom = load_polygons(source) # source is an OGR datasource if geom is None: geom = load_datasource(source) if geom: # get the first and maybe only geometry if not check_wgs84_srs(geom[0]): log.error('Geometry is not in EPSG:4326') return None if rtree: return LimitRTreeGeometry(geom) else: log.info('You should install RTree for large --limit-to polygons') return LimitPolygonGeometry(build_multipolygon(geom)[1]) return None
def load_geom(source): geom = load_datasource(source) if geom: # get the first and maybe only geometry if not check_wgs84_srs(geom[0]): log.error('Geometry is not in EPSG:4326') return None if rtree: return LimitRTreeGeometry(geom) else: log.info('You should install RTree for large --limit-to polygons') return LimitPolygonGeometry(build_multipolygon(geom)[1]) return None