#33840: GEOS C Error when creating a geometry on an M1 Mac
-----------------------------------------+------------------------------
               Reporter:  arielkaluzhny  |          Owner:  nobody
                   Type:  Bug            |         Status:  new
              Component:  GIS            |        Version:  3.2
               Severity:  Normal         |       Keywords:  Geos, M1 Mac
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+------------------------------
 Getting different flavors of a GEOS C Error whenever I try to create a
 geometry. `Point` & `LineString` work fine, but `Polygon`, `MultiPoint`,
 `MultiLineString`, and `MultiPolygon` all fail.

 I know the geometry is valid because it can be created via `GEOSGeometry`.
 Example:

 {{{
 from django.contrib.gis.geos import Point, Polygon, MultiPoint,
 MultiPolygon, MultiLineString, LineString
 from django.contrib.gis.geos.geometry import GEOSGeometry

 poly = GEOSGeometry('POLYGON((4 4, 4 4, 4 4, 4 4))')
 poly.coords()
 >>> (((4.0, 4.0), (4.0, 4.0), (4.0, 4.0), (4.0, 4.0)),)

 poly2 = Polygon(((4, 4), (4, 4), (4, 4), (4, 4)))
 >>> GEOSException: Error encountered checking Geometry returned from GEOS
 C function "GEOSGeom_createPolygon_r".

 ls1 = LineString((0, 0), (1, 1))
 ls2 = LineString((2, 2), (3, 3))
 mls = MultiLineString(ls1, ls2)
 >>> GEOSException: Error encountered checking Geometry returned from GEOS
 C function "GEOSGeom_createCollection_r".

  MultiPoint(Point(0, 0), Point(1, 1))
 >>> GEOSException: Error encountered checking Geometry returned from GEOS
 C function "GEOSGeom_createCollection_r".
 }}}

 More of the error stack trace below:

 {{{
 geos/factories.py:18: in <module>
     p = Polygon(
 ../venv39/lib/python3.9/site-
 packages/django/contrib/gis/geos/polygon.py:46: in __init__
     polygon = self._create_polygon(n_holes + 1, [ext_ring, *init_holes])
 ../venv39/lib/python3.9/site-
 packages/django/contrib/gis/geos/polygon.py:93: in _create_polygon
     return capi.create_polygon(shell, holes_param, c_uint(n_holes))
 ../venv39/lib/python3.9/site-
 packages/django/contrib/gis/geos/libgeos.py:152: in __call__
     return self.func(*args)
 ../venv39/lib/python3.9/site-
 packages/django/contrib/gis/geos/prototypes/threadsafe.py:47: in __call__
     return self.cfunc(self.thread_context.handle.ptr, *args)
 ../venv39/lib/python3.9/site-
 packages/django/contrib/gis/geos/prototypes/errcheck.py:32: in check_geom
     raise GEOSException('Error encountered checking Geometry returned from
 GEOS C function "%s".' % func.__name__)
 E   django.contrib.gis.geos.error.GEOSException: Error encountered
 checking Geometry returned from GEOS C function
 "GEOSGeom_createPolygon_r".
 }}}

 ----

 Operating System & other info:

 - MacOS Monterey 12.4, M1 chip
 - gdal installed via homebrew (3.5.1)
 - Python 3.8.12, Django 3.2
 - also have geos and proj installed previously as dependencies via
 homebrew

 Have set:
 `GDAL_LIBRARY_PATH="/opt/homebrew/lib/libgdal.dylib"`
 `GEOS_LIBRARY_PATH="/opt/homebrew/lib/libgeos_c.dylib"`

 Exact same code is working on an older Mac setup w/ the same environment
 just fine.

 Have also now tried Python 3.9 as well as reinstalling all related brew
 packages.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33840>
Django <https://code.djangoproject.com/>
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070181f3198568-94e7aee0-ccf6-48eb-92f0-3942c5410c5f-000000%40eu-central-1.amazonses.com.

Reply via email to