Skip to content

Maps Routing using A* Pathfinding Algorithm with OSM, Ruby, Elasticsearch and Electron stack

Notifications You must be signed in to change notification settings

panggi/maps-routing-electron

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Maps Routing Electron

screenshot

Stacks

Backend

  • Ruby with Sinatra framework for router and pointer REST API.
  • Routing mechanism using Astar algorithm implementation of mormon library by reading osm files generated by mapzen. Routing by osm is done by calculating between nodes.
  • Pointer converts longitude and latitude into array of osm nodes using Elasticsearch's feature of geo distance query.

Frontend

  • Electron app that called router, pointer and Google Maps API.

REST APIs

Pointer 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
              }
            }
          }
        }
      ]
    }
  }
}

Router API

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
    ]
  ]
}

Installation

  • 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 and bandung_indonesia.osm.zip inside data 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 inside source/maps-gui directory.

  • In source directory run $ npm install electron -g to fetch the Electron binaries.

  • Run $ electron maps-gui.

Credit

  • Danny Pranoto for helping me with index.html and main.css creation.

About

Maps Routing using A* Pathfinding Algorithm with OSM, Ruby, Elasticsearch and Electron stack

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published