|
Oracle® Spatial Java API Reference 10g Release 2 (10.2) B14373-02 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
oracle.spatial.geometry.JGeometry
public class JGeometry
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();
Requirements for this class:
Oracle JDBC driver ver. 8.1.7 or higher; JDK 1.2 or higher (for Java2D support)
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 | |
---|---|
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. |
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. |
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); } |
int |
getDimensions() Gets the dimensionality of this geometry. |
int[] |
getElemInfo() Gets the reference to the element infomation array of this JGeometry . |
double[] |
getFirstPoint() Gets the first coordinate for this geometry. |
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[] |
getLastPoint() Gets the last coordinate of the geometry. |
double[] |
getMBR() Gets the MBR of this geometry. |
int |
getNumPoints() Gets the number of points or verticies in this geometry. |
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. |
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 |
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, double tolerance) 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 |
void |
setSRID(int srid) Sets the srid for this geometry. |
void |
setType(int gt) Sets the geometry type for this geometry. |
static STRUCT |
store(JGeometry geom, java.sql.Connection conn) Convert the given geometry object into an Oracle JDBC STRUCT object. |
java.lang.String |
toString() |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int GTYPE_POINT
public static final int GTYPE_CURVE
public static final int GTYPE_POLYGON
public static final int GTYPE_COLLECTION
public static final int GTYPE_MULTIPOINT
public static final int GTYPE_MULTICURVE
public static final int GTYPE_MULTIPOLYGON
Constructor Detail |
---|
public JGeometry(int gtype, int srid, double x, double y, double z, int[] elemInfo, double[] ordinates)
gtype
- the geometry typesrid
- 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 pointy
- y ordinate of a label pointz
- z ordinate of a label pointelemInfo
- geometry element info arrayordinates
- geometry ordinates arraypublic JGeometry(int gtype, int srid, int[] elemInfo, double[] ordinates)
gtype
- the geometry typesrid
- 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 arrayordinates
- geometry ordinates arraypublic JGeometry(double x, double y, int srid)
x
- x ordinate of a label pointy
- y ordinate of a label pointsrid
- the SRS id; if 0 is used then the MDSYS.SDO_GEOMETRY.SDO_SRID will be set to null when converted into DB format.public JGeometry(double x, double y, double z, int srid)
x
- x ordinate of a label pointy
- y ordinate of a label pointz
- z ordinate of a label pointsrid
- the SRS id; if 0 is used then the MDSYS.SDO_GEOMETRY.SDO_SRID will be set to null when converted into DB format.public JGeometry(double minX, double minY, double maxX, double maxY, int srid)
minX
- the minimum x ordinate of the rectangleminY
- the minimum y ordinate of the rectanglemaxX
- the maximum x ordinate of the rectanglemaxY
- the maximum y ordinate of the rectanglesrid
- 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 |
---|
public java.lang.Object clone()
JGeometry
. All the fields of this object is deep-copied over to the clone.clone
in class java.lang.Object
public static JGeometry createPoint(double[] coord, int dim, int srid)
public static JGeometry createLRSPoint(double[] coord, int LRSdim, int srid)
LRSdim
- LRS dimensionality: X,Y,M=2D; X,Y,Z,M=3Dpublic static JGeometry createCircle(double x, double y, double radius, int srid)
x
- the x ordinate of the circle's centery
- the y ordinate of the circle's centerradius
- the radius of the circlesrid
- the srid of the circlepublic static JGeometry createCircle(double x1, double y1, double x2, double y2, double x3, double y3, int srid)
x1
- x ordinate of point 1y1
- y ordinate of point 1x2
- x ordinate of point 2y2
- y ordinate of point 2x3
- x ordinate of point 3y3
- y ordinate of point 3srid
- srs id for the circlepublic static JGeometry createLinearLineString(double[] coords, int dim, int srid)
coords
- the coordinates of the linear line stringdim
- the dimensionality of the line string.srid
- the srid of the linear line stringpublic static JGeometry createLRSLinearLineString(double[] coords, int LRSdim, int srid)
coords
- the coordinates of the LRS linear line stringLRSdim
- the LRS dimensionality of the line string: X,Y,M=2D; X,Y,Z,M=3Dsrid
- the srid of the linear line stringpublic static JGeometry createLinearMultiLineString(java.lang.Object[] coords, int dim, int srid)
coords
- an array of all the linestrings' coordinatesdim
- the dimensionality of the linestringsrid
- the srid of the multi-linestringpublic static JGeometry createLRSLinearMultiLineString(java.lang.Object[] coords, int LRSdim, int srid)
coords
- an array of all the LRS linestrings' coordinatesLRSdim
- the LRS dimensionality of the linestring: X,Y,M=2D; X,Y,Z,M=3Dsrid
- the srid of the multi-linestringpublic static JGeometry createMultiPoint(java.lang.Object[] coords, int dim, int srid)
coords
- the array of double-typed arrays each containing one pointdim
- the dimensionality of each pointsrid
- the srid for the geometry.public static JGeometry createLinearPolygon(double[] coords, int dim, int srid)
coords
- the coordinates of the linear polygondim
- the dimensionality of the polygonsrid
- the srid of the polygonpublic static JGeometry createLinearPolygon(java.lang.Object[] coords, int dim, int srid)
coords
- an array of double-typed arrays that contains all the rings' coordinatesdim
- the dimensionality of the polygonsrid
- the srid of the polygonpublic static JGeometry createLRSLinearPolygon(double[] coords, int LRSdim, int srid)
coords
- the coordinates of the LRS linear polygonLRSdim
- the LRS dimensionality of the polygon: X,Y,M=2D; X,Y,Z,M=3Dsrid
- the srid of the polygonpublic static JGeometry createLRSLinearPolygon(java.lang.Object[] coords, int LRSdim, int srid)
coords
- an array of double-typed arrays that contains all the rings' coordinatesLRSdim
- the LRS dimensionality of the polygon: X,Y,M=2D; X,Y,Z,M=3Dsrid
- the srid of the polygonpublic static int monoMeasure(double[] coords, int dim)
coords
- an array of double that contains all coordinatesdim
- the dimensionality of the feature: X,Y,M=3D; X,Y,Z,M=4Dpublic int getType()
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;
public void setType(int gt)
gt
- the geometry typepublic int getSRID()
public void setSRID(int srid)
srid
- the sridpublic java.awt.geom.Point2D getLabelPoint()
public double[] getPoint()
public java.awt.geom.Point2D getJavaPoint()
public java.awt.geom.Point2D[] getJavaPoints()
public final boolean isPoint()
public final boolean isMultiPoint()
public final boolean isRectangle()
public final boolean isCircle()
public final boolean isGeodeticMBR()
public final boolean isLRSGeometry()
public final boolean hasCircularArcs()
public int getDimensions()
public double[] getOrdinatesArray()
JGeometry
. Unless you know what you are doing, you should not modify the values in the returned array.public int[] getElemInfo()
JGeometry
. Unless you know what you are doing, you should not modify the values in the returned array.public final int getNumPoints()
public double[] getFirstPoint()
public double[] getLastPoint()
public double[] getMBR()
public java.lang.Object[] getOrdinatesOfElements()
Note: applicable only to linear geometries without compound elements.
public final java.awt.Shape createShape()
JGeometry
Note: for point geometry this method returns null. You should call getJavaPoint() for point or getJavaPoints() for multi-points.public static final JGeometry load(STRUCT st) throws java.sql.SQLException
st
- the STRUCT object from an oracle result set.java.sql.SQLException
public static STRUCT store(JGeometry geom, java.sql.Connection conn) throws java.sql.SQLException
geom
- the JGeometry instance to be converted.conn
- the connection to use.java.sql.SQLException
public static final double[] computeArc(double x1, double y1, double x2, double y2, double x3, double y3)
public static double[] linearizeArc(double x1, double y1, double x2, double y2, double x3, double y3, int numPoints)
public static double[] linearizeArc(double x1, double y1, double x2, double y2, double x3, double y3, double tolerance)
public static double[] linearizeArc(double x1, double y1, double x2, double y2, double x3, double y3)
public long getSize()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object otherObj)
equals
in class java.lang.Object
|
Oracle® Spatial Java API Reference 10g Release 2 (10.2) B14373-02 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |