Skip to content

Instantly share code, notes, and snippets.

@frafra
Last active April 6, 2018 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frafra/28bff90616d2278d77d93c10d34da6a7 to your computer and use it in GitHub Desktop.
Save frafra/28bff90616d2278d77d93c10d34da6a7 to your computer and use it in GitHub Desktop.
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
Copy link
Author

frafra commented Feb 24, 2018

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

@frafra
Copy link
Author

frafra commented Apr 6, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment