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

support for geojson boundingboxes. auto-generated or using a seperate field on the model #57

Merged
merged 1 commit into from May 18, 2015

Conversation

nmandery
Copy link
Contributor

@nmandery nmandery commented May 7, 2015

This pull request adds support for bounding boxes as specified in the GeoJSON specification at http://geojson.org/geojson-spec.html#bounding-boxes.

The patch implements tow ways how boundingboxes can be specifed, see the following extract of the README documentation:

The GeoJSON specification allows a feature to contain a boundingbox of a feature. GeoFeatureModelSerializer allows two different ways to fill this property. The first is using the geo_field to calculate the bounding box of a feature. This only allows read access for a REST client and can be achieved using auto_bbox. Example:

from rest_framework_gis.serializers import GeoFeatureModelSerializer

class LocationSerializer(GeoFeatureModelSerializer):
    class Meta:
        auto_bbox = True
        model = Location
        geo_field = 'geometry'

The second approach uses the bbox_geo_field to specify an addional GeometryField of the model which will be used to calculate the bounding box. This allows boundingboxes differ from the exact extent of a features geometry. Additionally this enables read and write access for the REST client. Bounding boxes send from the client will be saved as Polygons. Example:

from rest_framework_gis.serializers import GeoFeatureModelSerializer

class LocationSerializer(GeoFeatureModelSerializer):

    class Meta:
        model = BoxedLocation
        geo_field = 'geometry'
        bbox_geo_field = 'bbox_geometry'
        fields = ['name', 'id']

@landscape-bot
Copy link

Code Health
Repository health increased by 0.10% when pulling 336db4b on nmandery:feature/geojson-bbox into 269886e on djangonauts:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.67%) to 95.4% when pulling 336db4b on nmandery:feature/geojson-bbox into 269886e on djangonauts:master.

@landscape-bot
Copy link

Code Health
Code quality remained the same when pulling 294357b on nmandery:feature/geojson-bbox into 269886e on djangonauts:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.67%) to 95.4% when pulling 294357b on nmandery:feature/geojson-bbox into 269886e on djangonauts:master.

@nemesifier
Copy link
Member

hi @nmandery,

the patch looks very good, but I'll need some time to test it.

It'd be great to hear the opinions of other contributors too! @dmeehan @erictheise @JesseCrocker @Shanto

@nmandery
Copy link
Contributor Author

nmandery commented May 8, 2015

Hi @nemesisdesign,

sure thing. Take your time reviewing the patch.

@JesseCrocker
Copy link
Contributor

This looks like a great feature to add. I've got a couple projects where I would use this. 👍for including the bbox_geo_field option.

@landscape-bot
Copy link

Code Health
Code quality remained the same when pulling 294357b on nmandery:feature/geojson-bbox into 9761d6f on djangonauts:master.

@nemesifier nemesifier merged commit 294357b into openwisp:master May 18, 2015
@nemesifier
Copy link
Member

Thank you very much @nmandery, will release 0.9 in a few days.
Please test the development version on your systems if you can.

@nmandery
Copy link
Contributor Author

Thank you for merging.

I just switched to the development version in my projects and everything is doing fine.

@nemesifier
Copy link
Member

@nmandery released now, sorry for the delay
https://pypi.python.org/pypi/djangorestframework-gis/0.9

@nmandery
Copy link
Contributor Author

nmandery commented Jun 1, 2015

@nemesisdesign Thanks again

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 this pull request may close these issues.

None yet

5 participants