Skip navigation links

Oracle® Spatial Java API Reference
11g Release 1 (11.1)

B28401-02


oracle.spatial.geometry
Class JGeometry

java.lang.Object
  extended by oracle.spatial.geometry.JGeometry

All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
J3D_Geometry

public class JGeometry
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

A Java class that maps Oracle Spatial's SQL type MDSYS.SDO_GEOMETRY. Supports only Oracle JDBC Driver version 8.1.7 or higher. Provides basic access functions to the geomeries stroed in Oracle Spatial database.

Note that this class is not synchornized, meaning if one thread is reading this geometry and another is modifying it (such as changing its ordinates array), there may be in-consistencies.

The main methods for reading/writing db geometries are: load(STRUCT) and store(). Here is a simple example showing how to use these two methods:

     /// reading a geometry from database
     ResultSet rs = statement.executeQuery("SELECT geometry FROM states where name='Florida'");
     STRUCT st = (oracle.sql.STRUCT) rs.getObject(1);
     //convert STRUCT into geometry
     JGeometry j_geom = JGeometry.load(st);

     // ... manipulate the geometry or create a new JGeometry ...

     /// writing a geometry back to database
     PreparedStatement ps = connection.prepareStatement("UPDATE states set geometry=? where name='Florida'");
     //convert JGeometry instance to DB STRUCT
     STRUCT obj = JGeometry.store(j_geom, connection);
     ps.setObject(1, obj);
     ps.execute();
  

If you are building new applications using an 11g release of this API, you can speed up reading and writing of JGoemetry objects using the new load(byte[]) and store(Connection, JGeometry). It improves its performance by using an internal SDO pickler to unlinearize an a SDO_GEOMETRY to a JGeometry object and linearize a JGeometry object to a Oracle pickler image for storing to an Oracle database. Here is a simple example showing how to use these two new methods:

     /// reading a geometry from database
     ResultSet rs = statement.executeQuery("SELECT geometry FROM states where ");
     byte[] image = ((OracleResultSet)rs).getBytes(1);
     //convert image into a JGeometry object using the SDO pickler
     JGeometry j_geom = JGeometry.load(image);

     // ... manipulate the geometry or create a new JGeometry ...

     /// writing a geometry back to database
     PreparedStatement ps = connection.prepareStatement(
         "UPDATE states set geometry=? where name='Florida'");
     //convert JGeometry instance to DB STRUCT using the SDO pickler
     STRUCT obj = JGeometry.store(connection, j_geom);
     ps.setObject(1, obj);
     ps.execute();
  

Requirements for this class:

   Oracle JDBC driver ver. 8.1.7 or higher;
   JDK 1.2 or higher (for Java2D support)
   
Since:
JDBC Driver 8.1.7
See Also:
Serialized Form

Nested Class Summary
static class JGeometry.Point
          A convenient class that represents a double-typed point.

 

Field Summary
static int GTYPE_COLLECTION
          collection geometry type
static int GTYPE_CURVE
          curve geoemtry type
static int GTYPE_MULTICURVE
          multi-curve geometry type
static int GTYPE_MULTIPOINT
          multi-point geometry type
static int GTYPE_MULTIPOLYGON
          multi-polygon geometry type
static int GTYPE_POINT
          point geometry type
static int GTYPE_POLYGON
          polygon geometry type

 

Constructor Summary
JGeometry(double minX, double minY, double maxX, double maxY, int srid)
          Creates a JGeometry instance that is a Rectangle.
JGeometry(double x, double y, double z, int srid)
          Constructs a 3D JGeometry instance that is a point
JGeometry(double x, double y, int srid)
          Constructs a 2D JGeometry instance that is a point
JGeometry(int gtype, int srid, double x, double y, double z, int[] elemInfo, double[] ordinates)
          Constructs a JGeometry instance with given information
JGeometry(int gtype, int srid, int[] elemInfo, double[] ordinates)
          Constructs a JGeometry instance with given information

 

Method Summary
 JGeometry affineTransforms(boolean translation, double tx, double ty, double tz, boolean scaling, JGeometry Psc1, double sx, double sy, double sz, boolean rotation, JGeometry P1, JGeometry line1, double angle, int dir, boolean shearing, double SHxy, double SHyx, double SHxz, double SHzx, double SHyz, double SHzy, boolean reflection, JGeometry Pref, JGeometry lineR, int dirR, boolean planeR, double[] n, double[] bigD)
          Returns the affine transformed JGeometry in 2D and 3D Euclidean space.
 JGeometry buffer(double bufferWidth)
          This method generates a new JGeometry object which is the buffered version of the input geometry.
 JGeometry buffer(double bufferWidth, double SMA, double iFlat, double arcT)
          This method generates a new JGeometry object which is the buffered version of the input geometry.
static java.lang.String byteArrayToHexString(byte[] in)
           
 java.lang.Object clone()
          constructs an instance that is a clone of this JGeometry.
static double[] computeArc(double x1, double y1, double x2, double y2, double x3, double y3)
          Helper method to compute center, radius, and angles for this arc from the three coordinate points.
static JGeometry createCircle(double x1, double y1, double x2, double y2, double x3, double y3, int srid)
          Creates a JGeometry that is a 2D Circle.
static JGeometry createCircle(double x, double y, double radius, int srid)
          Creates a JGeometry that is a Circle with provided radius and center.
 java.awt.Shape createDoubleShape()
          Creates a Java2D double shape object from this JSDOGeometry Double shape object use double, not float, as the coordinates data type.
 java.awt.Shape createDoubleShape(java.awt.geom.AffineTransform xfm)
          Creates a transformed shape from the geometry using the given affine transform.
