Geo Linking Configuration

The setup of a geo linking configuration consists of three parts:

  1. Specification from which graphs candidates are selected and in which graph the Geo Link object are written
  2. The actual queries for the candidate selection
  3. Geo Linking conditions.

Configuration Example

The following configuration defines the linking of all waypoints in a Trail ( stored under a schema:GeoShape) with all objects that have a schema:geo property with a schema:GeoCoordinate object.

{
    "config": {
        "from": {
            "graphs": [
                {
                    "publisher": "publisherUUID",
                    "datasource": "datasourceUUID"
                }
            ],
            "sparql": "PREFIX ds: <https://vocab.sti2.at/ds/> PREFIX schema: <https://schema.org/> SELECT DISTINCT ?id ?dsUrl ?geoCoordinate ?coordinatesList WHERE { ?id ds:compliesWith ?dsUrl . ?id schema:geo ?geoCoordinate . ?geoCoordinate a schema:GeoShape. } limit 20"
        },
        "to": {
            "graphs": [
                {
                    "publisher": "publisherUUID",
                    "datasource": "datasourceUUID"
                }
            ],
            "sparql": "PREFIX ds: <https://vocab.sti2.at/ds/> PREFIX schema: <https://schema.org/> SELECT DISTINCT ?id ?dsUrl ?latitude ?longitude ?geoCoordinate WHERE { ?id ds:compliesWith ?dsUrl . ?id schema:geo ?geoCoordinate . ?geoCoordinate a schema:GeoCoordinates . ?geoCoordinate schema:latitude ?latitude . ?geoCoordinate schema:longitude ?longitude .} limit 200"
        },
        "linkGraph": {
            "publisher": "publisherUUID",
            "datasource": "datasourceUUID"
        }
    },
    "conditions": [
        {
            "type": "foot",
            "value": 5,
            "op": "<",
            "useDuration": "true"
        }
    ]
}

Candidate and Geo Linking Graph specification

One needs to define in the config section the candidate selection:

  • from which graph should the source candidates be selected?
    This is a publisherUUID / datasourceUUID pair:
    {
        "config": {
            "from": {
                "graphs": [
                    {
                        "publisher": "publisherUUIDFrom",
                        "datasource": "datasourceUUIDFrom"
                    }
                ]
            }
        }
    }
    
  • from the graph from which the target candidates are taken
    This is a publisherUUID / datasourceUUID pair:
    {
        "config": {
            "t": {
                "graphs": [
                    {
                        "publisher": "publisherUUIDTo",
                        "datasource": "datasourceUUIDTo"
                    }
                ]
            }
        }
    }
    
  1. define the graph in which we want to write the GeoLink Object
    This is a publisherUUID / datasourceUUID pair:
    {
        "config": {
            "linkGraph": {
            	"publisher": "publisherUUIDLink",
              "datasource": "datasourceUUIDLink"          
            }
        }
    }
    

Queries for candidate selection

Currently, we are relying on SPARQL queries to select the candidates for the source and target objects.

There are certain variables that the query needs to return:

  • ?id => the actual IRI of the candidate object ( e.g. the Hotel)
  • ?dsUrl => The dsUrl of the canidate object
  • ?geoCoordinate => the IRI of the schema:GeoCoordindates of the candidate object
  • ?latitude => the value of the schema:latitude property
  • ?longitude => the value of the schema:longitude property

The service algorithm is then creating potential link candidates based on this information.

Below is an example query

PREFIX  schema: <https://schema.org/>
PREFIX  ds:   <https://vocab.sti2.at/ds/>

SELECT DISTINCT  ?id ?dsUrl ?latitude ?longitude ?geoCoordinate
WHERE
  { ?id       ds:compliesWith   ?dsUrl ;
              schema:geo        ?geoCoordinate .
    ?geoCoordinate
              a                 schema:GeoCoordinates ;
              schema:latitude   ?latitude ;
              schema:longitude  ?longitude
 }

and its one-line version:

PREFIX ds: <https://vocab.sti2.at/ds/> PREFIX schema: <https://schema.org/> SELECT DISTINCT ?id ?dsUrl ?latitude ?longitude ?geoCoordinate WHERE { ?id ds:compliesWith ?dsUrl . ?id schema:geo ?geoCoordinate . ?geoCoordinate a schema:GeoCoordinates . ?geoCoordinate schema:latitude ?latitude . ?geoCoordinate schema:longitude ?longitude .}

Specific mode for Trails or a schema:Line objects.

Typically, the service creates GeoLink Objects between objects based on the latitude/longitude pairs. However, there is a specific case to link trails or tours with other objects. For this use case, we dont use the schema:GeoCoordinates but rather the schema:GeoShape and the schema:line information of tours. This also requires a sligthyl different query which is below.

PREFIX  schema: <https://schema.org/>
PREFIX  ds:   <https://vocab.sti2.at/ds/>

SELECT DISTINCT  ?id ?dsUrl ?geoCoordinate ?coordinatesList
WHERE
  { ?id       ds:compliesWith  ?dsUrl ;
              schema:geo       ?geoCoordinate .
    ?geoCoordinate
              a                schema:GeoShape .
    
  }

Geo Linking Conditions

Finally, the config requires at least one condition which needs to hold for creating GeoLink Objects

A condition is defined as follows

"conditions": [
        {
            "type": "foot",
            "useDuration": "true"
            "value": 5,
            "op": "<"
            
        }
    ]
condition keydescriptionvalues
typedoes the condition apply to walking, cycling or drive by car informationfoot for walking distance or duration
bike for cycling distance of duration
car for drive by car distance of duration
useDurationshould the condition be applied to the duration or distance - if true, the filter applies on the travel duration between the two candidates based on the selected typeboolean value
valuethe conditon value -
if distance computation then the value is interpreted in the unit meters
if duration is selected (useDuration: true) then the value is interpreted in the unit minutes
integer value
either considered as meters or minutes, depending on the useDuration value
opthe comparison operator - typically one wants to use "<"typical comparison values