1
0
mirror of https://github.com/django/django.git synced 2025-06-05 03:29:12 +00:00

Fixed #28020 -- Made GEOSGeometry.json use OGRGeometry.json for better performance.

This commit is contained in:
Sergey Fedoseev 2017-04-05 18:03:24 +05:00 committed by Tim Graham
parent 9f0c82971d
commit 12d0567aa5
5 changed files with 1 additions and 9 deletions

View File

@ -15,7 +15,6 @@ from django.contrib.gis.geos.polygon import Polygon
class GeometryCollection(GEOSGeometry): class GeometryCollection(GEOSGeometry):
_json_type = 'GeometryCollection'
_typeid = 7 _typeid = 7
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
@ -107,13 +106,11 @@ class GeometryCollection(GEOSGeometry):
# MultiPoint, MultiLineString, and MultiPolygon class definitions. # MultiPoint, MultiLineString, and MultiPolygon class definitions.
class MultiPoint(GeometryCollection): class MultiPoint(GeometryCollection):
_allowed = Point _allowed = Point
_json_type = 'MultiPoint'
_typeid = 4 _typeid = 4
class MultiLineString(LinearGeometryMixin, GeometryCollection): class MultiLineString(LinearGeometryMixin, GeometryCollection):
_allowed = (LineString, LinearRing) _allowed = (LineString, LinearRing)
_json_type = 'MultiLineString'
_typeid = 5 _typeid = 5
@property @property
@ -125,7 +122,6 @@ class MultiLineString(LinearGeometryMixin, GeometryCollection):
class MultiPolygon(GeometryCollection): class MultiPolygon(GeometryCollection):
_allowed = Polygon _allowed = Polygon
_json_type = 'MultiPolygon'
_typeid = 6 _typeid = 6

View File

@ -2,7 +2,6 @@
This module contains the 'base' GEOSGeometry object -- all GEOS Geometries This module contains the 'base' GEOSGeometry object -- all GEOS Geometries
inherit from this object. inherit from this object.
""" """
import json
from ctypes import addressof, byref, c_double from ctypes import addressof, byref, c_double
from django.contrib.gis import gdal from django.contrib.gis import gdal
@ -421,7 +420,7 @@ class GEOSGeometry(GEOSBase, ListMixin):
""" """
Return GeoJSON representation of this Geometry. Return GeoJSON representation of this Geometry.
""" """
return json.dumps({'type': self._json_type, 'coordinates': self.coords}) return self.ogr.json
geojson = json geojson = json
@property @property

View File

@ -8,7 +8,6 @@ from django.contrib.gis.shortcuts import numpy
class LineString(LinearGeometryMixin, GEOSGeometry): class LineString(LinearGeometryMixin, GEOSGeometry):
_init_func = capi.create_linestring _init_func = capi.create_linestring
_json_type = 'LineString'
_minlength = 2 _minlength = 2
has_cs = True has_cs = True

View File

@ -7,7 +7,6 @@ from django.contrib.gis.geos.geometry import GEOSGeometry
class Point(GEOSGeometry): class Point(GEOSGeometry):
_json_type = 'Point'
_minlength = 2 _minlength = 2
_maxlength = 3 _maxlength = 3
has_cs = True has_cs = True

View File

@ -7,7 +7,6 @@ from django.contrib.gis.geos.linestring import LinearRing
class Polygon(GEOSGeometry): class Polygon(GEOSGeometry):
_json_type = 'Polygon'
_minlength = 1 _minlength = 1
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):