02JanDal / osm-bjk

BästaJävlaKartan is a tool that compares OpenStreetMap data against various open data sources from Sweden, and reports and deviations it finds.
https://osm-bjk.jandal.se/
MIT License
3 stars 1 forks source link

Bidirectional sync with MapRoulette #19

Open 02JanDal opened 10 months ago

02JanDal commented 10 months ago

Python API: https://maproulette-python-client.readthedocs.io/en/latest/ Basic format: https://learn.maproulette.org/documentation/line-by-line-geojson/ External identifiers: https://learn.maproulette.org/documentation/setting-external-task-identifiers/

Attaching data: https://learn.maproulette.org/documentation/task-attachments/ Attaching suggestions: https://learn.maproulette.org/documentation/creating-cooperative-challenges/

Starting points:

CREATE FUNCTION api.maproulette(layer_id INT, municipality_code CHAR(4))
RETURNS JSON AS $$
    SELECT json_build_object('type', 'FeatureCollection', 'features', json_agg(ST_AsGeoJSON(deviation)))
    FROM api.deviation
    WHERE layer_id = layer_id AND (municipality_code IS NULL OR municipality_code = deviation.municipality_code);
$$ LANGUAGE SQL IMMUTABLE;

SELECT api.maproulette(15, '2180');

SELECT string_agg(E'\x1e' || json_build_object('type', 'FeatureCollection', 'features', json_build_array(json_build_object(
    'type', 'Feature',
    'id', 'deviation/' || deviation.id,
    'geometry', ST_AsGeoJSON(deviation.suggested_geom)::json,
    'properties', json_build_object(
        '@id', 'deviation/' || deviation.id
    )
))) || E'\n', '')
FROM api.deviation
WHERE deviation.layer_id = 15 AND '2180' = deviation.municipality_code
LIMIT 10: