Package org.apache.calcite.runtime
Class GeoFunctions
- java.lang.Object
-
- org.apache.calcite.runtime.GeoFunctions
-
public class GeoFunctions extends java.lang.Object
Helper methods to implement Geo-spatial functions in generated code.Remaining tasks:
- Determine type code for
ExtraSqlTypes.GEOMETRY
- Should we create aliases for functions in upper-case? Without ST_ prefix?
- Consider adding spatial literals, e.g. `GEOMETRY 'POINT (30 10)'`
- Integer arguments, e.g. SELECT ST_MakePoint(1, 2, 1.5), ST_MakePoint(1, 2)
- Are GEOMETRY values comparable? If so add ORDER BY test
- We have to add 'Z' to create 3D objects. This is inconsistent with PostGIS. Who is right? At least document the difference.
- Should add GeometryEngine.intersects; similar to disjoint etc.
- Make
ST_MakeLine(Geom, Geom)
varargs
- Determine type code for
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
GeoFunctions.CapStyle
How the "buffer" command terminates the end of a line.static interface
GeoFunctions.Geom
Geometry.(package private) static class
GeoFunctions.JoinStyle
How the "buffer" command decorates junctions between line segments.(package private) static class
GeoFunctions.MapGeom
Sub-class of geometry that has a spatial reference.(package private) static class
GeoFunctions.SimpleGeom
Sub-class of geometry that has no spatial reference.(package private) static class
GeoFunctions.Type
Geometry types, with the names and codes assigned by OGC.
-
Field Summary
Fields Modifier and Type Field Description private static int
NO_SRID
private static com.esri.core.geometry.SpatialReference
SPATIAL_REFERENCE
-
Constructor Summary
Constructors Modifier Constructor Description private
GeoFunctions()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static GeoFunctions.Geom
bind(com.esri.core.geometry.Geometry geometry, int srid)
private static GeoFunctions.MapGeom
bind(com.esri.core.geometry.Geometry geometry, com.esri.core.geometry.SpatialReference sr)
private static GeoFunctions.Geom
buffer(GeoFunctions.Geom geom, double bufferSize, int quadSegCount, GeoFunctions.CapStyle endCapStyle, GeoFunctions.JoinStyle joinStyle, float mitreLimit)
private static com.esri.core.geometry.Envelope
envelope(com.esri.core.geometry.Geometry g)
private static boolean
intersects(com.esri.core.geometry.Geometry g1, com.esri.core.geometry.Geometry g2, com.esri.core.geometry.SpatialReference sr)
private static GeoFunctions.Geom
makeLine(GeoFunctions.Geom... geoms)
private static GeoFunctions.Geom
point(double x, double y)
static java.lang.String
ST_AsText(GeoFunctions.Geom g)
static java.lang.String
ST_AsWKT(GeoFunctions.Geom g)
static GeoFunctions.Geom
ST_Boundary(GeoFunctions.Geom geom)
Returns the boundary ofgeom
.static GeoFunctions.Geom
ST_Buffer(GeoFunctions.Geom geom, double distance)
Computes a buffer aroundgeom
.static GeoFunctions.Geom
ST_Buffer(GeoFunctions.Geom geom, double distance, int quadSegs)
Computes a buffer aroundgeom
with .static GeoFunctions.Geom
ST_Buffer(GeoFunctions.Geom geom, double bufferSize, java.lang.String style)
Computes a buffer aroundgeom
.static boolean
ST_Contains(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2)
Returns whethergeom1
containsgeom2
.static boolean
ST_ContainsProperly(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2)
Returns whethergeom1
containsgeom2
but does not intersect its boundary.private static boolean
ST_Covers(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2)
Returns whether no point ingeom2
is outsidegeom1
.static boolean
ST_Crosses(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2)
Returns whethergeom1
crossesgeom2
.static boolean
ST_Disjoint(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2)
Returns whethergeom1
andgeom2
are disjoint.static double
ST_Distance(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2)
Returns the distance betweengeom1
andgeom2
.static boolean
ST_DWithin(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2, double distance)
Returns whethergeom1
andgeom2
are withindistance
of each other.static GeoFunctions.Geom
ST_Envelope(GeoFunctions.Geom geom)
Returns the minimum bounding box ofgeom
(which may be a GEOMETRYCOLLECTION).static boolean
ST_EnvelopesIntersect(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2)
Returns whether the envelope ofgeom1
intersects the envelope ofgeom2
.static boolean
ST_Equals(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2)
Returns whethergeom1
equalsgeom2
.static java.lang.String
ST_GeometryType(GeoFunctions.Geom geom)
Returns the type ofgeom
.static int
ST_GeometryTypeCode(GeoFunctions.Geom geom)
Returns the OGC SFS type code ofgeom
.static GeoFunctions.Geom
ST_GeomFromText(java.lang.String s)
static GeoFunctions.Geom
ST_GeomFromText(java.lang.String s, int srid)
static boolean
ST_Intersects(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2)
Returns whethergeom1
intersectsgeom2
.static boolean
ST_Is3D(GeoFunctions.Geom geom)
Returns whethergeom
has at least one z-coordinate.static GeoFunctions.Geom
ST_LineFromText(java.lang.String s)
static GeoFunctions.Geom
ST_LineFromText(java.lang.String wkt, int srid)
static GeoFunctions.Geom
ST_MakeLine(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2)
Creates a line-string from the given POINTs (or MULTIPOINTs).static GeoFunctions.Geom
ST_MakeLine(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2, GeoFunctions.Geom geom3)
static GeoFunctions.Geom
ST_MakeLine(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2, GeoFunctions.Geom geom3, GeoFunctions.Geom geom4)
static GeoFunctions.Geom
ST_MakeLine(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2, GeoFunctions.Geom geom3, GeoFunctions.Geom geom4, GeoFunctions.Geom geom5)
static GeoFunctions.Geom
ST_MakeLine(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2, GeoFunctions.Geom geom3, GeoFunctions.Geom geom4, GeoFunctions.Geom geom5, GeoFunctions.Geom geom6)
static GeoFunctions.Geom
ST_MakePoint(java.math.BigDecimal x, java.math.BigDecimal y)
Alias forST_Point(BigDecimal, BigDecimal)
.static GeoFunctions.Geom
ST_MakePoint(java.math.BigDecimal x, java.math.BigDecimal y, java.math.BigDecimal z)
Alias forST_Point(BigDecimal, BigDecimal, BigDecimal)
.static GeoFunctions.Geom
ST_MLineFromText(java.lang.String s)
static GeoFunctions.Geom
ST_MLineFromText(java.lang.String wkt, int srid)
static GeoFunctions.Geom
ST_MPointFromText(java.lang.String s)
static GeoFunctions.Geom
ST_MPointFromText(java.lang.String wkt, int srid)
static GeoFunctions.Geom
ST_MPolyFromText(java.lang.String s)
static GeoFunctions.Geom
ST_MPolyFromText(java.lang.String wkt, int srid)
static boolean
ST_OrderingEquals(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2)
Returns whethergeom1
equalsgeom2
and their coordinates and component Geometries are listed in the same order.static boolean
ST_Overlaps(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2)
Returnsgeom1
overlapsgeom2
.static GeoFunctions.Geom
ST_Point(java.math.BigDecimal x, java.math.BigDecimal y)
Constructs a 2D point from coordinates.static GeoFunctions.Geom
ST_Point(java.math.BigDecimal x, java.math.BigDecimal y, java.math.BigDecimal z)
Constructs a 3D point from coordinates.static GeoFunctions.Geom
ST_PointFromText(java.lang.String s)
static GeoFunctions.Geom
ST_PointFromText(java.lang.String wkt, int srid)
static GeoFunctions.Geom
ST_PolyFromText(java.lang.String s)
static GeoFunctions.Geom
ST_PolyFromText(java.lang.String wkt, int srid)
static GeoFunctions.Geom
ST_SetSRID(GeoFunctions.Geom geom, int srid)
Returns a copy ofgeom
with a new SRID.static boolean
ST_Touches(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2)
Returns whethergeom1
touchesgeom2
.static GeoFunctions.Geom
ST_Transform(GeoFunctions.Geom geom, int srid)
Transformsgeom
from one coordinate reference system (CRS) to the CRS specified bysrid
.static GeoFunctions.Geom
ST_Union(GeoFunctions.Geom geomCollection)
Computes the union of the geometries ingeomCollection
.static GeoFunctions.Geom
ST_Union(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2)
Computes the union ofgeom1
andgeom2
.static boolean
ST_Within(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2)
Returns whethergeom1
is withingeom2
.static java.lang.Double
ST_X(GeoFunctions.Geom geom)
Returns the x-value of the first coordinate ofgeom
.static java.lang.Double
ST_Y(GeoFunctions.Geom geom)
Returns the y-value of the first coordinate ofgeom
.static java.lang.Double
ST_Z(GeoFunctions.Geom geom)
Returns the z-value of the first coordinate ofgeom
.private static java.lang.UnsupportedOperationException
todo()
private static GeoFunctions.Type
type(com.esri.core.geometry.Geometry g)
Returns the OGC type of a geometry.
-
-
-
Field Detail
-
NO_SRID
private static final int NO_SRID
- See Also:
- Constant Field Values
-
SPATIAL_REFERENCE
private static final com.esri.core.geometry.SpatialReference SPATIAL_REFERENCE
-
-
Method Detail
-
todo
private static java.lang.UnsupportedOperationException todo()
-
bind
protected static GeoFunctions.Geom bind(com.esri.core.geometry.Geometry geometry, int srid)
-
bind
private static GeoFunctions.MapGeom bind(com.esri.core.geometry.Geometry geometry, com.esri.core.geometry.SpatialReference sr)
-
ST_AsText
public static java.lang.String ST_AsText(GeoFunctions.Geom g)
-
ST_AsWKT
public static java.lang.String ST_AsWKT(GeoFunctions.Geom g)
-
ST_GeomFromText
public static GeoFunctions.Geom ST_GeomFromText(java.lang.String s)
-
ST_GeomFromText
public static GeoFunctions.Geom ST_GeomFromText(java.lang.String s, int srid)
-
ST_LineFromText
public static GeoFunctions.Geom ST_LineFromText(java.lang.String s)
-
ST_LineFromText
public static GeoFunctions.Geom ST_LineFromText(java.lang.String wkt, int srid)
-
ST_MPointFromText
public static GeoFunctions.Geom ST_MPointFromText(java.lang.String s)
-
ST_MPointFromText
public static GeoFunctions.Geom ST_MPointFromText(java.lang.String wkt, int srid)
-
ST_PointFromText
public static GeoFunctions.Geom ST_PointFromText(java.lang.String s)
-
ST_PointFromText
public static GeoFunctions.Geom ST_PointFromText(java.lang.String wkt, int srid)
-
ST_PolyFromText
public static GeoFunctions.Geom ST_PolyFromText(java.lang.String s)
-
ST_PolyFromText
public static GeoFunctions.Geom ST_PolyFromText(java.lang.String wkt, int srid)
-
ST_MLineFromText
public static GeoFunctions.Geom ST_MLineFromText(java.lang.String s)
-
ST_MLineFromText
public static GeoFunctions.Geom ST_MLineFromText(java.lang.String wkt, int srid)
-
ST_MPolyFromText
public static GeoFunctions.Geom ST_MPolyFromText(java.lang.String s)
-
ST_MPolyFromText
public static GeoFunctions.Geom ST_MPolyFromText(java.lang.String wkt, int srid)
-
ST_MakeLine
public static GeoFunctions.Geom ST_MakeLine(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2)
Creates a line-string from the given POINTs (or MULTIPOINTs).
-
ST_MakeLine
public static GeoFunctions.Geom ST_MakeLine(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2, GeoFunctions.Geom geom3)
-
ST_MakeLine
public static GeoFunctions.Geom ST_MakeLine(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2, GeoFunctions.Geom geom3, GeoFunctions.Geom geom4)
-
ST_MakeLine
public static GeoFunctions.Geom ST_MakeLine(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2, GeoFunctions.Geom geom3, GeoFunctions.Geom geom4, GeoFunctions.Geom geom5)
-
ST_MakeLine
public static GeoFunctions.Geom ST_MakeLine(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2, GeoFunctions.Geom geom3, GeoFunctions.Geom geom4, GeoFunctions.Geom geom5, GeoFunctions.Geom geom6)
-
makeLine
private static GeoFunctions.Geom makeLine(GeoFunctions.Geom... geoms)
-
ST_MakePoint
public static GeoFunctions.Geom ST_MakePoint(java.math.BigDecimal x, java.math.BigDecimal y)
Alias forST_Point(BigDecimal, BigDecimal)
.
-
ST_MakePoint
public static GeoFunctions.Geom ST_MakePoint(java.math.BigDecimal x, java.math.BigDecimal y, java.math.BigDecimal z)
Alias forST_Point(BigDecimal, BigDecimal, BigDecimal)
.
-
ST_Point
public static GeoFunctions.Geom ST_Point(java.math.BigDecimal x, java.math.BigDecimal y)
Constructs a 2D point from coordinates.
-
ST_Point
public static GeoFunctions.Geom ST_Point(java.math.BigDecimal x, java.math.BigDecimal y, java.math.BigDecimal z)
Constructs a 3D point from coordinates.
-
point
private static GeoFunctions.Geom point(double x, double y)
-
ST_Is3D
public static boolean ST_Is3D(GeoFunctions.Geom geom)
Returns whethergeom
has at least one z-coordinate.
-
ST_X
public static java.lang.Double ST_X(GeoFunctions.Geom geom)
Returns the x-value of the first coordinate ofgeom
.
-
ST_Y
public static java.lang.Double ST_Y(GeoFunctions.Geom geom)
Returns the y-value of the first coordinate ofgeom
.
-
ST_Z
public static java.lang.Double ST_Z(GeoFunctions.Geom geom)
Returns the z-value of the first coordinate ofgeom
.
-
ST_Boundary
public static GeoFunctions.Geom ST_Boundary(GeoFunctions.Geom geom)
Returns the boundary ofgeom
.
-
ST_Distance
public static double ST_Distance(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2)
Returns the distance betweengeom1
andgeom2
.
-
ST_GeometryType
public static java.lang.String ST_GeometryType(GeoFunctions.Geom geom)
Returns the type ofgeom
.
-
ST_GeometryTypeCode
public static int ST_GeometryTypeCode(GeoFunctions.Geom geom)
Returns the OGC SFS type code ofgeom
.
-
type
private static GeoFunctions.Type type(com.esri.core.geometry.Geometry g)
Returns the OGC type of a geometry.
-
ST_Envelope
public static GeoFunctions.Geom ST_Envelope(GeoFunctions.Geom geom)
Returns the minimum bounding box ofgeom
(which may be a GEOMETRYCOLLECTION).
-
envelope
private static com.esri.core.geometry.Envelope envelope(com.esri.core.geometry.Geometry g)
-
ST_Contains
public static boolean ST_Contains(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2)
Returns whethergeom1
containsgeom2
.
-
ST_ContainsProperly
public static boolean ST_ContainsProperly(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2)
Returns whethergeom1
containsgeom2
but does not intersect its boundary.
-
ST_Covers
private static boolean ST_Covers(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2)
Returns whether no point ingeom2
is outsidegeom1
.
-
ST_Crosses
public static boolean ST_Crosses(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2)
Returns whethergeom1
crossesgeom2
.
-
ST_Disjoint
public static boolean ST_Disjoint(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2)
Returns whethergeom1
andgeom2
are disjoint.
-
ST_EnvelopesIntersect
public static boolean ST_EnvelopesIntersect(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2)
Returns whether the envelope ofgeom1
intersects the envelope ofgeom2
.
-
ST_Equals
public static boolean ST_Equals(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2)
Returns whethergeom1
equalsgeom2
.
-
ST_Intersects
public static boolean ST_Intersects(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2)
Returns whethergeom1
intersectsgeom2
.
-
intersects
private static boolean intersects(com.esri.core.geometry.Geometry g1, com.esri.core.geometry.Geometry g2, com.esri.core.geometry.SpatialReference sr)
-
ST_OrderingEquals
public static boolean ST_OrderingEquals(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2)
Returns whethergeom1
equalsgeom2
and their coordinates and component Geometries are listed in the same order.
-
ST_Overlaps
public static boolean ST_Overlaps(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2)
Returnsgeom1
overlapsgeom2
.
-
ST_Touches
public static boolean ST_Touches(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2)
Returns whethergeom1
touchesgeom2
.
-
ST_Within
public static boolean ST_Within(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2)
Returns whethergeom1
is withingeom2
.
-
ST_DWithin
public static boolean ST_DWithin(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2, double distance)
Returns whethergeom1
andgeom2
are withindistance
of each other.
-
ST_Buffer
public static GeoFunctions.Geom ST_Buffer(GeoFunctions.Geom geom, double distance)
Computes a buffer aroundgeom
.
-
ST_Buffer
public static GeoFunctions.Geom ST_Buffer(GeoFunctions.Geom geom, double distance, int quadSegs)
Computes a buffer aroundgeom
with .
-
ST_Buffer
public static GeoFunctions.Geom ST_Buffer(GeoFunctions.Geom geom, double bufferSize, java.lang.String style)
Computes a buffer aroundgeom
.
-
buffer
private static GeoFunctions.Geom buffer(GeoFunctions.Geom geom, double bufferSize, int quadSegCount, GeoFunctions.CapStyle endCapStyle, GeoFunctions.JoinStyle joinStyle, float mitreLimit)
-
ST_Union
public static GeoFunctions.Geom ST_Union(GeoFunctions.Geom geom1, GeoFunctions.Geom geom2)
Computes the union ofgeom1
andgeom2
.
-
ST_Union
public static GeoFunctions.Geom ST_Union(GeoFunctions.Geom geomCollection)
Computes the union of the geometries ingeomCollection
.
-
ST_Transform
public static GeoFunctions.Geom ST_Transform(GeoFunctions.Geom geom, int srid)
Transformsgeom
from one coordinate reference system (CRS) to the CRS specified bysrid
.
-
ST_SetSRID
public static GeoFunctions.Geom ST_SetSRID(GeoFunctions.Geom geom, int srid)
Returns a copy ofgeom
with a new SRID.
-
-