You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following groovy script could be used from WPS or OrbisGIS groovy console to extract osm buildings from a French commune.
//Set a path for the filepathOfTheFile = "/tmp/thefile.osm"//Replace the queryqueryURL ="area['ref:INSEE'='56260'][admin_level=8]->.searchArea;way [building](area.searchArea);(._;>;);out;"apiUrl = "http://overpass-api.de/api/interpreter?data=";
defconnection = newURL( apiUrl+URLEncoder.encode(queryURL) ).openConnection() asHttpURLConnectionconnection.setRequestMethod("GET")
printlnconnection.responseCode//Save the result in a fileif(connection.responseCode==200){
inputStream = connection.inputStream;
FileOutputStreamoutputStream = newFileOutputStream(newFile(pathOfTheFile));
intBUFFER_SIZE = 4096intbytesRead = -1;
byte[] buffer = newbyte[BUFFER_SIZE];
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
outputStream.close();
inputStream.close();
}
else{
println"Cannot execute the query"
}
//Import fileprintln"File to import"sql.execute"CALL OSMREAD('"+ pathOfTheFile+"', 'OSM_BRETAGNE', true)";
sql.execute("DROP TABLE IF EXISTS OSM_BRETAGNE_BUILDINGS;CREATE TABLE OSM_BRETAGNE_BUILDINGS(ID_WAY BIGINT PRIMARY KEY) AS SELECT DISTINCT ID_WAY FROM OSM_BRETAGNE_WAY_TAG WT, OSM_BRETAGNE_TAG T WHERE WT.ID_TAG = T.ID_TAG AND T.TAG_KEY IN ('building'); DROP TABLE IF EXISTS OSM_BRETAGNE_BUILDINGS_GEOM; CREATE TABLE OSM_BRETAGNE_BUILDINGS_GEOM AS SELECT ID_WAY, ST_MAKEPOLYGON(ST_MAKELINE(THE_GEOM)) THE_GEOM FROM (SELECT (SELECT ST_ACCUM(THE_GEOM) THE_GEOM FROM (SELECT N.ID_NODE, N.THE_GEOM,WN.ID_WAY IDWAY FROM OSM_BRETAGNE_NODE N,OSM_BRETAGNE_WAY_NODE WN WHERE N.ID_NODE = WN.ID_NODE ORDER BY WN.NODE_ORDER) WHERE IDWAY = W.ID_WAY) THE_GEOM ,W.ID_WAY FROM OSM_BRETAGNE_WAY W,OSM_BRETAGNE_BUILDINGS B WHERE W.ID_WAY = B.ID_WAY) GEOM_TABLE WHERE ST_GEOMETRYN(THE_GEOM,1) = ST_GEOMETRYN(THE_GEOM, ST_NUMGEOMETRIES(THE_GEOM)) AND ST_NUMGEOMETRIES(THE_GEOM) > 2;"
As illustrated in the figure below, the objective is to build a processing chain to analyse the quality of OSM data, extracted for a specified area.
The text was updated successfully, but these errors were encountered: