org.wkb4j.jts
Class JTSFactory

java.lang.Object
  |
  +--org.wkb4j.factories.AbstractWKBFactory
        |
        +--org.wkb4j.jts.JTSFactory
All Implemented Interfaces:
WKBFactory, WKBFactory3D, WKBGeometryTypes

public class JTSFactory
extends AbstractWKBFactory
implements WKBFactory3D

This class has the capability to transform data in the WKB format into JTS objects. Since JTS conforms to the Simple Features Specification for SQL published by the Open GIS Consortium, the mapping is straighforward: each feature described in the WKB is mapped to a corresponding feature in JTS.
You can download the JTS library from http://www.vividsolutions.com/JTS/jts_frame.htm. Implementation notes:


Creation date: 6 juil. 2002 23:10:29

Version:
$Revision: 1.5 $ $Date: 2003/08/02 23:52:18 $
Author:
David Garnier, Chris Holmes

Field Summary
private  com.vividsolutions.jts.geom.Coordinate[] coordinatesBuffer
          Stores a array of Coordinates objects.
private  com.vividsolutions.jts.geom.Geometry currentGeometry
          The Geometry being constructed now.
private  java.util.ArrayList geometries
          Keeps a list of all the object created by this Factory.
private  com.vividsolutions.jts.geom.Geometry[] geometryBuffer
          Stores a array of Geometry objects.
private  int geometryPointer
          Points to the next free slot in the geometryBuffer.
private  com.vividsolutions.jts.geom.LinearRing[] linearRingBuffer
          Stores a array of LinearRing objects.
private  int linearRingPointer
          Points to the next free slot in the linearRingBuffer.
private  com.vividsolutions.jts.geom.LineString[] lineStringBuffer
          Stores a array of LineString objects.
private  int lineStringPointer
          Points to the next free slot in the lineStringBuffer.
protected static org.apache.log4j.Logger log
           
private  int newSrid
          Transient SRID used for the next Geometries.
private  com.vividsolutions.jts.geom.Point[] pointBuffer
          Stores a array of Point objects.
private  int pointPointer
          Points to the next free slot in the pointBuffer.
private  com.vividsolutions.jts.geom.Polygon[] polygonBuffer
          Stores a array of Polygon objects.
private  int polygonPointer
          Points to the next free slot in the polygonBuffer.
private  com.vividsolutions.jts.geom.PrecisionModel precisionModel
          The PrecisionModel used to built every Geometry.
private  int srid
          The SRID of the top-level Geometry being created.
 
Fields inherited from class org.wkb4j.factories.AbstractWKBFactory
depthPointer, geometryDepth, inUnit, inWork, typeStack, values, words
 
Fields inherited from interface org.wkb4j.engine.WKBGeometryTypes
linearRing, wkbGeometryCollection, wkbLineString, wkbMultiLineString, wkbMultiPoint, wkbMultiPolygon, wkbPoint, wkbPolygon
 
Constructor Summary
JTSFactory()
          Construct a JTSFactory.
JTSFactory(com.vividsolutions.jts.geom.PrecisionModel pm)
          Construct a JTSFactory.
 
