CREATE SERVER linkedgeodata FOREIGN DATA WRAPPER rdf_fdw OPTIONS (endpoint 'http://linkedgeodata.org/sparql'); /* * LinkedGeoData Cities * List all that contain a WKT literal and a * label written in English. This example requires the extension PostGIS! */ CREATE FOREIGN TABLE cities ( uri text OPTIONS (variable '?city'), city text OPTIONS (variable '?label'), country_code text OPTIONS (variable '?countryCode'), geom geometry(point,4326) OPTIONS (variable '?wkt'), geog geography OPTIONS (variable '?wkt') ) SERVER linkedgeodata OPTIONS ( log_sparql 'true', sparql ' SELECT * WHERE { ?city a . ?city ?label . ?city ?geo . ?geo ?wkt . FILTER(LANG(?label) = "en") OPTIONAL { ?city ?countryCode } } '); /* * Select all records that overlap with a given bbox */ SELECT uri, city, country_code, geom, geog FROM cities WHERE ST_Contains( 'SRID=4326;POLYGON ((-8.613281 52.268157, -8.613281 56.218923, 0.878906 56.218923, 0.878906 52.268157, -8.613281 52.268157))', ST_SetSRID(geom,4326));