Skip to content

Commit

Permalink
fixes for geoprop recognition
Browse files Browse the repository at this point in the history
  • Loading branch information
situx committed Feb 3, 2025
1 parent 47325bd commit b69c082
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions util/graphutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def detectLiteralType(self,configuration,credentialUserName,credentialPassword,
configuration["geotriplepattern"]=[]
configuration["querytemplate"] = []
gottype=False
mandvardef=" ?item ?geo "
geomobjprop="?item ?rel ?item_geom . "
if self.testTripleStoreConnection(configuration["resource"], self.testQueries["hasGeometry"],
credentialUserName, credentialPassword, authmethod):
Expand Down Expand Up @@ -147,6 +148,7 @@ def detectLiteralType(self,configuration,credentialUserName,credentialPassword,
if self.testTripleStoreConnection(configuration["resource"], self.testQueries["hasWgs84LatLon"],
credentialUserName, credentialPassword, authmethod):
capabilitylist.append("WGS84 Lat/Lon")
mandvardef = " ?item ?lat ?lon "
configuration["geometryproperty"] = ["http://www.w3.org/2003/01/geo/wgs84_pos#long",
"http://www.w3.org/2003/01/geo/wgs84_pos#lat"]
configuration["mandatoryvariables"] = ["item", "lat","lon"]
Expand All @@ -155,13 +157,15 @@ def detectLiteralType(self,configuration,credentialUserName,credentialPassword,
if self.testTripleStoreConnection(configuration["resource"], self.testQueries["hasSchemaOrgGeoLatLonHTTPS"],
credentialUserName, credentialPassword, authmethod):
capabilitylist.append("Schema.org Lat/Lon")
mandvardef = " ?item ?lat ?lon "
configuration["mandatoryvariables"] = ["item", "lat", "lon"]
configuration["geometryproperty"] = ["https://schema.org/geo"]
configuration["geotriplepattern"].append(" ?item <https://schema.org/latitude> ?lat . ?item <https://schema.org/longitude> ?lon . ")
gottype = True
if self.testTripleStoreConnection(configuration["resource"], self.testQueries["hasSchemaOrgGeoLatLonHTTP"],
credentialUserName, credentialPassword, authmethod):
capabilitylist.append("Schema.org Lat/Lon")
mandvardef = " ?item ?lat ?lon "
configuration["mandatoryvariables"] = ["item", "lat", "lon"]
configuration["geometryproperty"] = ["http://schema.org/geo"]
configuration["geotriplepattern"].append(" ?item <http://schema.org/latitude> ?lat . ?item <http://schema.org/longitude> ?lon . ")
Expand Down Expand Up @@ -191,8 +195,11 @@ def detectLiteralType(self,configuration,credentialUserName,credentialPassword,
for res in results["results"]["bindings"]:
if "prop" in res:
if configuration is not None:
mandvardef = " ?item ?geo "
capabilitylist.append("Custom Geometry Property")
configuration["mandatoryvariables"] = ["item", "geo"]
configuration["geometryproperty"] = [res["prop"]["value"]]
configuration["geotriplepattern"].append(" ?item <https://schema.org/polygon> ?geo . ")
configuration["geotriplepattern"].append(" ?item <"+str(res["prop"]["value"])+"> ?geo . ")
gottype=True
break
#self.detectGeometryLiteralRelations(configuration, credentialUserName, credentialPassword, authmethod) #Does not terminate on most triple stores
Expand All @@ -212,7 +219,7 @@ def detectLiteralType(self,configuration,credentialUserName,credentialPassword,
if "geotriplepattern" in self.configuration and len(self.configuration["geotriplepattern"])>0:
self.configuration["querytemplate"].append(
{"label": "10 Random Geometries",
"query": "SELECT ?item ?lat ?lon WHERE {\n ?item %%typeproperty%% <%%concept%%> .\n "+str(self.configuration["geotriplepattern"][0])+"\n } LIMIT 10"})
"query": "SELECT "+str(mandvardef)+" WHERE {\n ?item %%typeproperty%% <%%concept%%> .\n "+str(self.configuration["geotriplepattern"][0])+"\n } LIMIT 10"})
self.configuration[
"subclassquery"] = "SELECT DISTINCT ?subclass ?label WHERE { ?item %%typeproperty%% ?subclass . ?item ?rel ?item_geom . " + str(
configuration["geotriplepattern"][
Expand Down

0 comments on commit b69c082

Please sign in to comment.