org.wkb4j.postgis
Class PostGISFactory

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

public class PostGISFactory
extends AbstractWKBFactory
implements WKBFactory3D

This class has the capability to transform data in the WKB format into PostGIS objects. Since they 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 PostGIS. Implementation notes:

Version:
$Revision: 1.3 $ $Date: 2003/07/28 22:21:26 $
Author:
David Garnier
Creation date: 6 juil. 2002 23:10:29

Field Summary
private  org.postgis.Point[] coordinatesBuffer
          Stores a array of Point objects.
private  org.postgis.Geometry currentGeometry
          The Geometry being constructed now.
private  java.util.ArrayList geometries
          Keeps a list of all the object created by this Factory.
private  org.postgis.Geometry[] geometryBuffer
           
private  int geometryPointer
          Points to the next free slot in the pointsBuffer.
private  org.postgis.LinearRing[] linearRingBuffer
          Stores a array of LinearRing objects.
private  int linearRingPointer
          Points to the next free slot in the linearRingBuffer.
private  org.postgis.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  org.postgis.Point[] pointsBuffer
          Stores a array of Point objects, for MultiPoint.
private  int pointsPointer
          Points to the next free slot in the pointsBuffer.
private  org.postgis.Polygon[] polygonBuffer
          Stores a array of Polygon objects.
private  int polygonPointer
          Points to the next free slot in the polygonBuffer.
private  int srid
          The SRID of the top-level Geometry being created.
 
Fields inherited from class org.wkb4j.factories.AbstractWKBFactory
depthPointer, geometryDepth, inUnit, inWork, log, typeStack, values, words
 
Fields inherited from interface org.wkb4j.engine.WKBGeometryTypes
linearRing, wkbGeometryCollection, wkbLineString, wkbMultiLineString, wkbMultiPoint, wkbMultiPolygon, wkbPoint, wkbPolygon
 
Constructor Summary
PostGISFactory()
          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 Points.
 boolean addPoints3D(double[] points)
          Transforms an array of doubles into an array of 3D Point objects.
 boolean beginGeometryCollection(int count)
          Signals the beginning of a new GeometryCollection.
 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.
 boolean endGeometryCollection()
          Signals the end of a GeometryCollection.
 boolean endLinearRing()
          Constructs a LinearRing using the current buffer of Points, resets the Points 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 Points, resets the Points 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.
 boolean newGeometryCollectionComponent()
          Signals that a new component for the geometry factory is about to processed OR that all components has been used.
 void reset()
           
 
Methods inherited from class org.wkb4j.factories.AbstractWKBFactory
abortLinearRing, abortMultiLineString, abortMultiPoint, abortMultiPolygon, abortPolygon, abortUnit, abortWork, beginLinearRing, beginLineString, beginPoint, beginUnit, beginUnit, 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

coordinatesBuffer

private org.postgis.Point[] coordinatesBuffer
Stores a array of Point objects.


pointsBuffer

private org.postgis.Point[] pointsBuffer
Stores a array of Point objects, for MultiPoint.


lineStringBuffer

private org.postgis.LineString[] lineStringBuffer
Stores a array of LineString objects.


polygonBuffer

private org.postgis.Polygon[] polygonBuffer
Stores a array of Polygon objects.


linearRingBuffer

private org.postgis.LinearRing[] linearRingBuffer
Stores a array of LinearRing objects.


geometryBuffer

private org.postgis.Geometry[] geometryBuffer

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.


pointsPointer

private volatile int pointsPointer
Points to the next free slot in the pointsBuffer.


geometryPointer

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


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 org.postgis.Geometry currentGeometry
The Geometry being constructed now.

Constructor Detail

PostGISFactory

public PostGISFactory()
Construct a JTSFactory.

Method Detail

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 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()

endLineString

public final boolean endLineString()
Constructs a LineString using the current buffer of Points, resets the Points 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()

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()

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()

endLinearRing

public final boolean endLinearRing()
Constructs a LinearRing using the current buffer of Points, resets the Points 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 Points.

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 doubles into an array of 3D Point objects.

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

getGeometries

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

Returns:
ArrayList

reset

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


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