-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rdfimport): import places from Geonames
Import data for Place entity objects from RDF endpoint of geonames.org.
- Loading branch information
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#################################################### | ||
# Create an E53_Place from a geonames RDF endpoint # | ||
#################################################### | ||
superclass = "apis_ontology.models.Place" | ||
# the second regex is for the test data | ||
regex = "https://sws.geonames.org.*" | ||
[[attributes]] | ||
# name | ||
#FILTER (LANGMATCHES(LANG(?prefName), "de") || LANGMATCHES(LANG(?prefName), "en") || LANG(?prefName) = "") | ||
sparql = """ | ||
PREFIX gn: <http://www.geonames.org/ontology#> | ||
SELECT ?label | ||
WHERE | ||
{ | ||
OPTIONAL { | ||
?subject gn:name ?gnname . | ||
} | ||
OPTIONAL { | ||
?subject gn:officialName ?officialName | ||
} | ||
OPTIONAL { | ||
?subject gn:alternateName ?alternateName | ||
} | ||
BIND(COALESCE(?gnname, ?officialName, ?alternateName) AS ?label) | ||
} | ||
""" | ||
[[attributes]] | ||
# kind | ||
sparql = """ | ||
PREFIX gn: <http://www.geonames.org/ontology#> | ||
SELECT ?kind | ||
WHERE { | ||
?subject gn:featureCode ?kind | ||
} | ||
""" | ||
[[attributes]] | ||
# lat | ||
sparql = """ | ||
PREFIX wgs84_pos: <http://www.w3.org/2003/01/geo/wgs84_pos#> | ||
SELECT ?latitude | ||
WHERE { | ||
?subject wgs84_pos:lat ?latitude. | ||
?subject wgs84_pos:long ?longitude | ||
} | ||
""" | ||
[[attributes]] | ||
# long | ||
sparql = """ | ||
PREFIX wgs84_pos: <http://www.w3.org/2003/01/geo/wgs84_pos#> | ||
SELECT ?longitude | ||
WHERE { | ||
?subject wgs84_pos:lat ?latitude. | ||
?subject wgs84_pos:long ?longitude | ||
} | ||
""" | ||
[[attributes]] | ||
# parent | ||
sparql = """ | ||
PREFIX gn: <http://www.geonames.org/ontology#> | ||
SELECT ?parent | ||
WHERE { | ||
?subject gn:parentCountry ?parent | ||
} | ||
""" |