Permalink
Browse files

Make save_polygons ignore any polygon with less than 4 points

  • Loading branch information...
1 parent e15d443 commit be1c0f423ab11c6f6a03c269ed4f563a3599424d @mhl mhl committed Nov 10, 2012
Showing with 5 additions and 8 deletions.
  1. +5 −0 mapit/management/command_utils.py
  2. +0 −8 mapit/management/commands/mapit_import_osm.py
@@ -44,6 +44,11 @@ def save_polygons(lookup):
else:
shapes = p
for g in shapes:
+ # Ignore any shape with fewer than four points, to
+ # avoid introducing invalid polygons into the
+ # database.
+ if g.point_count < 4:
+ continue
# XXX Using g.wkt directly when importing Norway KML works fine
# with Django 1.1, Postgres 8.3, PostGIS 1.3.3 but fails with
# Django 1.2, Postgres 8.4, PostGIS 1.5.1, saying that the
@@ -214,14 +214,6 @@ def update_or_create():
g = feat.geom.transform(4326, clone=True)
- # In generating the data we should have
- # excluded any "polygons" with less than four
- # points (the final one being the same as the
- # first), but just in case:
- for polygon in g:
- if polygon.num_points < 4:
- return
-
poly = [ g ]
if options['commit']:

0 comments on commit be1c0f4

Please sign in to comment.