Example #1
0
def test_load_osm():
    outfile = 'tmp-file.osm'
    data = etl2osm.extract(roads['geojson'])
    data.save(outfile)
    assert os.path.exists(outfile)
    os.remove(outfile)

    data = etl2osm.extract(addresses['geojson'])
    data.save(outfile)
    assert os.path.exists(outfile)
    os.remove(outfile)
Example #2
0
def test_load_geojson():
    outfile = 'tmp-file.geojson'
    data = etl2osm.extract(roads['lake_county'])
    data.transform(config={'foo': {'text': 'bar'}})
    data.save(outfile)
    assert os.path.exists(outfile)
    os.remove(outfile)
Example #3
0
def test_extract_geojson():
    data = etl2osm.extract(roads['geojson'])
    assert data.crs == crs
    assert data.epsg == 'EPSG:4326'
    assert data.geojson
    assert 'LineString' in data.geometry
    assert data.properties
    assert len(data)
Example #4
0
def test_load_no_geometry():
    outfile = 'tmp-file.osm'
    data = etl2osm.extract(geojson['no-geometry'])
    data.save(outfile)
    assert os.path.exists(outfile)
    os.remove(outfile)

    # ---------->>>>>>>>>-------------------
    # TO-DO: Find corrupt Shapefile
    # This shapefile does contain all it's goemetry
    # Coverage: extract.py LINE 93
    # Trigger: logging.warning('Could not find [geometry] in feature.')
    # ---------->>>>>>>>>-------------------
    data = etl2osm.extract(shapefile['no-geometry'])
    data.save(outfile)
    assert os.path.exists(outfile)
    os.remove(outfile)
Example #5
0
def test_extract_point():
    feature = {
        "type": "Feature",
        "geometry": {
            "type": "Point",
            "coordinates": [100.0, 0.0]
        }
    }
    data = etl2osm.extract(feature)
    assert data[0]['geometry']['type'] == 'Point'
Example #6
0
def test_extract_multi_point():
    feature = {
        "type": "Feature",
        "geometry": {
            "type": "MultiPoint",
            "coordinates": [[100.0, 0.0], [101.0, 1.0]]
        }
    }
    data = etl2osm.extract(feature)
    assert data[0]['geometry']['type'] == 'MultiPoint'
Example #7
0
def test_load_shapefile():
    outfile = 'tmp-file.shp'
    basename = os.path.splitext(outfile)[0]

    data = etl2osm.extract(roads['lake_county'])
    data.transform(config={'foo': {'text': 'bar'}})
    data.save(outfile)

    for ext in ['.shp', '.cpg', '.dbf', '.prj', '.shx']:
        filepath = ''.join((basename, ext))
        assert os.path.exists(filepath)
        os.remove(filepath)
Example #8
0
def test_speed_extract_shapefile(infile=roads['shp']):
    """
    Geometry: set(['LineString']) | count: 3 | time: 302 ms/feature
    Geometry: set(['Polygon']) | count: 106218 | time: 1 ms/feature
    """
    before = datetime.now()
    data = etl2osm.extract(infile)
    microseconds = (datetime.now() - before).microseconds
    print 'Geometry: {} | count: {} | time: {} ms/feature'.format(
        data.geometry,
        len(data),
        microseconds / len(data)
    )
Example #9
0
def test_speed_extract_geojson(infile=roads['geojson']):
    """
    Geometry: set([u'LineString']) | count: 17057 | time: 36 ms/feature
    Geometry: set([u'LineString']) | count: 3 | time: 55 ms/feature
    """
    before = datetime.now()
    data = etl2osm.extract(infile)
    microseconds = (datetime.now() - before).microseconds
    print 'Geometry: {} | count: {} | time: {} ms/feature'.format(
        data.geometry,
        len(data),
        microseconds / len(data)
    )
Example #10
0
def test_speed_transform_false(infile=roads['geojson']):
    """
    Geometry: set(['LineString']) | Reproject: False | count: 18809 | time: 1 ms/feature
    Geometry: set(['Point']) | Reproject: False | count: 31478 | time: 1 ms/feature
    Geometry: set(['Polygon']) | Reproject: False | count: 106218 | time: 1 ms/feature
    """
    data = etl2osm.extract(infile)
    before = datetime.now()
    data.transform(reproject=False)
    microseconds = (datetime.now() - before).microseconds
    print 'Geometry: {} | Reproject: False | count: {} | time: {} ms/feature'.format(
        data.geometry,
        len(data),
        microseconds / len(data)
    )
Example #11
0
def test_extract_blank():
    with pytest.raises(ValueError):
        etl2osm.extract(roads['geojson-blank'])
Example #12
0
def test_extract_file_extension():
    with pytest.raises(ValueError):
        etl2osm.extract("/path-not-exist.topojson")

    with pytest.raises(ValueError):
        etl2osm.extract("/path-not-exist.shp")
Example #13
0
def test_extract_zero():
    with pytest.raises(ValueError):
        etl2osm.extract(roads['geojson-zero'])
Example #14
0
def test_extract_unknown():
    with pytest.raises(ValueError):
        etl2osm.extract(roads['unknown'])
Example #15
0
def test_extract_shapefile():
    data = etl2osm.extract(roads['shp'])
    assert data.epsg == 'EPSG:4326'
    assert data.crs
    assert data.geojson
    assert len(data)
Example #16
0
def test_extract_lookup():
    data = etl2osm.extract(roads['geojson'])
    assert data[0]
Example #17
0
def test_overlapping_osm_nodes():
    outfile = 'tmp-file.osm'
    data = etl2osm.extract(geojson['overlapping'])
    data.save(outfile)
    assert os.path.exists(outfile)
    os.remove(outfile)
Example #18
0
def test_load_kml():
    outfile = 'tmp-file.kml'
    data = etl2osm.extract(roads['geojson'])
    with pytest.raises(ValueError):
        data.save(outfile)
Example #19
0
def test_extract_add():
    data1 = etl2osm.extract(roads['geojson'])
    data2 = etl2osm.extract(roads['geojson'])
    assert len(data1) == 3
    assert len(data2) == 3
    assert len(data1 + data2) == 6
Example #20
0
def test_extract_kml():
    with pytest.raises(ValueError):
        etl2osm.extract(roads['kml'])
Example #21
0
def test_extract_topojson():
    with pytest.raises(ValueError):
        etl2osm.extract(roads['topojson'])
Example #22
0
def test_extract_shapefile_utm():
    data = etl2osm.extract(shapefile['utm_projection'])
    assert data.epsg != 'EPSG:4326'
    data.transform()
    assert data.epsg == 'EPSG:4326'
Example #23
0
def test_extract_lake_county_roads():
    data = etl2osm.extract(roads['lake_county'])
    assert data.geojson
    assert len(data)
Example #24
0
def test_extract_osm():
    with pytest.raises(ValueError):
        etl2osm.extract(roads['osm'])
Example #25
0
def test_api_extract():
    data = etl2osm.extract(roads['geojson'])
    assert data.geojson
    assert data.epsg
Example #26
0
def test_transform_geojson():
    data = etl2osm.extract(roads['geojson'])
    data.transform()
    assert data.epsg == 'EPSG:4326'