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

[feature] Add GeoJSON API endpoint with device location data #360

Closed
nemesifier opened this issue Jan 5, 2021 · 2 comments · Fixed by #374
Closed

[feature] Add GeoJSON API endpoint with device location data #360

nemesifier opened this issue Jan 5, 2021 · 2 comments · Fixed by #374
Assignees
Labels
enhancement Important Higher priority or release blocker

Comments

@nemesifier
Copy link
Member

nemesifier commented Jan 5, 2021

Blocked by openwisp/openwisp-users#210.

We need to add a GeoJSON API endpoint (using django-rest-framework-gis) which returns geographic data which can be used to show a general device map.

  • the URL should be something like /api/v1/device/geojson/
  • it should fetch all the devices accessible to the current logged in user: if it's superuser it can see everything, otherwise the user can see only objects related to organizations they manage (we shall use the code which will be implemented in [feature] Add API classes to filter by organization and to check parent objects openwisp-users#210)
  • we need to fetch locations which have devices deployed in them, and for each location we need to know how many devices there are, eg: Location.objects.filter(devicelocation__isnull=False).annotate(device_count=Count('devicelocation'))
  • it should return at max 1000 items and paginate if more items are present, without breaking the GeoJSON format (see https://github.com/openwisp/django-rest-framework-gis/#geojsonpagination)
  • each element should display all the information available in the fields of the Location model (including the location ID)

We also need another endpoint, which will be called whenever an element is clicked on the map, to fetch more information about a specific point.

  • the URL could be something like /api/v1/location/{pk}/device/ (the user must have access to the organization of the location in order to see be able to access the URL)
  • it should return a list of devices, each device should include the basic device and config details, and shall include the URL to admin edit page
@nemesifier nemesifier added enhancement Important Higher priority or release blocker labels Jan 5, 2021
@openwisp openwisp deleted a comment from ManishShah120 Jan 25, 2021
@purhan purhan self-assigned this Jan 26, 2021
@purhan
Copy link
Contributor

purhan commented Jan 26, 2021

@nemesisdesign Thanks for the detailed explanation. However, a few things are not clear to me:

  • /api/v1/device/geojson/ should display devices or locations?
  • Also since both device and location have their own organization field, which one should be the deciding factor?

@nemesifier
Copy link
Member Author

@nemesisdesign Thanks for the detailed explanation. However, a few things are not clear to me:

  • /api/v1/device/geojson/ should display devices or locations?

we need to fetch locations which have devices deployed in them, and for each location we need to know how many devices there are, eg:

Location.objects.filter(devicelocation__isnull=False).annotate(device_count=Count('devicelocation'))

  • Also since both device and location have their own organization field, which one should be the deciding factor?

The two will always match, use the organizaiton field of the main model of the queryset, so if you follow the suggestion above, use the org field on the location model.

purhan added a commit to purhan/openwisp-controller that referenced this issue Jan 27, 2021
purhan added a commit to purhan/openwisp-controller that referenced this issue Jan 27, 2021
purhan added a commit to purhan/openwisp-controller that referenced this issue Jan 27, 2021
nemesifier pushed a commit that referenced this issue Feb 18, 2021
pandafy added a commit to pandafy/openwisp-controller that referenced this issue Dec 18, 2024
pandafy pushed a commit to pandafy/openwisp-controller that referenced this issue Dec 18, 2024
pandafy added a commit to pandafy/openwisp-controller that referenced this issue Dec 18, 2024
…es) openwisp#360

- Fixed mocking of request library in MockRequestPostRunner 
- Do not send metrics on post_migrate if no module is upgraded

Related to openwisp#360

---------

Co-authored-by: Federico Capoano <f.capoano@openwisp.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Important Higher priority or release blocker
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants