Geo data is getting more and more important for today’s applications. The growing number of location-aware services, IoT applications and other solutions using latitude and longitude ask for precise and fast processing of geo data.
Let me show you in this quick demonstration how you can use geo functions and visualize your data using Foxx and leaflet.js.
First install the Foxx Service hosted on GitHub: https://github.com/arangodb-foxx/demo-geo
To do that, simply open the ArangoDB Web UI and install either via the GitHub method or download the zip-file and import it.
After the finished installation you need to import the needed datasets as well using arangoimp:
./arangoimp restaurants.json --collection restaurants
./arangoimp neighborhoods.json --collection neighborhoods
Open the Web UI’s Services menu and click on the newly installed Foxx service “geo-example”. You’ll see a button “Show Interface”. Just hit the button and start exploring some geo functionalities.
* Click the
Random restaurant button to draw and point to a random restaurant.
* Click the
Random neighborhood button to draw and point to a random neighborhood.
* Click on a
drawn neighborhood to also show all restaurants within that range.
In total there are three routes defined inside the Foxx service
- /restaurants (returns a random restaurant)
- /neighborhoods (returns a random neighborhood)
- /pointsInNeighborhood/:id (returns all restaurants within a neighborhood, id is the document-handle)
The first two routes only use the collections
any() function. The third route defines a small AQL query to do the calculation of restaurants (points) in the neighborhoods (polygons). The browser logic is implemented in
frontend/js/app.js. The used library to do the rendering is leaflet.js. Feel free to examine the code for more details or ask questions your questions in the comments below.
Pingback: An Introduction to Geo Indexes and their performance characteristics: Part I – Cloud Data Architect