def test_claim(self): import dsl z, x, y = 16, 0, 0 self.generate_fixtures( # XA's claim relation dsl.way(1, dsl.tile_diagonal(z, x, y), { 'admin_level': '6', 'boundary': 'claim', 'name': 'XA county claim', 'claimed_by': 'XA', 'disputed_by': 'XB', 'source': 'openstreetmap.org', }), # XA's claim _way_, disputed by XB dsl.way(2, dsl.tile_diagonal(z, x, y), { 'disputed': 'yes', 'disputed_by': 'XB', 'source': 'openstreetmap.org', }), ) self.assert_has_feature( z, x, y, 'boundaries', { 'kind': 'unrecognized_county', 'kind:xa': 'county', })
def test_backfill_more_important_than_eroad(self): import dsl # randomly chosen tile with the M4 motorway west of London, GB z, x, y = (16, 32680, 21796) # although we model these both as "ways", this is really just a way to # get geometry into the pipeline. in real usage, the admin_area comes # from a static shapefile. self.generate_fixtures( dsl.way(1, dsl.tile_box(z, x, y), {'kind': 'admin_area', 'iso_code': 'GB', 'source': 'openstreetmap.org'}), dsl.way(2, dsl.tile_diagonal(z, x, y), {'highway': 'motorway', 'ref': 'M4', 'source': 'openstreetmap.org'}), dsl.relation( 1, { 'network': 'e-road', 'route': 'road', 'ref': 'E 30', 'type': 'route', }, ways=[2], ), ) # the main network should be GB, not e-road self.assert_has_feature( z, x, y, 'roads', {'id': 2, 'network': 'GB:M-road', 'shield_text': 'M4'})
def test_dispute(self): import dsl z, x, y = 16, 0, 0 self.generate_fixtures( # way, tagged disputed dsl.way(1, dsl.tile_diagonal(z, x, y), { 'admin_level': '4', 'boundary': 'administrative', 'disputed': 'yes', 'disputed_by': 'XB', 'name': 'XA internal county border', 'source': 'openstreetmap.org', }), # line from relation / county polygon dsl.way(3, dsl.tile_diagonal(z, x, y), { 'admin_level': '6', 'boundary': 'administrative', 'name': 'XA county 2', 'place': 'District', 'type': 'boundary', 'mz_boundary_from_polygon': True, # need this for hack }), ) self.assert_has_feature( z, x, y, 'boundaries', { 'kind': 'county', 'kind:xb': 'unrecognized_county', 'name': 'XA county 2', })
def test_generative_non_maritime(self): import dsl z, x, y = (8, 44, 88) self.generate_fixtures( dsl.way(1, dsl.tile_box(z, x, y), { 'source': 'tilezen.org', 'maritime_boundary': True, 'min_zoom': 0, 'kind': 'maritime', }), dsl.way(2, dsl.tile_diagonal(z, x, y), { 'source': 'openstreetmap.org', 'boundary': 'administrative', 'admin_level': '2', 'mz_boundary_from_polygon': True, # need this for hack }), ) self.assert_has_feature( z, x, y, 'boundaries', { 'kind': 'country', 'maritime_boundary': type(None), })
def test_s_road_not_in_t_relation(self): import dsl z, x, y = (16, 60607, 37966) self.generate_fixtures( dsl.way(1, dsl.tile_box(z, x, y), { 'kind': 'admin_area', 'iso_code': 'AU', 'source': 'openstreetmap.org' }), # https://www.openstreetmap.org/way/13851986 dsl.way(13851986, dsl.tile_diagonal(z, x, y), { 'source': 'openstreetmap.org', 'ref': '31;T8', 'name': 'Waterworks Road', 'highway': 'primary', 'surface': 'paved' }), dsl.relation(1, { 'network': 'S', 'ref': '31', 'route': 'road', 'addr:state': 'QLD', 'source': 'openstreetmap.org', 'type': 'route', 'addr:country': 'AU' }, ways=[13851986]), ) self.assert_has_feature( z, x, y, 'roads', { 'id': 13851986, 'shield_text': '31', 'network': 'AU:S-route', 'all_networks': ['AU:S-route', 'AU:T-drive'], 'all_shield_texts': ['31', '8'], })
def test_s_road_in_both_relations(self): import dsl z, x, y = (16, 60644, 38056) self.generate_fixtures( dsl.way(1, dsl.tile_box(z, x, y), { 'kind': 'admin_area', 'iso_code': 'AU', 'source': 'openstreetmap.org' }), # https://www.openstreetmap.org/way/240922938 dsl.way(240922938, dsl.tile_diagonal(z, x, y), { 'source:name': 'survey', 'maxspeed': '60', 'lanes': '2', 'name': 'Beaudesert Beenleigh Road', 'source:maxspeed': 'sign', 'surface': 'asphalt', 'source': 'openstreetmap.org', 'source:ref': 'survey', 'ref': '92;T8', 'highway': 'primary', 'network': 'S', }), dsl.relation(1, { 'network': 'S', 'ref': '92', 'route': 'road', 'addr:state': 'QLD', 'source': 'openstreetmap.org', 'type': 'route', 'addr:country': 'AU', }, ways=[240922938]), dsl.relation(2, { 'type': 'route', 'route': 'road', 'ref': '8', 'network': 'T', 'source': 'openstreetmap.org' }, ways=[240922938]), ) self.assert_has_feature( z, x, y, 'roads', { 'id': 240922938, 'shield_text': '92', 'network': 'AU:S-route', 'all_networks': ['AU:S-route', 'AU:T-drive'], 'all_shield_texts': ['92', '8'], })
def test_building_part(self): import dsl from tilequeue.tile import coord_to_bounds from shapely.geometry import box from ModestMaps.Core import Coordinate z, x, y = (16, 0, 0) bounds = coord_to_bounds(Coordinate(zoom=z, column=x, row=y)) shape = box(*bounds) self.generate_fixtures( dsl.way(1, shape, {'landuse': 'park', 'source': 'openstreetmap.org'}), dsl.way(2, shape, {'building': 'yes', 'source': 'openstreetmap.org'}), dsl.way(3, shape, {'building:part': 'yes', 'source': 'openstreetmap.org'}), ) self.assert_has_feature( z, x, y, 'buildings', {'id': 2, 'kind': 'building', 'landuse_kind': 'park'}) self.assert_has_feature( z, x, y, 'buildings', {'id': 3, 'kind': 'building_part', 'landuse_kind': 'park'})
def test_a_road_in_relation(self): import dsl z, x, y = (16, 58007, 39547) self.generate_fixtures( dsl.way(1, dsl.tile_box(z, x, y), { 'kind': 'admin_area', 'iso_code': 'AU', 'source': 'openstreetmap.org' }), # https://www.openstreetmap.org/way/582052008 dsl.way(582052008, dsl.tile_diagonal(z, x, y), { 'maxspeed': '60', 'lanes': '2', 'name': 'North East Road', 'surface': 'paved', 'cycleway': 'lane', 'source': 'openstreetmap.org', 'oneway': 'yes', 'ref': 'A10', 'highway': 'primary' }), dsl.relation(1, { 'type': 'route', 'route': 'road', 'ref': 'A10', 'addr:country': 'AU', 'addr:state': 'SA', 'source': 'openstreetmap.org' }, ways=[582052008]), ) self.assert_has_feature( z, x, y, 'roads', {'id': 582052008, 'shield_text': 'A10', 'network': 'AU:A-road', 'all_networks': ['AU:A-road'], 'all_shield_texts': ['A10']})
def test_ring_route(self): import dsl z, x, y = (16, 58001, 39557) self.generate_fixtures( dsl.way(1, dsl.tile_box(z, x, y), { 'kind': 'admin_area', 'iso_code': 'AU', 'source': 'openstreetmap.org', }), # https://www.openstreetmap.org/way/7795168 dsl.way(7795168, dsl.tile_diagonal(z, x, y), { 'maxspeed': '60', 'name': 'Hackney Road', 'surface': 'asphalt', 'cycleway': 'lane', 'source': 'openstreetmap.org', 'postal_code': '5069', 'oneway': 'yes', 'ref': 'R1', 'highway': 'primary', }), dsl.relation(1, { 'ref': 'R1', 'route': 'road', 'addr:state': 'SA', 'source': 'openstreetmap.org', 'type': 'route', 'addr:country': 'AU' }, ways=[7795168]), ) self.assert_has_feature( z, x, y, 'roads', {'id': 7795168, 'shield_text': '1', 'network': 'AU:R-route'})
def test_metroad(self): import dsl z, x, y = (16, 60622, 37990) self.generate_fixtures( dsl.way(1, dsl.tile_box(z, x, y), { 'kind': 'admin_area', 'iso_code': 'AU', 'source': 'openstreetmap.org', }), # https://www.openstreetmap.org/way/463027243 dsl.way(463027243, dsl.tile_diagonal(z, x, y), { 'maxspeed': '60', 'lanes': '2', 'name': 'Granard Road', 'surface': 'asphalt', 'source': 'openstreetmap.org', 'oneway': 'yes', 'ref': 'MR2', 'highway': 'trunk', 'network': 'MR', }), dsl.relation(1, { 'type': 'route', 'route': 'road', 'ref': '2', 'network': 'MR', 'source': 'openstreetmap.org', }, ways=[463027243]), ) self.assert_has_feature( z, x, y, 'roads', {'id': 463027243, 'shield_text': '2', 'network': 'AU:Metro-road'})
def test_d_road(self): import dsl z, x, y = (16, 57903, 38425) self.generate_fixtures( dsl.way(1, dsl.tile_box(z, x, y), { 'kind': 'admin_area', 'iso_code': 'AU', 'source': 'openstreetmap.org' }), # https://www.openstreetmap.org/way/229978585 dsl.way(229978585, dsl.tile_diagonal(z, x, y), { 'maxspeed': '80', 'lanes': '2', 'name': 'The Outback Highway', 'source': 'openstreetmap.org', 'surface': 'paved', 'name:source': 'data.sa.gov.au roads', 'ref': 'D83', 'highway': 'secondary', }), dsl.relation(1, { 'type': 'route', 'route': 'road', 'ref': 'D83', 'source': 'openstreetmap.org' }, ways=[229978585]), ) self.assert_has_feature( z, x, y, 'roads', { 'id': 229978585, 'shield_text': '83', 'network': 'AU', })
def test_m_road(self): import dsl z, x, y = (16, 60296, 39327) self.generate_fixtures( dsl.way(1, dsl.tile_box(z, x, y), { 'kind': 'admin_area', 'iso_code': 'AU', 'source': 'openstreetmap.org' }), # https://www.openstreetmap.org/way/3188239 dsl.way(3188239, dsl.tile_diagonal(z, x, y), { 'old_ref': '1', 'maxspeed': '60', 'lanes': '2', 'name': 'Cahill Expressway', 'toll': 'yes', 'surface': 'asphalt', 'source': 'openstreetmap.org', 'ref:start_date': '2013-08', 'oneway': 'yes', 'ref': 'M1', 'highway': 'motorway', 'old_network': 'MR', }), dsl.relation(1, { 'ref': 'M1', 'route': 'road', 'addr:state': 'NSW', 'source': 'openstreetmap.org', 'type': 'route', 'addr:country': 'AU' }, ways=[3188239]), ) self.assert_has_feature( z, x, y, 'roads', {'id': 3188239, 'shield_text': 'M1', 'network': 'AU:M-road'})
def test_s_road_not_in_s_relation(self): import dsl z, x, y = (16, 60571, 37936) self.generate_fixtures( dsl.way(1, dsl.tile_box(z, x, y), { 'kind': 'admin_area', 'iso_code': 'AU', 'source': 'openstreetmap.org' }), # https://www.openstreetmap.org/way/16477624 dsl.way(16477624, dsl.tile_diagonal(z, x, y), { 'source': 'openstreetmap.org', 'ref': '31;T9', 'name': 'Mount Glorious Road', 'highway': 'secondary' }), dsl.relation(1, { 'network': 'T', 'ref': '9', 'route': 'road', 'addr:state': 'QLD', 'source': 'openstreetmap.org', 'type': 'route', 'addr:country': 'AU' }, ways=[16477624]), ) self.assert_has_feature( z, x, y, 'roads', { 'id': 16477624, 'shield_text': '9', 'network': 'AU:T-drive', 'all_networks': ['AU:T-drive', 'AU'], 'all_shield_texts': ['9', '31'], })
def test_c_road(self): import dsl z, x, y = (16, 59435, 40315) self.generate_fixtures( dsl.way(1, dsl.tile_box(z, x, y), { 'kind': 'admin_area', 'iso_code': 'AU', 'source': 'openstreetmap.org', }), # https://www.openstreetmap.org/way/7787334 dsl.way(7787334, dsl.tile_diagonal(z, x, y), { 'name': 'Churchill - Traralgon Road', 'surface': 'paved', 'source': 'openstreetmap.org', 'oneway': 'yes', 'ref': 'C475;C476', 'highway': 'secondary', }), dsl.relation(1, { 'name': 'Mattingley Hill Road', 'ref': 'C475', 'route': 'road', 'addr:state': 'VIC', 'source': 'openstreetmap.org', 'type': 'route', 'addr:country': 'AU', }, ways=[7787334]), dsl.relation(2, { 'ref': 'C476', 'route': 'road', 'addr:state': 'VIC', 'source': 'openstreetmap.org', 'type': 'route', 'addr:country': 'AU', }, ways=[7787334]), ) self.assert_has_feature( z, x, y, 'roads', { 'id': 7787334, 'shield_text': 'C475', 'network': 'AU:C-road', 'all_shield_texts': ['C475', 'C476'], 'all_networks': ['AU:C-road', 'AU:C-road'], })
def test_drop_label(self): from shapely.ops import transform from tilequeue.tile import reproject_mercator_to_lnglat import math import dsl thresholds = { 8: 200000000, 9: 100000000, 10: 10000000, 11: 4000000, 12: 750000, 13: 100000, 14: 50000, 15: 10000, } for zoom in range(8, 16): area = thresholds.get(zoom) radius = math.sqrt(area / math.pi) coord = 2 ** (zoom - 1) # larger feature should retain name shape = dsl.tile_centre_shape( zoom, coord, coord).buffer(radius * 1.1) shape_lnglat = transform( reproject_mercator_to_lnglat, shape) self.generate_fixtures( dsl.way(1, shape_lnglat, { 'natural': 'water', 'name': 'Foo', }), ) self.assert_has_feature( zoom, coord, coord, 'water', { 'kind': 'water', 'name': 'Foo', }) # smaller shape should drop it shape = dsl.tile_centre_shape( zoom, coord, coord).buffer(radius / 1.1) shape_lnglat = transform( reproject_mercator_to_lnglat, shape) self.generate_fixtures( dsl.way(1, shape_lnglat, { 'natural': 'water', 'name': 'Foo', }), ) self.assert_has_feature( zoom, coord, coord, 'water', { 'kind': 'water', 'name': type(None), })
def _check_downgrade_poi(self, tags, kind, min_zoom): import dsl z, x, y = (16, 0, 0) full_tags = tags.copy() full_tags['source'] = 'openstreetmap.org' # test without a name self.generate_fixtures( dsl.way(1, dsl.tile_box(z, x, y), full_tags), ) self.assert_has_feature( z, x, y, 'pois', { 'kind': kind, 'min_zoom': min_zoom, }) # and with a name full_tags['name'] = 'Some kind of name' self.generate_fixtures( dsl.way(1, dsl.tile_box(z, x, y), full_tags), ) self.assert_has_feature( z, x, y, 'pois', { 'kind': kind, 'name': full_tags['name'], 'min_zoom': lambda z: z < min_zoom, })
def test_successful_merge(self): from ModestMaps.Core import Coordinate from shapely.geometry import LineString from tilequeue.tile import coord_to_bounds import dsl z, x, y = 9, 145, 201 bounds = coord_to_bounds(Coordinate(zoom=z, column=x, row=y)) mid_x = (bounds[2] - bounds[0]) / 2.0 + bounds[0] mid_y = (bounds[3] - bounds[1]) / 2.0 + bounds[1] ls1 = LineString([(mid_x-0.01, mid_y-0.01), (mid_x, mid_y)]) ls2 = LineString([(mid_x, mid_y), (mid_x+0.01, mid_y+0.01)]) props = dict(waterway=u'river', name=u'foo') self.generate_fixtures( dsl.way(1, ls1, props), dsl.way(2, ls2, props), ) self.assert_n_matching_features( z, x, y, 'water', { 'name': 'foo', 'kind': 'river', 'label_placement': type(None), }, 1) with self.features_in_tile_layer(z, x, y, 'water') as features: for f in features: if 'label_placement' in f['properties']: continue assert f['geometry']['type'] == 'LineString' assert len(f['geometry']['coordinates']) == 2
def test_junction_x(self): from tilequeue.tile import coord_to_bounds from shapely.geometry import LineString, asShape from ModestMaps.Core import Coordinate import dsl z, x, y = (12, 2048, 2048) minx, miny, maxx, maxy = coord_to_bounds( Coordinate(zoom=z, column=x, row=y)) midx = 0.5 * (minx + maxx) midy = 0.5 * (miny + maxy) road_props = dict( highway='residential', source='openstreetmap.org', ) # make a tile with 4 roads in an X shape, as below. # # \ / # 1 2 # \/ # /\ # 3 4 # / \ # # these should get merged into two lines 1->4 & 2->3. self.generate_fixtures( dsl.way(1, LineString([[minx, maxy], [midx, midy]]), road_props), dsl.way(2, LineString([[maxx, maxy], [midx, midy]]), road_props), dsl.way(3, LineString([[minx, miny], [midx, midy]]), road_props), dsl.way(4, LineString([[maxx, miny], [midx, midy]]), road_props), ) with self.features_in_tile_layer(z, x, y, 'roads') as features: # multilinestrings which contain lines which cross (as in the X # above) are "non-simple", and many geometry operations start by # forcing multilinestrings to be simple. we don't want this, as # it introduces an extra coordinate where the lines cross. # instead, we split into features which are individually simple, # which means we'll need 2 in this example. self.assertTrue(len(features) == 2) # when the test suite runs in "download only mode", an empty # set of features is passed into this block. the assertion # is shorted out, so we need this additional check which is # trivially satisfied in the case we're doing real testing. if len(features) == 2: for i in (0, 1): # the shapes should be single linestrings in this example. shape = asShape(features[i]['geometry']) self.assertTrue(shape.geom_type == 'LineString') # consisting of _only two_ points. (i.e: one didn't get # inserted into the middle) self.assertTrue(len(shape.coords) == 2)
def test_sfo(self): # SFO should be "international": both the polygon _and_ the POI. import dsl z, x, y = (13, 1311, 3170) self.generate_fixtures( # https://www.openstreetmap.org/way/545819287 dsl.way(545819287, dsl.tile_box(z, x, y), { 'aerodrome': 'international', 'aerodrome:type': 'public', 'aeroway': 'aerodrome', 'city_served': 'San Francisco, California', 'ele': '4', 'iata': 'SFO', 'icao': 'KSFO', 'name': 'San Francisco International Airport', 'source': 'openstreetmap.org', 'wikidata': 'Q8688', 'wikipedia': 'en:San Francisco International Airport', }), # https://www.openstreetmap.org/way/22567191 dsl.way(22567191, dsl.tile_diagonal(z, x, y), { 'aeroway': 'runway', 'length': '3618', 'ref': '10L/28R', 'surface': 'asphalt', 'width': '61', 'source': 'openstreetmap.org', }), ) # POI self.assert_has_feature( z, x, y, 'pois', { 'id': 545819287, 'kind': 'aerodrome', 'kind_detail': 'international', }) self.assert_has_feature( z, x, y, 'landuse', { 'id': 545819287, 'kind': 'aerodrome', 'kind_detail': 'international', }) # runway inside polygon self.assert_has_feature( z, x, y, 'roads', { 'id': 22567191, 'kind': 'aeroway', 'kind_detail': 'runway', 'aerodrome_kind_detail': 'international', })
def test_wood(self): self.generate_fixtures(dsl.way(52497271, wkt_loads('POLYGON ((-121.954353215747 37.34413271456221, -121.954112646914 37.34428461761629, -121.953889595229 37.34453921701549, -121.953810004495 37.3445377886903, -121.953726910331 37.3444308784707, -121.953744607142 37.34433389498678, -121.954353215747 37.34413271456221))'), {u'way_area': u'1191.25', u'source': u'openstreetmap.org', u'landuse': u'wood', u'natural': u'wood'})) # noqa self.assert_has_feature( 16, 10566, 25429, 'landuse', {'id': 52497271, 'kind': 'wood'}) self.generate_fixtures(dsl.way(207859675, wkt_loads('POLYGON ((-117.89005453116 33.91136551127548, -117.890027671533 33.91175720307361, -117.889979432002 33.9118240007339, -117.889933797586 33.91180841958788, -117.889847469487 33.91179552227351, -117.889797074 33.91180402108199, -117.889737964854 33.91183958187699, -117.889576627429 33.91175772493049, -117.889617321111 33.91172156769318, -117.889649480799 33.9116391887757, -117.889606631159 33.91161481056499, -117.889652175744 33.91149455953338, -117.889550306791 33.91082009198559, -117.88888258904 33.91056646635377, -117.889542221954 33.91055297243508, -117.889633400955 33.9104550109947, -117.889421488379 33.91019899860129, -117.889343784107 33.91020347174229, -117.889270840906 33.9101460664147, -117.889118486634 33.90998756786778, -117.889356630016 33.90954725944538, -117.889737515696 33.90960742363259, -117.889998566118 33.90958871086019, -117.889974131942 33.9113676732641, -117.89005453116 33.91136551127548))'), {u'way_area': u'18306.8', u'source': u'openstreetmap.org', u'landuse': u'wood'})) # noqa self.assert_has_feature( 16, 11306, 26199, 'landuse', {'id': 207859675, 'kind': 'wood'})
def test_offshore_platform_way(self): self.generate_fixtures(dsl.way(346405529, wkt_loads('POLYGON ((-119.906535907426 34.3897671631719, -119.906489105199 34.3899948169202, -119.905999703033 34.38992632070937, -119.906022879567 34.38981349457748, -119.905964219579 34.3898052661218, -119.905994133478 34.38965967421188, -119.906246110915 34.38969496025808, -119.906239822708 34.38972579847117, -119.906535907426 34.3897671631719))'), {u'building': u'industrial', u'source': u'openstreetmap.org', u'way_area': u'1944.96', u'man_made': u'offshore_platform', u'name': u'Platform Holly'})) # noqa self.assert_has_feature( 13, 1367, 3261, 'pois', {'kind': 'offshore_platform', 'min_zoom': 13}) self.generate_fixtures(dsl.way(446514311, wkt_loads('POLYGON ((57.28399280807089 69.26576040721967, 57.28402739320939 69.2669031049751, 57.2874108078955 69.26689028887759, 57.287376222757 69.26574749503671, 57.28399280807089 69.26576040721967))'), {u'source': u'openstreetmap.org', u'way_area': u'135352', u'man_made': u'offshore_platform', u'name': u'\u041c\u041b\u0421\u041f \xab\u041f\u0440\u0438\u0440\u0430\u0437\u043b\u043e\u043c\u043d\u0430\u044f\xbb'})) # noqa self.assert_has_feature( 13, 5399, 1881, 'pois', {'kind': 'offshore_platform', 'min_zoom': 13, 'id': 446514311})
def test_historic_railway_halt(self): # Historic railway halt self.generate_fixtures(dsl.way(708144563, wkt_loads('POINT (14.8139903286339 59.15514209522067)'), {u'historic:railway': u'halt', u'historic': u'yes', u'disused': u'yes', u'name': u'Kvistbro', u'source': u'openstreetmap.org'})) # noqa self.assert_no_matching_feature( 13, 4433, 2416, 'pois', {'id': 708144563}) self.generate_fixtures(dsl.way(2468597590, wkt_loads('POINT (9.147960458165631 46.24711157299198)'), {u'source': u'openstreetmap.org', u'railway': u'halt', u'historic': u'railway_station', u'name': u'Grono'})) # noqa self.assert_no_matching_feature( 13, 4304, 2906, 'pois', {'id': 2468597590})
def test_man_made_offshore_platform(self): self.generate_fixtures(dsl.way(4239915448, wkt_loads('POINT (-97.05473509633438 26.12074297830959)'), {u'seamark:type': u'platform', u'man_made': u'offshore_platform', u'source': u'openstreetmap.org'})) # noqa self.assert_has_feature( 15, 7549, 13919, 'pois', {'id': 4239915448}) # originally from 675-man_made-outdoor-landmarks.py self.generate_fixtures(dsl.way(350328482, wkt_loads('POLYGON ((-94.63139900237969 29.40923572279329, -94.63116238613378 29.40925700824868, -94.6311144160976 29.4088532881355, -94.6313510323435 29.40883200259559, -94.63139900237969 29.40923572279329))'), {u'source': u'openstreetmap.org', u'way_area': u'1373.41', u'man_made': u'offshore_platform', u'area': u'yes'})) # noqa self.assert_has_feature( 13, 1942, 3395, 'pois', {'id': 350328482})
def test_landuse_quarry(self): self.generate_fixtures(dsl.way(3356570361, wkt_loads('POINT (-122.153005130541 38.21004035449701)'), {u'source': u'openstreetmap.org', u'landuse': u'quarry', u'resource': u'rock'})) # noqa self.assert_has_feature( 16, 10530, 25230, 'pois', {'id': 3356570361}) # Way:184367568 quarry in POIS self.generate_fixtures(dsl.way(184367568, wkt_loads('POLYGON ((-120.977489333016 37.75803770943879, -120.977486997396 37.76081756655368, -120.976233937406 37.76077552360858, -120.975400929643 37.7607743873124, -120.974583372903 37.76077332203479, -120.973504316584 37.76062567440368, -120.97213699089 37.76035516386188, -120.971016971394 37.7601061001177, -120.970661597867 37.7599816034407, -120.97063294161 37.75963545470499, -120.970616682103 37.7594398664594, -120.970625485593 37.75941607482559, -120.970835242212 37.75885182025329, -120.970928667001 37.7585999816441, -120.971144981322 37.75855530967489, -120.971802368447 37.75841951808628, -120.971967209301 37.7582608575149, -120.9720635087 37.75745135660739, -120.971951219289 37.75722600441009, -120.972019042093 37.75718296511631, -120.972093961588 37.75713530936738, -120.972331386317 37.7569844584784, -120.972452838544 37.75689695914001, -120.972641574585 37.75557287981598, -120.972647683129 37.75482471444889, -120.975799062977 37.75418158732738, -120.975874970619 37.75416880285528, -120.976019329885 37.7541445833771, -120.976370571161 37.75533779164638, -120.976515469416 37.75582998445129, -120.976667733857 37.7561338213188, -120.976875693845 37.75641066831778, -120.97701762766 37.7564229552437, -120.977076287648 37.75642806887698, -120.977279396734 37.75644568250009, -120.977288110392 37.75651152048169, -120.977319461596 37.7567493747943, -120.977408125314 37.75742181157429, -120.977429145892 37.7575811841611, -120.977489333016 37.75803770943879))'), {u'attribution': u'Farmland Mapping and Monitoring Program', u'way_area': u'508870', u'source': u'openstreetmap.org', u'FMMP_modified': u'no', u'addr:county': u'San Joaquin', u'landuse': u'quarry', u'FMMP_reviewed': u'no'})) # noqa self.assert_has_feature( 14, 2686, 6333, 'pois', {'id': 184367568, 'min_zoom': 13})
def test_multiple_shields(self): import dsl z, x, y = 16, 18022, 25522 # I-77, I-81, US-11 & US-52 all in one road West Virginia. self.generate_fixtures( dsl.way(1, dsl.tile_box(z, x, y), { 'kind': 'admin_area', 'iso_code': 'US', 'source': 'openstreetmap.org' }), # http://www.openstreetmap.org/way/51388984 dsl.way(51388984, dsl.tile_diagonal(z, x, y), { 'horse': 'no', 'maxspeed': '70 mph', 'bicycle': 'no', 'source': 'openstreetmap.org', 'hgv': 'designated', 'surface': 'asphalt', 'oneway': 'yes', 'foot': 'no', 'lanes': '3', 'sidewalk': 'none', 'ref': 'I 77;I 81;US 11;US 52', 'highway': 'motorway' }), dsl.relation(1, { 'name': 'US 11 (VA)', 'type': 'route', 'route': 'road', 'wikipedia': 'en:U.S. Route 11', 'is_in:state': 'VA', 'source': 'openstreetmap.org', 'wikidata': 'Q407534', 'ref': '11', 'network': 'US:US' }, ways=[51388984]), dsl.relation(2, { 'name': 'I 77 (VA) (North)', 'type': 'route', 'route': 'road', 'wikipedia': 'en:Interstate 77 in Virginia', 'is_in:state': 'VA', 'source': 'openstreetmap.org', 'wikidata': 'Q2447354', 'ref': '77', 'network': 'US:I' }, ways=[51388984]), dsl.relation(3, { 'direction': 'south', 'name': 'I 81 (VA southbound)', 'type': 'route', 'route': 'road', 'wikipedia': 'en:Interstate 81 in Virginia', 'is_in:state': 'VA', 'source': 'openstreetmap.org', 'wikidata': 'Q2447647', 'ref': '81', 'network': 'US:I' }, ways=[51388984]), dsl.relation(4, { 'name': 'US 52 (VA)', 'type': 'route', 'route': 'road', 'wikipedia': 'en:U.S. Route 52', 'is_in:state': 'VA', 'source': 'openstreetmap.org', 'ref': '52', 'network': 'US:US' }, ways=[51388984]), ) self.assert_has_feature( 16, 18022, 25522, 'roads', {'kind': 'highway', 'network': 'US:I', 'id': 51388984, 'shield_text': '77', 'all_networks': ['US:I', 'US:I', 'US:US', 'US:US'], 'all_shield_texts': ['77', '81', '11', '52']})
def test_proposed_stations(self): # Antioch Station self.generate_fixtures(dsl.way(3353451464, wkt_loads('POINT (-121.785229642994 37.99688077243528)'), {u'name': u'Antioch Station (in construction)', u'source': u'openstreetmap.org', u'state': u'proposed', u'train': u'yes', u'public_transport': u'station', u'operator': u'BART', u'railway': u'station'})) # noqa self.assert_has_feature( 16, 10597, 25279, 'pois', {'id': 3353451464, 'state': 'proposed'}) # Pittsburg Center self.generate_fixtures(dsl.way(3354463416, wkt_loads('POINT (-121.88916373322 38.01684868163071)'), {u'toilets': u'yes', u'name': u'BART - Pittsburg Center Station (In Construction)', u'wheelchair': u'yes', u'source': u'openstreetmap.org', u'state': u'proposed', u'train': u'yes', u'public_transport': u'station', u'operator': u'BART', u'railway': u'station', u'toilets:wheelchair': u'yes'})) # noqa self.assert_has_feature( 16, 10578, 25275, 'pois', {'id': 3354463416, 'state': 'proposed'})
def _setup(self, z, x, y, left_id, right_id): from tilequeue.tile import coord_to_bounds from shapely.geometry import LineString from ModestMaps.Core import Coordinate import dsl minx, miny, maxx, maxy = coord_to_bounds( Coordinate(zoom=z, column=x, row=y)) # move the coordinate points slightly out of the tile, so that we # don't get borders along the sides of the tile. w = maxx - minx h = maxy - miny minx -= 0.5 * w miny -= 0.5 * h maxx += 0.5 * w maxy += 0.5 * h self.generate_fixtures( dsl.way( 1, LineString([ [minx, miny], [minx, maxy], [maxx, maxy], [minx, miny], ]), { 'boundary': 'administrative', 'admin_level': '2', 'id': left_id, 'name': 'Left', 'mz_boundary_from_polygon': True, # need this for hack } ), dsl.way( 2, LineString([ [minx, miny], [maxx, maxy], [maxx, miny], [minx, miny], ]), { 'boundary': 'administrative', 'admin_level': '2', 'id': right_id, 'name': 'Right', 'mz_boundary_from_polygon': True, # need this for hack } ), )
def test_mud_sort_rank(self): # Mud landuse should sort above water, below wetland import dsl z, x, y = (16, 0, 0) water_sort_rank = 204 mud_sort_rank = 219 wetland_sort_rank = 220 self.generate_fixtures( dsl.way(1, dsl.tile_box(z, x, y), { 'natural': 'mud', 'source': 'openstreetmap.org', }), dsl.way(2, dsl.tile_box(z, x, y), { 'natural': 'water', 'source': 'openstreetmap.org', }), dsl.way(3, dsl.tile_box(z, x, y), { 'natural': 'wetland', 'source': 'openstreetmap.org', }), ) # first, check the ordering self.assertTrue(water_sort_rank < mud_sort_rank) self.assertTrue(mud_sort_rank < wetland_sort_rank) # now check features match that self.assert_has_feature( z, x, y, 'landuse', { 'id': 1, 'kind': 'mud', 'sort_rank': mud_sort_rank, }) self.assert_has_feature( z, x, y, 'water', { 'id': 2, 'kind': 'water', 'sort_rank': water_sort_rank, }) self.assert_has_feature( z, x, y, 'landuse', { 'id': 3, 'kind': 'wetland', 'sort_rank': wetland_sort_rank, })
def test_unnamed_rock(self): # originally from 657-natural-man_made.py # unnamed rock self.generate_fixtures(dsl.way(4013703516, wkt_loads('POINT (-122.523488499681 38.0215078752183)'), {u'source': u'openstreetmap.org', u'natural': u'rock'})) # noqa self.assert_has_feature( 16, 10463, 25274, 'pois', {'id': 4013703516}) # another unnamed rock self.generate_fixtures(dsl.way(3150154140, wkt_loads('POINT (-122.416442645311 37.93267727336828)'), {u'source': u'openstreetmap.org', u'natural': u'rock'})) # noqa self.assert_has_feature( 16, 10482, 25294, 'pois', {'id': 3150154140})
def test_large_outdoor(self): # http://www.openstreetmap.org/way/377630800 # Large Bass Pro building that should appear earlier self.generate_fixtures(dsl.way(377630800, wkt_loads('POLYGON ((-104.827294994284 39.02406511310399, -104.826632037605 39.02437706682608, -104.826394792538 39.02407285962249, -104.826073285498 39.0242241608225, -104.82564496877 39.02367478517689, -104.82595291125 39.0235299033882, -104.825856611851 39.0234063767732, -104.826482198615 39.02311200569858, -104.826618562875 39.0232869675069, -104.826799932731 39.0232016850202, -104.827087303791 39.0235703112002, -104.826957137906 39.0236315858692, -104.827294994284 39.02406511310399))'), {u'shop': u'outdoor', u'building': u'retail', u'way_area': u'18864.9', u'name': u'Bass Pro Shop', u'source': u'openstreetmap.org'})) # noqa self.assert_has_feature( 15, 6842, 12520, 'pois', {'kind': 'outdoor', 'id': 377630800}) # Large REI building that should appear earlier self.generate_fixtures(dsl.way(290195878, wkt_loads('POLYGON ((-111.802024167649 40.70123485563938, -111.802023987986 40.7014723988414, -111.8015969289 40.70146919800679, -111.801545365603 40.7014105614151, -111.800970443821 40.70141709929548, -111.800970443821 40.70153416810739, -111.800824467587 40.70153416810739, -111.800807309766 40.70066878023668, -111.801682807841 40.70066878023668, -111.801777220778 40.70074035716837, -111.801785844605 40.70123485563938, -111.802024167649 40.70123485563938))'), {u'shop': u'outdoor', u'building': u'yes', u'name': u'REI', u'addr:postcode': u'84109', u'way_area': u'13133', u'addr:housenumber': u'3285', u'addr:city': u'Salt Lake City', u'source': u'openstreetmap.org', u'opening_hours': u'Mo-Fr 10:00-21:00;Sa 9:00-19:00;Su 11:00-18:00', u'internet_access': u'wlan', u'addr:street': u'3300 S'})) # noqa self.assert_has_feature( 15, 6207, 12321, 'pois', {'kind': 'outdoor', 'id': 290195878})
def test_3_zanational(self): import dsl z, x, y = (16, 38204, 38297) self.generate_fixtures( dsl.is_in('ZA', z, x, y), # https://www.openstreetmap.org/way/4075691 dsl.way( 4075691, dsl.tile_diagonal(z, x, y), { 'highway': u'motorway', 'maxspeed': u'120', 'oneway': u'yes', 'ref': u'N3', 'source': u'openstreetmap.org', }), # TODO: figure out what this SADC network is... wasn't able to find # any signage for it. is it a multinational network? dsl.relation(1, { 'direction': u'south', 'name': u'SADC 36 (southbound)', 'network': u'sadc', 'ref': u'SADC 36', 'route': u'road', 'source': u'openstreetmap.org', 'type': u'route', }, ways=[4075691]), dsl.relation(2, { 'direction': u'south', 'name': u'N3 (southbound)', 'network': u'za:national', 'ref': u'N3', 'route': u'road', 'source': u'openstreetmap.org', 'type': u'route', }, ways=[4075691]), ) self.assert_has_feature(z, x, y, 'roads', { 'id': 4075691, 'network': u'ZA:national', 'shield_text': u'3', })
def test_zoom_1(self): import dsl z, x, y = (3, 7, 3) self.generate_fixtures( dsl.way( 607976629, dsl.tile_centre_shape(z, x, y), { "min_zoom": 1, "__ne_max_zoom": 10, "__ne_min_zoom": 3, "area": 0, "place": "country", "name": "Guam", "population": 185427, "source": "openstreetmap.org", }), ) # should exist at zoom 3 (the min zoom from NE) self.assert_has_feature(z, x, y, 'places', { 'id': 607976629, 'kind': 'country', 'name': 'Guam', }) # should not exist at zoom 2 (one past the min zoom) self.assert_no_matching_feature(z - 1, x // 2, y // 2, 'places', {'id': 607976629}) # should not exist at zoom 1 self.assert_no_matching_feature(z - 2, x // 4, y // 4, 'places', { 'id': 607976629, }) # should not exist at zoom 0 self.assert_no_matching_feature(0, 0, 0, 'water', { 'kind': 'ocean', 'label_placement': True, }) # should not exist at zoom 0 self.assert_no_matching_feature(0, 0, 0, 'earth', { 'kind': 'continent', 'label_placement': True, })
def test_inroads(self): import dsl z, x, y = (16, 46765, 26893) self.generate_fixtures( dsl.is_in('IN', z, x, y), # https://www.openstreetmap.org/way/169248989 dsl.way( 169248989, dsl.tile_diagonal(z, x, y), { 'highway': u'secondary', 'lanes': u'2', 'maxspeed': u'50', 'name': u'Panchkula - Nahan Road', 'ref': u'MDR118', 'source': u'openstreetmap.org', }), dsl.relation(1, { 'name': u'Haryana Major District Road 118', 'network': u'IN:SH:HR', 'ref': u'MDR118', 'route': u'road', 'source': u'openstreetmap.org', 'type': u'route', }, ways=[169248989]), dsl.relation(2, { 'name': u'Panchkula - Nahan Road', 'name:en': u'Panchkula - Nahan Road', 'network': u'IN-roads', 'route': u'road', 'source': u'openstreetmap.org', 'type': u'route', }, ways=[169248989]), ) self.assert_has_feature( z, x, y, 'roads', { 'id': 169248989, 'network': 'IN:MDR', 'shield_text': '118', 'all_networks': ['IN:MDR'], 'all_shield_texts': ['118'], })
def test_track(self): # tracks_network_rcn: # filter: { $zoom: { max: 12 }, kind_detail: track } # draw: # mapzen_icon_library: # visible: false # # roughly translates to: don't draw shields on tracks when zoom<=12. import dsl z, x, y = (13, 4096, 4096) self.generate_fixtures( dsl.way( 1, dsl.tile_diagonal(z, x, y), { 'highway': u'track', 'surface': u'paved', 'source': u'openstreetmap.org', }), dsl.relation(2, { 'type': u'route', 'route': u'bicycle', 'network': u'icn', 'ref': u'X', 'source': u'openstreetmap.org', }, ways=[1]), ) # should exist with all properties at zoom 13 self.assert_has_feature( z, x, y, 'roads', { 'id': 1, 'bicycle_network': u'icn', 'bicycle_shield_text': u'X', 'min_zoom': 11, }) # should drop properties by zoom 12 self.assert_no_matching_feature(z - 1, x // 2, y // 2, 'roads', { 'bicycle_network': None, }) self.assert_no_matching_feature(z - 1, x // 2, y // 2, 'roads', { 'bicycle_shield_text': None, })
def test_label_lake_athabasca_z5(self): import dsl z, x, y = (5, 6, 9) self.generate_fixtures( dsl.way( 1, dsl.box_area(z, x, y, 31390412728.710949), { 'featurecla': u'Lake', 'label': u'Lake Athabasca', 'min_label': 3.7, 'min_zoom': 2.0, 'name': u'Lake Athabasca', 'name_abb': u'L. Athabasca', 'name_de': u'Athabascasee', 'name_en': u'Lake Athabasca', 'name_es': u'Lago Athabasca', 'name_fr': u'lac Athabasca', 'name_hu': u'Atabaszk-tó', 'name_it': u'Athabasca', 'name_ja': u'アサバスカ湖', 'name_nl': u'Athabascameer', 'name_pl': u'Athabaska', 'name_pt': u'Lago Athabasca', 'name_ru': u'Атабаска', 'name_sv': u'Athabascasjön', 'name_tr': u'Athabasca Gölü', 'name_zh': u'阿薩巴斯卡湖', 'ne_id': u'1159106863', 'scalerank': 2, 'source': u'naturalearthdata.com', 'wdid_score': 4, 'wikidataid': u'Q272463', }), ) # we should get a label placement point, and its zoom should have been # adjusted. we should also have all the names at this point. self.assert_has_feature( z, x, y, 'water', { 'kind': 'lake', 'label_placement': True, 'min_zoom': 5, 'name': str, 'name:de': str, })
def test_miniature_golf_way(self): import dsl z, x, y = (16, 19293, 24645) self.generate_fixtures( # https://www.openstreetmap.org/way/510028688 dsl.way( 510028688, dsl.tile_box(z, x, y), { 'leisure': u'miniature_golf', 'name': u'FIGMENT Mini Golf', 'source': u'openstreetmap.org', }), ) self.assert_has_feature(z, x, y, 'pois', { 'id': 510028688, 'kind': u'miniature_golf', })
def test_citywalls(self): # citywalls in landuse self.generate_fixtures( dsl.way( 392978585, wkt_loads( 'LINESTRING (24.4720476224511 35.37148697890318, 24.4712704898988 35.3713100065569)' ), { u'source': u'openstreetmap.org', u'historic': u'citywalls' })) # noqa self.assert_has_feature(12, 2326, 1617, 'landuse', {'kind': 'city_wall'}) # citywalls not in boundaries self.assert_no_matching_feature(12, 2326, 1617, 'boundaries', {'kind': 'city_wall'})
def test_generative_maritime(self): import dsl z, x, y = (8, 44, 88) self.generate_fixtures( dsl.way(2, dsl.tile_diagonal(z, x, y), { 'source': 'openstreetmap.org', 'boundary': 'administrative', 'admin_level': '2', }), ) self.assert_has_feature( z, x, y, 'boundaries', { 'kind': 'country', 'maritime_boundary': True, })
def test_old_south_ferry(self): # Old South Ferry (1) (disused=yes) self.generate_fixtures( dsl.way( 2086974744, wkt_loads('POINT (-74.01325716895789 40.701283821753)'), { u'name': u'Old South Ferry (1)', u'wheelchair': u'no', u'source': u'openstreetmap.org', u'railway': u'station', u'disused': u'yes', u'network': u'New York City Subway' })) # noqa self.assert_no_matching_feature(16, 19294, 24643, 'pois', { 'kind': 'station', 'id': 2086974744 })
def test_heavenly_mountain_resort(self): # Heavenly Mountain Resort NV/CA self.generate_fixtures( dsl.way( 317721523, wkt_loads( 'POLYGON ((-119.943792366025 38.9318315811565, -119.943406090453 38.93208195867911, -119.943148633292 38.93258278095151, -119.941582240931 38.93413511885359, -119.942264870716 38.93522659155598, -119.942130842075 38.93529968189359, -119.94225687571 38.9354414601634, -119.942742415121 38.9360757904203, -119.942739720175 38.93611855405371, -119.94269004334 38.9361504870115, -119.938846421733 38.93782376785669, -119.938751200313 38.93785695776939, -119.938692180999 38.93785905397387, -119.93861169195 38.9378174093664, -119.93753964249 38.93630085820809, -119.937377227086 38.93621351438268, -119.937251283283 38.93615272301678, -119.937196036893 38.93612596082418, -119.936677529311 38.93581005438838, -119.936152823354 38.93555745400288, -119.93555310807 38.9353437037623, -119.934459768538 38.9350131896996, -119.933534234301 38.93479049362628, -119.931754581891 38.93350077123829, -119.929458577857 38.9320318552936, -119.928578857699 38.93244917278829, -119.927505999755 38.93211536091647, -119.92529578483 38.93104711044089, -119.923407615934 38.9301457200956, -119.922098680734 38.9298118973828, -119.918815607865 38.93047961111808, -119.916197827296 38.93128078942348, -119.914137900518 38.9320318552936, -119.911799046844 38.9332003660422, -119.911133844376 38.9339013793977, -119.911176694015 38.93436871778529, -119.912099443475 38.93490285495809, -119.912271021694 38.93575408409009, -119.911477090646 38.93622141026889, -119.91106943517 38.93677216363341, -119.910597280657 38.93727302265959, -119.910318443593 38.93785709751631, -119.910039426865 38.93832447970939, -119.909460103339 38.9387917889493, -119.9087519614 38.93895871430539, -119.908194107609 38.93887521674029, -119.907893710978 38.93867489205539, -119.907893710978 38.9384413073081, -119.907807832036 38.93804065492078, -119.907443116031 38.9382075820451, -119.906584775777 38.93857476443707, -119.90596251278 38.9391422688583, -119.905919573309 38.9396596707408, -119.906434577462 38.93999351697389, -119.907593314347 38.94022709660789, -119.907657633721 38.9418960890882, -119.907078310194 38.94331470530078, -119.906606245512 38.94404901528998, -119.905447508627 38.9449334609636, -119.904310241478 38.9458680591144, -119.902872577697 38.94785396067778, -119.902314723906 38.94997331214239, -119.902314723906 38.9521259930512, -119.902185905494 38.95359442288199, -119.90132756524 38.9553465090758, -119.899439396344 38.95656458198948, -119.897036133465 38.9577660087491, -119.895812987374 38.9580830048665, -119.8950833757 38.95833328969279, -119.894246595013 38.95885048166019, -119.893495603435 38.95975150710918, -119.892572943807 38.9614199700634, -119.892229607705 38.96317186277449, -119.892036469919 38.9642396990966, -119.892250987609 38.9651405861659, -119.892229607705 38.96562448170126, -119.89229392708 38.9662250858957, -119.89184081685 38.96661091151149, -119.891671664082 38.96690907979579, -119.891907741339 38.9672928063521, -119.891006461615 38.9678266954673, -119.890448607823 38.9676432151904, -119.889483008724 38.96717609614698, -119.889332810409 38.96674229010197, -119.889203991997 38.9661750066383, -119.889311340673 38.9658746700424, -119.889933603671 38.96559109525059, -119.890234000302 38.96512396267509, -119.89089920277 38.9636056906835, -119.891242538871 38.9624877629413, -119.891113810291 38.9616036061589, -119.891221069136 38.9606692154917, -119.891735983457 38.95985160481811, -119.892401185925 38.95918416766697, -119.892358336286 38.95836660971048, -119.891800392663 38.9575489724671, -119.891264008606 38.95728205953967, -119.889470342479 38.95780407909378, -119.889400094223 38.9591308702168, -119.887620531646 38.9606618811363, -119.88701542647 38.96071929864108, -119.886672000537 38.96045225795317, -119.886951017264 38.95978489631188, -119.887594660165 38.95868367299398, -119.887895146628 38.95804961486188, -119.888023875208 38.95738216073708, -119.887830737422 38.95636430728829, -119.88862466847 38.95521301366169, -119.889225461732 38.95426191268249, -119.889096822984 38.95299371161568, -119.888860745727 38.9516920948552, -119.888066814679 38.95085768390329, -119.885792280379 38.95010681742608, -119.882530677246 38.94927238781168, -119.880985844452 38.9486717097764, -119.880256232778 38.94696948157569, -119.880342021888 38.94611838707938, -119.881221831877 38.94520049026399, -119.882058612564 38.94459970785727, -119.882530677246 38.94384870522239, -119.882874013347 38.94304759902919, -119.882959892289 38.941962814433, -119.884140009077 38.94032729176409, -119.884590604024 38.93997681771238, -119.885448944278 38.93989332134609, -119.886736409743 38.93992671990438, -119.888324271839 38.939960118447, -119.889590267569 38.9397931954484, -119.890448607823 38.93929249396669, -119.891714603553 38.93862486320029, -119.892057939655 38.93767346976308, -119.892444125395 38.93687236367141, -119.892444125395 38.93640497190737, -119.890234000302 38.93642167200998, -119.888925065101 38.93587091592349, -119.888088194583 38.93473598993108, -119.88722994416 38.93311686169681, -119.887380142476 38.93271631898448, -119.887187004689 38.93221556753409, -119.886693470272 38.93164800768059, -119.886393073641 38.9311807212453, -119.886414543377 38.93024585961498, -119.886457482847 38.9295448101288, -119.887702008842 38.9287937179232, -119.888195543259 38.92847652093838, -119.888302802104 38.92797566967189, -119.88875339705 38.92764190662998, -119.888796336521 38.92695746385529, -119.889010944042 38.9262229768729, -119.889311340673 38.92588906581409, -119.890598806139 38.92528818967369, -119.89128538851 38.92522137875329, -119.892873340438 38.9252046760134, -119.894203745374 38.92522137875329, -119.894804538636 38.92473727724449, -119.895834546941 38.9240361034304, -119.897486728411 38.92305117768679, -119.897744185572 38.92248361439469, -119.897572517521 38.92159881882498, -119.897894383887 38.92111469259788, -119.89879557378 38.92006291052098, -119.899460776248 38.919996164571, -119.899825582085 38.92004627645759, -119.899868521555 38.91956206974588, -119.900297736598 38.91866060335608, -119.900791181184 38.91804289167699, -119.900662362772 38.91744187919207, -119.902915517168 38.91421957148438, -119.903795327157 38.91400261158058, -119.904717896954 38.9139692008148, -119.906284289315 38.91365186765279, -119.907443116031 38.91336808393178, -119.908601763085 38.913084299076, -119.909481483242 38.91303418227301, -119.910339823496 38.91338478945808, -119.910704629333 38.91376880578709, -119.911369831801 38.91430309807468, -119.911906305689 38.91503770845448, -119.9123354309 38.91557199118939, -119.912893284691 38.91622306420259, -119.913687215739 38.91682408700998, -119.914524086258 38.91725819858469, -119.915275077836 38.91747521842948, -119.916004689509 38.9173417215987, -119.916498223927 38.91744187919207, -119.916948818873 38.9176087849025, -119.917592461774 38.91789262155969, -119.91857962044 38.91824320474318, -119.919180413702 38.91871071618591, -119.92018886244 38.91946191514499, -119.920875624475 38.91976237852361, -119.921669465691 38.91986260259158, -119.922098680734 38.91941187273728, -119.922849672311 38.91882750620009, -119.923708012565 38.9182933178678, -119.92495253856 38.91802618724719, -119.926690598972 38.91859378619469, -119.928063943378 38.91941187273728, -119.928857784595 38.92029669557818, -119.929136801322 38.9215654116356, -119.928793375389 38.92271732158768, -119.929630335739 38.9229176913462, -119.930252598736 38.92306788093371, -119.930746133153 38.9226338747895, -119.930831922263 38.92230001672669, -119.931582913841 38.92204960467639, -119.932612922145 38.92189927315498, -119.933342533819 38.92196608720379, -119.934179314506 38.92218309265029, -119.934865986709 38.92218309265029, -119.935402370766 38.92219979610159, -119.936003164028 38.92235005709749, -119.936646986592 38.9226171714404, -119.937140521009 38.9231012874158, -119.937633965594 38.92353529070078, -119.937870042851 38.92365221254888, -119.937977301696 38.92385250977988, -119.937848573116 38.9240361034304, -119.937462297544 38.92431991437778, -119.937011702597 38.924687168671, -119.936754245437 38.92500438259989, -119.936615365894 38.92515715355188, -119.937033172332 38.92547177960891, -119.937483767279 38.92600598378308, -119.938148969747 38.92677380788037, -119.93883564195 38.92755839574049, -119.939500844418 38.92820935877318, -119.940037318306 38.92874361221491, -119.940616641832 38.92931105554499, -119.940680961207 38.92977849406069, -119.940874098993 38.93036270052237, -119.941324693939 38.93072999341319, -119.941560771196 38.93084676364278, -119.942290293038 38.93101370770039, -119.942719508081 38.93121398414699, -119.943234512233 38.93143096130588, -119.943706487083 38.9315812726297, -119.943792366025 38.9318315811565))' ), { u'way_area': u'1.8992e+07', u'source': u'openstreetmap.org', u'landuse': u'winter_sports', u'name': u'Heavenly Mountain Resort' })) # noqa self.assert_has_feature(15, 5467, 12531, 'landuse', { 'kind': 'winter_sports', 'sort_rank': 36 })
def test_aerialway_no_detail(self): self.generate_fixtures( dsl.way( 232074914, wkt_loads( 'LINESTRING (-106.9157086076 39.2062991907858, -106.916424834376 39.20577900674078)' ), { u'source': u'openstreetmap.org', u'fixme': u'Please confirm that this actually is an aerialway.', u'aerialway': u'yes' })) # noqa self.assert_has_feature(16, 13304, 24998, 'roads', { 'id': 232074914, 'kind': 'aerialway', 'kind_detail': type(None) })
def test_monorail(self): self.generate_fixtures( dsl.way( 296530703, wkt_loads( 'LINESTRING (-82.68938578864038 41.48358272065969, -82.6895748840077 41.48360889914459)' ), { u'source': u'openstreetmap.org', u'railway': u'monorail' })) # noqa self.assert_has_feature( 16, 17714, 24454, "roads", { "kind": "rail", "kind_detail": "monorail", "id": 296530703, "sort_rank": 382 })
def test_geyser(self): self.generate_fixtures( dsl.way( 358832354, wkt_loads('POINT (-122.602134116344 38.5969426835878)'), { u'gnis:state_id': u'06', u'natural': u'geyser', u'name': u'Old Faithful Geyser of California', u'geyser:type': u'artificial,volcanic', u'gnis:county_id': u'055', u'ele': u'124', u'source': u'openstreetmap.org', u'gnis:created': u'07/20/1998', u'gnis:feature_id': u'1800305', u'tourism': u'attraction' })) # noqa self.assert_has_feature(15, 5224, 12570, 'pois', {'kind': 'geyser'})
def test_military(self): import dsl z, x, y = (16, 0, 0) self.generate_fixtures( dsl.way( 1, dsl.tile_box(z, x, y), { 'aeroway': 'aerodrome', 'aerodrome:type': 'military', 'name': 'Fake Aerodrome', 'source': 'openstreetmap.org', }), ) # note: kind=airfield means a _military_ airfield self.assert_has_feature(z, x, y, 'pois', { 'kind': 'airfield', })
def _check_rank(self, population, rank): import dsl z, x, y = 16, 0, 0 self.generate_fixtures( dsl.way( 1, dsl.tile_centre_shape(z, x, y), { 'place': 'city', 'population': str(population), 'name': 'Fooville', 'source': 'openstreetmap.org', }), ) self.assert_has_feature(z, x, y, 'places', { 'population': population, 'population_rank': rank, })
def test_region_population_rank(self): import dsl z, x, y = 16, 0, 0 self.generate_fixtures( dsl.way( 1, dsl.tile_centre_shape(z, x, y), { 'place': 'state', 'name': 'Foo State', 'population': '100000000', 'source': 'openstreetmap.org', }), ) self.assert_has_feature(z, x, y, 'places', { 'kind': 'region', 'population_rank': 17, })
def __init__(self, z, x, y, landuse_kind=None): from tilequeue.tile import coord_to_mercator_bounds from ModestMaps.Core import Coordinate import dsl bounds = coord_to_mercator_bounds(Coordinate(zoom=z, column=x, row=y)) self.origin_x = bounds[0] self.origin_y = bounds[1] self.buildings = [] self.way_id = 1 if landuse_kind is not None: self.buildings.append( dsl.way(self.way_id, dsl.tile_box(z, x, y), { 'landuse': landuse_kind, 'source': 'openstreetmap.org', })) self.way_id += 1
def test_mud_way(self): import dsl z, x, y = (16, 19455, 24611) self.generate_fixtures( # https://www.openstreetmap.org/way/451611986 dsl.way( 451611986, dsl.tile_box(z, x, y), { 'name': u'mud', 'natural': u'mud', 'source': u'openstreetmap.org', }), ) self.assert_has_feature(z, x, y, 'landuse', { 'id': 451611986, 'kind': u'mud', })
def test_abandoned_rail(self): import dsl z, x, y = (16, 34900, 23738) self.generate_fixtures( # https://www.openstreetmap.org/way/521306174 dsl.way( 521306174, dsl.tile_diagonal(z, x, y), { 'railway': 'abandoned', 'service': 'yard', 'source': 'openstreetmap.org', }), ) # should _not_ include abandoned rails self.assert_no_matching_feature(z, x, y, 'roads', { 'id': 521306174, })
def test_narrow_gauge(self): self.generate_fixtures( dsl.way( 105574666, wkt_loads( 'LINESTRING (-74.44287932819699 40.13493861208138, -74.44282030888279 40.1349980878628)' ), { u'source': u'openstreetmap.org', u'railway': u'narrow_gauge' })) # noqa self.assert_has_feature( 16, 19216, 24778, "roads", { "kind": "rail", "kind_detail": "narrow_gauge", "id": 105574666, "sort_rank": 382 })
def test_taxiway(self): self.generate_fixtures( dsl.way( 115434129, wkt_loads( 'LINESTRING (-75.7299211479091 41.3342970935806, -75.7294168337086 41.33452865486557, -75.7286980018182 41.33485896384377, -75.7286202077146 41.33488715840641, -75.72854780350271 41.33489929960178, -75.72848608924269 41.33489929960178, -75.72842976487441 41.33489120547178)' ), { u'source': u'openstreetmap.org', u'aeroway': u'taxiway' })) # noqa self.assert_has_feature( 16, 18981, 24490, "roads", { "kind": "aeroway", "kind_detail": "taxiway", "id": 115434129, "sort_rank": 61 })
def test_unnamed_drain(self): # Unnamed drain self.generate_fixtures( dsl.way( 61954975, wkt_loads( 'LINESTRING (-112.037643103858 33.5772040880044, -112.037477185025 33.57720251631478, -112.037265002955 33.577194358497, -112.037106809633 33.57720086978289, -112.036973679308 33.57717677053839, -112.036890764808 33.57715431782019, -112.036773085505 33.5771912151174, -112.036670947058 33.57714780653078, -112.036593691943 33.57715910773388, -112.036443313965 33.57714615999777, -112.036348811197 33.57712849718689, -112.036169417634 33.57714615999777, -112.036030538092 33.5771124809062, -112.035897407766 33.57716711587028, -112.035743975516 33.5771669661855, -112.035422917633 33.57710769098989, -112.035376564565 33.57710926268129, -112.035271371845 33.57715746120109, -112.035110393746 33.57719600502909, -112.035073832314 33.5772168860472, -112.034984988932 33.57728282213209, -112.03487260969 33.57726635682619, -112.034651803793 33.5772034144232, -112.034581914864 33.5771799887609, -112.034500886826 33.57721209613667, -112.034278104635 33.5771692114573, -112.034176774671 33.57719600502909, -112.034053435983 33.57716711587028, -112.033687641999 33.57719346038861, -112.033461266547 33.5772317796735, -112.033335771902 33.5772731674758, -112.033258606619 33.5773117860944, -112.033139040855 33.57733917835989, -112.032841967991 33.57743385374619, -112.03257391071 33.57749978966539, -112.032441499037 33.5776538145787, -112.032366310048 33.57772027422318, -112.032263902105 33.57782931882178, -112.032058008242 33.57790101725429, -112.031871158663 33.57797555961149, -112.031602742056 33.57803011918759)' ), { u'source': u'openstreetmap.org', u'waterway': u'drain', u'intermittent': u'yes', u'oneway': u'yes' })) # noqa self.assert_has_feature(16, 12372, 26272, 'water', { 'kind': 'drain', 'intermittent': True })
def test_country_ne(self): import dsl z, x, y = 16, 0, 0 self.generate_fixtures( dsl.way(1, dsl.tile_centre_shape(z, x, y), { 'place': 'country', 'source': 'openstreetmap.org', 'name': 'Foo', '__ne_min_zoom': 2, }), ) self.assert_has_feature( z, x, y, 'places', { 'kind': 'country', 'min_zoom': 2, })
def test_drive_through(self): self.generate_fixtures( dsl.way( 219071307, wkt_loads( 'LINESTRING (-122.439743506477 37.74433156222058, -122.439601931988 37.74445487765141)' ), { u'source': u'openstreetmap.org', u'service': u'drive-through', u'highway': u'service', u'oneway': u'yes' })) # noqa self.assert_has_feature(16, 10478, 25338, 'roads', { 'id': 219071307, 'kind': 'minor_road', 'service': 'drive_through' })
def test_valle_az(self): # Valle, AZ (disused=station) self.generate_fixtures( dsl.way( 366220389, wkt_loads('POINT (-112.200039193448 35.65261688375637)'), { u'name': u'Valle', u'gnis:reviewed': u'no', u'addr:state': u'AZ', u'ele': u'1794', u'source': u'openstreetmap.org', u'gnis:feature_id': u'21103', u'disused': u'station', u'gnis:county_name': u'Coconino' })) # noqa self.assert_no_matching_feature(16, 12342, 25813, 'pois', {'id': 366220389})
def test_windmill_without_attraction(self): # windmill without tourism = attraction self.generate_fixtures( dsl.way(2304462088, wkt_loads('POINT (-121.222603731272 36.38242898668528)'), { u'source': u'openstreetmap.org', u'man_made': u'windmill' })) # noqa self.assert_no_matching_feature(14, 2675, 6412, 'pois', { 'id': 2304462088, 'kind': 'windmill' }) self.assert_has_feature(15, 5350, 12824, 'pois', { 'id': 2304462088, 'kind': 'windmill' })
def test_snow_fence(self): # snow_fence in landuse self.generate_fixtures( dsl.way( 356771680, wkt_loads( 'LINESTRING (-105.418546531019 41.17472586849339, -105.417813236252 41.17203419617208, -105.417465408574 41.17044640452401)' ), { u'source': u'openstreetmap.org', u'man_made': u'snow_fence' })) # noqa self.assert_has_feature(15, 6788, 12264, 'landuse', {'kind': 'snow_fence'}) # snow_fence not in boundaries self.assert_no_matching_feature(15, 6788, 12264, 'boundaries', {'kind': 'snow_fence'})
def test_elevator_way(self): import dsl z, x, y = (16, 19300, 24647) self.generate_fixtures( # https://www.openstreetmap.org/way/510502210 dsl.way( 510502210, dsl.tile_box(z, x, y), { 'highway': u'elevator', 'level': u'(-1,-2)', 'source': u'openstreetmap.org', }), ) self.assert_has_feature(z, x, y, 'pois', { 'id': 510502210, 'kind': u'elevator', })
def test_retaining_wall(self): # retaining_wall in landuse self.generate_fixtures( dsl.way( 288896098, wkt_loads( 'LINESTRING (-73.99848590124648 40.75414757104189, -73.99858175148739 40.75397751643467, -73.9986491251337 40.75378119434839, -73.99868658488099 40.75361998524168)' ), { u'source': u'openstreetmap.org', u'barrier': u'retaining_wall' })) # noqa self.assert_has_feature(15, 9648, 12315, 'landuse', {'kind': 'retaining_wall'}) # retaining_wall not in boundaries self.assert_no_matching_feature(15, 9648, 12315, 'boundaries', {'kind': 'retaining_wall'})
def test_sports_pitch_with_name(self): import dsl z, x, y = (16, 0, 0) self.generate_fixtures( dsl.way( 1, dsl.tile_box(z, x, y), { 'leisure': 'pitch', 'name': 'Foo pitch', 'source': u'openstreetmap.org', }), ) self.assert_has_feature(z, x, y, 'pois', { 'id': 1, 'min_zoom': 16, 'kind': 'pitch', })