mirror of
				https://github.com/django/django.git
				synced 2025-10-30 17:16:10 +00:00 
			
		
		
		
	Fixed #25950 -- Added support for GEOSisClosed.
This commit is contained in:
		
				
					committed by
					
						 Tim Graham
						Tim Graham
					
				
			
			
				
	
			
			
			
						parent
						
							64ba7d8252
						
					
				
				
					commit
					5d348bba31
				
			| @@ -7,10 +7,9 @@ import warnings | ||||
| from ctypes import byref, c_int, c_uint | ||||
|  | ||||
| from django.contrib.gis.geos import prototypes as capi | ||||
| from django.contrib.gis.geos.geometry import ( | ||||
|     GEOSGeometry, ProjectInterpolateMixin, | ||||
| ) | ||||
| from django.contrib.gis.geos.libgeos import get_pointer_arr | ||||
| from django.contrib.gis.geos.error import GEOSException | ||||
| from django.contrib.gis.geos.geometry import GEOSGeometry, LinearGeometryMixin | ||||
| from django.contrib.gis.geos.libgeos import geos_version_info, get_pointer_arr | ||||
| from django.contrib.gis.geos.linestring import LinearRing, LineString | ||||
| from django.contrib.gis.geos.point import Point | ||||
| from django.contrib.gis.geos.polygon import Polygon | ||||
| @@ -114,17 +113,15 @@ class MultiPoint(GeometryCollection): | ||||
|     _typeid = 4 | ||||
|  | ||||
|  | ||||
| class MultiLineString(ProjectInterpolateMixin, GeometryCollection): | ||||
| class MultiLineString(LinearGeometryMixin, GeometryCollection): | ||||
|     _allowed = (LineString, LinearRing) | ||||
|     _typeid = 5 | ||||
|  | ||||
|     @property | ||||
|     def merged(self): | ||||
|         """ | ||||
|         Returns a LineString representing the line merge of this | ||||
|         MultiLineString. | ||||
|         """ | ||||
|         return self._topology(capi.geos_linemerge(self.ptr)) | ||||
|     def closed(self): | ||||
|         if geos_version_info()['version'] < '3.5': | ||||
|             raise GEOSException("MultiLineString.closed requires GEOS >= 3.5.0.") | ||||
|         return super(MultiLineString, self).closed | ||||
|  | ||||
|  | ||||
| class MultiPolygon(GeometryCollection): | ||||
|   | ||||
| @@ -685,7 +685,7 @@ class GEOSGeometry(GEOSBase, ListMixin): | ||||
|         return GEOSGeometry(capi.geom_clone(self.ptr), srid=self.srid) | ||||
|  | ||||
|  | ||||
| class ProjectInterpolateMixin(object): | ||||
| class LinearGeometryMixin(object): | ||||
|     """ | ||||
|     Used for LineString and MultiLineString. | ||||
|     """ | ||||
| @@ -706,3 +706,17 @@ class ProjectInterpolateMixin(object): | ||||
|         if not isinstance(point, Point): | ||||
|             raise TypeError('locate_point argument must be a Point') | ||||
|         return capi.geos_project_normalized(self.ptr, point.ptr) | ||||
|  | ||||
|     @property | ||||
|     def merged(self): | ||||
|         """ | ||||
|         Return the line merge of this Geometry. | ||||
|         """ | ||||
|         return self._topology(capi.geos_linemerge(self.ptr)) | ||||
|  | ||||
|     @property | ||||
|     def closed(self): | ||||
|         """ | ||||
|         Return whether or not this Geometry is closed. | ||||
|         """ | ||||
|         return capi.geos_isclosed(self.ptr) | ||||
|   | ||||
| @@ -1,15 +1,13 @@ | ||||
| from django.contrib.gis.geos import prototypes as capi | ||||
| from django.contrib.gis.geos.coordseq import GEOSCoordSeq | ||||
| from django.contrib.gis.geos.error import GEOSException | ||||
| from django.contrib.gis.geos.geometry import ( | ||||
|     GEOSGeometry, ProjectInterpolateMixin, | ||||
| ) | ||||
| from django.contrib.gis.geos.geometry import GEOSGeometry, LinearGeometryMixin | ||||
| from django.contrib.gis.geos.point import Point | ||||
| from django.contrib.gis.shortcuts import numpy | ||||
| from django.utils.six.moves import range | ||||
|  | ||||
|  | ||||
| class LineString(ProjectInterpolateMixin, GEOSGeometry): | ||||
| class LineString(LinearGeometryMixin, GEOSGeometry): | ||||
|     _init_func = capi.create_linestring | ||||
|     _minlength = 2 | ||||
|     has_cs = True | ||||
| @@ -154,11 +152,6 @@ class LineString(ProjectInterpolateMixin, GEOSGeometry): | ||||
|         "Returns a numpy array for the LineString." | ||||
|         return self._listarr(self._cs.__getitem__) | ||||
|  | ||||
|     @property | ||||
|     def merged(self): | ||||
|         "Returns the line merge of this LineString." | ||||
|         return self._topology(capi.geos_linemerge(self.ptr)) | ||||
|  | ||||
|     @property | ||||
|     def x(self): | ||||
|         "Returns a list or numpy array of the X variable." | ||||
|   | ||||
| @@ -19,8 +19,8 @@ from django.contrib.gis.geos.prototypes.geom import (  # NOQA | ||||
| from django.contrib.gis.geos.prototypes.misc import *  # NOQA | ||||
| from django.contrib.gis.geos.prototypes.predicates import (  # NOQA | ||||
|     geos_contains, geos_covers, geos_crosses, geos_disjoint, geos_equals, | ||||
|     geos_equalsexact, geos_hasz, geos_intersects, geos_isempty, geos_isring, | ||||
|     geos_issimple, geos_isvalid, geos_overlaps, geos_relatepattern, | ||||
|     geos_touches, geos_within, | ||||
|     geos_equalsexact, geos_hasz, geos_intersects, geos_isclosed, geos_isempty, | ||||
|     geos_isring, geos_issimple, geos_isvalid, geos_overlaps, | ||||
|     geos_relatepattern, geos_touches, geos_within, | ||||
| ) | ||||
| from django.contrib.gis.geos.prototypes.topology import *  # NOQA | ||||
|   | ||||
| @@ -23,6 +23,7 @@ class BinaryPredicate(UnaryPredicate): | ||||
|  | ||||
| # ## Unary Predicates ## | ||||
| geos_hasz = UnaryPredicate('GEOSHasZ') | ||||
| geos_isclosed = UnaryPredicate('GEOSisClosed') | ||||
| geos_isempty = UnaryPredicate('GEOSisEmpty') | ||||
| geos_isring = UnaryPredicate('GEOSisRing') | ||||
| geos_issimple = UnaryPredicate('GEOSisSimple') | ||||
|   | ||||
		Reference in New Issue
	
	Block a user