Coder Social home page Coder Social logo

reverse-geocoder's Introduction

reverse-geocoder

Reverse geocoding served over gRPC, written in Scala. Location data is obtained from Geonames.

Reverse geocoding is the process of back (reverse) coding of a point location (latitude, longitude) to a readable address or place name. [Wikipedia]

API

The API is defined in reverse-geocoder.proto:

service ReverseGeocoder {
    rpc ReverseGeocodeLocation (ReverseGeocodeLocationRequest) returns (ReverseGeocodeLocationResponse) {};
}

message ReverseGeocodeLocationRequest {
    double latitude = 1;
    double longitude = 2;
}

message ReverseGeocodeLocationResponse {
    // Empty if none found
    Place place = 1;
}

message Place {
    string name = 1;
    string country_code = 2;
    double latitude = 3;
    double longitude = 4;
    uint32 elevation_meters = 5;
    string timezone = 6;
    uint64 population = 7;
    google.protobuf.Timestamp sunrise_today = 8;
    google.protobuf.Timestamp sunset_today = 9;
}

Building

make docker

By default, the Docker image will download and use the cities500.zip data file from Geonames.

Running

The easiest way to run reverse-geocoder is using Docker:

docker run -d vyshane/reverse-geocoder

You then can make a test request to the service using grpcurl. The application serves the reverse geocoder gRPC service on port 8080.

grpcurl -plaintext \
    -proto src/main/protobuf/reverse-geocoder.proto \
    -d '{"latitude": -20.2664803, "longitude": 57.4679569}' \
    localhost:8080 \
    mu.node.reversegeocoder.ReverseGeocoder/ReverseGeocodeLocation

Sample output of above call, in JSON format:

{
  "place": {
    "name": "Quatre Bornes",
    "countryCode": "MU",
    "latitude": -20.26381,
    "longitude": 57.4791,
    "timezone": "Indian/Mauritius",
    "population": 80961,
    "sunriseToday": "2018-11-13T01:23:08Z",
    "sunsetToday": "2018-11-13T14:25:42Z"
  }
}

Health and Readiness Status

reverse-geocoder will report health and readiness on port 3401 via HTTP, at /health and /readiness respectively. You can poll /readiness during startup to know when reverse-geocoder is ready to be added to your load balancer.

❱ curl -i http://localhost:3401/readiness                                                                                                                                                                                              master 
HTTP/1.1 200 OK 
Content-Type: text/html; charset=utf-8
Date: Tue, 13 Nov 2018 13:48:52 GMT
Connection: keep-alive
Content-Length: 5

Ready%

Configuration

reverse-geocoder can be configured through the following environment variables.

Environment Variable Default Value
GRPC_PORT 8080
STATUS_PORT 3401
PLACES_FILE_PATH N/A

reverse-geocoder's People

Contributors

vyshane avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.