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

working trim_to_boundary #71

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 5 additions & 1 deletion djgeojson/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def end_serialization(self):
self.options.pop('properties', None)
self.options.pop('primary_key', None)
self.options.pop('geometry_field', None)
self.options.pop('trim_to_boundary', None)
self.options.pop('use_natural_keys', None)
self.options.pop('crs', None)
self.options.pop('srid', None)
Expand Down Expand Up @@ -354,7 +355,10 @@ def serialize(self, queryset, **options):
self.stream = options.get("stream", StringIO())
self.primary_key = options.get("primary_key", None)
self.properties = options.get("properties")
self.geometry_field = options.get("geometry_field", "geom")
if options.get("trim_to_boundary", None):
self.geometry_field = 'intersection'
else:
self.geometry_field = options.get("geometry_field", "geom")
self.use_natural_keys = options.get("use_natural_keys", False)
self.bbox = options.get("bbox", None)
self.bbox_auto = options.get("bbox_auto", None)
Expand Down
4 changes: 2 additions & 2 deletions djgeojson/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ def render_to_response(self, context, **response_kwargs):
geometry_field=self.geometry_field,
force2d=self.force2d,
bbox=self.bbox,
bbox_auto=self.bbox_auto)
bbox_auto=self.bbox_auto,
trim_to_boundary=self.trim_to_boundary)
serializer.serialize(queryset, stream=response, ensure_ascii=False,
**options)
return response
Expand Down Expand Up @@ -134,6 +135,5 @@ def get_queryset(self):
not isinstance(model_field, PointField))
if self.trim_to_boundary:
qs = qs.intersection(bbox)
self.geometry_field = 'intersection'

return qs