Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix problems with disputed boundaries from RAWR tiles #380

Merged
merged 2 commits into from
May 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions tests/test_query_rawr.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,19 +783,6 @@ def props_fn(shape, props, fid, meta):

return read_rows

def test_linestrings_dropped(self):
# test that linestrings in the RAWR tile don't make it into the tile.
from shapely.geometry import LineString

def _tile_diagonal(bounds):
return LineString([
[bounds[0], bounds[1]],
[bounds[2], bounds[3]],
])

read_rows = self._fetch_data(_tile_diagonal, 'planet_osm_line')
self.assertEqual(read_rows, [])

def test_boundaries_from_polygons(self):
# check that a polygon in the RAWR tile contributes its oriented
# (anti-clockwise) boundary to the tile data.
Expand All @@ -819,6 +806,8 @@ def _tile_triangle(bounds):
self.assertEqual(props.get('boundary'), 'administrative')
# check no area
self.assertIsNone(props.get('area'))
# check we set the flag
self.assertTrue(props.get('mz_boundary_from_polygon'))

def test_boundaries_from_multipolygons(self):
# check that the boundary extraction code also works for multipolygons
Expand Down Expand Up @@ -861,6 +850,8 @@ def _tile_squares(bounds):
self.assertEqual(props.get('boundary'), 'administrative')
# check no area
self.assertIsNone(props.get('area'))
# check we set the flag
self.assertTrue(props.get('mz_boundary_from_polygon'))


class TestBufferedLand(RawrTestCase):
Expand Down
11 changes: 5 additions & 6 deletions tilequeue/query/rawr.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,10 +798,7 @@ def _parse_row(self, zoom, unpadded_bounds, bbox, source, fid, shape,
# disable this special processing for those features.
if read_row and '__boundaries_properties__' in read_row and \
read_row['__boundaries_properties__'].get('kind') != 'maritime':
if shape.geom_type in ('LineString', 'MultiLineString'):
read_row.pop('__boundaries_properties__')

elif shape.geom_type in ('Polygon', 'MultiPolygon'):
if shape.geom_type in ('Polygon', 'MultiPolygon'):
# make sure boundary rings are oriented in the correct
# direction; anti-clockwise for outers and clockwise for
# inners, which means the interior should be on the left.
Expand All @@ -815,12 +812,14 @@ def _parse_row(self, zoom, unpadded_bounds, bbox, source, fid, shape,
clip_shape = _lines_only(boundaries_shape.intersection(bbox))
read_row['__boundaries_geometry__'] = bytes(clip_shape.wkb)

boundary_props = read_row['__boundaries_properties__']
# we don't want area on boundaries
read_row['__boundaries_properties__'].pop('area', None)
boundary_props.pop('area', None)
boundary_props.pop('way_area', None)

# set a flag to indicate that we transformed this from a
# polygon to a boundary.
read_row['mz_boundary_from_polygon'] = True
boundary_props['mz_boundary_from_polygon'] = True

if read_row:
read_row['__id__'] = fid
Expand Down