Skip to content

Commit

Permalink
Merge pull request #72 from fle/master
Browse files Browse the repository at this point in the history
Make django-leaflet work without libgeos (fixes #65)
  • Loading branch information
leplatrem committed Jun 13, 2014
2 parents fa7f8bd + 3e0970c commit 6ab9fb4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
4 changes: 2 additions & 2 deletions leaflet/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
GeoJSONField = type(object)
try:
from django.contrib.gis.db.models import GeometryField
from .forms.widgets import LeafletWidget
except ImportError:
GeometryField = type(object)
from django.forms.widgets import Textarea as LeafletWidget

from .forms.widgets import LeafletWidget


class LeafletGeoAdmin(ModelAdmin):
Expand Down
11 changes: 10 additions & 1 deletion leaflet/forms/backport.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

from django.conf import settings
from django.contrib.gis import gdal
from django.contrib.gis.geos import GEOSGeometry, GEOSException
from django.forms.widgets import Widget
from django.template import loader
from django.utils import six
Expand All @@ -43,6 +42,16 @@
from django.utils.translation import ugettext_lazy as _
from django.core import validators

try:
from django.contrib.gis.geos import GEOSGeometry
except ImportError:
from .nogeos import GEOSGeometry

try:
from django.contrib.gis.geos import GEOSException
except ImportError:
from .nogeos import GEOSException

logger = logging.getLogger('django.contrib.gis')


Expand Down
16 changes: 16 additions & 0 deletions leaflet/forms/nogeos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-


class GEOSGeometry(object):
"""
A simple mock of django.contrib.gis.geos.GEOSGeometry to make
django-leaflet work with only django-geojson (without libgeos)
"""
def __init__(self, geo_input, srid=None):
self.srid = srid
self.geojson = geo_input
return


class GEOSException(Exception):
pass

0 comments on commit 6ab9fb4

Please sign in to comment.