From 12d0567aa5e82322543f0c0c126ba18c91a1e439 Mon Sep 17 00:00:00 2001 From: Sergey Fedoseev Date: Wed, 5 Apr 2017 18:03:24 +0500 Subject: [PATCH] Fixed #28020 -- Made GEOSGeometry.json use OGRGeometry.json for better performance. --- django/contrib/gis/geos/collections.py | 4 ---- django/contrib/gis/geos/geometry.py | 3 +-- django/contrib/gis/geos/linestring.py | 1 - django/contrib/gis/geos/point.py | 1 - django/contrib/gis/geos/polygon.py | 1 - 5 files changed, 1 insertion(+), 9 deletions(-) diff --git a/django/contrib/gis/geos/collections.py b/django/contrib/gis/geos/collections.py index 74a45d7cde..c3904774dd 100644 --- a/django/contrib/gis/geos/collections.py +++ b/django/contrib/gis/geos/collections.py @@ -15,7 +15,6 @@ from django.contrib.gis.geos.polygon import Polygon class GeometryCollection(GEOSGeometry): - _json_type = 'GeometryCollection' _typeid = 7 def __init__(self, *args, **kwargs): @@ -107,13 +106,11 @@ class GeometryCollection(GEOSGeometry): # MultiPoint, MultiLineString, and MultiPolygon class definitions. class MultiPoint(GeometryCollection): _allowed = Point - _json_type = 'MultiPoint' _typeid = 4 class MultiLineString(LinearGeometryMixin, GeometryCollection): _allowed = (LineString, LinearRing) - _json_type = 'MultiLineString' _typeid = 5 @property @@ -125,7 +122,6 @@ class MultiLineString(LinearGeometryMixin, GeometryCollection): class MultiPolygon(GeometryCollection): _allowed = Polygon - _json_type = 'MultiPolygon' _typeid = 6 diff --git a/django/contrib/gis/geos/geometry.py b/django/contrib/gis/geos/geometry.py index 13047b0b5b..15c7369b49 100644 --- a/django/contrib/gis/geos/geometry.py +++ b/django/contrib/gis/geos/geometry.py @@ -2,7 +2,6 @@ This module contains the 'base' GEOSGeometry object -- all GEOS Geometries inherit from this object. """ -import json from ctypes import addressof, byref, c_double from django.contrib.gis import gdal @@ -421,7 +420,7 @@ class GEOSGeometry(GEOSBase, ListMixin): """ Return GeoJSON representation of this Geometry. """ - return json.dumps({'type': self._json_type, 'coordinates': self.coords}) + return self.ogr.json geojson = json @property diff --git a/django/contrib/gis/geos/linestring.py b/django/contrib/gis/geos/linestring.py index aec2f558bd..9f98ed7e23 100644 --- a/django/contrib/gis/geos/linestring.py +++ b/django/contrib/gis/geos/linestring.py @@ -8,7 +8,6 @@ from django.contrib.gis.shortcuts import numpy class LineString(LinearGeometryMixin, GEOSGeometry): _init_func = capi.create_linestring - _json_type = 'LineString' _minlength = 2 has_cs = True diff --git a/django/contrib/gis/geos/point.py b/django/contrib/gis/geos/point.py index 3b2a77c81f..d46844248c 100644 --- a/django/contrib/gis/geos/point.py +++ b/django/contrib/gis/geos/point.py @@ -7,7 +7,6 @@ from django.contrib.gis.geos.geometry import GEOSGeometry class Point(GEOSGeometry): - _json_type = 'Point' _minlength = 2 _maxlength = 3 has_cs = True diff --git a/django/contrib/gis/geos/polygon.py b/django/contrib/gis/geos/polygon.py index 221a3b1b04..845c440e53 100644 --- a/django/contrib/gis/geos/polygon.py +++ b/django/contrib/gis/geos/polygon.py @@ -7,7 +7,6 @@ from django.contrib.gis.geos.linestring import LinearRing class Polygon(GEOSGeometry): - _json_type = 'Polygon' _minlength = 1 def __init__(self, *args, **kwargs):