static JGeometry createLinearLineString(double[] coords, int dim, int srid)
          Creates a JGeometry that is a single linear Line String.
static JGeometry createLinearMultiLineString(java.lang.Object[] coords, int dim, int srid)
          Creates a JGeometry that is a linear multi-linestring.
static JGeometry createLinearPolygon(double[] coords, int dim, int srid)
          Creates a JGeometry that is a simple linear Polygon without holes.
static JGeometry createLinearPolygon(java.lang.Object[] coords, int dim, int srid)
          Creates a JGeometry that is a linear polygon which may have holes.
static JGeometry createLRSLinearLineString(double[] coords, int LRSdim, int srid)
          Creates a JGeometry that is a single LRS linear Line String.
static JGeometry createLRSLinearMultiLineString(java.lang.Object[] coords, int LRSdim, int srid)
          Creates a JGeometry that is a LRS linear multi-linestring.
static JGeometry createLRSLinearPolygon(double[] coords, int LRSdim, int srid)
          Creates a JGeometry that is a simple LRS linear Polygon without holes.
static JGeometry createLRSLinearPolygon(java.lang.Object[] coords, int LRSdim, int srid)
          Creates a JGeometry that is a linear LRS polygon which may have holes.
static JGeometry createLRSPoint(double[] coord, int LRSdim, int srid)
           
static JGeometry createMultiPoint(java.lang.Object[] coords, int dim, int srid)
          Creates a JGeometry that is a multi-point geometry.
static JGeometry createPoint(double[] coord, int dim, int srid)
           
 java.awt.Shape createShape()
          Creates a Java2D shape object from this JGeometry Note: for point geometry this method returns null.
 java.awt.Shape createShape(java.awt.geom.AffineTransform xfm)
          Creates a transformed shape from the geometry using the given affine transform.
 java.awt.Shape createShape(java.awt.geom.AffineTransform xfm, boolean simplify)
          Creates a simplified transformed shape from the geometry using the given affine transform.
 JGeometry densifyArcs(double arc_tolerance)
          Arcs densification method to densify arcs into lines.
 JGeometry densifyArcs(double arc_tolerance, boolean flag)
           
 boolean equals(java.lang.Object otherObj)
          Deprecated. This function has been moved to oracle.spatial.util.GML. public static JGeometry fromNodeToGeometry(Node nd) throws DataException { return GML.fromNodeToGeometry(nd); }
static double[] expandCircle(double x1, double y1, double x2, double y2, double x3, double y3)
           
 int getDimensions()
          Gets the dimensionality of this geometry.
 JGeometry getElementAt(int position)
          Gets an element in this geometry.
 JGeometry[] getElements()
          Gets an array of the (geometry) elements in this geometry.
 int[] getElemInfo()
          Gets the reference to the element infomation array of this JGeometry.
 double[] getFirstPoint()
          Gets the first coordinate for this geometry.
static StructDescriptor getGeomDescriptor(java.sql.Connection conn)
          Obtains a StructDescriptor object to the MDSYS.SDO_GEOMETRY PL/SQL object type from the given connection.
 java.awt.geom.Point2D getJavaPoint()
          Gets the java2D point rerepsentation of this geometry.
 java.awt.geom.Point2D[] getJavaPoints()
          Gets the java2D points rerepsentation of this geometry.
 java.awt.geom.Point2D getLabelPoint()
          Gets the SDO_GEOMETRY.sdo_point as a label point.
 double[] getLabelPointXYZ()
          Returns the x,y and z value of the label point in a double array.
 double[] getLastPoint()
          Gets the last coordinate of the geometry.
 int getLRMDimension()
          Gets the dimension index for LRS measure.
 double[] getMBR()
          Gets the MBR of this geometry.
 int getNumPoints()
          Gets the number of points or verticies in this geometry.
static java.lang.Object[] getOracleDescriptors(java.sql.Connection conn)
          Obtains a set of Oracle type descriptors related to the SDO_GEOMETRY type from the given connection.
 double[] getOrdinatesArray()
          Gets the reference to the ordinate array of this JGeometry.
 java.lang.Object[] getOrdinatesOfElements()
          Gets an array of the (top-level) elements in this geometry.
 int getOrientMultiPointOffset()
          Returns the offset to get the orientation parameters for a Multi-point.
 double[] getPoint()
          Gets the coordinate of this point geometry.
 long getSize()
          Gets an estimated size of the geometry in bytes.
 int getSRID()
          Gets the geometry SRID.
 int getType()
          Gets the geometry type.
 boolean hasCircularArcs()
          Checks if this geometry is a compound one.
 boolean isCircle()
          Checks if this geometry represents a circle.
 boolean isGeodeticMBR()
          Checks if this geometry represents a geodetic MBR.
 boolean isLRSGeometry()
          Checks if this is a LRS (Linear Reference System) geometry.
 boolean isMultiPoint()
          Checks if this geometry is of Multi-Point type.
 boolean isOrientedMultiPoint()
          Checks if this geometry is of Multi-Point type and oriented.
 boolean isOrientedPoint()
          Checks if this geometry is of point type and oriented.
 boolean isPoint()
          Checks if this geometry is of point type.
 boolean isRectangle()
          Checks if this geometry represents a rectangle.
static double[] linearizeArc(double x1, double y1, double x2, double y2, double x3, double y3)
          For a given arc, returns a linearized array of 2D line segments.
static double[] linearizeArc(double x1, double y1, double x2, double y2, double x3, double y3, int numPoints)
          returns a linearized array of 2D line segments for an ARC given in three points.
static JGeometry load(STRUCT st)
          Creates a JGeometry instance from a STRUCT object representing a geometry column in a JDBC result set.
static int monoMeasure(double[] coords, int dim)
          Edited version of PL/SQL monotonic_measure() monoMeasure() determines whether a line is monotonically increasing or decreasing Returns: 1 if increasing or all measures null; -1 if decreasing; 0 if measures are inconsistent Note: Repeated measures are not flagged as inconsistent (but are not valid in LRS); assumes measure is in the last position: X,Y,M or X,Y,Z,M
 JGeometry projectFromLTP()
          This method generates a new JGeometry object by projecting the input from a Local Tangent Plane to geodetic long/lat.
 JGeometry projectToLTP(double smax, double flat)
          This method generates a new JGeometry object by projecting the input to a Local Tangent Plane.
static double[] reFormulateArc(double[] d)
          In order to create arc shape, Recalculate centerX, centerY, radius, startAngle, midAngle and endAngle.
 void setLRMDimension(int m)
          Sets the dimension index for LRS measure.
 void setSRID(int srid)
          Sets the srid for this geometry.
 void setType(int gt)
          Sets the geometry type for this geometry.
 JGeometry simplify(double threshold)
          This method generates a new JGeometry object by simplifying the input geometry using the Douglas-Peucker Algorithm.
 JGeometry simplify(double threshold, double SMA, double iFlat)
          This method generates a new JGeometry object which is the simplified version of the input geometry.
static STRUCT store(java.sql.Connection conn, JGeometry geom)
          Converts a JGeometry instance to an Oracle JDBC STRUCT object using the SdoPickler.
static STRUCT store(java.sql.Connection conn, JGeometry geom, StructDescriptor desc)
          Converts a JGeometry instance to an Oracle JDBC STRUCT object using the SdoPickler.
static byte[] store(JGeometry geom)
          Converts a JGeometry instance to an Oracle pickler image of the SDO_GEOMETRY type.
static STRUCT store(JGeometry geom, java.sql.Connection conn)
          Converts the given geometry object into an Oracle JDBC STRUCT object.
static STRUCT store(JGeometry geom, java.sql.Connection conn, java.lang.Object[] descriptors)
          Converts the given geometry object into an Oracle JDBC STRUCT object.
 java.lang.String toString()
           
 java.lang.String toStringFull()
           

 

Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait

 

Field Detail

GTYPE_POINT

public static final int GTYPE_POINT
point geometry type
See Also:
Constant Field Values

GTYPE_CURVE

public static final int GTYPE_CURVE
curve geoemtry type
See Also:
Constant Field Values

GTYPE_POLYGON

public static final int GTYPE_POLYGON
polygon geometry type
See Also:
Constant Field Values

GTYPE_COLLECTION

public static final int GTYPE_COLLECTION
collection geometry type
See Also:
Constant Field Values

GTYPE_MULTIPOINT

public static final int GTYPE_MULTIPOINT
multi-point geometry type
See Also:
Constant Field Values

GTYPE_MULTICURVE

public static final int GTYPE_MULTICURVE
multi-curve geometry type
See Also:
Constant Field Values

GTYPE_MULTIPOLYGON

public static final int GTYPE_MULTIPOLYGON
multi-polygon geometry type
See Also:
Constant Field Values

Constructor Detail

JGeometry

public JGeometry(int gtype,
                 int srid,
                 double x,
                 double y,
                 double z,
                 int[] elemInfo,
                 double[] ordinates)
Constructs a JGeometry instance with given information
Parameters:
gtype - the geometry type
srid - the SRS id; if 0 is used then the MDSYS.SDO_GEOMETRY.SDO_SRID will be set to null when converted into DB format.
x - x ordinate of a label point
y - y ordinate of a label point
z - z ordinate of a label point
elemInfo - geometry element info array
ordinates - geometry ordinates array

JGeometry

public JGeometry(int gtype,
                 int srid,
                 int[] elemInfo,
                 double[] ordinates)
Constructs a JGeometry instance with given information
Parameters:
gtype - the geometry type
srid - the SRS id; if 0 is used then the MDSYS.SDO_GEOMETRY.SDO_SRID will be set to null when converted into DB format.
elemInfo - geometry element info array
ordinates - geometry ordinates array

JGeometry

public JGeometry(double x,
                 double y,
                 int srid)
Constructs a 2D JGeometry instance that is a point
Parameters:
x - x ordinate of a label point
y - y ordinate of a label point
srid - the SRS id; if 0 is used then the MDSYS.SDO_GEOMETRY.SDO_SRID will be set to null when converted into DB format.

JGeometry

public JGeometry(double x,
                 double y,
                 double z,
                 int srid)
Constructs a 3D JGeometry instance that is a point
Parameters:
x - x ordinate of a label point
y - y ordinate of a label point
z - z ordinate of a label point
srid - the SRS id; if 0 is used then the MDSYS.SDO_GEOMETRY.SDO_SRID will be set to null when converted into DB format.

JGeometry

public JGeometry(double minX,
                 double minY,
                 double maxX,
                 double maxY,
                 int srid)
Creates a JGeometry instance that is a Rectangle. The coordinates for the lower-left and upper-right corners are supplied.
Parameters:
minX - the minimum x ordinate of the rectangle
minY - the minimum y ordinate of the rectangle
maxX - the maximum x ordinate of the rectangle
maxY - the maximum y ordinate of the rectangle
srid - the SRS id. if 0 is used then the MDSYS.SDO_GEOMETRY.SDO_SRID will be set to null when converted into DB format.

