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

Fixed unnecessary GDAL dependency. #100

Merged
merged 3 commits into from
Dec 5, 2018
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions djgeojson/views.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import math

import django
from django.core.exceptions import ImproperlyConfigured

try:
from django.contrib.gis.db.models.functions import Intersection
except ImportError:
pass
except (ImportError, ImproperlyConfigured):
Intersection = None
from django.views.generic import ListView
from django.utils.decorators import method_decorator
from django.views.decorators.gzip import gzip_page
Expand Down Expand Up @@ -149,7 +150,8 @@ def get_queryset(self):
# Won't trim point geometries to a boundary
model_field = qs.model._meta.get_field(self.geometry_field)
self.trim_to_boundary = (self.trim_to_boundary and
not isinstance(model_field, PointField))
not isinstance(model_field, PointField) and
Intersection)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intersection is not None would be easier to read I think

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Fix incoming.

if self.trim_to_boundary:
if django.VERSION < (1, 9):
qs = qs.intersection(bbox)
Expand Down