Talk:SPARQL vs Overpass QL examples

From OpenStreetMap Wiki
Jump to navigation Jump to search

Remove redundant overpass turbo link

All overpass examples can be directly executed by clicking on the steering wheel icon in the upper right corner, and that icon is executing exactly the query as it is shown on the wiki page. There's no need to keep an overpass turbo shortlink http://overpass-turbo.eu/s/... I would propose to get rid of it. Mmd (talk) 12:11, 13 August 2020 (UTC)

Horizontal vs vertical layout

The table has 4 columns. It does not fit the PC screen and the code fragments are word-wrapped.

What about changing the layout?

  • Option 1. List the code fragments one below another, each language into its own subsection.
  • Option 2. If comparing QLever and Sophox side-by-side is useful: have a table with QLever and Sophox side-by-side, and have Overpass turbo and Overpass Wizard below the table.

I am learning SPARQL, but I do not have experience with it and cannot decide which option is best in the long term. What do people think?

--Opk12 (talk) 21:31, 22 February 2024 (UTC)

Also: In the QLever examples, can I remove the PREFIX lines, to allow for a direct visual comparison with the Sophox syntax side-by-side? Because the QLever editor auto-generates these lines, when I copy-paste the SELECT.
--Opk12 (talk) 22:08, 22 February 2024 (UTC)
I agree that this is a problem that should be improved.
A query like this...

Four columns

Subtitle

QLever SPARQL Sophox SPARQL Overpass QL Overpass turbo wizard
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX osmkey: <https://www.openstreetmap.org/wiki/Key:>
PREFIX osm: <https://www.openstreetmap.org/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT * WHERE {
  ?osmId rdf:type osm:node;
         osmkey:office "education" ;
         geo:hasGeometry/geo:asWKT ?loc .
}
Run it (edit query)
#defaultView:Map
SELECT * WHERE {
  ?osmId osmm:type "n" ;
         osmt:office "education" ;
         osmm:loc ?loc .
}
Run it (edit query)
try it yourself in overpass-turbo
node["office"="education"]({{bbox}});

out body;
>;
out skel qt;
office=education and type:node
Could be changed to this...

Three columns

Subtitle

QLever SPARQL Sophox SPARQL Overpass wizard & QL
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX osmkey: <https://www.openstreetmap.org/wiki/Key:>
PREFIX osm: <https://www.openstreetmap.org/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT * WHERE {
  VALUES ?types { osm:node osm:way }
  ?osmId rdf:type ?types;
         osmkey:crane:type ?key;
         geo:hasGeometry/geo:asWKT ?loc.
}
Run it (edit query)
#defaultView:Map
SELECT * WHERE {
  VALUES ?types { "n" "w" }
  ?osmId osmm:type ?types;
         osmt:crane:type ?key;
         osmm:loc ?loc.
}
Run it (edit query)
crane:type=* and type:node or crane:type=* and type:way
try it yourself in overpass-turbo
(
  nw ["crane:type"]({{bbox}});
);

out body;
>;
out skel qt;
Or it could be changed to this

Two columns

Subtitle

QLever SPARQL
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX osmkey: <https://www.openstreetmap.org/wiki/Key:>
PREFIX osm: <https://www.openstreetmap.org/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT * WHERE {
  VALUES ?types { osm:node osm:way }
  ?osmId rdf:type ?types;
         osmkey:crane:type ?key;
         geo:hasGeometry/geo:asWKT ?loc.
}
Run it (edit query)
Sophox SPARQL Overpass wizard & QL
#defaultView:Map
SELECT * WHERE {
  VALUES ?types { "n" "w" }
  ?osmId osmm:type ?types;
         osmt:crane:type ?key;
         osmm:loc ?loc.
}
Run it (edit query)
crane:type=* and type:node or crane:type=* and type:way
try it yourself in overpass-turbo
(
  nw ["crane:type"]({{bbox}});
);

out body;
>;
out skel qt;
Regarding the prefixes, I think they are necessary as if you click the "Run it" or "edit query" link for a query without prefix it does not apply it and consequently throws an error. Example:
SELECT * WHERE {
  VALUES ?types { osm:node osm:way }
  ?osmId rdf:type ?types;
         osmkey:crane:type ?key;
         geo:hasGeometry/geo:asWKT ?loc.
}
Run it (edit query)
--Danysan (talk) 22:16, 22 February 2024 (UTC)