Method Detail

clone

public java.lang.Object clone()
constructs an instance that is a clone of this JGeometry. All the fields of this object is deep-copied over to the clone.
Overrides:
clone in class java.lang.Object

createPoint

public static JGeometry createPoint(double[] coord,
                                    int dim,
                                    int srid)

createLRSPoint

public static JGeometry createLRSPoint(double[] coord,
                                       int LRSdim,
                                       int srid)
Parameters:
LRSdim - LRS dimensionality: X,Y,M=2D; X,Y,Z,M=3D

createCircle

public static JGeometry createCircle(double x,
                                     double y,
                                     double radius,
                                     int srid)
Creates a JGeometry that is a Circle with provided radius and center.
Parameters:
x - the x ordinate of the circle's center
y - the y ordinate of the circle's center
radius - the radius of the circle
srid - the srid of the circle

createCircle

public static JGeometry createCircle(double x1,
                                     double y1,
                                     double x2,
                                     double y2,
                                     double x3,
                                     double y3,
                                     int srid)
Creates a JGeometry that is a 2D Circle. The three supplied coordinates form the circumference of the circle.
Parameters:
x1 - x ordinate of point 1
y1 - y ordinate of point 1
x2 - x ordinate of point 2
y2 - y ordinate of point 2
x3 - x ordinate of point 3
y3 - y ordinate of point 3
srid - srs id for the circle

createLinearLineString

public static JGeometry createLinearLineString(double[] coords,
                                               int dim,
                                               int srid)
Creates a JGeometry that is a single linear Line String.
Parameters:
coords - the coordinates of the linear line string
dim - the dimensionality of the line string.
srid - the srid of the linear line string
Returns:
a JGeometry object that is a linear line string

createLRSLinearLineString

public static JGeometry createLRSLinearLineString(double[] coords,
                                                  int LRSdim,
                                                  int srid)
Creates a JGeometry that is a single LRS linear Line String.
Parameters:
coords - the coordinates of the LRS linear line string
LRSdim - the LRS dimensionality of the line string: X,Y,M=2D; X,Y,Z,M=3D
srid - the srid of the linear line string
Returns:
a JGeometry object that is a LRS linear line string

createLinearMultiLineString

public static JGeometry createLinearMultiLineString(java.lang.Object[] coords,
                                                    int dim,
                                                    int srid)
Creates a JGeometry that is a linear multi-linestring.
Parameters:
coords - an array of all the linestrings' coordinates
dim - the dimensionality of the linestring
srid - the srid of the multi-linestring

createLRSLinearMultiLineString

public static JGeometry createLRSLinearMultiLineString(java.lang.Object[] coords,
                                                       int LRSdim,
                                                       int srid)
Creates a JGeometry that is a LRS linear multi-linestring.
Parameters:
coords - an array of all the LRS linestrings' coordinates
LRSdim - the LRS dimensionality of the linestring: X,Y,M=2D; X,Y,Z,M=3D
srid - the srid of the multi-linestring

createMultiPoint

public static JGeometry createMultiPoint(java.lang.Object[] coords,
                                         int dim,
                                         int srid)
Creates a JGeometry that is a multi-point geometry.
Parameters:
coords - the array of double-typed arrays each containing one point
dim - the dimensionality of each point
srid - the srid for the geometry.

createLinearPolygon

public static JGeometry createLinearPolygon(double[] coords,
                                            int dim,
                                            int srid)
Creates a JGeometry that is a simple linear Polygon without holes. Note that if the supplied coordinate array does not close itslef, meaning the last coordinate is not the same as the first, a new coordinate will be appended to the end of the input coordinates array. the new coordinate repeats the first one.
Parameters:
coords - the coordinates of the linear polygon
dim - the dimensionality of the polygon
srid - the srid of the polygon

createLinearPolygon

public static JGeometry createLinearPolygon(java.lang.Object[] coords,
                                            int dim,
                                            int srid)
Creates a JGeometry that is a linear polygon which may have holes. Each array in the double array parameter represents a single ring of the polygon. The outer ring must be the first in the double array. Note that for each ring, if its coordinate array does not close itslef, meaning the last coordinate is not the same as the first, a new coordinate will be appended to the end of that ring's coordinates array. The new coordinate repeats the first one for the said ring.
Parameters:
coords - an array of double-typed arrays that contains all the rings' coordinates
dim - the dimensionality of the polygon
srid - the srid of the polygon

createLRSLinearPolygon

public static JGeometry createLRSLinearPolygon(double[] coords,
                                               int LRSdim,
                                               int srid)
Creates a JGeometry that is a simple LRS linear Polygon without holes. Note that if the supplied coordinate array does not close itslef, meaning the last coordinate is not the same as the first, a new coordinate will be appended to the end of the input coordinates array. the new coordinate repeats the first one.
Parameters:
coords - the coordinates of the LRS linear polygon
LRSdim - the LRS dimensionality of the polygon: X,Y,M=2D; X,Y,Z,M=3D
srid - the srid of the polygon

createLRSLinearPolygon

public static JGeometry createLRSLinearPolygon(java.lang.Object[] coords,
                                               int LRSdim,
                                               int srid)
