- Ruby with Sinatra framework for
router
andpointer
REST API. - Routing mechanism using Astar algorithm implementation of
mormon
library by readingosm
files generated by mapzen. Routing by osm is done by calculating between nodes. - Pointer converts
longitude
andlatitude
into array of osm nodes using Elasticsearch's feature of geo distance query.
- Electron app that called
router
,pointer
andGoogle Maps
API.
Sample Request:
POST /pointer HTTP/1.1
Content-Type: application/json; charset=utf-8
Host: localhost:4567
{
"lat": -6.893559,
"lon": 107.611851,
"distance": "15m"
}
Sample Response:
{
"status": "success",
"data": {
"took": 5,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 2,
"max_score": 1.0,
"hits": [
{
"_index": "bandung",
"_type": "location",
"_id": "32524032",
"_score": 1.0,
"_source": {
"pin": {
"location": {
"lat": -6.8936441,
"lon": 107.6119504
}
}
}
},
{
"_index": "bandung",
"_type": "location",
"_id": "1880477622",
"_score": 1.0,
"_source": {
"pin": {
"location": {
"lat": -6.893564,
"lon": 107.6119466
}
}
}
}
]
}
}
}
Sample Request:
POST /router HTTP/1.1
Content-Type: application/json
Host: localhost:4567
{
"start": 3376871364,
"destination": 32524032
}
Sample Response:
{
"status": "success",
"data": [
[
-6.893759,
107.6084671
],
[
-6.8935901,
107.6087933
],
[
-6.8933655,
107.6093821
],
[
-6.8932224,
107.6101272
],
[
-6.8932083,
107.6103897
],
[
-6.893203,
107.6105077
],
[
-6.8932536,
107.610902
],
[
-6.8934601,
107.6115446
],
[
-6.8936441,
107.6119504
]
]
}
-
This project was tested on Elasticsearch 5.4.0, Ruby 2.3.1 and NodeJS 6.10.3.
-
Clone the project.
-
Extract
bandung_coord.csv.zip
andbandung_indonesia.osm.zip
insidedata
directory. -
Make sure Elasticsearch is up and running.
-
Create Elasticsearch mapping by running
$ curl -X "PUT" "http://localhost:9200/bandung" -H "Content-Type:application/json" -d $'{"mappings":{"location":{"properties":{"pin":{"properties":{"location":{"type":"geo_point"}}}}}}}'
-
Run
$ gem install faraday
and then$ ruby seeder.rb
and wait till the process finished. -
After seeding process finished, go to
source/router-api
directory and run$ bundle install
to install the dependencies. -
In
source/router-api
directory, run$ ruby application.rb
to start the API. -
Obtain API Key of Google Maps and edit
index.html
insidesource/maps-gui
directory. -
In
source
directory run$ npm install electron -g
to fetch the Electron binaries. -
Run
$ electron maps-gui
.
- Danny Pranoto for helping me with
index.html
andmain.css
creation.