Giter Club home page Giter Club logo

magicbox-latlon-admin-server's Introduction

Latitude/longitude coordinates to admin ID server

Chat on Gitter Build Status

This is a component of Magic Box

API that takes latitude/longitude pairs and returns an ID and metadata for the administrative boundaries they're located within

screenshot

Example

curl http://localhost:8082/api/coordinates/33.385586,66.445313

returns ...

{
  "iso": "AFG",
  "name_0": "Afghanistan",
  "name_1": "Daykundi",
  "name_2": "Gizab",
  "admin_id": "afg_1_6_53_gadm2-8",
  "lon": 66.445313,
  "lat": 33.385586
}

Dependencies:

NVM

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash

Node.js

nvm install 8

Prerequisites

Setup

git clone https://github.com/unicef/coordinates_to_admin_id_server
cd coordinates_to_admin_id_server
cp config-sample.js config.js
npm install
npm run build

Batch example

curl http://localhost:8082/api/coordinates/33.385586,66.445313,-16.351768,-45.703125

Note to pairs of coordinates in the url. This returns:
[
  {
    "iso": "AFG",
    "name_0": "Afghanistan",
    "name_1": "Daykundi",
    "name_2": "Gizab",
    "admin_id": "afg_1_6_53_gadm2-8",
    "lon": 66.445313,
    "lat": 33.385586
  },
  {
    "iso": "BRA",
    "name_0": "Brazil",
    "name_1": "MinasGerais",
    "name_2": "Riachinho",
    "name_3": "Riachinho",
    "admin_id": "bra_33_13_2179_4369_gadm2-8",
    "lon": -45.703125,
    "lat": -16.351768
  }
]

magicbox-latlon-admin-server's People

Contributors

joyrex2001 avatar jwflory avatar mikefab avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

nixworks thoat

magicbox-latlon-admin-server's Issues

Batch example return error

Dear all,

I am trying to test the batch example, but the server return this:

[{"error":{"message":"No results"}},{"error":{"message":"No results"}}]
 

The all_countries_one_table table has 0 rows .. Is that expected?
The spatial_ref_sys table has 5435 rows.

Any idea about how to resolve this problem?

Curling results in empty response, server crashes

Summary

curling against localhost results in empty response, server throws ECONNREFUSED and crashes

Analysis

I followed the example in the README to see how the project worked, but I was unable to get the output demonstrated in the README. The server starts up as expected, but when I tried curling, it crashes and I don't receive the payload.

It's unclear to me as to why it's not able to retrieve the data.

Expected results

$ curl http://localhost:8082/api/coordinates/33.385586,66.445313

{
  "iso": "AFG",
  "name_0": "Afghanistan",
  "name_1": "Daykundi",
  "name_2": "Gizab",
  "admin_id": "afg_1_6_53_gadm2-8",
  "lon": 66.445313,
  "lat": 33.385586
}

Actual results

$ curl http://localhost:8082/api/coordinates/33.385586,66.445313
curl: (52) Empty reply from server

---

$ npm run build

> [email protected] build /home/jflory/git/unicef/coordinates_to_admin_id_server
> babel src -d dist; node dist/server

src/helper.js -> dist/helper.js
src/router.js -> dist/router.js
src/search.js -> dist/search.js
src/server.js -> dist/server.js
Magic happens on port 8082
/home/jflory/git/unicef/coordinates_to_admin_id_server/dist/search.js:30
      if (err) throw err;
               ^

Error: connect ECONNREFUSED 127.0.0.1:5432
    at Object._errnoException (util.js:1024:11)
    at _exceptionWithHostPort (util.js:1046:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)

Better document pre-requisites

Summary

Better explain how to use the pre-requisites to run this project

Background

We link to two repos, download_shapefiles_from_gadm and import_shapefiles_to_postgres, without explaining what they are or how to use them. It's unclear what is needed by the user to get those repos set up and working in the context of coordinates_to_admin_id_server.

Details

Preferably, the best solution is to prompt the user to set these pre-requisites up interactively when building this project.

Alternatively, better documentation is needed to explain how to set them up and what the user is expected to have running (or not) when using this repo. Do they need to have another project running? Do they need a Postgres database to already be set up and running?

Outcome

Easier to run the project for the first time, better idea of how to set up a development environment or even run it in a production environment

Set description string for repo

Let's set the description field for this repo too, so anyone will know what this repo is for when scrolling or searching on GitHub.

I suggest the first line of the README: API that takes latitude/longitude pairs and returns an ID and metadata for the administrative boundaries they're located within

It requires an admin of the repo to do this. @mikefab can edit it on the home page of the repo.

Edit the repo description

Create Docker image for project

A Docker image lets us "configure" the environment with all the pre-requisites exactly as we wish. This makes it easier for the user to take the software and get started with it (similar to what @carloscdias did with Spark in aggregate_airport_mobility). I'm hoping to complete this in a few hours.

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.