Creates a JGeometry that is a linear LRS polygon which may have holes. Each array in the double array parameter represents a single ring of the polygon. The outer ring must be the first in the double array. Note that for each ring, if its coordinate array does not close itslef, meaning the last coordinate is not the same as the first, a new coordinate will be appended to the end of that ring's coordinates array. The new coordinate repeats the first one for the said ring.
Parameters:
coords - an array of double-typed arrays that contains all the rings' coordinates
LRSdim - the LRS dimensionality of the polygon: X,Y,M=2D; X,Y,Z,M=3D
srid - the srid of the polygon

monoMeasure

public static int monoMeasure(double[] coords,
                              int dim)
Edited version of PL/SQL monotonic_measure() monoMeasure() determines whether a line is monotonically increasing or decreasing Returns: 1 if increasing or all measures null; -1 if decreasing; 0 if measures are inconsistent Note: Repeated measures are not flagged as inconsistent (but are not valid in LRS); assumes measure is in the last position: X,Y,M or X,Y,Z,M
Parameters:
coords - an array of double that contains all coordinates
dim - the dimensionality of the feature: X,Y,M=3D; X,Y,Z,M=4D

getType

public int getType()
Gets the geometry type.

Known geom types (1st digit from right):

 GTYPE_POINT = 1;
 GTYPE_CURVE = 2;
 GTYPE_POLYGON = 3;
 GTYPE_COLLECTION = 4;
 GTYPE_MULTIPOINT = 5;
 GTYPE_MULTICURVE = 6;
 GTYPE_MULTIPOLYGON = 7;


Returns:
the geometry type


setType

public void setType(int gt)
Sets the geometry type for this geometry.
Parameters:
gt - the geometry type

getLRMDimension

public int getLRMDimension()
Gets the dimension index for LRS measure. This is the 2nd digit (from left) of the 4-digit SDO_Geometry GTYPE.
Returns:
the LRS mesaure dimension

setLRMDimension

public void setLRMDimension(int m)
Sets the dimension index for LRS measure. This is the 2nd digit (from left) of the 4-digit SDO_Geometry GTYPE.
Parameters:
m - the LRS measure dimension

getSRID

public int getSRID()
Gets the geometry SRID.

setSRID

public void setSRID(int srid)
Sets the srid for this geometry.
Parameters:
srid - the srid

getLabelPoint

public java.awt.geom.Point2D getLabelPoint()
Gets the SDO_GEOMETRY.sdo_point as a label point.

getLabelPointXYZ

public double[] getLabelPointXYZ()
Returns the x,y and z value of the label point in a double array.
Note that if these values are not set in the database geometry, this method will return them as Double.NaN.
Returns:
a double array contianing 3 doubles

getPoint

public double[] getPoint()
Gets the coordinate of this point geometry. Retruns null if this geometry is not of point type.
Returns:
a double array which stores the oridnates of this point; null if this geometry is not a point

getJavaPoint

public java.awt.geom.Point2D getJavaPoint()
Gets the java2D point rerepsentation of this geometry. Returns null if this geometry is not of point type.
Returns:
a java Point2D.Double instance if this is a point geometry.

getJavaPoints

public java.awt.geom.Point2D[] getJavaPoints()
Gets the java2D points rerepsentation of this geometry. Returns null if this geometry is not of 2D multipoint type.
Returns:
an array of java Point2D.Double instances if this is a 2D multipoint geometry.

isPoint

public final boolean isPoint()
Checks if this geometry is of point type.
Returns:
true if this geometry is a point

isOrientedPoint

public final boolean isOrientedPoint()
Checks if this geometry is of point type and oriented.
Returns:
true if this geometry is a point

isMultiPoint

public final boolean isMultiPoint()
Checks if this geometry is of Multi-Point type.
Returns:
true if this geometry is a multi-point; otherwise false.

isOrientedMultiPoint

public final boolean isOrientedMultiPoint()
Checks if this geometry is of Multi-Point type and oriented.
Returns:
true if this geometry is an oriented multi-point (if any of the points is an oriented point).

isRectangle

public final boolean isRectangle()
Checks if this geometry represents a rectangle.
Returns:
true if this geometry is a rectangle.

isCircle

public final boolean isCircle()
Checks if this geometry represents a circle.
Returns:
true if this geometry is a circle.

isGeodeticMBR

public final boolean isGeodeticMBR()
Checks if this geometry represents a geodetic MBR.
Returns:
true if this geometry is a geodetic MBR.

isLRSGeometry

public final boolean isLRSGeometry()
Checks if this is a LRS (Linear Reference System) geometry.
Returns:
true if this is a LRS geometry; otherwise false

hasCircularArcs

public final boolean hasCircularArcs()
Checks if this geometry is a compound one. A compound geometry has circular arcs as part of its boundary.

getDimensions

public int getDimensions()
Gets the dimensionality of this geometry.
Returns:
the dimensions of this geoemtry.

getOrdinatesArray

public double[] getOrdinatesArray()
Gets the reference to the ordinate array of this JGeometry. Unless you know what you are doing, you should not modify the values in the returned array.
Returns:
the ordinates array corresponding to the server side MDSYS.SDO_GEOMETRY.SDO_ORDINATE_ARRAY. Null will be returned if this geometry is a point with optimal storage (i.e., the coordinate is stored in the SDO_GEOM.SDO_POINT field).

getElemInfo

public int[] getElemInfo()
Gets the reference to the element infomation array of this JGeometry. Unless you know what you are doing, you should not modify the values in the returned array.
Returns:
the element information array corresponding to the server side MDSYS.SDO_GEOMETRY.SDO_ELEM_INFO_ARRAY.

getNumPoints

