From 07565addaf4e25902d4c2c8cc32977764feb0e8e Mon Sep 17 00:00:00 2001 From: KK Date: Mon, 6 May 2024 14:40:59 +0200 Subject: [PATCH] feat(rdfimport): import places from Geonames Import data for Place entity objects from RDF endpoint of geonames.org. --- .../rdfimport/PlaceFromGeonames.toml | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 apis_ontology/rdfimport/PlaceFromGeonames.toml diff --git a/apis_ontology/rdfimport/PlaceFromGeonames.toml b/apis_ontology/rdfimport/PlaceFromGeonames.toml new file mode 100644 index 0000000..b0a4cc9 --- /dev/null +++ b/apis_ontology/rdfimport/PlaceFromGeonames.toml @@ -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: +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: +SELECT ?kind +WHERE { + ?subject gn:featureCode ?kind +} +""" +[[attributes]] +# lat +sparql = """ +PREFIX wgs84_pos: +SELECT ?latitude +WHERE { + ?subject wgs84_pos:lat ?latitude. + ?subject wgs84_pos:long ?longitude +} +""" +[[attributes]] +# long +sparql = """ +PREFIX wgs84_pos: +SELECT ?longitude +WHERE { + ?subject wgs84_pos:lat ?latitude. + ?subject wgs84_pos:long ?longitude +} +""" +[[attributes]] +# parent +sparql = """ +PREFIX gn: +SELECT ?parent +WHERE { + ?subject gn:parentCountry ?parent +} +"""