freifunk / openwifimap-api

OpenWiFiMap database and its api
40 stars 12 forks source link

drop usage of couchdb #11

Closed SvenRoederer closed 3 years ago

SvenRoederer commented 3 years ago

As stated in #9 the current API became unmaintained and was finally shutdown. @sarumpaet mentioned this was caused of required API-change to recent couchDB versions, which nobody was willing to do. @andrenarchy was this the only reason or are there additional ones?


@sarumpaet has the vision of switching to postgres-postGIS. This might be a way to go, as SQL has proven as a stable "API" in the last decades. Also running a postgresql database is more common than a couchDB. What's the advantage of using the postGIS extension inplace of native postgresql? I expect the native Postgresql support of geometric-data (https://www.postgresql.org/docs/12/datatype-geometric.html) will fit our needs also.

this seems to work with native Postgres already.

geotest=# select * from node ;
 name  |     pos     
-------+-------------
 node1 | (13.5,51)
 node2 | (13.5,51.1)
 node3 | (13.4,51.1)

geotest=# select * from node where pos <@ BOX'(13,51.01,13.45,51.2)';
 name  |     pos     
-------+-------------
 node3 | (13.4,51.1)

geotest=# select * from node where pos <@ BOX'(13,51.01,13.5,51.2)';
 name  |     pos     
-------+-------------
 node2 | (13.5,51.1)
 node3 | (13.4,51.1)

The compare operators can be found: https://www.postgresql.org/docs/12/functions-array.html

sarumpaet commented 3 years ago

The geometric type and query by bounding box is probably fine for our purposes. It doesn't have an exact "give me all nodes with max X meters distance", but as far as I can see even the original OWM didn't have that, and it's not really necessary.

We started a new implementation here: https://github.com/freifunk/openwifimap-api/tree/backend-rewrite-36c3 (which is just scaffolding at the moment; I'd probably use FastAPI rather than aiohttp these days, but it doesn't really matter).

SvenRoederer commented 3 years ago

The geometric type and query by bounding box is probably fine for our purposes. It doesn't have an exact "give me all nodes with max X meters distance", but as far as I can see even the original OWM didn't have that, and it's not really necessary.

Using the "CIRCLE-type" for this should work. Using an existing node as center and the distance as radius should do, inplace of the BBOX.

sarumpaet commented 3 years ago

fixed in 13c379e