Ejemplo n.º 1
0
def test_api_process():
    outfile = 'tmp-filepath.geojson'
    data = etl2osm.process(roads['geojson'], outfile, config={'foo': {'text': 'bar'}})
    assert data.geojson
    assert data.epsg
    assert os.path.exists(outfile)
    os.remove(outfile)

    data = etl2osm.process(roads['geojson'], outfile)
    assert data.geojson
    assert data.epsg
    assert os.path.exists(outfile)
    os.remove(outfile)
Ejemplo n.º 2
0
import re
import etl2osm
from etl2osm import Models

models = Models()
path = '/home/denis/Downloads/canvec_021G_shp'

for root, dirs, files in os.walk(path):
    for file_name in files:
        if '.geojson' in file_name:
            pattern = r'(?P<theme>[a-zA-Z]{2})_(?P<feature>\d+)_(?P<version>\d+)'
            match = re.search(pattern, file_name)
            if match:
                theme = models.canvecThemes.get(match.group('theme'))
                feature = models.canvecFeatures.get(int(match.group('feature')))
                version = match.group('version')
                if feature:
                    infile = os.path.join(root, file_name)
                    outfile = os.path.join(root, '{} - {}.osm'.format(theme, feature))
                    if feature == 'Road segment':
                        config = {
                            'name': "rtename1en",
                            "name:fr": "rtename1fr",
                            "speed": {"field": "speedrestr", "model": "canvecRoadSegementSpeedrestr"},
                            "highway": {"field": "roadclass", "model": "canvecRoadSegementRoadclass"},
                            "canvec:roadclass": "roadclass",
                            "surface": {"field": "pavstatus", "model": "canvecRoadSegementPavstatus"}
                        }
                        print 'Processing:', outfile
                        etl2osm.process(infile, outfile, config=config)
Ejemplo n.º 3
0
def cli(infile, outfile, config, **kwargs):
    """Command Line Interface for ETL2OSM"""

    etl2osm.process(infile, outfile, config=config, **kwargs)