Spatial DataBlade
JAVA API v8.21

com.ibm.spatial.geom
Class GeometryFactory

java.lang.Object
  extended by com.ibm.spatial.geom.GeometryFactory
Direct Known Subclasses:
IfxSQLGeometryFactory

public class GeometryFactory
extends java.lang.Object

This class contains methods to create geometry objects.


Method Summary
 Geometry createEmptyGeometry(java.lang.String type, boolean is3D, boolean isMeasured)
          Returns an empty Geometry of type specified by the string type, with characteristics specified by is3D and isMeasured.
 Geometry createGeometry(java.lang.String type, double[] xy, double[] z, double[] m, int[] partOffsets, int[] subPartOffsets)
          Returns a Geometry of type specified by the string type, with coordinates specified by arrays xy (xy coordinate pairs), z (z coordinates - optional), m (m values - optional).
 Geometry createGeometryCollection(java.lang.String type, Geometry[] geometries)
          Returns a GeometryCollection descendent of type specified by the string type, from the specified array of geometries.
 Point createPoint(CoordPoint point)
          Returns a Point located at the coordinates specified by point.
 Point createPoint(double x, double y)
          Returns a Point located at the coordinates specified by x and y.
 Point createPoint(double x, double y, double z, double m)
          Returns a Point located at the coordinates specified by point.
 Polygon createPolygon(Envelope envelope)
          Returns a Polygon with an exterior ring specified by the envelope passed as argument.
static GeometryFactory getInstance(CoordRef cr)
          Returns a GeometryFactory object that can create geometries in the coordinate reference specified by srs.
static GeometryFactory getInstance(java.lang.String family, CoordRef cr)
           
 CoordRef getSpatialReference()
          Returns the spatial reference system of this GeometryFactory.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static GeometryFactory getInstance(java.lang.String family,
                                          CoordRef cr)

getInstance

public static GeometryFactory getInstance(CoordRef cr)
Returns a GeometryFactory object that can create geometries in the coordinate reference specified by srs.

Parameters:
cr - The coordinate reference in which the geometries will be created.
Returns:
a GeometryFactory object

getSpatialReference

public CoordRef getSpatialReference()
Returns the spatial reference system of this GeometryFactory.

Returns:
the coordinate reference of this object

createPoint

public Point createPoint(CoordPoint point)
                  throws SpatialException
Returns a Point located at the coordinates specified by point.

Parameters:
point - A CoordPoint object specifying the coordinates of the returned Point. If point holds integer values, they are assumed to be system values relative to the coordinate reference of this factory, and are converted to world values before creating the Point geometry. If the point argument falls outside the region specified by the coordinate reference associated with this factory, an error is reported to the SpatialManager.
Returns:
a Point object
Throws:
SpatialException

createPoint

public Point createPoint(double x,
                         double y)
                  throws SpatialException
Returns a Point located at the coordinates specified by x and y. If any of the coordinates fall outside the region specified by the coordinate reference associated with this factory, an error is reported to the SpatialManager.

Parameters:
x - the x ordinate
y - the y ordinate
Returns:
a Point object
Throws:
SpatialException

createPoint

public Point createPoint(double x,
                         double y,
                         double z,
                         double m)
                  throws SpatialException
Returns a Point located at the coordinates specified by point. If any of the coordinates fall outside the region specified by the coordinate reference associated with this factory, an error is reported to the SpatialManager.

Parameters:
x - the x ordinate
y - the y ordinate
z - the z ordinate (optional). If this value is Double.NaN, the geometry returned will not have a z coordinate
m - the m ordinate (optional). If this value is Double.NaN, the geometry returned will not have a measure.
Returns:
a Point object
Throws:
SpatialException

createPolygon

public Polygon createPolygon(Envelope envelope)
Returns a Polygon with an exterior ring specified by the envelope passed as argument.

If the argument has z or m coordinates, then the returning polygon will have z or m coordinates, with values interpolated between the limits specified by the envelope.

Parameters:
envelope - an Envelope specifying the exterior ring of the polygon
Returns:
a Polygon object

createEmptyGeometry

public Geometry createEmptyGeometry(java.lang.String type,
                                    boolean is3D,
                                    boolean isMeasured)
                             throws java.lang.ClassNotFoundException
Returns an empty Geometry of type specified by the string type, with characteristics specified by is3D and isMeasured.

Parameters:
type - the type of the geometry to be created
is3D - true if the geometry has Z coordinates
isMeasured - true if the geometry has M values
Returns:
a geometry object
Throws:
java.lang.ClassNotFoundException - if type is not the name of an instantiable geometry class from the package com.ibm.spatial.geom.

createGeometry

public Geometry createGeometry(java.lang.String type,
                               double[] xy,
                               double[] z,
                               double[] m,
                               int[] partOffsets,
                               int[] subPartOffsets)
                        throws java.lang.ClassNotFoundException,
                               SpatialException
Returns a Geometry of type specified by the string type, with coordinates specified by arrays xy (xy coordinate pairs), z (z coordinates - optional), m (m values - optional). If any of the coordinates fall outside the region specified by the coordinate reference associated with this factory, an error is reported to the SpatialManager.

In order to create an empty geometry, xy must be null or a zero length array. In this case, the geometry has a "z" subtype iff z is not null, and has a "m" subtype iff m is not null.

Note: when creating a Polygon, you have to make sure that the exterior ring is located first in the coordinate arrays.

Parameters:
type - the type of the geometry to be created
xy - array of xy coordinate pairs; if null or of length equal to zero, an empty geometry will be created
z - array of z coordinate pairs; if null, the geometry created will not have z coordinates
m - array of m values; if null, the geometry created will not have measure values
partOffsets - array holding positions in the xy coordinate array where geometry parts start. This argument is required for MultiLineString, Polygon, and MultiPolygon geometries.
subPartOffsets - array holding positions in the xy coordinate array where geometry subparts start. This argument is required for Polygon and MultiPolygon geometries.
Returns:
a geometry object
Throws:
java.lang.ClassNotFoundException - if type is not the name of an instantiable geometry class from the package com.ibm.spatial.geom.
SpatialException - in case of invalid coordinate/offset data

createGeometryCollection

public Geometry createGeometryCollection(java.lang.String type,
                                         Geometry[] geometries)
                                  throws java.lang.ClassNotFoundException,
                                         SpatialException
Returns a GeometryCollection descendent of type specified by the string type, from the specified array of geometries. The geometry array should contain objects with the same characteristics, that is, same coordinate reference, and same subtype (Z, M, ZM, etc.)

Descendents of GeometryCollection may impose additional restrictions on the geometry array, for example the elements must have the same type. If any of the restrictions are not satisfied, an error is reported to the SpatialManager.

Parameters:
type - the type of the geometry to be created
geometries - array of geometry objects; if null or empty, an empty geometry of the specified type will be created.
Returns:
a geometry object
Throws:
java.lang.ClassNotFoundException - if type is not the name of a geometry interface from the package com.ibm.spatial.geom.
SpatialException - in case the geometry objects specified by geometries can't be members of the geometry collection object of type specified by type

Spatial DataBlade
JAVA API v8.21


Licensed Materials - Property of IBM
Copyright IBM Corp. 2002, 2012 All Rights Reserved.