Class Geometry

java.lang.Object
com.surrealdb.Native
com.surrealdb.Geometry

public class Geometry extends Native
A SurrealDB geometry value. Supports all GeoJSON-style types: Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, and GeometryCollection.

Coordinates use Point2D.Double where x is the longitude and y is the latitude (GeoJSON ordering). Multi-coordinate types are exposed as nested Lists of points.

Instances can be read from query results (via Value.getGeometry()) and constructed with the static factory methods to be sent back to the database.

  • Method Details

    • getType

      public String getType()
      Returns the geometry type: one of "Point", "LineString", "Polygon", "MultiPoint", "MultiLineString", "MultiPolygon", or "GeometryCollection".
    • isPoint

      public boolean isPoint()
    • isLineString

      public boolean isLineString()
    • isPolygon

      public boolean isPolygon()
    • isMultiPoint

      public boolean isMultiPoint()
    • isMultiLineString

      public boolean isMultiLineString()
    • isMultiPolygon

      public boolean isMultiPolygon()
    • isGeometryCollection

      public boolean isGeometryCollection()
    • getPoint

      public Point2D.Double getPoint()
    • getLineString

      public List<Point2D.Double> getLineString()
    • getMultiPoint

      public List<Point2D.Double> getMultiPoint()
    • getPolygon

      public List<List<Point2D.Double>> getPolygon()
      Returns the polygon's rings. The first ring is the exterior boundary; any subsequent rings are interior holes.
    • getMultiLineString

      public List<List<Point2D.Double>> getMultiLineString()
    • getMultiPolygon

      public List<List<List<Point2D.Double>>> getMultiPolygon()
    • getGeometryCollection

      public List<Geometry> getGeometryCollection()
    • point

      public static Geometry point(double x, double y)
    • point

      public static Geometry point(Point2D.Double point)
    • lineString

      public static Geometry lineString(List<Point2D.Double> points)
    • multiPoint

      public static Geometry multiPoint(List<Point2D.Double> points)
    • polygon

      public static Geometry polygon(List<List<Point2D.Double>> rings)
      Builds a polygon. The first ring is the exterior boundary; any subsequent rings are interior holes.
    • multiLineString

      public static Geometry multiLineString(List<List<Point2D.Double>> lines)
    • multiPolygon

      public static Geometry multiPolygon(List<List<List<Point2D.Double>>> polygons)
    • geometryCollection

      public static Geometry geometryCollection(List<Geometry> geometries)