raster2pgsql -s 3857 -d -I -C -M -l 4 n40e9.tif -F -t 100x100 eu_dem_25mx25m > n40e9.sql
psql -U webmapp -d general -h localhost -f n40e9.sql


[out:xml][timeout:1200];
// gather results
relation(7342827);
(._;>;);
out meta;

curl -o relation.osm -g https://overpass-api.de/api/interpreter?data=%5Bout%3Axml%5D%5Btimeout%3A1200%5D%3B%0A%2F%2F%20gather%20results%0Arelation%287342827%29%3B%0A%28._%3B%3E%3B%29%3B%0Aout%20meta%3B

#importo linea geojson in postgis:
psql -U webmapp -d general -h localhost -c "DROP TABLE ogrgeojson "
ogr2ogr -f "PostgreSQL" PG:"dbname=general user=webmapp host=localhost" "line.geojson"

#esporto linea 3d geojson da postgis:
ogr2ogr -f GeoJSON 3dline.geojson "PG:host=localhost dbname=general user=webmapp" -sql "WITH line AS (SELECT ST_TRANSFORM (wkb_geometry, 3857) AS geom FROM ogrgeojson), points2d AS (SELECT (ST_DumpPoints(geom)).geom AS geom FROM line), cells AS (SELECT p.geom AS geom, ST_Value(eu_dem_25mx25m.rast, 1, p.geom) AS val FROM eu_dem_25mx25m, points2d p WHERE ST_Intersects(eu_dem_25mx25m.rast, p.geom)), points3d AS (SELECT ST_SetSRID(ST_MakePoint(ST_X(geom), ST_Y(geom), val), 3857) AS geom FROM cells) SELECT ST_Transform(ST_MakeLine(geom), 4326) AS geom_3d FROM points3d"