Method Summary
 void abortGeometryCollection()
          Signals a malformed GeometryCollection.
 void abortLineString()
          Signals a malformed LineString.
 void abortPoint()
          Signals a malformed Point.
 boolean addPoints(double[] points)
          Transforms an array of points in an array of Coordinates.
 boolean addPoints3D(double[] points)
          Transforms an array of points in an array of Coordinates in 3D.
 boolean beginGeometryCollection(int count)
          Signals the beginning of a new GeometryCollection.
 boolean beginLinearRing(int count)
          Constructs a new array of Coordinates with the supplied number of elements.
 boolean beginMultiLineString(int count)
          Constructs a new array of LineStrings with the supplied number of elements.
 boolean beginMultiPoint(int count)
          Constructs a new array of Points with the supplied number of elements.
 boolean beginMultiPolygon(int count)
          Constructs a new array of Polygons with the supplied number of elements.
 boolean beginPolygon(int count)
          Constructs a new array of LinearRings with the supplied number of elements.
 void beginUnit(int srid)
          Signals the beginning of the transcription process for a Geometry.
 void beginUnit(java.lang.String[] words, int[] values)
          Signals the beginning of the transcription process for a Geometry.
 boolean endGeometryCollection()
          Signals the end of a GeometryCollection.
 boolean endLinearRing()
          Constructs a LinearRing using the current buffer of Coordinates, resets the Coordinates buffer, add the LinearRing to the linearRingBuffer and defines the new LineString as the currentGeometry.
 boolean endLineString()
          Constructs a LineString using the current buffer of Coordinates, resets the Coordinates buffer, add the LineString to the lineStringBuffer and defines the new LineString as the currentGeometry.
 boolean endMultiLineString()
          Constructs a MultiLineString using the current buffer of LineStrings, resets the LineStrings buffer and defines the new MultiLineString as the currentGeometry.
 boolean endMultiPoint()
          Constructs a MultiPoint using the current buffer of Points, resets the Points buffer and defines the new MultiPoint as the currentGeometry.
 boolean endMultiPolygon()
          Constructs a MultiPolygon using the current buffer of LinearRings, resets the LinearRings buffer and defines the new LineString as the currentGeometry.
 boolean endPoint()
          Constructs a Point using the current buffer of Coordinates, resets the Coordinates buffer, add the Point to the PointBuffer and defines the new Point as the currentGeometry.
 boolean endPolygon()
          Constructs a Polygon using the current buffer of LinearRings, resets the LinearRings buffer, add the Polygon to the polygonBuffer and defines the new Polygon as the currentGeometry.
 void endUnit()
          Signals the end of the transcription process for a Geometry.
 java.util.ArrayList getGeometries()
          Returns the geometries.
 com.vividsolutions.jts.geom.PrecisionModel getPrecisionModel()
          Returns the precisionModel.
 int getSrid()
          Returns the SRID used to construct the current Geometry.
 boolean newGeometryCollectionComponent()
          Signals that a new component for the geometry factory is about to processed OR that all components has been used.
 void reset()
           
 void setPrecisionModel(com.vividsolutions.jts.geom.PrecisionModel precisionModel)
          Sets the precisionModel.
private  void setSrid(int srid)
          Sets the SRID used to construct Geometries.
 
Methods inherited from class org.wkb4j.factories.AbstractWKBFactory
abortLinearRing, abortMultiLineString, abortMultiPoint, abortMultiPolygon, abortPolygon, abortUnit, abortWork, beginLineString, beginPoint, beginWork, endWork, getValues, getWords, init, setValues, setWords
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.log4j.Logger log

precisionModel

private com.vividsolutions.jts.geom.PrecisionModel precisionModel
The PrecisionModel used to built every Geometry.


coordinatesBuffer

private com.vividsolutions.jts.geom.Coordinate[] coordinatesBuffer
Stores a array of Coordinates objects.


lineStringBuffer

private com.vividsolutions.jts.geom.LineString[] lineStringBuffer
Stores a array of LineString objects.


polygonBuffer

private com.vividsolutions.jts.geom.Polygon[] polygonBuffer
Stores a array of Polygon objects.


linearRingBuffer

private com.vividsolutions.jts.geom.LinearRing[] linearRingBuffer
Stores a array of LinearRing objects.


pointBuffer

private com.vividsolutions.jts.geom.Point[] pointBuffer
Stores a array of Point objects.


geometryBuffer

private com.vividsolutions.jts.geom.Geometry[] geometryBuffer
Stores a array of Geometry objects.


lineStringPointer

private volatile int lineStringPointer
Points to the next free slot in the lineStringBuffer.


polygonPointer

private volatile int polygonPointer
Points to the next free slot in the polygonBuffer.


linearRingPointer

private volatile int linearRingPointer
Points to the next free slot in the linearRingBuffer.


pointPointer

private volatile int pointPointer
Points to the next free slot in the pointBuffer.


geometryPointer

private volatile int geometryPointer
Points to the next free slot in the geometryBuffer.


srid

private int srid
The SRID of the top-level Geometry being created.


geometries

private final java.util.ArrayList geometries
Keeps a list of all the object created by this Factory.


currentGeometry

private com.vividsolutions.jts.geom.Geometry currentGeometry
The Geometry being constructed now.


newSrid

private int newSrid
Transient SRID used for the next Geometries.

Constructor Detail

JTSFactory

public JTSFactory()
Construct a JTSFactory.


JTSFactory

public JTSFactory(com.vividsolutions.jts.geom.PrecisionModel pm)
Construct a JTSFactory. The supplied PrecisionModel will be used to create the JTS objects.

Parameters:
pm - PrecisionModel used by this Factory.
Method Detail

beginUnit

public final void beginUnit(java.lang.String[] words,
                            int[] values)
Description copied from interface: WKBFactory
Signals the beginning of the transcription process for a Geometry. The submitted values will be available to all the Geometries contained in this Geometry

