Ticket #5434: simplify_preserve_topology.patch

File simplify_preserve_topology.patch, 1.5 KB (added by Robert Coup, 17 years ago)
  • django/contrib/gis/geos/base.py

     
    480480        "Computes an interior point of this Geometry."
    481481        return self._unary_topology(lgeos.GEOSPointOnSurface)
    482482
    483     def simplify(self, tolerance=0.0):
     483    def simplify(self, tolerance=0.0, preserve_topology=False):
    484484        """
    485485        Returns the Geometry, simplified using the Douglas-Peucker algorithm
    486486         to the specified tolerance (higher tolerance => less points).  If no
    487487         tolerance provided, defaults to 0.
     488
     489        By default, this function does not preserve topology - e.g. polygons can
     490         be split, collapse to lines or disappear holes can be created or
     491         disappear, and lines can cross. By specifying preserve_topology=True,
     492         the result will have the same dimension and number of components as the
     493         input. This is significantly slower.         
    488494        """
    489         return self._unary_topology(lgeos.GEOSSimplify, c_double(tolerance))
     495        if preserve_topology:
     496            return self._unary_topology(lgeos.GEOSTopologyPreserveSimplify, c_double(tolerance))
     497        else:
     498            return self._unary_topology(lgeos.GEOSSimplify, c_double(tolerance))       
    490499
    491500    def relate(self, other):
    492501        "Returns the DE-9IM intersection matrix for this Geometry and the other."
Back to Top