Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serializer still depends on GDAL? #75

Closed
flesser opened this issue Feb 23, 2016 · 8 comments · Fixed by #100
Closed

Serializer still depends on GDAL? #75

flesser opened this issue Feb 23, 2016 · 8 comments · Fixed by #100

Comments

@flesser
Copy link

flesser commented Feb 23, 2016

I encountered a strange issue. On my development machine, everything worked fine. When I tried to run my project on another computer, I suddenly got errors like the following when saving a PointField:

>>> self.pointField = {'type': 'Point', 'coordinates': [lon, lat]}
>>> self.save()
[2016-28-23 20:28:53] ERROR [django.contrib.gis:45] Error creating geometry from value '{
  "type":"Point",
  "coordinates":[
    7.09,
    50.72
  ]
}' (Initializing geometry from JSON input requires GDAL.)

After performing a sudo apt-get install gdal-bin (which also installed a whole bunch of other geospatial libraries), the errors were gone. But the whole point of using django-geojson is that I don't need to install geospatial libraries just to store some Points and have nice Leaflet widgets.

On both computers, Django runs in the same freshly installed Python3-virtualenv:

$ pip freeze
Django==1.9.2
PyYAML==3.11
crispy-forms-foundation==0.5.3
django-crispy-forms==1.6.0
django-geojson==2.9.0
django-leaflet==0.18.0
jsonfield==1.0.3
mysqlclient==1.3.7
pytz==2015.7
six==1.10.0
xlwt==1.0.0
@leplatrem
Copy link
Collaborator

That's a string from contrib.gis indeed!

Can you check the type of your PointField ? It should be djgeojson.fields.PointField.

@ghost
Copy link

ghost commented Mar 3, 2016

I can confirm this, had the same issue on arch after installing gdal all works fine!

@dzh21
Copy link

dzh21 commented Jun 2, 2016

the same problem, after sudo aptitude install gdal-bin all good

@maltem-za
Copy link

Confirmed - with the same solution as mentioned above.

Not really surprising considering the following import pattern is used throughout django-geojson & django-leaflet:

# from django-geojson serializers.py
try:
    from django.contrib.gis.geos import WKBWriter
    from django.contrib.gis.geos import GEOSGeometry
    from django.contrib.gis.db.models.fields import GeometryField
except (ImportError, ImproperlyConfigured):
    from .nogeos import WKBWriter
    from .nogeos import GEOSGeometry
    from .fields import GeometryField

As contrib.gis comes with Django I don't see how this was intended to prefer the nogeos stuff. Perhaps contrib.gis used to raise ImproperlyConfigured when gdal isn't present? However django-leaflet only handles ImportError in all the places I looked...

@cgestes
Copy link

cgestes commented Dec 6, 2017

Encountered the same since I updated to 2.11.0 :(

(the bug is not present in 2.10.0)

@leplatrem
Copy link
Collaborator

leplatrem commented Dec 6, 2017

You can check the diff
2.10.0...2.11.0

@Gagaro could you update the Github releases page please? And also, use PRs where Travis tests remain green instead of committing to master (easier to follow regressions etc.). Thanks!

@Gagaro
Copy link
Member

Gagaro commented Dec 6, 2017

Travis tests are green, the only PR I merged without travis was the pip install one which was very simple (but still needed travis...).

And yes I should update the releases.

@coredumperror
Copy link
Contributor

Is there any chance that this issue could be resolved? I just started using django-geojson, and I'm getting the same error as @flesser for apparently the same reason. I don't want to install gdal just to make an import I don't plan to use not crash. I cannot downgrade to 2.10 because my project uses Django 2.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants