Update GeoJson section in reference documentation.

Mention the relation of Point/GeoJsonPoint x/y coordinates to longitude/latitude.

Original Pull Request: #3956
This commit is contained in:
Christoph Strobl
2022-02-09 14:38:27 +01:00
parent 2a3f746cb6
commit 4f6501f140
2 changed files with 17 additions and 3 deletions

View File

@@ -21,7 +21,8 @@ import java.util.List;
import org.springframework.data.geo.Point; import org.springframework.data.geo.Point;
/** /**
* {@link GeoJson} representation of {@link Point}. * {@link GeoJson} representation of {@link Point}. Uses {@link Point#getX()} as {@literal longitude} and
* {@link Point#getY()} as {@literal latitude}.
* *
* @author Christoph Strobl * @author Christoph Strobl
* @since 1.7 * @since 1.7
@@ -36,8 +37,8 @@ public class GeoJsonPoint extends Point implements GeoJson<List<Double>> {
/** /**
* Creates {@link GeoJsonPoint} for given coordinates. * Creates {@link GeoJsonPoint} for given coordinates.
* *
* @param x : longitude * @param x longitude between {@literal -180} and {@literal 180} (inclusive).
* @param y : latitude * @param y latitude between {@literal -90} and {@literal 90} (inclusive).
*/ */
public GeoJsonPoint(double x, double y) { public GeoJsonPoint(double x, double y) {
super(x, y); super(x, y);
@@ -45,6 +46,8 @@ public class GeoJsonPoint extends Point implements GeoJson<List<Double>> {
/** /**
* Creates {@link GeoJsonPoint} for given {@link Point}. * Creates {@link GeoJsonPoint} for given {@link Point}.
* <p>
* {@link Point#getX()} translates to {@literal longitude}, {@link Point#getY()} to {@literal latitude}.
* *
* @param point must not be {@literal null}. * @param point must not be {@literal null}.
*/ */
@@ -57,6 +60,11 @@ public class GeoJsonPoint extends Point implements GeoJson<List<Double>> {
return TYPE; return TYPE;
} }
/**
* Obtain the coordinates (x/longitude, y/latitude) array.
*
* @return the coordinates putting {@link #getX() x/longitude} first, and {@link #getY() y/latitude} second.
*/
@Override @Override
public List<Double> getCoordinates() { public List<Double> getCoordinates() {
return Arrays.asList(Double.valueOf(getX()), Double.valueOf(getY())); return Arrays.asList(Double.valueOf(getX()), Double.valueOf(getY()));

View File

@@ -1537,6 +1537,12 @@ public class Store {
---- ----
==== ====
[TIP]
====
If the `coordinates` of a GeoJSON object represent _latitude_ and _longitude_ pairs, the _longitude_ goes first followed by _latitude_. +
`GeoJsonPoint` therefore treats `getX()` as _longitude_ and `getY()` as _latitude_.
====
[[mongo.geo-json.query-methods]] [[mongo.geo-json.query-methods]]
==== GeoJSON Types in Repository Query Methods ==== GeoJSON Types in Repository Query Methods