Skip to content

Commit

Permalink
feat(rdfimport): import places from Geonames
Browse files Browse the repository at this point in the history
Import data for Place entity objects from
RDF endpoint of geonames.org.
  • Loading branch information
koeaw committed May 6, 2024
1 parent e420afa commit 07565ad
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions apis_ontology/rdfimport/PlaceFromGeonames.toml
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
}
"""

0 comments on commit 07565ad

Please sign in to comment.