X-Git-Url: https://git.argeo.org/?p=gpl%2Fargeo-suite.git;a=blobdiff_plain;f=org.argeo.app.geo%2Fsrc%2Forg%2Fargeo%2Fapp%2Fgeo%2FGeoJson.java;h=8c4c7b23259054d4d784451ad4533ac68aa35d99;hp=c1ba1d393b71627ce70632e50253344da273d779;hb=e9978679e86dcd297270432e4ed953b782f1e7c6;hpb=36a9a4d540f617bd23170a109ee08e9e200e2143 diff --git a/org.argeo.app.geo/src/org/argeo/app/geo/GeoJson.java b/org.argeo.app.geo/src/org/argeo/app/geo/GeoJson.java index c1ba1d3..8c4c7b2 100644 --- a/org.argeo.app.geo/src/org/argeo/app/geo/GeoJson.java +++ b/org.argeo.app.geo/src/org/argeo/app/geo/GeoJson.java @@ -93,8 +93,9 @@ public class GeoJson { /** Writes a pair of coordinates [lat,lon]. */ public static void writeCoordinate(JsonGenerator g, Coordinate coordinate) { - g.write(coordinate.getX()); + // !! longitude is first in GeoJSON g.write(coordinate.getY()); + g.write(coordinate.getX()); double z = coordinate.getZ(); if (!Double.isNaN(z)) { g.write(z); @@ -149,13 +150,14 @@ public class GeoJson { return (T) res; } - /** Reads a coordinate sequence [[lat,lon],[lat,lon]]. */ + /** Reads a coordinate pair [lon,lat]. */ public static Coordinate readCoordinate(JsonArray arr) { assert arr.size() >= 2; - return new Coordinate(arr.getJsonNumber(0).doubleValue(), arr.getJsonNumber(1).doubleValue()); + // !! longitude is first in GeoJSon + return new Coordinate(arr.getJsonNumber(1).doubleValue(), arr.getJsonNumber(0).doubleValue()); } - /** Reads a coordinate pair [lat,lon]. */ + /** Reads a coordinate sequence [[lon,lat],[lon,lat]]. */ public static Coordinate[] readCoordinates(JsonArray arr) { Coordinate[] coords = new Coordinate[arr.size()]; for (int i = 0; i < arr.size(); i++)