public final int getNumPoints()
Gets the number of points or verticies in this geometry. Not to be confused with the number of ordinates or double values in the ordinates array.
Returns:
the number of points (including all parts) in this geometry.

getFirstPoint

public double[] getFirstPoint()
Gets the first coordinate for this geometry. If the geometry is a point, the point's coordinate will be returned. If anything else, the first coordinate in the geometry's ordinates array (MDSYS.SDO_GEOMETRY.SDO_ORDINATES) will be returned.
Returns:
the first point of the geometry in an array that stores the ordinates. The size of the result array is the same as the dimension of the geometry.

getLastPoint

public double[] getLastPoint()
Gets the last coordinate of the geometry. If the geometry is a point its coordinate will be returned. For any other geometry types the last coordinate in the ordinates array (MDSYS.SDO_GEOMETRY.SDO_ORDINATES) will be returned. Note that this method does not take into account the logica separation that may exist for the ordinates array (such as that of a multi-polygon geometry). It merely picks the last coordinate in the array.
Returns:
the last point of the geometry in an array that stores the ordinates. The size of the result array is the same as the dimension of the geometry.

getMBR

public double[] getMBR()
Gets the MBR of this geometry. When a JSDOGeoemtry is first instantiated from a db geometry STRUCT, no MBR is computed. The MBR exists only after the first call to this method. The MBR will be recalucated only when the geoemtry's structure has been modified.
Returns:
a double array containing the minX,minY, maxX,maxY value of the MBR for 2D or a double array containing the minX,minY,minZ maxX,maxY, maxZ value of the MBR for 3D

getOrdinatesOfElements

public java.lang.Object[] getOrdinatesOfElements()
Gets an array of the (top-level) elements in this geometry. Each array element in the result array is itself an array of all the ordinates for a geometry element. In other words, if this geometry has three elements, each with 10,20 and 30 ordinates, then the result Object[] array will have three elements, each being double[10], double[20] and double[30].

Note: applicable only to linear geometries without compound elements.

Returns:
an array of ordinates arrays

getElementAt

public JGeometry getElementAt(int position)
Gets an element in this geometry. The element to be returned is specified by the position parameter. The element returned is a single JGeometry.

Note: applicable to all valid elements, including compound elements.

Parameters:
position - the position of the element to be returned (1..n)
Returns:
a JGeometry if successful; otherwise null is returned.

getElements

public JGeometry[] getElements()
Gets an array of the (geometry) elements in this geometry. Each array element in the result array is a JGeometry. If this geometry has three elements, there will be three JGeometries in the result array.

Note: applicable to all valid elements, including compound elements.

Returns:
an array of JGeometries if successful; otherwise null is returned.

getOrientMultiPointOffset

public int getOrientMultiPointOffset()
Returns the offset to get the orientation parameters for a Multi-point.
Returns:

createShape

public final java.awt.Shape createShape()
Creates a Java2D shape object from this JGeometry Note: for point geometry this method returns null. You should call getJavaPoint() for point or getJavaPoints() for multi-points.
Returns:
a Java2D shape representation of this geometry; NULL if the geometry is of Point or Multi-point type.

createShape

public final java.awt.Shape createShape(java.awt.geom.AffineTransform xfm)
Creates a transformed shape from the geometry using the given affine transform. We could also do some smart resampling of the shape based on the transformed coordinates.

createShape

public final java.awt.Shape createShape(java.awt.geom.AffineTransform xfm,
                                        boolean simplify)
Creates a simplified transformed shape from the geometry using the given affine transform. Redundant shape points are removed from the shape. We could also do some smart resampling of the shape based on the transformed coordinates.

createDoubleShape

public final java.awt.Shape createDoubleShape()
Creates a Java2D double shape object from this JSDOGeometry Double shape object use double, not float, as the coordinates data type. Note: for point geometry this method returns null. You should call getJavaPoint() for point or getJavaPoints() for multi-points.
Returns:
a Java2D shape representation of this geometry; NULL if the geometry is of Point or Multi-point type.

createDoubleShape

public final java.awt.Shape createDoubleShape(java.awt.geom.AffineTransform xfm)
Creates a transformed shape from the geometry using the given affine transform. The shape use double for shape coordinates We could also do some smart resampling of the shape based on the transformed coordinates.

load

public static final JGeometry load(STRUCT st)
                            throws java.sql.SQLException
Creates a JGeometry instance from a STRUCT object representing a geometry column in a JDBC result set.
Parameters:
st - the STRUCT object from an oracle result set.
Returns:
a JGeometry instance if successful; otherwise null is returned.
Throws:
java.sql.SQLException

store

public static STRUCT store(JGeometry geom,
                           java.sql.Connection conn)
                    throws java.sql.SQLException
Converts the given geometry object into an Oracle JDBC STRUCT object. You can then bind the STRUCT object to a SQL statment that inserts or updates the geometry in the database.
Usage note: Do not bind the STRUCT object of a JGeometry of the geodetic MBR type to an SQL DML statement that inserts or updates the geometry in the database. a database, you are not allowed to use this method to convert it into a STRUCT object.
Parameters:
geom - the JGeometry instance to be converted.
conn - the connection to use.
Returns:
a Oracle STRUCT object when successful; otherwise null
Throws:
java.sql.SQLException

store

public static STRUCT store(JGeometry geom,
                           java.sql.Connection conn,
                           java.lang.Object[] descriptors)
                    throws java.sql.SQLException
