Created
November 14, 2017 21:38
-
-
Save scottlowe/e8139533f91537b27cf260b200748eaa to your computer and use it in GitHub Desktop.
SPARQL syntax for casting a variable (with a string in it) to a literal type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> | |
PREFIX ospc: <http://data.ordnancesurvey.co.uk/ontology/postcode/> | |
PREFIX geopos: <http://www.w3.org/2003/01/geo/wgs84_pos#> | |
PREFIX geosparql: <http://www.opengis.net/ont/geosparql> | |
CONSTRUCT { | |
?postcode geosparql:hasGeometry [ | |
a geosparql:Geometry ; | |
geosparql:asWKT ?wktlit ; | |
] | |
} | |
WHERE { | |
{ | |
SELECT (STR(?lat) as ?latstr) | |
(STR(?long) as ?longstr) | |
(CONCAT("POINT (", ?latstr, " ", ?longstr, ")") as ?wktstr) | |
(STRDT(?wktstr, geosparql:wktLiteral) as ?wktlit) # <- THERE IT IS! | |
WHERE | |
{ | |
GRAPH ?source_postcodes_graph_uri { | |
?postcode a ospc:PostcodeUnit ; | |
geopos:lat ?lat ; | |
geopos:long ?long . | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment