public class JGeometry
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable
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 inconsistencies.
However, this JGeometry class can be used to write thread safe applications by follwing these guidelines.
These following static methods are not thread safe, rest of the static methods and other non static methods are thread safe in this class.
public static STRUCT store(JGeometry geom, Connection conn) throws SQLException
public static STRUCT store(JGeometry geom, Connection conn, boolean BigD) throws SQLException
public static STRUCT store(JGeometry geom, Connection conn, Object[] descriptors )
public static STRUCT store(JGeometry geom, Connection conn, Object[] descriptors, boolean BigD)
protected final static void createDBDescriptors(Connection conn) throws SQLException
public final static STRUCT store(Connection conn, JGeometry geom, StructDescriptor desc) throws Exception
Use the store(conn,geom) method for storing the geometry objects to the database. This method will not change any static variables, so it is thread safe. All the other variations of the store method are not thread safe, so don't use those store methods in a thread safe application. Don't extend the JGeometry class to expose any of instance variables to external methods.
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)
Modifier and Type | Class and Description |
---|---|
static class |
JGeometry.Point
A convenient class that represents a double-typed point.
|
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
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
|
Modifier and Type | Method and Description |
---|---|
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.
|
boolean |
anyInteract(JGeometry A, double tolerance, java.lang.String isGeodetic)
This method determines if a 2D/3D Geometry has anyinteraction with another 2D/3D Geometry.
|
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) |
static JGeometry |
circle_polygon(double center_longitude, double center_latitude, double radius, double arc_tolerance)
This method return JGeometry which is the approximated Geodetic Circle.
|
static JGeometry |
circle_polygon(double center_longitude, double center_latitude, double radius, double start_azimuth, double end_azimuth, double arc_tolerance)
This method return JGeometry which is the approximated Geodetic Arc CirclePolygon - Stroked circle (arc actually) polygon with start and end azimuths and tolerance.
|
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 |
createArc2d(double[] coords, int dim, int srid)
Creates a JGeometry simple arc in 2D
|
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 |
createNURBScurve(double[] coords, int dim, int srid)
Creates a JGeometry that is a single NURBS curve.
|
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) |
JGeometry |
densifyGeodesic()
Chooses a default tolerance value and calls
densifyGeodesic(double) . |
JGeometry |
densifyGeodesic(double tolerance)
Densify a geodesic geometry by interpolating points along great circle arcs.
|
double |
distance(JGeometry A, double tolerance, java.lang.String isGeodetic)
This method determines the distance between two 2D Geometries.
|
boolean |
equals(java.lang.Object otherObj) |
static double[] |
expandCircle(double x1, double y1, double x2, double y2, double x3, double y3) |
static double |
geodetic3DLength(JGeometry geom)
This method computes Geodetic/Geographic 3D length for WGS-84 ellipsoid.
|
static double |
geodetic3DLength(JGeometry geom, double smax, double flat, double geog_crs_uom_factor)
This method computes Geodetic/Geographic 3D length for any Geodetic/Geographic 3D SRID.
|
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 JGeometry |
getNurbsApprox(JGeometry geom) |
static java.lang.Object[] |
getOracleDescriptors(java.sql.Connection conn)
Deprecated.
Use
getOracleDescriptors(java.sql.Connection) and the storeJS method instead of store |
static java.lang.Object[] |
getOracleDescriptorsStr()
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 |
isInside(JGeometry A, double tolerance, java.lang.String isGeodetic)
This method determines if a 2D/3D Geometry is inside another 2D/3D Geometry.
|
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)
Deprecated.
Use java.sql.Struct and
loadJS(java.sql.Struct) instead. |
static JGeometry |
loadJS(java.sql.Struct st)
Creates a JGeometry instance from a java.sql.Struct object representing a geometry column in a JDBC result set.
|
static JGeometry |
make_2d(JGeometry geom3D, boolean ignoreSRID, int targetSRID)
This method converts 3D Geometry into 2D Geometry.
|
static JGeometry |
make_3d(JGeometry geom2D, boolean ignoreSRID, int targetSRID, double height)
This method converts 2D Geometry into 3D Geometry.
|
static J3D_Geometry |
make_3dgeom(JGeometry geom2D, boolean ignoreSRID, int targetSRID, double height)
This method converts 2D Geometry into 3D Geometry, returning a J3D_Geometry.
|
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 |
projectFromGNM_longLat(double central_longitude, double central_latitude)
Projects a geometry vertex by vertex from Gnomonic to longitude/latitude/height with a user-defined central longitude and latitude.
|
JGeometry |
projectFromLTP()
This method generates a new JGeometry object by projecting the input from a Local Tangent Plane to geodetic long/lat.
|
JGeometry |
projectToGNM_longLat()
Projects a geometry vertex by vertex from longitude/latitude/height to Gnomonic with an internally computed central longitude and latitude.
|
JGeometry |
projectToGNM_longLat(double central_longitude, double central_latitude)
Projects a geometry vertex by vertex from longitude/latitude/height to Gnomonic with a user-defined central longitude and latitude.
|
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 JGeometry |
simplifyVW(JGeometry geom1, double vertexThreshold, boolean taller_triangles, double M, double N, double KS, double KH, double SM, double SK)
This method is a new line simplification based on the enhanced version of Visvalingham-Whyatt (1993) line simplification algorithm using weighted effecive area concept (Ref: Zhou, Jones SDH'04: Shape Aware Line Generalization with Weighted Effective Area) on projected space.
|
static JGeometry |
simplifyVW(JGeometry geom1, double vertexThreshold, boolean taller_triangles, double M, double N, double KS, double KH, double SM, double SK, double SMA, double iFlat)
This method is a new line simplification based on the enhanced version of Visvalingham-Whyatt (1993) line simplification algorithm using weighted effecive area concept (Ref: Zhou, Jones SDH'04: Shape Aware Line Generalization with Weighted Effective Area) on geodetic space.
|
static STRUCT |
store(java.sql.Connection conn, JGeometry geom)
Deprecated.
Use
storeJS(Connection, JGeometry) instead. |
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)
Deprecated.
Use
storeJS(JGeometry, Connection) instead. |
static STRUCT |
store(JGeometry geom, java.sql.Connection conn, boolean BigD)
Deprecated.
Use
storeJS(JGeometry, Connection, boolean) instead. |
static STRUCT |
store(JGeometry geom, java.sql.Connection conn, java.lang.Object[] descriptors)
Deprecated.
Use
storeJS(JGeometry, Connection, Object[]) instead. |
static STRUCT |
store(JGeometry geom, java.sql.Connection conn, java.lang.Object[] descriptors, boolean BigD)
Deprecated.
Use
storeJS(JGeometry, Connection, Object[], boolean) instead. |
static java.sql.Struct |
storeJS(java.sql.Connection conn, JGeometry geom)
Converts a JGeometry instance to an Oracle JDBC Struct object using the SdoPickler.
|
static java.sql.Struct |
storeJS(JGeometry geom, java.sql.Connection conn)
Converts the given geometry object into an Oracle JDBC Struct object.
|
static java.sql.Struct |
storeJS(JGeometry geom, java.sql.Connection conn, boolean BigD) |
static java.sql.Struct |
storeJS(JGeometry geom, java.sql.Connection conn, java.lang.Object[] descriptors)
Converts the given geometry object into an Oracle JDBC Struct object.
|
static java.sql.Struct |
storeJS(JGeometry geom, java.sql.Connection conn, java.lang.Object[] descriptors, boolean BigD) |
void |
tfm_8307_to_PopularMercator(boolean ellipsoidal) |
void |
tfm_8307_to_PopularMercator(int[] elemInfo, double[] ords, boolean ellipsoidal) |
void |
tfm_PopularMercator_to_8307(boolean ellipsoidal) |
void |
tfm_PopularMercator_to_8307(int[] elemInfo, double[] ords, boolean ellipsoidal) |
java.lang.String |
toString() |
java.lang.String |
toStringFull() |
java.lang.String |
toStringFull(int doublePrecision)
This is similar to the toStringFull method of Java String class.
|
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
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.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 createArc2d(double[] coords, int dim, int srid)
coords
-dim
-srid
-public 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 createNURBScurve(double[] coords, int dim, int srid)
coords
- the coordinates of the nurbs curvedim
- the dimensionality of the nurbs curve.srid
- the srid of the nurbscurvepublic 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 getLRMDimension()
public void setLRMDimension(int m)
m
- the LRS measure dimensionpublic int getSRID()
public void setSRID(int srid)
srid
- the sridpublic java.awt.geom.Point2D getLabelPoint()
public double[] getLabelPointXYZ()
Double.NaN
.public double[] getPoint()
public java.awt.geom.Point2D getJavaPoint()
public java.awt.geom.Point2D[] getJavaPoints()
public final boolean isPoint()
public final boolean isOrientedPoint()
public final boolean isMultiPoint()
public final boolean isOrientedMultiPoint()
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 JGeometry getElementAt(int position)
Note: applicable to all valid elements, including compound elements.
position
- the position of the element to be returned (1..n)public JGeometry[] getElements()
Note: applicable to all valid elements, including compound elements.
public int getOrientMultiPointOffset()
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 final java.awt.Shape createShape(java.awt.geom.AffineTransform xfm)
public final java.awt.Shape createShape(java.awt.geom.AffineTransform xfm, boolean simplify)
public final java.awt.Shape createDoubleShape()
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.public final java.awt.Shape createDoubleShape(java.awt.geom.AffineTransform xfm)
@Deprecated public static final JGeometry load(STRUCT st) throws java.sql.SQLException
loadJS(java.sql.Struct)
instead.st
- the STRUCT object from an oracle result set.java.sql.SQLException
public static final JGeometry loadJS(java.sql.Struct st) throws java.sql.SQLException
st
- the Struct object from an oracle result set.java.sql.SQLException
@Deprecated public static STRUCT store(JGeometry geom, java.sql.Connection conn) throws java.sql.SQLException
storeJS(JGeometry, Connection)
instead.geom
- the JGeometry instance to be converted.conn
- the connection to use.java.sql.SQLException
@Deprecated public static STRUCT store(JGeometry geom, java.sql.Connection conn, boolean BigD) throws java.sql.SQLException
storeJS(JGeometry, Connection, boolean)
instead.geom
-conn
-BigD
-java.sql.SQLException
public static java.sql.Struct storeJS(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 java.sql.Struct storeJS(JGeometry geom, java.sql.Connection conn, boolean BigD) throws java.sql.SQLException
java.sql.SQLException
@Deprecated public static STRUCT store(JGeometry geom, java.sql.Connection conn, java.lang.Object[] descriptors) throws java.sql.SQLException
storeJS(JGeometry, Connection, Object[])
instead.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.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 descriptorsjava.sql.SQLException
@Deprecated public static STRUCT store(JGeometry geom, java.sql.Connection conn, java.lang.Object[] descriptors, boolean BigD) throws java.sql.SQLException
storeJS(JGeometry, Connection, Object[], boolean)
instead.geom
-conn
-descriptors
-BigD
-java.sql.SQLException
public static java.sql.Struct storeJS(JGeometry geom, java.sql.Connection conn, java.lang.Object[] descriptors) throws java.sql.SQLException
descriptors
, which lets you supply SQL type descriptors that are most appropriate with the given connection. To obtain these descriptors, call the getOracleDescriptorsStr()
method. If NULL is passed in, this method will use the global static descriptors that are cached.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 descriptorsjava.sql.SQLException
public static java.sql.Struct storeJS(JGeometry geom, java.sql.Connection conn, java.lang.Object[] descriptors, boolean BigD) throws java.sql.SQLException
java.sql.SQLException
@Deprecated public static java.lang.Object[] getOracleDescriptors(java.sql.Connection conn) throws java.sql.SQLException
getOracleDescriptors(java.sql.Connection)
and the storeJS method instead of storestore
method that requires them.conn
- an Oracle JDBC connectionjava.sql.SQLException
public static java.lang.Object[] getOracleDescriptorsStr() throws java.sql.SQLException
storeJS
method that requires them.java.sql.SQLException
public static final double[] computeArc(double x1, double y1, double x2, double y2, double x3, double y3)
public static double[] expandCircle(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)
public static double[] reFormulateArc(double[] d)
public long getSize()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toStringFull()
public java.lang.String toStringFull(int doublePrecision)
doublePrecision
- Number of digits needed after decimalpublic boolean equals(java.lang.Object otherObj)
equals
in class java.lang.Object
public static byte[] store(JGeometry geom) throws java.lang.Exception
geom
- a JGeometry instancce.java.lang.Exception
- if an error occurs.@Deprecated public static final STRUCT store(java.sql.Connection conn, JGeometry geom) throws java.lang.Exception
storeJS(Connection, JGeometry)
instead.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.
conn
- a JDBC connection.geom
- a JGeometry instancce.java.lang.Exception
- if an error occurs.public static final java.sql.Struct storeJS(java.sql.Connection conn, JGeometry geom) throws java.lang.Exception
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.
conn
- a JDBC connection.geom
- a JGeometry instancce.java.lang.Exception
- if an error occurs.public static final STRUCT store(java.sql.Connection conn, JGeometry geom, StructDescriptor desc) throws java.lang.Exception
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. However, this method is not thread safe due to this geomDesc parameter.
geom
- the JGeometry instance to be converted.conn
- the JDBC connection to use.desc
- 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.java.lang.Exception
- if an error occurs.public static StructDescriptor getGeomDescriptor(java.sql.Connection conn) throws java.sql.SQLException
store(conn, geom, geomDesc)
method that requires it.conn
- an Oracle JDBC connectionjava.sql.SQLException
public static java.lang.String byteArrayToHexString(byte[] in)
public final JGeometry projectToLTP(double smax, double flat) throws DataException
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.
smax
- is the Semi Major Axis for the Datum used in the CS of the input.flat
- is the Flattening from CS parametersDataException
- if an error occurs.public final JGeometry projectFromLTP() throws DataException
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.
DataException
- if an error occurs.public final JGeometry projectToGNM_longLat() throws DataException
Gnomonic Projection for small test cases that cover less than half of the hemisphere.
The input vertices are in longitude,latitude,height format. We directly convert to Gnomonic projected geometry.
This is Java version of forward transformation algorithm in Map Projections- A Working Manual, 1987.
The central_longitude and central_latitude are computed properly in radians by choosing the centroid of the MBR of the input geometry. On the other hand, if you choose to enter central_longitude and central_latitude, use the other signature.
DataException
public final JGeometry projectToGNM_longLat(double central_longitude, double central_latitude) throws DataException
Gnomonic Projection for small test cases that cover less than half of the hemisphere.
The input vertices are in longitude,latitude,height format. We directly convert to Gnomonic projected geometry.
This is Java version of forward transformation algorithm in Map Projections- A Working Manual, 1987.
We assume central_longitude and central_latitude for central longitude and latitude respectively are computed properly in radians (e.g., by choosing centroid of the centroid-MBR of geometries)
Note for the inverse transform: As long as you keep the central coordinates (wrt which you did the forward transform) in the inverse transform, you will arrive back at original the long/lat coordinates.
central_longitude
- Center of projection Longitude in radians which is centroid of centroid-MBR of two geometries in querycentral_latitude
- Center of projection Latitude in radians which is centroid of centroid-MBR of two geometries in queryDataException
public final JGeometry projectFromGNM_longLat(double central_longitude, double central_latitude) throws DataException
This is Java version of the inverse transformation algorithm in Map Projections- A Working Manual, 1987.
Input geometry (i.e., this) is in Gnomonic domain (multiplied by Radius of earth already).
As long as you keep the central coordinates (wrt which you did the forward transform) in the inverse transform, you will arrive back at original the long/lat coordinates.
central_longitude
- Any center of projection Longitude in radians (which could be centroid of centroid-MBR of original two geometries in query)central_latitude
- Any center of projection Latitude in radians (which could be centroid of centroid-MBR of original two geometries in query)DataException
public final JGeometry densifyArcs(double arc_tolerance)
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
public JGeometry densifyArcs(double arc_tolerance, boolean flag)
public JGeometry simplify(double threshold, double SMA, double iFlat) throws java.lang.Exception, java.sql.SQLException
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.
SMA
- is the Semi Major Axis for the Datum used in the CS of the input.iFlat
- is the Flattening from CS parametersjava.lang.Exception
- if an error occurs.java.sql.SQLException
public final JGeometry simplify(double threshold)
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.
threshold
- used for simplification.java.lang.Exception
- if an error occurs.public JGeometry buffer(double bufferWidth, double SMA, double iFlat, double arcT) throws java.lang.Exception, java.sql.SQLException
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.
bufferWidth
- is the distance value used for bufferSMA
- is the Semi Major Axis for the Datum used in the CS of the input.iFlat
- is the Flattening from CS parametersarcT
- is the arc_tolerance for geodetic arc densificationjava.lang.Exception
- if an error occurs.java.sql.SQLException
public JGeometry buffer(double bufferWidth) throws java.lang.Exception, java.sql.SQLException, DataException
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.
bufferWidth
- is the distance value used for bufferjava.lang.Exception
- if an error occurs.java.sql.SQLException
DataException
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
3D and 2D affine transformations: translation, scaling, rotation, shear, reflection. The input geometries Psc1, P1, line1, Pref and lineR are regular geometries where regular geometry is defined as a non-LRS and non-orientedPoint geometry. In 3D case:
In 2D case:
Please note that: bigD=delta and N=(A,B,C) where N is the normal of the plane in 3-D space. Thus: Plane equation: Ax+By+Cz+bigD= 3DDotProd(N,anypointonplane)+bigD=0;
translation
- Boolean flag to denote that translation is performedtx
- translation parameter for x-axisty
- translation parameter for y-axistz
- translation parameter for z-axisscaling
- Boolean flag to denote that scaling is performedPsc1
- Arbitrary JGeometry point on geometry to do scalingsx
- scaling parameter for x-axissy
- scaling parameter for y-axissz
- scaling parameter for z-axisrotation
- Boolean flag to denote that rotation is performedP1
- rotation parameter for 2-D/3-D rotation about an arbitrary JGeometry pointline1
- rotation parameter as JGeometry line geometry for rotation about an arbitrary axisangle
- rotation parameter for rotation about an arbitrary axis or x,y, or z-axis rolldir
- integer rotation parameter for x(0),y(1) or z(2)-axis roll, and it is -1 if rotation is true but this parameter is not usedshearing
- Boolean flag to denote that shearing is performed.SHxy
- parameter for shearing due to x along y direction (also in 2-D)SHyx
- parameter for shearing due to y along x direction (also in 2-D)SHxz
- parameter for shearing due to x along z direction (not used in 2-D)SHzx
- parameter for shearing due to z along x direction (not used in 2-D)SHyz
- parameter for shearing due to y along z direction (not used in 2-D)SHzy
- parameter for shearing due to z along y direction (not used in 2-D)reflection
- Boolean flag to denote that reflection is performedPref
- JGeometry point geometry to do reflection through arbitrary pointlineR
- JGeometry line geometry to do reflection along an arbitrary axisdirR
- integer parameter to do reflection about (through) xy(2),xz(1),yz(0) planes, and it is -1 if reflection parameter is true but this parameter is not usedplaneR
- Boolean flag denoting that reflection about an arbitrary plane is performedn
- 3-element double array for the normal vector of the planebigD
- single element double array for the constant number in plane equation (explained above)java.lang.Exception
public JGeometry densifyGeodesic() throws java.lang.Exception
densifyGeodesic(double)
.java.lang.Exception
- if the geometry is not a 2D or 3D geodetic geometrypublic JGeometry densifyGeodesic(double tolerance) throws java.lang.Exception
Interpolation assumes a spherical earth; ellipsoid information is not used.
Geometry must be geodetic, latitude/longitude, 2D and contain only linestring and optimized rectangle types. Coordinates must be in the range -180..+180, -90..+90.
Linestring lengths must be less than 180 degrees. Optimized rectangles are not modified.
tolerance
- the maximum deviation from the true geodesic line in the returned geometry.java.lang.Exception
- if the geometry is not a valid geodetic geometrypublic void tfm_8307_to_PopularMercator(int[] elemInfo, double[] ords, boolean ellipsoidal)
public void tfm_8307_to_PopularMercator(boolean ellipsoidal)
public void tfm_PopularMercator_to_8307(int[] elemInfo, double[] ords, boolean ellipsoidal)
public void tfm_PopularMercator_to_8307(boolean ellipsoidal)
public static JGeometry simplifyVW(JGeometry geom1, double vertexThreshold, boolean taller_triangles, double M, double N, double KS, double KH, double SM, double SK, double SMA, double iFlat) throws java.lang.Exception, java.sql.SQLException
This method takes the Semi major Axis and Inverse Flattening as two additional parameters. These parameters should be specified for geodetic data.
geom1
- Input geometry which is a line string or polygon with n vertices where v_0 and v_(n-1) are the end-points of this line string or polygon. Line is assumed to be open.vertexThreshold
- Percentage of vertices to be eliminated i.e., Threshold of weighted effective area to select a subset of original vertices of input line or polygon geometry to get the less detailed representation of the input line or polygon.taller_triangles
- If taller triangles preferred to flatter triangles, set to TRUE, else FALSE. This is needed for flatness filter.M
- Flatness filter parameterN
- Flatness filter parameterKS
- Flatness filter parameterKH
- Flatness filter parameterSM
- Skewness filter parameterSK
- Skewness filter parameterSMA
- is the Semi Major Axis for the Datum used in the CS of the input.iFlat
- is the Flattening from CS parametersjava.lang.Exception
- if an error occurs.java.sql.SQLException
public static JGeometry simplifyVW(JGeometry geom1, double vertexThreshold, boolean taller_triangles, double M, double N, double KS, double KH, double SM, double SK) throws java.lang.Exception
geom1
- Input geometry which is a line string or polygon with n vertices where v_0 and v_(n-1) are the end-points of this line string or polygon. Line is assumed to be open.vertexThreshold
- Percentage of vertices to be eliminated i.e., Threshold of weighted effective area to select a subset of original vertices of input line or polygon geometry to get the less detailed representation of the input line or polygon.taller_triangles
- If taller triangles preferred to flatter triangles, set to TRUE, else FALSE. This is needed for flatness filter.M
- Flatness filter parameterN
- Flatness filter parameterKS
- Flatness filter parameterKH
- Flatness filter parameterSM
- Skewness filter parameterSK
- Skewness filter parameterjava.lang.Exception
- if an error occurs.public static double geodetic3DLength(JGeometry geom)
On SQL side for sdo_length, COUNT_SHARED_EDGES parameter should be NULL (default value) for Geodetic/Geographic 3D length.
geom
- Input geometry whose length is soughtpublic static double geodetic3DLength(JGeometry geom, double smax, double flat, double geog_crs_uom_factor)
On SQL side for sdo_length, COUNT_SHARED_EDGES parameter should be NULL (default value) for Geodetic/Geographic 3D length.
geom
- Input geometry whose length is soughtsmax
- Changes with SRIDflat
- Changes with SRIDgeog_crs_uom_factor
- Height factor due to SRIDpublic static JGeometry circle_polygon(double center_longitude, double center_latitude, double radius, double arc_tolerance)
center_longitude
- center point x (2D) coordinatecenter_latitude
- center point y (2D) coordinateradius
-arc_tolerance
-public static JGeometry circle_polygon(double center_longitude, double center_latitude, double radius, double start_azimuth, double end_azimuth, double arc_tolerance)
center_longitude
- center point x (2D) coordinatecenter_latitude
- center point y (2D) coordinateradius
-start_azimuth
- startAngleend_azimuth
- endAnglearc_tolerance
-public static JGeometry make_3d(JGeometry geom2D, boolean ignoreSRID, int targetSRID, double height)
public static J3D_Geometry make_3dgeom(JGeometry geom2D, boolean ignoreSRID, int targetSRID, double height)
public static JGeometry make_2d(JGeometry geom3D, boolean ignoreSRID, int targetSRID)
public boolean anyInteract(JGeometry A, double tolerance, java.lang.String isGeodetic) throws java.lang.Exception
A
- 2D/3D Geometrytolerance
- at which the given geometry is validisGeodetic
- is a string that is either "TRUE" or "FALSE"java.lang.Exception
public boolean isInside(JGeometry A, double tolerance, java.lang.String isGeodetic) throws java.lang.Exception
A
- Geometry that is any polygon or any solid (it cannot be any point/curve geometry)tolerance
- at which the given geometry is validisGeodetic
- is a string that is either "TRUE" or "FALSE"java.lang.Exception
public double distance(JGeometry A, double tolerance, java.lang.String isGeodetic) throws java.lang.Exception
A
- 2D Geometry that is a polygon or multi-polygontolerance
- at which the given geometry is validisGeodetic
- is a string that is either "TRUE" or "FALSE"java.lang.Exception