Converts the given geometry object into an Oracle JDBC STRUCT object. You can then bind the STRUCT object to a SQL statment that inserts or updates the geometry in the database.
This method has an optional third parameter descriptors, which lets you supply SQL type descriptors that are most appropriate with the given connection. To obtain these descriptors, call the getOracleDescriptors() method. If NULL is passed in, this method will use the global static descriptors that are cached.
Parameters:
geom - the JGeometry instance to be converted.
conn - the connection to use.
descriptors - a set of SQL type descriptors to be used; or NULL if you wish to use the globally cached static descriptors
Returns:
a Oracle STRUCT object when successful; otherwise null
Throws:
java.sql.SQLException

getOracleDescriptors

public static java.lang.Object[] getOracleDescriptors(java.sql.Connection conn)
                                               throws java.sql.SQLException
Obtains a set of Oracle type descriptors related to the SDO_GEOMETRY type from the given connection. The descriptors are to be passed to the store method that requires them.
Parameters:
conn - an Oracle JDBC connection
Returns:
an Object array containing the SDO_GEOMETRY related SQL type desriptors from the provided connection for SDO_GEOMETRY.
Throws:
java.sql.SQLException

computeArc

public static final double[] computeArc(double x1,
                                        double y1,
                                        double x2,
                                        double y2,
                                        double x3,
                                        double y3)
Helper method to compute center, radius, and angles for this arc from the three coordinate points.
Returns:
an array if an arc can be computed; null if the three points overlap or are co-linear. The array contains the following (in radians): centerX, centerY, radius, startAngle, midAngle, endAngle;

expandCircle

public static double[] expandCircle(double x1,
                                    double y1,
                                    double x2,
                                    double y2,
                                    double x3,
                                    double y3)

linearizeArc

public static double[] linearizeArc(double x1,
                                    double y1,
                                    double x2,
                                    double y2,
                                    double x3,
                                    double y3,
                                    int numPoints)
returns a linearized array of 2D line segments for an ARC given in three points.
Returns:
an double array in the form of (x1,y1,x2,y2....xn,yn)

linearizeArc

public static double[] linearizeArc(double x1,
                                    double y1,
                                    double x2,
                                    double y2,
                                    double x3,
                                    double y3)
For a given arc, returns a linearized array of 2D line segments. This will use a default tolerance value that is 1% of the arc radius.
Returns:
an double array in the form of (x1,y1,x2,y2....xn,yn)

reFormulateArc

public static double[] reFormulateArc(double[] d)
In order to create arc shape, Recalculate centerX, centerY, radius, startAngle, midAngle and endAngle.

getSize

public long getSize()
Gets an estimated size of the geometry in bytes.
Returns:
size of this geometry in bytes.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toStringFull

public java.lang.String toStringFull()

equals

public boolean equals(java.lang.Object otherObj)
Deprecated. This function has been moved to oracle.spatial.util.GML. public static JGeometry fromNodeToGeometry(Node nd) throws DataException { return GML.fromNodeToGeometry(nd); }
Overrides:
equals in class java.lang.Object

store

public static byte[] store(JGeometry geom)
                    throws java.lang.Exception
Converts a JGeometry instance to an Oracle pickler image of the SDO_GEOMETRY type.
Parameters:
geom - a JGeometry instancce.
Returns:
an Oracle pickler image for the SDO_GEOMETRY object type if successful; otherwise, an exception will be raised.
Throws:
java.lang.Exception - if an error occurs.
Since:
11gR1.

store

public static final STRUCT store(java.sql.Connection conn,
                                 JGeometry geom)
                          throws java.lang.Exception
Converts a JGeometry instance to an Oracle JDBC STRUCT object using the SdoPickler.

This method will use the class geometry descriptor to the MDSYS.SDO_GEOMETRY PL/SQL object type if it is not null; otherwise, the class geometry descriptor will be created.

Parameters:
conn - a JDBC connection.
geom - a JGeometry instancce.
Returns:
an Oracle STRUCT object if successful; otherwise, an exception will be raised.
Throws:
java.lang.Exception - if an error occurs.
Since:
11gR1

store

public static final STRUCT store(java.sql.Connection conn,
                                 JGeometry geom,
                                 StructDescriptor desc)
                          throws java.lang.Exception
Converts a JGeometry instance to an Oracle JDBC STRUCT object using the SdoPickler.

This method has a third parameter geomDesc, which lets you supply a StructDescriptor object to the MDSYS.SDO_GEOMETRY object type. You can use a Java statement like: StructDescriptor myGeomDesc = JGeometry.getGeomDescriptor(conn); to create such a descriptor with a JDBC connection.

Parameters:
geom - the JGeometry instance to be converted.
conn - the JDBC connection to use.
geomDesc - a StructDescriptor object to the MDSYS.SDO_GEOMETRY object type to be used; or NULL if you wish to use the cached class geometry descriptor, and if the class geometry descriptor is null, then one will be created and used.
Returns:
an Oracle STRUCT object when successful; otherwise, an exception will be raised.
Throws:
java.lang.Exception - if an error occurs.
Since:
11gR1

getGeomDescriptor

public static StructDescriptor getGeomDescriptor(java.sql.Connection conn)
                                          throws java.sql.SQLException
Obtains a StructDescriptor object to the MDSYS.SDO_GEOMETRY PL/SQL object type from the given connection. The descriptor is to be passed to the store(conn, geom, geomDesc) method that requires it.
Parameters:
conn - an Oracle JDBC connection
Returns:
an structure descriptor for the Oracle SQL SDO_GEOMETRY object type for SDO_GEOMETRY.
Throws:
java.sql.SQLException

