Skip to content

Commit bb603ba

Browse files
christophstroblmp911de
authored andcommitted
Updated reference documentation regarding GeoJsonModule.
Original pull request: #3539. Closes #3517
1 parent 02eaa4c commit bb603ba

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/main/asciidoc/reference/mongodb.adoc

+26
Original file line numberDiff line numberDiff line change
@@ -1446,6 +1446,7 @@ The geo-near operations return a `GeoResults` wrapper object that encapsulates `
14461446

14471447
MongoDB supports https://geojson.org/[GeoJSON] and simple (legacy) coordinate pairs for geospatial data. Those formats can both be used for storing as well as querying data. See the https://docs.mongodb.org/manual/core/2dsphere/#geospatial-indexes-store-geojson/[MongoDB manual on GeoJSON support] to learn about requirements and restrictions.
14481448

1449+
[[mongo.geo-json.domain.classes]]
14491450
==== GeoJSON Types in Domain Classes
14501451

14511452
Usage of https://geojson.org/[GeoJSON] types in domain classes is straightforward. The `org.springframework.data.mongodb.core.geo` package contains types such as `GeoJsonPoint`, `GeoJsonPolygon`, and others. These types are extend the existing `org.springframework.data.geo` types. The following example uses a `GeoJsonPoint`:
@@ -1469,6 +1470,7 @@ public class Store {
14691470
----
14701471
====
14711472

1473+
[[mongo.geo-json.query-methods]]
14721474
==== GeoJSON Types in Repository Query Methods
14731475

14741476
Using GeoJSON types as repository query parameters forces usage of the `$geometry` operator when creating the query, as the following example shows:
@@ -1529,6 +1531,7 @@ repo.findByLocationWithin( <4>
15291531
<4> Use the legacy format `$polygon` operator.
15301532
====
15311533

1534+
[[mongo.geo-json.metrics]]
15321535
==== Metrics and Distance calculation
15331536

15341537
Then MongoDB `$geoNear` operator allows usage of a GeoJSON Point or legacy coordinate pairs.
@@ -1700,6 +1703,29 @@ Returning the 3 Documents just like the GeoJSON variant:
17001703
<4> Distance from center point in _Kilometers_ - take it times 1000 to match _Meters_ of the GeoJSON variant.
17011704
====
17021705

1706+
[[mongo.geo-json.jackson-modules]]
1707+
==== GeoJSON Jackson Modules
1708+
1709+
By using the <<core.web>>, Spring Data registers additional Jackson ``Modules``s to the `ObjectMapper` for deserializing common Spring Data domain types.
1710+
Please refer to the <<core.web.basic.jackson-mappers>> section to learn more about the infrastructure setup of this feature.
1711+
1712+
The MongoDB module additionally registers ``JsonDeserializer``s for the following GeoJSON types via its `GeoJsonConfiguration` exposing the `GeoJsonModule`.
1713+
----
1714+
org.springframework.data.mongodb.core.geo.GeoJsonPoint
1715+
org.springframework.data.mongodb.core.geo.GeoJsonMultiPoint
1716+
org.springframework.data.mongodb.core.geo.GeoJsonLineString
1717+
org.springframework.data.mongodb.core.geo.GeoJsonMultiLineString
1718+
org.springframework.data.mongodb.core.geo.GeoJsonPolygon
1719+
org.springframework.data.mongodb.core.geo.GeoJsonMultiPolygon
1720+
----
1721+
1722+
[NOTE]
1723+
====
1724+
The `GeoJsonModule` only registers ``JsonDeserializer``s!
1725+
1726+
The next major version (`4.0`) will register both, ``JsonDeserializer``s and ``JsonSerializer``s for GeoJSON types by default.
1727+
====
1728+
17031729
[[mongo.textsearch]]
17041730
=== Full-text Queries
17051731

0 commit comments

Comments
 (0)