Closed GeraldGrootRoessink closed 7 years ago
Most simple solution is not use the ?pc
at all, but simply use "@PC@"
:
select * where {?na bag:postcode "@PC@"}
You might experience a problem with datatype, but that can be solved with:
select * where {?na bag:postcode "@PC@"^^xsd:string
At runtime, the LDT simple replaces the @PC@
with the corresponding value from the parameter, so the actual executed query will be:
select * where {?na bag:postcode "3527XL"^^xsd:string}
Another tip: you might want to use elmo:endpoint <http://almere.pilod.nl/sparql>
instead of a SERVICE
clause: you are not using the data in your local triplestore, so you could access the sparql endpoint at almere.pilod.nl directly. By the way: did you now that the official BAG is now available at https://bag.basisregistraties.overheid.nl/sparql?
got it. it works nice now with the offcial BAG. Thanks
I figured out how to retrieve data form the BAG register with a SPARQL-query:
prefix geo: http://www.w3.org/2003/01/geo/wgs84_pos# prefix geosparql: http://www.opengis.net/ont/geosparql# select distinct ?pc ?hn ?na ?vo ?pand ?geo ?wkt WHERE { SERVICE http://almere.pilod.nl/sparql { ?na rdf:type http://bag.kadaster.nl/def#Nummeraanduiding . BIND ("3527XL"^^http://www.w3.org/2001/XMLSchema#string AS ?pc)
?na http://bag.kadaster.nl/def#postcode ?pc BIND ("2"^^http://www.w3.org/2001/XMLSchema#string AS ?hn) ?na http://bag.kadaster.nl/def#huisnummer ?hn . ?vo http://bag.kadaster.nl/def#hoofdadres ?na . OPTIONAL {?vo http://bag.kadaster.nl/def#onderdeelVan ?pand . ?pand geosparql:hasGeometry ?geo. ?geo geosparql:asWKT ?wkt.} . } } Now I would like tot put this query behind a URI-pattern like this: https://lod.duo.nl/bag?PC=3527XL&HN=2
I have tried several options to bind the variable to ?pc( and likewise ?hn): BIND (@PC@>^^<http://www.w3.org/2001/XMLSchema#string AS ?pc) ERROR BIND (<@PC@> AS ?pc) NOT FOUND BIND (str(<@PC@>) AS ?pc NOT FOUND BIND (strdt(<@PC@>,xsd:string) AS ?pc) FOUND BIND (xsd:string(<@PC@>) AS ?pc) NOT FOUND
Number 4 does the tric, but is very much slower then the example above. Is there a better way? Thanks for your attention Gerald Groot Roessink (Dienst UItvoering Onderwijs)