byteArrayToHexString

public static java.lang.String byteArrayToHexString(byte[] in)

projectToLTP

public final JGeometry projectToLTP(double smax,
                                    double flat)
                             throws DataException
This method generates a new JGeometry object by projecting the input to a Local Tangent Plane.

This method takes the Semi major Axis and Flattening as the parameters. The input geometry is assumed to be geodetic. Since this does not assume any DB connectivity, there are no checks done to make sure the input is in geodetic space.

Parameters:
smax - is the Semi Major Axis for the Datum used in the CS of the input.
flat - is the Flattening from CS parameters
Returns:
a JGeometry class, a null if srid=0.
Throws:
DataException - if an error occurs.
Since:
11gR1

projectFromLTP

public final JGeometry projectFromLTP()
                               throws DataException
This method generates a new JGeometry object by projecting the input from a Local Tangent Plane to geodetic long/lat.

This method requires the gtransH and lttpH attributes set in the input JGeometry class. These are set in projectToLTP() method. So this method is always called after projectToLTP() method, so those attributes must be reused in calling this method. The input geometry is assumed to be in projected. This method has no parameters.

Returns:
a JGeometry class in geodetic long/lat.
Throws:
DataException - if an error occurs.
Since:
11gR1

densifyArcs

public final JGeometry densifyArcs(double arc_tolerance)
Arcs densification method to densify arcs into lines.

Arc_Tolerance is given in the units of geometry. For Geodetic, this is in meters. The Arc_Tolerance is the maximum length of the perpendicular line between the surface of the arc and the straight line between the start and end points of the arc. When the flag is set, Arc tolerance is the largest length of the cord


densifyArcs

public JGeometry densifyArcs(double arc_tolerance,
                             boolean flag)

simplify

public JGeometry simplify(double threshold,
                          double SMA,
                          double iFlat)
                   throws java.lang.Exception,
                          java.sql.SQLException
This method generates a new JGeometry object which is the simplified version of the input geometry.

This takes the threshold as the parameter and this threshold is assumed to be in the same unit as the Unit of Projection for projected geometry. If the geometry is geodetic, this buffer width should be in meters. This method takes the Semi major Axis and Inverse Flattening as two additional parameters. These parameters should be specified for geodetic data.

Parameters:
smax - is the Semi Major Axis for the Datum used in the CS of the input.
flat - is the Flattening from CS parameters
Returns:
a JGeometry class
Throws:
java.lang.Exception - if an error occurs.
java.sql.SQLException
Since:
11gR1

simplify

public final JGeometry simplify(double threshold)
This method generates a new JGeometry object by simplifying the input geometry using the Douglas-Peucker Algorithm.

This method takes a threshold as the input. The input geometry is assumed to be have no arcs, and in projected space. Depending on the threshold value, a polygon can simplify into a line or a point. A line can simplify into a point. So the output should be checked for type as the type may by different from the input geometry type.

Parameters:
threshold - used for simplification.
Returns:
a JGeometry class,
Throws:
java.lang.Exception - if an error occurs.
Since:
11gR1

buffer

public JGeometry buffer(double bufferWidth,
                        double SMA,
                        double iFlat,
                        double arcT)
                 throws java.lang.Exception,
                        java.sql.SQLException
This method generates a new JGeometry object which is the buffered version of the input geometry.

This takes the bufferWidth as the parameter and this bufferWidth is assumed to be in the same unit as the Unit of Projection for projected geometry. If the geometry is geodetic, this buffer width should be in meters. This method takes the Semi major Axis and Inverse Flattening as two additional parameters. These parameters should be specified for geodetic data.

Parameters:
bufferWidth - is the distance value used for buffer
smax - is the Semi Major Axis for the Datum used in the CS of the input.
flat - is the Flattening from CS parameters
arcT - is the arc_tolerance for geodetic arc densification
Returns:
a JGeometry class
Throws:
java.lang.Exception - if an error occurs.
java.sql.SQLException
Since:
11gR1

buffer

public JGeometry buffer(double bufferWidth)
                 throws java.lang.Exception,
                        java.sql.SQLException,
                        DataException
This method generates a new JGeometry object which is the buffered version of the input geometry.

This takes the bufferWidth as the parameter and this bufferWidth is assumed to be in the same unit as the Unit of Projection for projected geometry. This should only be used for non-geodetic data.

Parameters:
bufferWidth - is the distance value used for buffer
Returns:
a JGeometry class
Throws:
java.lang.Exception - if an error occurs.
java.sql.SQLException
DataException
Since:
11gR1

affineTransforms

public JGeometry affineTransforms(boolean translation,
                                  double tx,
                                  double ty,
                                  double tz,
                                  boolean scaling,
                                  JGeometry Psc1,
                                  double sx,
                                  double sy,
                                  double sz,
                                  boolean rotation,
                                  JGeometry P1,
                                  JGeometry line1,
                                  double angle,
                                  int dir,
                                  boolean shearing,
                                  double SHxy,
                                  double SHyx,
                                  double SHxz,
                                  double SHzx,
                                  double SHyz,
                                  double SHzy,
                                  boolean reflection,
                                  JGeometry Pref,
                                  JGeometry lineR,
                                  int dirR,
                                  boolean planeR,
                                  double[] n,
                                  double[] bigD)
                           throws java.lang.Exception
Returns the affine transformed JGeometry in 2D and 3D Euclidean space.

3D and 2D affine transformations: translation, scaling, rotation, shear, reflection. In 3D case: