Skip to content

Instantly share code, notes, and snippets.

@frafra frafra/gpap-notes2osm.sql
Last active Apr 6, 2018

Embed
What would you like to do?
From GeoPaparazzi notes to OpenStreetMap XML
/*
Description:
This query allows to convert notes from GeoPaparazzi into a OSM XML
file that can be imported into JOSM.
Usage:
$ sqlite3 geopaparazzi.gpap < gpap-notes2osm.sql > geopaparazzi.osm
Made by:
Francesco Frassinelli - https://frafra.eu
*/
with body as (
select '<node action="modify" ' ||
'id="-' || _id || '" ' ||
'lat="' || lat || '" ' ||
'lon="' || lon || '">' ||
group_concat('<tag ' ||
'k="' || replace(json_extract(value, '$.key'), '"', '&quot;') || '" ' ||
'v="' || replace(json_extract(value, '$.value'), '"', '&quot;') || '"/>', ''
) ||
'</node>' as nodes
from notes,
json_each(json_extract(notes.form, '$.forms[0].formitems'))
where json_extract(value, '$.value') != ''
group by _id
)
select '<?xml version="1.0" encoding="UTF-8"?>' ||
'<osm version="0.6" generator="gpap-notes2osm 0.0.3">' ||
group_concat(nodes, '') ||
'</osm>'
from body;
@frafra

This comment has been minimized.

Copy link
Owner Author

frafra commented Feb 24, 2018

If you want to export to GeoJSON instead of OSM XML use gpap-notes2geojson.sql .

@frafra

This comment has been minimized.

Copy link
Owner Author

frafra commented Apr 6, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.