Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

gis: Fixed #5434, GEOS `simplify()` may now preserve topologies via p…

…atch from rcoup.

git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@6315 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 9c1714234a8695a8c0838f2e5f650da043a52892 1 parent 101446d
Justin Bronn authored September 15, 2007

Showing 1 changed file with 11 additions and 2 deletions. Show diff stats Hide diff stats

  1. 13  django/contrib/gis/geos/base.py
13  django/contrib/gis/geos/base.py
@@ -496,13 +496,22 @@ def point_on_surface(self):
496 496
         "Computes an interior point of this Geometry."
497 497
         return self._unary_topology(lgeos.GEOSPointOnSurface)
498 498
 
499  
-    def simplify(self, tolerance=0.0):
  499
+    def simplify(self, tolerance=0.0, preserve_topology=False):
500 500
         """
501 501
         Returns the Geometry, simplified using the Douglas-Peucker algorithm
502 502
          to the specified tolerance (higher tolerance => less points).  If no
503 503
          tolerance provided, defaults to 0.
  504
+
  505
+        By default, this function does not preserve topology - e.g. polygons can 
  506
+         be split, collapse to lines or disappear holes can be created or 
  507
+         disappear, and lines can cross. By specifying preserve_topology=True, 
  508
+         the result will have the same dimension and number of components as the 
  509
+         input. This is significantly slower.         
504 510
         """
505  
-        return self._unary_topology(lgeos.GEOSSimplify, c_double(tolerance))
  511
+        if preserve_topology:
  512
+            return self._unary_topology(lgeos.GEOSTopologyPreserveSimplify, c_double(tolerance))
  513
+        else:
  514
+            return self._unary_topology(lgeos.GEOSSimplify, c_double(tolerance))        
506 515
 
507 516
     def relate(self, other):
508 517
         "Returns the DE-9IM intersection matrix for this Geometry and the other."

0 notes on commit 9c17142

Please sign in to comment.
Something went wrong with that request. Please try again.