Hi,
So unfortunately the way osmosis works, there are only linestrings
in LGD, which however can be converted to polygons.
This has to be decided on the tags, e.g. Parks are most likely to be
interpreted as polygons - but the transformation can be done
directly with sparql:
Basically, you just have to replace "LINESTRING" with "POLYGON(" and
append a closing ")" at the end. They meta:Node / meta:Way triple
can be used to filter
by ways and nodes that imply linestring and point geometries,
respectively.
PREFIX geom:
<http://geovocab.org/geometry#>
PREFIX lgdo:
<http://linkedgeodata.org/ontology/>
PREFIX meta:
<http://linkedgeodata.org/meta/>
PREFIX ogc:
<http://www.opengis.net/ont/geosparql#>
SELECT ?s ?w2 WHERE {
?s
a lgdo:Park ;
a meta:Way ;
geom:geometry [ ogc:asWKT ?w ]
BIND(
bif:st_geomFromText(
concat(
replace(str(?w), "LINESTRING", "POLYGON("),
")"
)) AS ?w2)
}
LIMIT 10
http://linkedgeodata.org/sparql?default-graph-uri=http%3A%2F%2Flinkedgeodata.org&qtxt=PREFIX+geom%3A+%3Chttp%3A%2F%2Fgeovocab.org%2Fgeometry%23%3E%0D%0APREFIX+lgdo%3A+%3Chttp%3A%2F%2Flinkedgeodata.org%2Fontology%2F%3E%0D%0APREFIX+meta%3A+%3Chttp%3A%2F%2Flinkedgeodata.org%2Fmeta%2F%3E%0D%0APREFIX+ogc%3A+%3Chttp%3A%2F%2Fwww.opengis.net%2Font%2Fgeosparql%23%3E%0D%0ASELECT+%3Fs+%3Fw2+WHERE+{%0D%0A++%3Fs%0D%0A++++a+lgdo%3APark+%3B%0D%0A++++a+meta%3AWay+%3B%0D%0A++++geom%3Ageometry+[+ogc%3AasWKT+%3Fw+]%0D%0A++BIND%28%0D%0A++++bif%3Ast_geomFromText%28%0D%0A
+
+++++concat%28%0D%0A++++++++replace%28str%28%3Fw%29%2C+%22LINESTRING%22%2C+%22POLYGON%28%22%29%2C%0D%0A++++++++%22%29%22%0D%0A++++++%29%29+AS+%3Fw2%29%0D%0A}%0D%0ALIMIT+10&format=text%2Fhtml&timeout=0&debug=on
If the distance on linestrings in unsuitable for your use case, you
can either run sparql update queries on the dataset in order to
replace the linestrings with polygons using the idea of the query
above, or or you can create queries that do a rough first check
using e.g. bif:st_intersects on the linestring - which will use the
spatial index - and then a subsequent precise filter on the
geometries converted to polygons.
Virtuoso's bif:st_distance (see
http://docs.openlinksw.com/virtuoso/fn_rdf_geo_add.html for geo
functions) apparently only works for points, but as a workaround
bif:st_intersects (I accidently used bif:st_within in my prior mail)
can be used, which accepts a tolerance as the last argument:
http://docs.openlinksw.com/virtuoso/fn_st_within.html
Best regards,
Claus