You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Greg Albiston (Jira)" <ji...@apache.org> on 2022/01/30 18:33:00 UTC

[jira] [Commented] (JENA-2266) convertLatLon swaps coordinates

    [ https://issues.apache.org/jira/browse/JENA-2266?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17484418#comment-17484418 ] 

Greg Albiston commented on JENA-2266:
-------------------------------------

Longitude is indeed the X axis and latitude is the Y axis. However, the SRS EPSG 4326 (referenced by {{{}SRS_URI.WGS84_CRS{}}}) used for WGS84 reverses the axis order when encoding to latitude/longitude. The SRS OGC CRS84 has the axis order longitude/latitude.

The produced Point literal conforms with the axis order, if it is perhaps somewhat confusing in the naming of function parameters.

An example of this is provided on page 17 of the GeoSPARQL standard.

!image-2022-01-30-18-28-56-974.png!

> convertLatLon swaps coordinates
> -------------------------------
>
>                 Key: JENA-2266
>                 URL: https://issues.apache.org/jira/browse/JENA-2266
>             Project: Apache Jena
>          Issue Type: Bug
>          Components: GeoSPARQL
>    Affects Versions: Jena 4.3.2
>            Reporter: Claus Stadler
>            Priority: Major
>         Attachments: image-2022-01-30-18-28-56-974.png
>
>
> The correct setting is that longitude corresponds to x-axis and latitude to y-axis, but in the code lat is passed for x and lon for y.
> {code:java}
> public class ConvertLatLon {
>     public static final Literal toLiteral(double lat, double lon) {
>         checkBounds(lat, lon);
>         return WKTLiteralFactory.createPoint(lat, lon, SRS_URI.WGS84_CRS);
>     }
> }
> {code}
> {code:java}
> public class WKTLiteralFactory {
>     public static final Literal createPoint(Double x, Double y, String srsURI) {
>         String tidyURI = tidySrsURI(srsURI);
>         return ResourceFactory.createTypedLiteral(tidyURI + "POINT(" + reducePrecision(x) + " " + reducePrecision(y)
>  + ")", WKTDatatype.INSTANCE);
>     }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)