Commit c12a00e5 authored by Daniel Wiesmann's avatar Daniel Wiesmann Committed by Tim Graham
Browse files

Fixed #26455 -- Allowed filtering and repairing invalid geometries.

Added the IsValid and MakeValid database functions, and the isvalid lookup,
all for PostGIS.

Thanks Tim Graham for the review.
parent f6ca63a9
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -64,6 +64,10 @@ class BaseSpatialFeatures(object):
    def supports_relate_lookup(self):
        return 'relate' in self.connection.ops.gis_operators

    @property
    def supports_isvalid_lookup(self):
        return 'isvalid' in self.connection.ops.gis_operators

    # For each of those methods, the class will have a property named
    # `has_<name>_method` (defined in __init__) which accesses connection.ops
    # to determine GIS method availability.
+4 −4
Original line number Diff line number Diff line
@@ -58,10 +58,10 @@ class BaseSpatialOperations(object):
    unsupported_functions = {
        'Area', 'AsGeoJSON', 'AsGML', 'AsKML', 'AsSVG',
        'BoundingCircle', 'Centroid', 'Difference', 'Distance', 'Envelope',
        'ForceRHR', 'GeoHash', 'Intersection', 'Length', 'MemSize', 'NumGeometries',
        'NumPoints', 'Perimeter', 'PointOnSurface', 'Reverse', 'Scale',
        'SnapToGrid', 'SymDifference', 'Transform', 'Translate',
        'Union',
        'ForceRHR', 'GeoHash', 'Intersection', 'IsValid', 'Length', 'MakeValid',
        'MemSize', 'NumGeometries', 'NumPoints', 'Perimeter', 'PointOnSurface',
        'Reverse', 'Scale', 'SnapToGrid', 'SymDifference', 'Transform',
        'Translate', 'Union',
    }

    # Serialization
+1 −1
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ class MySQLOperations(BaseSpatialOperations, DatabaseOperations):
    def unsupported_functions(self):
        unsupported = {
            'AsGeoJSON', 'AsGML', 'AsKML', 'AsSVG', 'BoundingCircle',
            'ForceRHR', 'GeoHash', 'MemSize',
            'ForceRHR', 'GeoHash', 'IsValid', 'MakeValid', 'MemSize',
            'Perimeter', 'PointOnSurface', 'Reverse', 'Scale', 'SnapToGrid',
            'Transform', 'Translate',
        }
+1 −1
Original line number Diff line number Diff line
@@ -127,7 +127,7 @@ class OracleOperations(BaseSpatialOperations, DatabaseOperations):
    unsupported_functions = {
        'AsGeoJSON', 'AsGML', 'AsKML', 'AsSVG',
        'BoundingCircle', 'Envelope',
        'ForceRHR', 'GeoHash', 'MemSize', 'Scale',
        'ForceRHR', 'GeoHash', 'IsValid', 'MakeValid', 'MemSize', 'Scale',
        'SnapToGrid', 'Translate',
    }

+3 −0
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ class PostGISOperations(BaseSpatialOperations, DatabaseOperations):
        'disjoint': PostGISOperator(func='ST_Disjoint'),
        'equals': PostGISOperator(func='ST_Equals'),
        'intersects': PostGISOperator(func='ST_Intersects', geography=True),
        'isvalid': PostGISOperator(func='ST_IsValid'),
        'overlaps': PostGISOperator(func='ST_Overlaps'),
        'relate': PostGISOperator(func='ST_Relate'),
        'touches': PostGISOperator(func='ST_Touches'),
@@ -118,11 +119,13 @@ class PostGISOperations(BaseSpatialOperations, DatabaseOperations):
        self.geojson = prefix + 'AsGeoJson'
        self.gml = prefix + 'AsGML'
        self.intersection = prefix + 'Intersection'
        self.isvalid = prefix + 'IsValid'
        self.kml = prefix + 'AsKML'
        self.length = prefix + 'Length'
        self.length3d = prefix + '3DLength'
        self.length_spheroid = prefix + 'length_spheroid'
        self.makeline = prefix + 'MakeLine'
        self.makevalid = prefix + 'MakeValid'
        self.mem_size = prefix + 'mem_size'
        self.num_geom = prefix + 'NumGeometries'
        self.num_points = prefix + 'npoints'
Loading