Package dev.morphia.geo
Class GeoJson
- java.lang.Object
-
- dev.morphia.geo.GeoJson
-
public final class GeoJson extends java.lang.Object
Factory class for creating GeoJSON types. See the documentation for all the types.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.List<java.util.List<com.mongodb.client.model.geojson.Position>>
convertLineStrings(java.util.List<LineString> values)
static java.util.List<com.mongodb.client.model.geojson.Position>
convertPoints(java.util.List<Point> values)
static GeometryCollection
geometryCollection(Geometry... geometries)
Return a GeometryCollection that will let you create a GeoJSON GeometryCollection.static LineString
lineString(Point... points)
Create a new LineString representing a GeoJSON LineString type.static MultiLineString
multiLineString(LineString... lines)
Create a new MultiLineString representing a GeoJSON MultiLineString type.static MultiPoint
multiPoint(Point... points)
Create a new MultiPoint representing a GeoJSON MultiPoint type.static MultiPolygon
multiPolygon(Polygon... polygons)
Create a new MultiPolygon representing a GeoJSON MultiPolygon type.static Point
point(double latitude, double longitude)
Create a new Point representing a GeoJSON point type.static Polygon
polygon(LineString exteriorBoundary, LineString... interiorBoundaries)
Lets you create a Polygon representing a GeoJSON Polygon type.static Polygon
polygon(Point... points)
Create a new Polygon representing a GeoJSON Polygon type.
-
-
-
Method Detail
-
point
public static Point point(double latitude, double longitude)
Create a new Point representing a GeoJSON point type. For a safer way to create points with latitude and longitude coordinates without mixing up the order,PointBuilder
.- Parameters:
latitude
- the point's latitude coordinatelongitude
- the point's longitude coordinate- Returns:
- a Point instance representing a single location point defined by the given latitude and longitude
- See Also:
PointBuilder
, GeoJSON- Since server release
- 2.4
-
polygon
public static Polygon polygon(Point... points)
Create a new Polygon representing a GeoJSON Polygon type. This helper method usespolygon(LineString, LineString...)
to create the Polygon. If you need to create Polygons with interior rings (holes), use that method.- Parameters:
points
- an ordered series of Points that make up the polygon. The first and last points should be the same to close the polygon- Returns:
- a Polygon as defined by the points.
- Throws:
java.lang.IllegalArgumentException
- if the start and end points are not the same- See Also:
polygon(LineString, LineString...)
, GeoJSON- Since server release
- 2.4
-
lineString
public static LineString lineString(Point... points)
Create a new LineString representing a GeoJSON LineString type.
-
polygon
public static Polygon polygon(LineString exteriorBoundary, LineString... interiorBoundaries)
Lets you create a Polygon representing a GeoJSON Polygon type. This method is especially useful for defining polygons with inner rings.- Parameters:
exteriorBoundary
- a LineString that contains a series of Points that make up the polygon. The first and last points should be the same to close the polygoninteriorBoundaries
- optional varargs that let you define the boundaries for any holes inside the polygon- Returns:
- a PolygonBuilder to be used to build up the required Polygon
- Throws:
java.lang.IllegalArgumentException
- if the start and end points are not the same- See Also:
- GeoJSON
- Since server release
- 2.4
-
multiPoint
public static MultiPoint multiPoint(Point... points)
Create a new MultiPoint representing a GeoJSON MultiPoint type.
-
multiLineString
public static MultiLineString multiLineString(LineString... lines)
Create a new MultiLineString representing a GeoJSON MultiLineString type.
-
multiPolygon
public static MultiPolygon multiPolygon(Polygon... polygons)
Create a new MultiPolygon representing a GeoJSON MultiPolygon type.
-
geometryCollection
public static GeometryCollection geometryCollection(Geometry... geometries)
Return a GeometryCollection that will let you create a GeoJSON GeometryCollection.
-
convertPoints
public static java.util.List<com.mongodb.client.model.geojson.Position> convertPoints(java.util.List<Point> values)
- Parameters:
values
- the values to convert- Returns:
- the converted values
Developer note. This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
convertLineStrings
public static java.util.List<java.util.List<com.mongodb.client.model.geojson.Position>> convertLineStrings(java.util.List<LineString> values)
- Parameters:
values
- the values to convert- Returns:
- the converted values
Developer note. This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
-