Coder Social home page Coder Social logo

gfw-glad-alerts-api's Introduction

GFW Glad Alerts API

This repository is the microservice that it implement the glad alerts funcionality and exposed the /glad-alerts endpoints in the api-gateway

View the documentation for this API

First time user

Perform the following steps:

  • Install docker
  • Clone this repository: git clone [email protected]:Vizzuality/gfw-glad-alerts-api.git
  • Enter in the directory (cd gfw-glad-alerts-api)
  • After, you open a terminal (if you have mac or windows, open a terminal with the 'Docker Quickstart Terminal') and execute the next command:
    docker-compose -f docker-compose-develop.yml build

Run in develop mode (Watch mode)

Remember: In windows and Mac, open the terminal with 'Docker Quickstart Terminal'

docker-compose -f docker-compose-develop.yml build
//this command up the machine. If you want up in background mode, you add the -d option

Execute test

Remember: In windows and Mac, open the terminal with 'Docker Quickstart Terminal'

docker-compose -f docker-compose-test.yml run test

Install in heroku

Is necessary define the next environment variables:

  • API_GATEWAY_URI => Url the register of the API Gateway. Remember: If the authentication is active in API Gateway, add the username and password in the url
  • NODE_ENV => Environment (prod, staging, dev)
  • CARTODB_APIKEY => API key to connect to CartoDB
  • CARTODB_USER => User to connect to CartoDB

Is necessary the pem file of Google Earth Engine authentication in the root of the project

Config

register.json

This file contain the configuration about the endpoints that public the microservice. This json will send to the apigateway. it can contain variables:

  • #(service.id) => Id of the service setted in the config file by environment
  • #(service.name) => Name of the service setted in the config file by environment
  • #(service.uri) => Base uri of the service setted in the config file by environment

Example:

{
    "id": "#(service.id)",
    "name": "#(service.name)",
    "urls": [{
        "url": "/story",
        "method": "POST",
        "endpoints": [{
            "method": "POST",
            "baseUrl": "#(service.uri)",
            "path": "/api/v1/story",
            "data": ["loggedUser"]
        }]
    }, {
        "url": "/story/:id",
        "method": "GET",
        "endpoints": [{
            "method": "GET",
            "baseUrl": "#(service.uri)",
            "path": "/api/v1/story/:id"
        }]
    }, {
        "url": "/user",
        "method": "GET",
        "endpoints": [{
            "method": "GET",
            "baseUrl": "#(service.uri)",
            "path": "/api/v1/story"
        }]
    }]
}


```

gfw-glad-alerts-api's People

Contributors

aagm avatar archelogos avatar geriux avatar rrequero avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

leo-hyde

gfw-glad-alerts-api's Issues

No glad alerts from GLAD-API later than June 8 2016.

It is only possible to retrieve alerts up to June 8th 2016.

For example the request for all of Republic of Congo:
http://api.globalforestwatch.org/forest-change/glad-alerts/admin/ROC?period=2016-07-04,2016-08-10

Returns, among other things, the query string:

https://wri-01.cartodb.com/api/v2/sql?q=SELECT+f.date%2C+st_transform%28f.the_geom_webmercator%2C+4326%29+as+the_geom%2C+ST_Y%28st_transform%28the_geom_webmercator%2C+4326%29%29+as+lat%2C+ST_X%28st_transform%28the_geom_webmercator%2C+4326%29%29+as+long+FROM+umd_alerts_agg_analysis+f+WHERE+iso+%3D+UPPER%28%27PER%27%29+AND+date+%3E%3D+%272016-01-01%27%3A%3Adate+AND+date+%3C%3D+%272016-08-10%27%3A%3Adate&version=v2&format=csv

URL decoded this gives
/sql?q=SELECT f.date, st_transform(f.the_geom_webmercator, 4326) as the_geom, ST_Y(st_transform(the_geom_webmercator, 4326)) as lat, ST_X(st_transform(the_geom_webmercator, 4326)) as long FROM umd_alerts_agg_analysis f WHERE iso = UPPER('PER') AND date >= '2016-01-01'::date AND date <= '2016-08-10'::date&version=v2&format=c

And this gives a large file of 368934 CSV rows.

Sorting by dates, the latest date in the file is June 8th 2016.

Similarly the request for Peru:
http://api.globalforestwatch.org/forest-change/glad-alerts/admin/PER?period=2016-05-04,2016-09-01

Response includes the query:
https://wri-01.cartodb.com/api/v2/sql?q=SELECT+f.date%2C+st_transform%28f.the_geom_webmercator%2C+4326%29+as+the_geom%2C+ST_Y%28st_transform%28the_geom_webmercator%2C+4326%29%29+as+lat%2C+ST_X%28st_transform%28the_geom_webmercator%2C+4326%29%29+as+long+FROM+umd_alerts_agg_analysis+f+WHERE+iso+%3D+UPPER%28%27PER%27%29+AND+date+%3E%3D+%272016-05-04%27%3A%3Adate+AND+date+%3C%3D+%272016-09-01%27%3A%3Adate&version=v2&format=csv

URL decoded this is
/sql?q=SELECT f.date, st_transform(f.the_geom_webmercator, 4326) as the_geom,ST_Y(st_transform(the_geom_webmercator, 4326)) as lat,ST_X(st_transform(the_geom_webmercator, 4326)) as long FROM umd_alerts_agg_analysis f WHERE iso = UPPER('PER') AND date >= '2016-05-04'::date AND date <= '2016-09-01'::date&version=v2format=csv

Returns a file of 132270 rows, but still the latest row is June 8th.

Change the last line to format=kml, returns a kml file with the same result - no alerts since June 8th.

I have been unable to retrieve any alerts later than this date for several months now.

Has anyone else been experiencing this issue?

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.