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

No bounding box in FeatureCollection #101

Open
azlekov opened this issue Mar 30, 2016 · 3 comments
Open

No bounding box in FeatureCollection #101

azlekov opened this issue Mar 30, 2016 · 3 comments

Comments

@azlekov
Copy link

azlekov commented Mar 30, 2016

I have following configuration:

class GuideItemSerializer(GeoFeatureModelSerializer):

    class Meta:
        depth = 1
        model = GuideItem
        geo_field = 'point'
        auto_bbox = True
        id_field = False
        fields = ('id', 'name', 'description', 'address', 'city', 'state', 'hours')

I try to fetch and parse this using Android Maps Utils and seems that the parser expects bbox in FeatureCollections but there are bbox in all feature elements but not in the root, take a look here: Snippet

@nemesifier
Copy link
Member

drf-gis currently does not support adding bbox properties to a FeatureCollection. You may achieve this by extending one of its serializer and adding the custom logic needed to suit your needs. If you publish your solution here more people will be able to see it, use it, improve it and it might be eventually merged.

@azlekov
Copy link
Author

azlekov commented Apr 2, 2016

@nemesisdesign, thanks. I examined drf-gis serializers and I will open pull request soon.

@nemesifier
Copy link
Member

The bounding box on the feature collection is not implemented correctly in drf-gis. We should fix that.

From the spec: https://tools.ietf.org/html/rfc7946#section-5

A GeoJSON object MAY have a member named "bbox" to include
information on the coordinate range for its Geometries, Features, or
FeatureCollections. The value of the bbox member MUST be an array of
length 2*n where n is the number of dimensions represented in the
contained geometries, with all axes of the most southwesterly point
followed by all axes of the more northeasterly point. The axes order
of a bbox follows the axes order of geometries.

The "bbox" values define shapes with edges that follow lines of
constant longitude, latitude, and elevation.

Example of a 2D bbox member on a Feature:

{
"type": "Feature",
"bbox": [-10.0, -10.0, 10.0, 10.0],
"geometry": {
"type": "Polygon",
"coordinates": [
[
[-10.0, -10.0],
[10.0, -10.0],
[10.0, 10.0],
[-10.0, -10.0]
]
]
}
//...
}

Example of a 2D bbox member on a FeatureCollection:

{
"type": "FeatureCollection",
"bbox": [100.0, 0.0, 105.0, 1.0],
"features": [
//...
]
}

Example of a 3D bbox member with a depth of 100 meters:

{
"type": "FeatureCollection",
"bbox": [100.0, 0.0, -100.0, 105.0, 1.0, 0.0],
"features": [
//...
]
}

So when the object is a FeatureCollection we should output the bbox only at the FeatureCollection level and not in each feature contained in it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants