-- Class Definition that includes SPIN Rules SPARQL CLEAR GRAPH ; SPARQL DROP SPIN LIBRARY ; TTLP (' @prefix owl: . @prefix sp: . @prefix spl: . @prefix spin: . @prefix rdf: . @prefix rdfs: . @prefix xsd: . @prefix foaf: . @prefix rel: . @prefix wdrs: . @prefix schema: . @prefix sioc: . sioc:Item a rdfs:Class ; rdfs:label "An Item"^^xsd:string ; spin:rule [ a sp:Construct ; rdfs:label "Latitude Rule" ; rdfs:comment """Handler for different kinds of Latitude oriented fields (relations). """ ; sp:text """ CONSTRUCT { ?this <#hasLatitude> ?n. } WHERE { FILTER (contains(str(?p),"latitude") || contains(str(?p),"Latitude") ) . ?this ?p ?n } """ ] ; spin:rule [ a sp:Construct ; rdfs:label "Longitude Rule" ; rdfs:comment """ Handler for different kinds of Longitude oriented fields (relations) """ ; sp:text """ CONSTRUCT { ?this <#hasLongitude> ?n. } WHERE { FILTER (contains(str(?p),"longitude") || contains(str(?p),"Longitude") ) . ?this ?p ?n } """ ] . ', '', 'urn:spin:rule:geospatial:lib', 4096) ; -- Macro Generation -- Diagnostic for reading what's generated from SPIN descriptions -- SELECT SPARQL_SPIN_GRAPH_TO_DEFSPIN('urn:spin:rule:geospatial:lib'); EXEC ('SPARQL ' || SPARQL_SPIN_GRAPH_TO_DEFSPIN('urn:spin:rule:geospatial:lib')); -- Test Queries -- Data Set #1 SPARQL DEFINE get:soft "soft" DEFINE input:macro-lib SELECT ?x ?y ?z FROM WHERE { ?x a sioc:Item . ?x <#hasLatitude> ?y. ?x <#hasLongitude> ?z. } ; -- Data Set #2 SPARQL DEFINE get:soft "soft" DEFINE input:macro-lib SELECT ?y ?z FROM FROM FROM WHERE { ?x a sioc:Item . ?x <#hasLatitude> ?y . ?x <#hasLongitude> ?z . }