Skip to content

Commit

Permalink
Try to get rid of libgeos dependancy
Browse files Browse the repository at this point in the history
  • Loading branch information
fle committed Jun 28, 2014
1 parent 240b769 commit be7d2cc
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 5 deletions.
16 changes: 16 additions & 0 deletions djgeojson/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-geojson work without libgeos
"""
def __init__(self, geo_input, srid=None):
self.srid = srid
self.geojson = geo_input
return


class WKBWriter(object):
pass
19 changes: 16 additions & 3 deletions djgeojson/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,22 @@
from django.core.serializers.json import DjangoJSONEncoder
from django.core.serializers.base import SerializationError, DeserializationError
from django.utils.encoding import smart_text
from django.contrib.gis.geos import WKBWriter
from django.contrib.gis.geos.geometry import GEOSGeometry
from django.contrib.gis.db.models.fields import GeometryField


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

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

try:
from django.contrib.gis.db.models.fields import GeometryField
except ImportError:
from .fields import GeometryField

from . import GEOJSON_DEFAULT_SRID
from .fields import GeoJSONField
Expand Down
11 changes: 9 additions & 2 deletions djgeojson/templatetags/geojson_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@
from six import string_types

from django import template
from django.contrib.gis.geos import GEOSGeometry
from django.contrib.gis.db.models.fields import GeometryField
try:
from django.contrib.gis.geos import GEOSGeometry
except ImportError:
from ..nogeos import GEOSGeometry

try:
from django.contrib.gis.db.models.fields import GeometryField
except ImportError:
from ..fields import GeometryField

from .. import GEOJSON_DEFAULT_SRID
from ..serializers import Serializer, DjangoGeoJSONEncoder
Expand Down

0 comments on commit be7d2cc

Please sign in to comment.