Last active
April 6, 2018 20:50
-
-
Save frafra/28bff90616d2278d77d93c10d34da6a7 to your computer and use it in GitHub Desktop.
From GeoPaparazzi notes to OpenStreetMap XML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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'), '"', '"') || '" ' || | |
'v="' || replace(json_extract(value, '$.value'), '"', '"') || '"/>', '' | |
) || | |
'</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; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you want to export to GeoJSON instead of OSM XML use gpap-notes2geojson.sql .