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

On invalid geometry make valid and clean #78

Open
wants to merge 59 commits into
base: master
Choose a base branch
from
Open
Changes from 10 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
e612122
Adding extra function which cleans an invalid MultiPolygon
Oct 28, 2016
632c251
New test for clean_multi
Oct 28, 2016
66dde6a
Add new custom validity function (on_invalid_geometry_make_valid_and_…
Oct 28, 2016
6c1e37f
Adding new method that make polygon valid
Nov 3, 2016
e463bd8
Script for benching encoding
Nov 7, 2016
c904d12
First version of more simple encoding
Oct 28, 2016
5444a6f
Improved looping in _geo_encode
Oct 28, 2016
f4e1e95
Moved encoding of geometry to a class
Oct 28, 2016
8270239
Moved geometry encoding to a dedicated module
Oct 28, 2016
427a8e9
Fixed wrong tests : points are skipped in linestrings if they are the…
Oct 28, 2016
acaa3a0
Fixed flake8 errors
Oct 28, 2016
6e1a21c
Fixed tests unproperly removed
Nov 2, 2016
d41a81a
function force_int()
Nov 2, 2016
4688db8
Moved all encoding logic to the GeometryEncoder class
Nov 2, 2016
2c504fc
flake8
Nov 2, 2016
5d29ee5
Don't encode geometries where LINE_TO commands are reduced to 0
Nov 2, 2016
5aee985
points and multipoints in the new encoding model
Nov 2, 2016
10cdaef
Small refactor
Nov 2, 2016
09f5c25
Working version without last_x and last_y as properties
Nov 3, 2016
3468ead
Only pure functions
Nov 3, 2016
5de59e3
_last_x and _last_y are back as GeometryEncoder variables
Nov 3, 2016
d2856fc
Slight improvement in coords_on_grid
Nov 3, 2016
385991a
When a shape is to small to be displayed, it shouldn't be added to th…
Nov 3, 2016
8e69c4f
Removed useless code
Nov 3, 2016
e62d787
Adding extra function which cleans an invalid MultiPolygon
Oct 28, 2016
9c50fed
New test for clean_multi
Oct 28, 2016
6e3f7fd
Add new custom validity function (on_invalid_geometry_make_valid_and_…
Oct 28, 2016
6c3a844
Moved round_fn test from the _round function to the VectorTile class …
Nov 9, 2016
64f8b7f
Refactoring code
Nov 10, 2016
7d6c9d8
Remove unnecessary lines
Nov 10, 2016
e5de72c
More pep8 complian
Nov 10, 2016
1ae1511
Applying new code indentation
Nov 10, 2016
be0813a
Adding extra function which cleans an invalid MultiPolygon
Oct 28, 2016
9aee5d9
New test for clean_multi
Oct 28, 2016
682f193
Add new custom validity function (on_invalid_geometry_make_valid_and_…
Oct 28, 2016
bb91f4f
Adding new method that make polygon valid
Nov 3, 2016
177e990
Refactoring code
Nov 10, 2016
95efe73
Remove unnecessary lines
Nov 10, 2016
bc27c2d
More pep8 complian
Nov 10, 2016
f6c43f2
Applying new code indentation
Nov 10, 2016
90fec86
Made winding order optional
Nov 10, 2016
561ef6e
Added winding order to addfeatures function
Nov 10, 2016
ecd221f
Fix bad merge from bad origin
Nov 14, 2016
c545e51
Merge
Nov 14, 2016
4bd85b3
Remove unused import
Nov 14, 2016
4222d97
Make flake8 happy
Nov 14, 2016
03d13ad
Added check_winding_order option to encode function
Nov 14, 2016
dd842fb
fixed missing param on __init__ and encoder.py
Nov 14, 2016
4d657c2
Fix conflicts
Nov 15, 2016
fe7e198
Merge branch 'master' of https://github.com/Mappy/mapbox-vector-tile
Nov 15, 2016
73ef4eb
Fix conflicts
Nov 15, 2016
104f159
Fix remaining conflicts and make flake8 happy
Nov 15, 2016
4ca4f64
On invalid multipolygon clean first before make it valid if necessary
Nov 22, 2016
c27eccc
Remove unecessary test
Nov 22, 2016
cad219f
Revert two last commits
Nov 23, 2016
76def1c
Merge branch 'master' into on_invalid_geometry_make_valid_and_clean
Nov 29, 2016
68fea5d
Merge master and fix conflicts
May 11, 2017
8b044cb
Fix broken tests
May 11, 2017
68772f3
Make more flake8
May 11, 2017
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
15 changes: 10 additions & 5 deletions mapbox_vector_tile/polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,24 +222,29 @@ def clean_multi(shape):
Remove self- and ring-selfintersections from input Polygon geometries
"""
polygons = []
for p in polygons:
exterior_lines = []
interior_lines = []
for p in shape:
exterior_lines = []
interior_lines = []
lnum = 0
boundary = p.boundary
if boundary.type == 'LineString':
exterior_lines.append(boundary)
if lnum == 0:
exterior_lines.append(boundary)
else:
for ls in boundary:
if lnum == 0:
exterior_lines.append(ls)
else:
interior_lines.append(ls)
interior_lines.append(ls)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this spacing change intentional?

lnum += 1
for el in exterior_lines:
if len(interior_lines) == 0:
polygons.append(Polygon(exterior_lines).buffer(0))
polygons.append(Polygon(el).buffer(0))
else:
polygons.append(Polygon(exterior_lines, interior_lines).buffer(0))
for il in interior_lines:
polygons.append(Polygon(el, Polygon(il).interiors).buffer(0))
poly = MultiPolygon(polygons)
assert poly.is_valid, \
"Not valid multipolygon %s because %s" \
Expand Down