Re: [Django] #31366: GEOSGeometry fails on instance with GEOJson and srid not 4326. (was: GEOSGeometry fails on instance with GEOJson and srid not 4326)

2020-03-16 Thread Django
#31366: GEOSGeometry fails on instance with GEOJson and srid not 4326.
---+--
 Reporter:  Walter Lorenzetti  |Owner:  nobody
 Type:  Bug|   Status:  closed
Component:  GIS|  Version:  master
 Severity:  Normal |   Resolution:  invalid
 Keywords:  Geodjango  | Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--
Changes (by felixxm):

 * status:  new => closed
 * version:  2.2 => master
 * resolution:   => invalid


Comment:

 It's
 [https://docs.djangoproject.com/en/3.0/ref/contrib/gis/geos/#geosgeometry
 documented] that ''"for the GeoJSON format, the SRID is set based on the
 crs member. If crs isn’t provided, the SRID defaults to 4326"''. So if you
 want to use GeoJSON with a different SRID you need to use `crs`, e.g.
 {{{
 {
   "type": "Point",
   "coordinates": [2, 49],
   "crs": {
 "type": "name",
 "properties": {
   "name": "urn:ogc:def:crs:EPSG::3857"
 }
   }
 }
 }}}

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/069.6034d0074b867104fa5a14841aa8c2a0%40djangoproject.com.


[Django] #31366: GEOSGeometry fails on instance with GEOJson and srid not 4326

2020-03-16 Thread Django
#31366: GEOSGeometry fails on instance with GEOJson and srid not 4326
-+---
   Reporter:  Walter Lorenzetti  |  Owner:  nobody
   Type:  Bug| Status:  new
  Component:  GIS|Version:  2.2
   Severity:  Normal |   Keywords:  Geodjango
   Triage Stage:  Unreviewed |  Has patch:  0
Needs documentation:  0  |Needs tests:  0
Patch needs improvement:  0  |  Easy pickings:  0
  UI/UX:  0  |
-+---
 On creating a GEOSGeometry intance by a GEOJson string with a srid not
 4326, I obtain this error:
 coord = '{"type": "Point", "coordinates": [1, 1]}'

 {{{
 g = GEOSGeometry(coord, srid=3857)
 Traceback (most recent call last):
   File "", line 1, in 
   File "/home/envs/g3w_suite_dj22/lib/python3.6/site-
 packages/django/contrib/gis/geos/geometry.py", line 732, in __init__
 raise ValueError('Input geometry already has SRID: %d.' % input_srid)
 ValueError: Input geometry already has SRID: 4326.
 }}}

 So to fix it I use this not beautyfull solution:

 {{{
 g = GEOSGeometry(GEOSGeometry(coord).wkt, srid=3857)
 }}}

 Thanks in advance.
 W

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/054.8ca702193ed0d14148d0985e3c8f4865%40djangoproject.com.