Specified by:
beginUnit in interface WKBFactory
Overrides:
beginUnit in class AbstractWKBFactory
See Also:
org.wkb4j.engine.WKBFactory#beginUnit()

beginUnit

public final void beginUnit(int srid)
Description copied from interface: WKBFactory
Signals the beginning of the transcription process for a Geometry. The submitted SRID will be assigned to all the Geometries contained in this Geometry

Specified by:
beginUnit in interface WKBFactory
Overrides:
beginUnit in class AbstractWKBFactory
See Also:
org.wkb4j.engine.WKBFactory#beginUnit()

endUnit

public final void endUnit()
Description copied from interface: WKBFactory
Signals the end of the transcription process for a Geometry.

Specified by:
endUnit in interface WKBFactory
Overrides:
endUnit in class AbstractWKBFactory
See Also:
WKBFactory.endUnit()

beginGeometryCollection

public final boolean beginGeometryCollection(int count)
Description copied from interface: WKBFactory
Signals the beginning of a new GeometryCollection.

Specified by:
beginGeometryCollection in interface WKBFactory
Overrides:
beginGeometryCollection in class AbstractWKBFactory
See Also:
org.wkb4j.engine.WKBFactory#beginGeometryCollection()

endGeometryCollection

public final boolean endGeometryCollection()
Description copied from interface: WKBFactory
Signals the end of a GeometryCollection.

Specified by:
endGeometryCollection in interface WKBFactory
Overrides:
endGeometryCollection in class AbstractWKBFactory
See Also:
WKBFactory.endGeometryCollection()

newGeometryCollectionComponent

public final boolean newGeometryCollectionComponent()
Description copied from interface: WKBFactory
Signals that a new component for the geometry factory is about to processed OR that all components has been used. and therefore that the current WKBFactory should take adequate steps.

Specified by:
newGeometryCollectionComponent in interface WKBFactory
Overrides:
newGeometryCollectionComponent in class AbstractWKBFactory
See Also:
WKBFactory.abortGeometryCollection()

abortGeometryCollection

public final void abortGeometryCollection()
Description copied from interface: WKBFactory
Signals a malformed GeometryCollection. This can happen at any time, and Factories should just skip the malformed Geometry and maybe escalate the error.

Specified by:
abortGeometryCollection in interface WKBFactory
Overrides:
abortGeometryCollection in class AbstractWKBFactory
See Also:
WKBFactory.abortGeometryCollection()

endPoint

public final boolean endPoint()
Constructs a Point using the current buffer of Coordinates, resets the Coordinates buffer, add the Point to the PointBuffer and defines the new Point as the currentGeometry.

Specified by:
endPoint in interface WKBFactory
Overrides:
endPoint in class AbstractWKBFactory
See Also:
WKBFactory.endPoint()

abortPoint

public final void abortPoint()
Description copied from interface: WKBFactory
Signals a malformed Point. This can happen at any time, and Factories should just skip the malformed and maybe escalate the error.

Specified by:
abortPoint in interface WKBFactory
Overrides:
abortPoint in class AbstractWKBFactory
See Also:
WKBFactory.abortPoint()

beginMultiPoint

public final boolean beginMultiPoint(int count)
Constructs a new array of Points with the supplied number of elements.

Specified by:
beginMultiPoint in interface WKBFactory
Overrides:
beginMultiPoint in class AbstractWKBFactory
See Also:
org.wkb4j.engine.WKBFactory#beginMultiPoint()

endMultiPoint

public final boolean endMultiPoint()
Constructs a MultiPoint using the current buffer of Points, resets the Points buffer and defines the new MultiPoint as the currentGeometry.

Specified by:
endMultiPoint in interface WKBFactory
Overrides:
endMultiPoint in class AbstractWKBFactory
See Also:
WKBFactory.endMultiPoint()

endLineString

public final boolean endLineString()
Constructs a LineString using the current buffer of Coordinates, resets the Coordinates buffer, add the LineString to the lineStringBuffer and defines the new LineString as the currentGeometry.

Specified by:
endLineString in interface WKBFactory
Overrides:
endLineString in class AbstractWKBFactory
See Also:
WKBFactory.endLineString()

abortLineString

public final void abortLineString()
Description copied from interface: WKBFactory
Signals a malformed LineString. This can happen at any time, and Factories should just skip the malformed and maybe escalate the error.

Specified by:
abortLineString in interface WKBFactory
Overrides:
abortLineString in class AbstractWKBFactory
See Also:
WKBFactory.abortLineString()

beginMultiLineString

public final boolean beginMultiLineString(int count)
Constructs a new array of LineStrings with the supplied number of elements.

