org.geotools.data.shapefile.shp
Class PolygonHandler

Object
  extended by PolygonHandler
All Implemented Interfaces:
ShapeHandler

public class PolygonHandler
extends Object
implements ShapeHandler

Wrapper for a Shapefile polygon.

Author:
aaime, Ian Schneider
Module:
modules/plugin/shapefile (gt-shapefile.jar)

Constructor Summary
PolygonHandler(GeometryFactory gf)
           
PolygonHandler(ShapeType type, GeometryFactory gf)
           
 
Method Summary
static int computeOrientation(CoordinateSequence cs, int p1, int p2, int q)
           
 int getLength(Object geometry)
          Get the length of the given geometry Object in bytes not 16-bit words.
 ShapeType getShapeType()
          Get the ShapeType of this handler.
static boolean isCCW(CoordinateSequence ring)
          Computes whether a ring defined by an array of Coordinates is oriented counter-clockwise.
 Object read(ByteBuffer buffer, ShapeType type)
          Read a geometry from the ByteBuffer.
 void write(ByteBuffer buffer, Object geometry)
          Write the geometry into the ByteBuffer.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PolygonHandler

public PolygonHandler(GeometryFactory gf)

PolygonHandler

public PolygonHandler(ShapeType type,
                      GeometryFactory gf)
               throws ShapefileException
Throws:
ShapefileException
Method Detail

getShapeType

public ShapeType getShapeType()
Description copied from interface: ShapeHandler
Get the ShapeType of this handler.

Specified by:
getShapeType in interface ShapeHandler
Returns:
The ShapeType.

getLength

public int getLength(Object geometry)
Description copied from interface: ShapeHandler
Get the length of the given geometry Object in bytes not 16-bit words. This is easier to keep track of, since the ByteBuffer deals with bytes. Do not include the 8 bytes of record.

Specified by:
getLength in interface ShapeHandler
Parameters:
geometry - The geometry to analyze.
Returns:
The number of bytes the shape will take up.

read

public Object read(ByteBuffer buffer,
                   ShapeType type)
Description copied from interface: ShapeHandler
Read a geometry from the ByteBuffer. The buffer's position, byteOrder, and limit are set to that which is needed. The record has been read as well as the shape type integer. The handler need not worry about reading unused information as the ShapefileReader will correctly adjust the buffer position after this call.

Specified by:
read in interface ShapeHandler
Parameters:
buffer - The ByteBuffer to read from.
Returns:
A geometry object.

write

public void write(ByteBuffer buffer,
                  Object geometry)
Description copied from interface: ShapeHandler
Write the geometry into the ByteBuffer. The position, byteOrder, and limit are all set. The handler is not responsible for writing the record or shape type integer.

Specified by:
write in interface ShapeHandler
Parameters:
buffer - The ByteBuffer to write to.
geometry - The geometry to write.

isCCW

public static boolean isCCW(CoordinateSequence ring)
Computes whether a ring defined by an array of Coordinates is oriented counter-clockwise. This algorithm is only guaranteed to work with valid rings. If the ring is invalid (e.g. self-crosses or touches), the computed result may not be correct.

Parameters:
ring - an array of Coordinates forming a ring
Returns:
true if the ring is oriented counter-clockwise.

computeOrientation

public static int computeOrientation(CoordinateSequence cs,
                                     int p1,
                                     int p2,
                                     int q)


Copyright © 1996-2009 Geotools. All Rights Reserved.