Apologies in advance, as my knowledge is more on the geospatial side than on the SPARQL side, so I am interested if there is a solution as well.

Geospatially speaking, order can be preserved if the chronologically sorted points returned can be converted to a LineString before display. Looking into the topic, it seems that for this to be supported you might need to support GeoSPARQL extensions.

https://opengeospatial.github.io/ogc-geosparql/geosparql11/spec.html

The only reference I could find to a function for this conversion from  points--> LineString was in these docs:
https://graphdb.ontotext.com/documentation/standard/sparql-functions-reference.html#geosparql-functions

in which there is a reference to a GeoSPARQL extension function that could be of use:

shortestLine(geomLiteral g1, geomLiteral g2)

This appears to only create individual line segments between 2 points at a time, but it is a start. LineStrings can be arbitrarily long, however, so using 2 points is just the bare bones of functionality. A function that accepts an ordered list of points would be more ideal.

Geospatially speaking, individual line segments can also be grouped together as MultiLineStrings, which would allow you to join multiple journeys together (useful for e.g. taking one long train journey and connecting to a second train line midway).


Other docs that seem to mention support for LineStrings or MultiLineStrings if useful:

https://docs.cambridgesemantics.com/anzograph/v2.3/userdoc/geo-spatial.htm
https://jena.apache.org/documentation/geosparql/



On Thu, Jan 27, 2022 at 5:49 AM James Heald <jpm.heald@gmail.com> wrote:
[This email originated from outside of OSU. Use caution with links and attachments.]

Agreed.  I don't think it's guaranteed that the GROUP_CONCAT will
respect the order of items it's given.  (I believe this is a standing
well-known requested feature in SPARQL circles).

But yet, it seems to work.

eg here's a version of the previous query, sorted by longitude
    https://w.wiki/4kXS
and the points *do* seem to be being joined together in the right order.

   --  J.


On 27/01/2022 13:39, Bruno BELHOSTE wrote:
> The real problem is how to order the events in the query according to
> their dates in order to draw the line from one event place to the next
> event place.
>
> It is clearly not easy.
>
> Best,
>
> Bruno
>
> Le 27/01/2022 à 14:04, James Heald a écrit :
>> You're looking for a query like this one, I think
>>
>> https://w.wiki/4kW4
>>
>> but adapted to your data.
>>
>> All best,
>>
>>   James.
>>
>>
_______________________________________________
Wikidata mailing list -- wikidata@lists.wikimedia.org
To unsubscribe send an email to wikidata-leave@lists.wikimedia.org