akvo / akvo-maps

Akvo Maps service
GNU Affero General Public License v3.0
0 stars 1 forks source link

Akvo Maps service (Proof of Concept) #1

Closed iperdomo closed 7 years ago

iperdomo commented 7 years ago

The Akvo Maps service is in charge of serving tiles to be use in Akvo products (Flow, Lumen, etc).

Deliverables

Assumptions

Out of scope

iperdomo commented 7 years ago

Our base image should be something that will be supported for a few years, e.g. Ubuntu 14.04 or 16.04

https://upload.wikimedia.org/wikipedia/en/timeline/09570d97e8879c50ac2be27c6a39b045.png

strk commented 7 years ago

You mentioned you want the PostGIS docker image to have a demo database preloaded with data, correct ? Do you have a link to such example data or do you want me to put something togheter ?

mtwestra commented 7 years ago

@strk, I'll send you a data set by email

strk commented 7 years ago

Ok. The data will need to be in this git repository in order to get into the PostGIS docker, fine with you ?

mtwestra commented 7 years ago

@strk, yes, that is fine - it is an open data set

strk commented 7 years ago

With 7d8c759 I made a stub at a akvo-postgis image, with an "akvo" database preloaded with the given dataset. NOTE: 150 records in that CSV file have empty longitude/latitude

Tomorrow will look at the windshaft component

strk commented 7 years ago

I've made progress, but hit a roadblock: https://github.com/CartoDB/Windshaft/issues/503

Basically, it looks like Windshaft is now also depending on the presence of CartoDB functions in the database. For the POC I'll probably add the required functions (in a few hours)

mtwestra commented 7 years ago

@strk, the main issue for us is that most hosted postgres services don't support custom extensions, so if the functions are part of an extension, it is a problem. However, those services do support loading individual SQL functions, so that could be a fallback option if needed. But the dependency does seem strange.

strk commented 7 years ago

Ok for this POC I'll give priority to get it up and running, later I'll see how could the required structure be added to a database w/out using extensions (does it also apply to PostGIS or can it be considered available on systems?).

mtwestra commented 7 years ago

@strk, absolutely, for the POC it is no problem. PostGIS is always available as an extension, it is just unknown 'custom' extensions that are restricted.

strk commented 7 years ago

So it turns out the required database function are shipped with Windshaft, so I modified the Docker for the database to load those functions from SQL files (no need for them to be on the server).

As of current master (71947a876dbc17eb62af06e99f5a54e06a682c3b) you can get a running system by following instructions in the top-level README.md file.

Please let me know if you can get to the point of seeing those blue dots :)

NOTE: you'll have to zoom in to see more dots, evidently the default CSS forbids overlaps (but can be changed in the viewer interface)

mtwestra commented 7 years ago

@strk, @iperdomo, excellent! We'll be testing first thing in the morning, and let you know the results.

iperdomo commented 7 years ago

