예제 #1
0
파일: geom.py 프로젝트: kaiCu/imposm
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
예제 #2
0
파일: geom.py 프로젝트: aroche/imposm
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
예제 #3
0
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
예제 #4
0
파일: geom.py 프로젝트: quiqua/imposm
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