Class GeoJson


  • public final class GeoJson
    extends java.lang.Object
    Factory class for creating GeoJSON types. See the documentation for all the types.
    • 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 coordinate
        longitude - 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 uses polygon(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.
        Parameters:
        points - an ordered series of Points that make up the line
        Returns:
        a LineString instance representing a series of ordered points that make up a line
        See Also:
        GeoJSON
        Since server release
        2.4
      • 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 polygon
        interiorBoundaries - 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.
        Parameters:
        points - a set of points that make up the MultiPoint object
        Returns:
        a MultiPoint object containing all the given points
        See Also:
        GeoJSON
        Since server release
        2.6
      • multiLineString

        public static MultiLineString multiLineString​(LineString... lines)
        Create a new MultiLineString representing a GeoJSON MultiLineString type.
        Parameters:
        lines - a set of lines that make up the MultiLineString object
        Returns:
        a MultiLineString object containing all the given lines
        See Also:
        GeoJSON
        Since server release
        2.6
      • multiPolygon

        public static MultiPolygon multiPolygon​(Polygon... polygons)
        Create a new MultiPolygon representing a GeoJSON MultiPolygon type.
        Parameters:
        polygons - a series of polygons (which may contain inner rings)
        Returns:
        a MultiPolygon object containing all the given polygons
        See Also:
        GeoJSON
        Since server release
        2.6
      • geometryCollection

        public static GeometryCollection geometryCollection​(Geometry... geometries)
        Return a GeometryCollection that will let you create a GeoJSON GeometryCollection.
        Parameters:
        geometries - a series of Geometry instances that will make up this GeometryCollection
        Returns:
        a GeometryCollection made up of all the geometries
        See Also:
        GeoJSON
        Since server release
        2.6
      • 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.