It seems that our development.js settings has a reference to the_geom column (not completely sure if this is the issue of this error in the logs.

2016-11-09 20:25:04 UTC [8-1] LOG:  database system is ready to accept connections
2016-11-09 20:25:39 UTC [18-1] akvo@akvo ERROR:  attribute "the_geom" does not exist
2016-11-09 20:25:39 UTC [18-2] akvo@akvo STATEMENT:  SELECT row_to_json(s) as result FROM(select _postgis_stats('public.liberia'::regclass, 'the_geom') as stats) as s
2016-11-09 20:27:12 UTC [26-1] akvo@akvo ERROR:  attribute "the_geom" does not exist
2016-11-09 20:27:12 UTC [26-2] akvo@akvo STATEMENT:  SELECT row_to_json(s) as result FROM(select _postgis_stats('public.liberia'::regclass, 'the_geom') as stats) as s
2016-11-09 20:33:06 UTC [38-1] akvo@akvo ERROR:  attribute "the_geom" does not exist
2016-11-09 20:33:06 UTC [38-2] akvo@akvo STATEMENT:  SELECT row_to_json(s) as result FROM(select _postgis_stats('public.liberia'::regclass, 'the_geom') as stats) as s
2016-11-09 20:33:19 UTC [41-1] akvo@akvo ERROR:  attribute "the_geom" does not exist
2016-11-09 20:33:19 UTC [41-2] akvo@akvo STATEMENT:  SELECT row_to_json(s) as result FROM(select _postgis_stats('public.liberia'::regclass, 'the_geom') as stats) as s
2016-11-09 20:42:53 UTC [52-1] akvo@akvo ERROR:  attribute "the_geom" does not exist
2016-11-09 20:42:53 UTC [52-2] akvo@akvo STATEMENT:  SELECT row_to_json(s) as result FROM(select _postgis_stats('public.liberia'::regclass, 'the_geom') as stats) as s
strk commented 7 years ago

It's a bug in Windshaft, filed earlier today: https://github.com/CartoDB/Windshaft/issues/504

iperdomo commented 7 years ago

I can see the blue dots :+1: 2016-11-09-215253_865x610_scrot

strk commented 7 years ago

On Wed, Nov 09, 2016 at 12:53:34PM -0800, Iván Perdomo wrote:

I can see the blue dots :+1: 2016-11-09-215253_865x610_scrot

:)

Try adding to the CSS:

marker-fill:#f45; marker-line-color:#813; marker-allow-overlap:true; marker-fill-opacity: 0.3;

iperdomo commented 7 years ago

Interesting :smile:

2016-11-10-084351_840x786_scrot

iperdomo commented 7 years ago

... adding a OSM base layer

2016-11-10-091553_839x815_scrot

strk commented 7 years ago

Nice! How did you add the baselayer ? Worth pushing it :)

iperdomo commented 7 years ago

Done in https://github.com/akvo/akvo-maps/commit/c9cb5f2adfbbca61d9fd6a2cf0a6d412fe83cbce

iperdomo commented 7 years ago

@strk do you think the tile server can be setup using a maintained version of express? Checking the package.json we depend on "express": "~2.5.11" while this version is not longer supported:

Express 2.x IS NO LONGER MAINTAINED Known and unknown security and performance issues in 2.x have not been addressed since the last update (29 June, 2012). It is highly recommended to use the latest version of Express.

http://expressjs.com/2x/

strk commented 7 years ago

Sure, as the http-facing part is all handled by "us".

Note that we're using the example server implementation as found in "windshaft", so it needs more cleanups too ...

iperdomo commented 7 years ago

Having some fun with CartoCSS. The blue points are water pumps with year construction on 2009 or later (had to clean up the data in the query).

{
  "version": "1.5.0",
  "layers": [
    {
      "type": "mapnik",
      "options": {
        "sql": "select instance, geom, yearcons::integer as yearcons from liberia where yearcons ~ '^\\d{4}$';",
        "geom_column": "geom",
        "cartocss": "#s { marker-width: 5; marker-fill:#f45; marker-line-color:#813;
  marker-allow-overlap:true; marker-fill-opacity: 0.3;} #s[yearcons>=2009] {marker-fill: #1F78B4; marker-line-color: #0000FF;}",
        "cartocss_version": "2.0.0",
        "interactivity": "instance"
      }
    }
  ]
}

2016-11-11-111950_910x616_scrot

strk commented 7 years ago

Nice ! Not as much fun in upgrading server to express 5 :) -- but slowly getting there.

WARNING: I've pushed a commit changing the name of the "akvo-windshaft" image to "akvo-tiler"

strk commented 7 years ago

Express upgraded to 4.3.x as of 9829a41fcc911830b4248031c3479b5e777c25c1 I suggest further changes are discussed with separate issues (as I'd call the Proof of Concept completed, don't you think?)

iperdomo commented 7 years ago

@strk agree. No need more code changes. There are some function calls in the data (postgis image) that I would like to document. The MultiLayer API is already documented, but the data preparation for a table to be used as source of markers is something I would like to have documented.

Deliverables

strk commented 7 years ago

Will document in a README in the image/postgis

iperdomo commented 7 years ago

I think with the current state we're done as proof of concept