File tree 2 files changed +16
-6
lines changed
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo
src/main/asciidoc/reference
2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change 21
21
import org .springframework .data .geo .Point ;
22
22
23
23
/**
24
- * {@link GeoJson} representation of {@link Point}.
24
+ * {@link GeoJson} representation of {@link Point}. Uses {@link Point#getX()} as {@literal longitude} and
25
+ * {@link Point#getY()} as {@literal latitude}.
25
26
*
26
27
* @author Christoph Strobl
27
28
* @since 1.7
@@ -36,15 +37,17 @@ public class GeoJsonPoint extends Point implements GeoJson<List<Double>> {
36
37
/**
37
38
* Creates {@link GeoJsonPoint} for given coordinates.
38
39
*
39
- * @param x : longitude
40
- * @param y : latitude
40
+ * @param x longitude between {@literal -180} and {@literal 180} (inclusive).
41
+ * @param y latitude between {@literal -90} and {@literal 90} (inclusive).
41
42
*/
42
43
public GeoJsonPoint (double x , double y ) {
43
44
super (x , y );
44
45
}
45
46
46
47
/**
47
48
* Creates {@link GeoJsonPoint} for given {@link Point}.
49
+ * <p>
50
+ * {@link Point#getX()} translates to {@literal longitude}, {@link Point#getY()} to {@literal latitude}.
48
51
*
49
52
* @param point must not be {@literal null}.
50
53
*/
@@ -61,9 +64,10 @@ public String getType() {
61
64
return TYPE ;
62
65
}
63
66
64
- /*
65
- * (non-Javadoc)
66
- * @see org.springframework.data.mongodb.core.geo.GeoJson#getCoordinates()
67
+ /**
68
+ * Obtain the coordinates (x/longitude, y/latitude) array.
69
+ *
70
+ * @return the coordinates putting {@link #getX() x/longitude} first, and {@link #getY() y/latitude} second.
67
71
*/
68
72
@ Override
69
73
public List <Double > getCoordinates () {
Original file line number Diff line number Diff line change @@ -1537,6 +1537,12 @@ public class Store {
1537
1537
----
1538
1538
====
1539
1539
1540
+ [TIP]
1541
+ ====
1542
+ If the `coordinates` of a GeoJSON object represent _latitude_ and _longitude_ pairs, the _longitude_ goes first followed by _latitude_. +
1543
+ `GeoJsonPoint` therefore treats `getX()` as _longitude_ and `getY()` as _latitude_.
1544
+ ====
1545
+
1540
1546
[[mongo.geo-json.query-methods]]
1541
1547
==== GeoJSON Types in Repository Query Methods
1542
1548
You can’t perform that action at this time.
0 commit comments