Specified by:
beginMultiLineString in interface WKBFactory
Overrides:
beginMultiLineString in class AbstractWKBFactory
See Also:
org.wkb4j.engine.WKBFactory#beginMultiLineString()

endMultiLineString

public final boolean endMultiLineString()
Constructs a MultiLineString using the current buffer of LineStrings, resets the LineStrings buffer and defines the new MultiLineString as the currentGeometry.

Specified by:
endMultiLineString in interface WKBFactory
Overrides:
endMultiLineString in class AbstractWKBFactory
See Also:
WKBFactory.endMultiLineString()

beginMultiPolygon

public final boolean beginMultiPolygon(int count)
Constructs a new array of Polygons with the supplied number of elements.

Specified by:
beginMultiPolygon in interface WKBFactory
Overrides:
beginMultiPolygon in class AbstractWKBFactory
See Also:
org.wkb4j.engine.WKBFactory#beginMultiPolygon()

endMultiPolygon

public final boolean endMultiPolygon()
Constructs a MultiPolygon using the current buffer of LinearRings, resets the LinearRings buffer and defines the new LineString as the currentGeometry.

Specified by:
endMultiPolygon in interface WKBFactory
Overrides:
endMultiPolygon in class AbstractWKBFactory
See Also:
WKBFactory.endMultiPolygon()

beginPolygon

public final boolean beginPolygon(int count)
Constructs a new array of LinearRings with the supplied number of elements.

Specified by:
beginPolygon in interface WKBFactory
Overrides:
beginPolygon in class AbstractWKBFactory
See Also:
org.wkb4j.engine.WKBFactory#beginPolygon()

endPolygon

public final boolean endPolygon()
Constructs a Polygon using the current buffer of LinearRings, resets the LinearRings buffer, add the Polygon to the polygonBuffer and defines the new Polygon as the currentGeometry. If the LinearRings buffer contains only one LinearRing, the Polygon is constructed with only one ring. If the LinearRings buffer contains more than one LinearRing, the Polygon is constructed with the first LinearRing as the exterior ring and the others LinearRings as the interior rings.

Specified by:
endPolygon in interface WKBFactory
Overrides:
endPolygon in class AbstractWKBFactory
See Also:
WKBFactory.endPolygon()

beginLinearRing

public final boolean beginLinearRing(int count)
Constructs a new array of Coordinates with the supplied number of elements.

Specified by:
beginLinearRing in interface WKBFactory
Overrides:
beginLinearRing in class AbstractWKBFactory
See Also:
org.wkb4j.engine.WKBFactory#beginLinearRing()

endLinearRing

public final boolean endLinearRing()
Constructs a LinearRing using the current buffer of Coordinates, resets the Coordinates buffer, add the LinearRing to the linearRingBuffer and defines the new LineString as the currentGeometry.

Specified by:
endLinearRing in interface WKBFactory
Overrides:
endLinearRing in class AbstractWKBFactory
See Also:
WKBFactory.endLinearRing()

addPoints

public final boolean addPoints(double[] points)
Transforms an array of points in an array of Coordinates.

Specified by:
addPoints in interface WKBFactory
Overrides:
addPoints in class AbstractWKBFactory
See Also:
WKBFactory.addPoints(double[])

addPoints3D

public final boolean addPoints3D(double[] points)
Transforms an array of points in an array of Coordinates in 3D.

Specified by:
addPoints3D in interface WKBFactory3D
Overrides:
addPoints3D in class AbstractWKBFactory
See Also:
WKBFactory.addPoints(double[])

getPrecisionModel

public final com.vividsolutions.jts.geom.PrecisionModel getPrecisionModel()
Returns the precisionModel.

Returns:
PrecisionModel

setPrecisionModel

public final void setPrecisionModel(com.vividsolutions.jts.geom.PrecisionModel precisionModel)
Sets the precisionModel.

Parameters:
precisionModel - The precisionModel to set

getGeometries

public final java.util.ArrayList getGeometries()
Returns the geometries.

Returns:
ArrayList

getSrid

public final int getSrid()
Returns the SRID used to construct the current Geometry.

Returns:
int SRID

setSrid

private void setSrid(int srid)
Sets the SRID used to construct Geometries. The submitted SRID will only be used for the Geometries after the current one.

Parameters:
srid - The SRID to set

reset

public void reset()
Specified by:
reset in class AbstractWKBFactory
See Also:
AbstractWKBFactory.reset()


Copyright © 2002-2003 David Garnier. All Rights Reserved.