org.gvsig.fmap.geom.impl
Class DefaultGeometryManager

java.lang.Object
  extended by org.gvsig.fmap.geom.impl.DefaultGeometryManager
All Implemented Interfaces:
GeometryManager

public class DefaultGeometryManager
extends Object
implements GeometryManager

Default implementation for the GeometryManager. When the application starts, this class is registered in the GeometryLocator using the DefaultGeometryLibrary.

Author:
Jorge Piera

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.gvsig.fmap.geom.GeometryManager
GeometryManager.OPERATIONS
 
Constructor Summary
DefaultGeometryManager()
           
DefaultGeometryManager(int initialTypesSize, int initialSubtypesSize)
           
 
Method Summary
 Geometry create(GeometryType geomType)
           This method creates a Geometry with the type specified by this GeometryType.
 Geometry create(int type, int subType)
           This method creates a Geometry with a concrete type and subtype.
 Geometry create(String name)
           This method creates a Geometry with the type specified by this name.
 Curve createCurve(GeneralPathX generalPathX, int subType)
           Create a new curve with a concrete type and sets the value for the coordinates using a GeneralPathX.
 Envelope createEnvelope(double minX, double minY, double maxX, double maxY, int subType)
           Creates a Envelope with a concrete subtype.
 Envelope createEnvelope(int subType)
           Creates a Envelope with a concrete subtype.
 Geometry createFrom(byte[] wkb)
          Create a geometry from a WKB definition.
 Geometry createFrom(String wkt)
           
 Geometry createFrom(String wkt, String srs)
          Create a geometry from a WKT definition.
 MultiCurve createMultiCurve(GeneralPathX generalPathX, int subType)
           Create a new multicurve with a concrete type and sets the value for the coordinates using a GeneralPathX.
 MultiSurface createMultiSurface(GeneralPathX generalPathX, int subType)
           Create a new multisurface with a concrete type and sets the value for the coordinates using a GeneralPathX.
 NullGeometry createNullGeometry(int subType)
           It creates a null geometry with a concrete subtype.
 Point createPoint(double x, double y, int subType)
           Create a new point with a concrete type and sets the value for the X and the Y.
 Surface createSurface(GeneralPathX generalPathX, int subType)
           Create a new surface with a concrete type and sets the value for the coordinates using a GeneralPathX.
 double getFlatness()
          Returns the flatness used to convert a curve is a set of points.
 GeometryOperation getGeometryOperation(int opCode)
           Returns an common operation with given operation code.
 GeometryOperation getGeometryOperation(int opCode, int type, int subType)
           Returns an operation given the Geometry type, the Geometry subtype and and the operation code.
 int getGeometryOperationCode(String geomOpName)
           Registers the unique name of one operation.
 List getGeometryOperationNames()
          Returns a list with the name of the operations that have been registered.
 GeometryType getGeometryType(int type, int subType)
           Returns an instance of GeometryType given the Geometry type and the subtype.
 GeometryType getGeometryType(String className)
           
 Object invokeOperation(int opCode, Geometry geom, GeometryOperationContext ctx)
           Invokes an operation given its code, the geometry and the operation context holding the parameters required for the operation.
 Object invokeOperation(String geomOpName, Geometry geom, GeometryOperationContext ctx)
           Invokes an operation given its code, the geometry and the operation context holding the parameters required for the operation.
 Object invokeOperation(String geomOpName, GeometryOperationContext ctx)
           Invokes an operation given its code, and the operation context holding the parameters required for the operation.
 int registerGeometryOperation(String geomOpName, GeometryOperation geomOp)
           Registers a GeometryOperation that is common for all GeometryType (registered yet or not).
 int registerGeometryOperation(String geomOpName, GeometryOperation geomOp, GeometryType geomType)
           Registers a GeometryOperation associated to a GeometryType.
 int registerGeometryOperation(String geomOpName, GeometryOperation geomOp, int type)
           Registers a GeometryOperation associated to all the geometries with a concrete type.
 int registerGeometryOperation(String geomOpName, GeometryOperation geomOp, int type, int subType)
           Registers a GeometryOperation associated to a GeometryType, that has been specified using the type code and the subtype code.
 int registerGeometryOperationBySubtype(String geomOpName, GeometryOperation geomOp, int subType)
           Registers a GeometryOperation associated to all the geometries with a concrete subtype.
 int registerGeometryOperationBySuperSubType(String geomOpName, GeometryOperation geomOp, int superSubType)
           Registers a GeometryOperation associated to all the geometries which super subType matches with a concrete subType.
 int registerGeometryOperationBySuperType(String geomOpName, GeometryOperation geomOp, int superType)
           Registers a GeometryOperation associated to all the geometries which super type matches with a concrete type.
 GeometryType registerGeometryType(Class geomClass, int type, int subType)
           Registers a Geometry implementation class with a predefined geometry type and returns the associated GeometryType instance.
 GeometryType registerGeometryType(Class geomClass, String name, int type, int subType)
           Registers a Geometry implementation class with a predefined geometry type and returns the associated GeometryType instance.
 GeometryType registerGeometryType(Class geomClass, String name, int type, int subType, int superType)
           Registers a Geometry implementation class with a predefined geometry type and returns the associated GeometryType instance.
 GeometryType registerGeometryType(Class geomClass, String name, int type, int subType, int[] superTypes)
           Registers a Geometry implementation class with a predefined geometry type and returns the associated GeometryType instance.
 GeometryType registerGeometryType(Class geomClass, String name, int type, int subType, int[] superTypes, int[] superSubTypes)
           Registers a Geometry implementation class with a predefined geometry type and returns the associated GeometryType instance.
 GeometryType registerGeometryType(Class geomClass, String name, int type, int subType, int superType, int superSubType)
           Registers a Geometry implementation class with a predefined geometry type and returns the associated GeometryType instance.
 void setFlatness(double flatness)
          Sets the application flatness.
 GeometryType unregisterGeometryType(Class geomClass)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultGeometryManager

public DefaultGeometryManager()

DefaultGeometryManager

public DefaultGeometryManager(int initialTypesSize,
                              int initialSubtypesSize)
Method Detail

registerGeometryOperation

public int registerGeometryOperation(String geomOpName,
                                     GeometryOperation geomOp,
                                     GeometryType geomType)
Description copied from interface: GeometryManager

Registers a GeometryOperation associated to a GeometryType. Returns an unique index that is used later to identify and invoke the operation.

By convention this index should be in a final and static variable in the class that implements the operation. The value of this variable must be set using the method GeometryManager.getGeometryOperationCode(String):

 
 public class MyOperation extends GeometryOperation {
 
     public static final int CODE = GeometryLocator.getGeometryManager()
         .getGeometryOperationCode("MyOperation");
 }
 

Specified by:
registerGeometryOperation in interface GeometryManager
Parameters:
geomOpName - Operation's unique name
geomOp - Specific GeometryOperation's instance implementing this operation
geomType - GeometryType instance to which this operation should be associated
Returns:
Index assigned to this operation. This index is used later to access the operation.

registerGeometryOperation

public int registerGeometryOperation(String geomOpName,
                                     GeometryOperation geomOp)
Description copied from interface: GeometryManager

Registers a GeometryOperation that is common for all GeometryType (registered yet or not). Returns an unique index that is used later to identify and invoke the operation.

By convention this index should be in a final and static variable in the class that implements the operation. The value of this variable must be set using the method GeometryManager.getGeometryOperationCode(String):

 
 public class MyOperation extends GeometryOperation {
 
     public static final int CODE = GeometryLocator.getGeometryManager()
         .getGeometryOperationCode("MyOperation");
 }
 

Specified by:
registerGeometryOperation in interface GeometryManager
Parameters:
geomOpName - Operation's unique name
geomOp - Specific GeometryOperation's instance implementing this operation
Returns:
Index assigned to this operation. This index is used later to access the operation.

registerGeometryOperation

public int registerGeometryOperation(String geomOpName,
                                     GeometryOperation geomOp,
                                     int type,
                                     int subType)
                              throws GeometryTypeNotSupportedException,
                                     GeometryTypeNotValidException
Description copied from interface: GeometryManager

Registers a GeometryOperation associated to a GeometryType, that has been specified using the type code and the subtype code. Returns an unique index that is used later to identify and invoke the operation.

By convention this index should be in a final and static variable in the class that implements the operation. The value of this variable must be set using the method GeometryManager.getGeometryOperationCode(String):

 
 public class MyOperation extends GeometryOperation {
 
     public static final int CODE = GeometryLocator.getGeometryManager()
         .getGeometryOperationCode("MyOperation");
 }
 

This method is only used if you have not a reference to the GeometryType associated to the geometry class. If you have such reference then it is slightly faster to use the method that receives the GeometryType.

Specified by:
registerGeometryOperation in interface GeometryManager
Parameters:
geomOpName - Operation's unique name
geomOp - Specific GeometryOperation's instance implementing this operation
type - Type of geometry. Must be a value defined in Geometry.TYPES
subType - SubType of geometry. Must be a value defined in Geometry.SUBTYPES
Returns:
Index assigned to this operation. This index is used later to access the operation.
Throws:
GeometryTypeNotSupportedException - Returns this exception if there is not a registered geometry with these type and subtype
GeometryTypeNotValidException - Returns if the type and subtype are not valid

registerGeometryOperation

public int registerGeometryOperation(String geomOpName,
                                     GeometryOperation geomOp,
                                     int type)
Description copied from interface: GeometryManager

Registers a GeometryOperation associated to all the geometries with a concrete type. Returns an unique index that is used later to identify and invoke the operation.

By convention this index should be in a final and static variable in the class that implements the operation. The value of this variable must be set using the method GeometryManager.getGeometryOperationCode(String):

 
 public class MyOperation extends GeometryOperation {
 
     public static final int CODE = GeometryLocator.getGeometryManager()
         .getGeometryOperationCode("MyOperation");
 }
 

Specified by:
registerGeometryOperation in interface GeometryManager
Parameters:
geomOpName - Operation's unique name
geomOp - Specific GeometryOperation's instance implementing this operation
type - Type of geometry. Must be a value defined in Geometry.TYPES
Returns:
Index assigned to this operation. This index is used later to access the operation.

registerGeometryOperationBySubtype

public int registerGeometryOperationBySubtype(String geomOpName,
                                              GeometryOperation geomOp,
                                              int subType)
Description copied from interface: GeometryManager

Registers a GeometryOperation associated to all the geometries with a concrete subtype. Returns an unique index that is used later to identify and invoke the operation.

By convention this index should be in a final and static variable in the class that implements the operation. The value of this variable must be set using the method GeometryManager.getGeometryOperationCode(String):

 
 public class MyOperation extends GeometryOperation {
 
     public static final int CODE = GeometryLocator.getGeometryManager()
         .getGeometryOperationCode("MyOperation");
 }
 

Specified by:
registerGeometryOperationBySubtype in interface GeometryManager
Parameters:
geomOpName - Operation's unique name
geomOp - Specific GeometryOperation's instance implementing this operation
subType - SubType of geometry. Must be a value defined in Geometry.SUBTYPES
Returns:
Index assigned to this operation. This index is used later to access the operation.

registerGeometryOperationBySuperType

public int registerGeometryOperationBySuperType(String geomOpName,
                                                GeometryOperation geomOp,
                                                int superType)
Description copied from interface: GeometryManager

Registers a GeometryOperation associated to all the geometries which super type matches with a concrete type. Returns an unique index that is used later to identify and invoke the operation.

By convention this index should be in a final and static variable in the class that implements the operation. The value of this variable must be set using the method GeometryManager.getGeometryOperationCode(String):

 
 public class MyOperation extends GeometryOperation {
 
     public static final int CODE = GeometryLocator.getGeometryManager()
         .getGeometryOperationCode("MyOperation");
 }
 

Specified by:
registerGeometryOperationBySuperType in interface GeometryManager
Parameters:
geomOpName - Operation's unique name
geomOp - Specific GeometryOperation's instance implementing this operation
superType - super type of geometries that is used to register the operation. Must be a value defined in Geometry.TYPES
Returns:
Index assigned to this operation. This index is used later to access the operation.

registerGeometryOperationBySuperSubType

public int registerGeometryOperationBySuperSubType(String geomOpName,
                                                   GeometryOperation geomOp,
                                                   int superSubType)
Description copied from interface: GeometryManager

Registers a GeometryOperation associated to all the geometries which super subType matches with a concrete subType. Returns an unique index that is used later to identify and invoke the operation.

By convention this index should be in a final and static variable in the class that implements the operation. The value of this variable must be set using the method GeometryManager.getGeometryOperationCode(String):

 
 public class MyOperation extends GeometryOperation {
 
     public static final int CODE = GeometryLocator.getGeometryManager()
         .getGeometryOperationCode("MyOperation");
 }
 

Specified by:
registerGeometryOperationBySuperSubType in interface GeometryManager
Parameters:
geomOpName - Operation's unique name
geomOp - Specific GeometryOperation's instance implementing this operation
superSubType - super subType of geometries that is used to register the operation. Must be a value defined in Geometry.SUBTYPES
Returns:
Index assigned to this operation. This index is used later to access the operation.

registerGeometryType

public GeometryType registerGeometryType(Class geomClass,
                                         String name,
                                         int type,
                                         int subType)
Description copied from interface: GeometryManager

Registers a Geometry implementation class with a predefined geometry type and returns the associated GeometryType instance. Available predefined types are defined in Geometry.TYPES and the subtypes are defined in Geometry.SUBTYPES.

How to register a geometry class with a predefined type:

 
 GeometryType geomType = GeometryLocator.getGeometryManager()
     .registerBasicGeometryType(Point2D.class, "Point2D", Geometry.TYPES.POINT,
         Geometry.SYBTYPES.GEOM2D);
 

Specified by:
registerGeometryType in interface GeometryManager
Parameters:
geomClass - Geometry subclass. It must not be null and must implement Geometry, otherwise an exception is raised.
name - Symbolic name for the geometry type, it can be null. If it is null then the symbolic name will be the simple class name.
type - Type of geometry. Must be a value defined in Geometry.TYPES
subType - SubType of geometry. Must be a value defined in Geometry.SUBTYPES
Returns:
Instance of GeometryType associated to the Geometry implementation class geomClass

registerGeometryType

public GeometryType registerGeometryType(Class geomClass,
                                         String name,
                                         int type,
                                         int subType,
                                         int superType,
                                         int superSubType)
Description copied from interface: GeometryManager

Registers a Geometry implementation class with a predefined geometry type and returns the associated GeometryType instance. Available predefined types are defined in Geometry.TYPES and the subtypes are defined in Geometry.SUBTYPES.

It adds also the super type and the super subType of the geometry, that can be used to check if the type (or the subtype) inherits of other type (or subType)

How to register a geometry class with a predefined type:

 
 GeometryType geomType = GeometryLocator.getGeometryManager()
     .registerBasicGeometryType(Arc3D.class, "Arc3D", Geometry.TYPES.ARC,
         Geometry.SYBTYPES.GEOM3D, Geometry.TYPES.CURVE, Geometry.SYBTYPES.GEOM2D);
 

Specified by:
registerGeometryType in interface GeometryManager
Parameters:
geomClass - Geometry subclass. It must not be null and must implement Geometry, otherwise an exception is raised.
name - Symbolic name for the geometry type, it can be null. If it is null then the symbolic name will be the simple class name.
type - Type of geometry. Must be a value defined in Geometry.TYPES
subType - SubType of geometry. Must be a value defined in Geometry.SUBTYPES
superType - Super type of a geometry. Must be a value defined in Geometry.TYPES
superSubType - Super subType of a geometry. Must be a value defined in Geometry.SUBTYPES
Returns:
Instance of GeometryType associated to the Geometry implementation class geomClass

registerGeometryType

public GeometryType registerGeometryType(Class geomClass,
                                         String name,
                                         int type,
                                         int subType,
                                         int superType)
Description copied from interface: GeometryManager

Registers a Geometry implementation class with a predefined geometry type and returns the associated GeometryType instance. Available predefined types are defined in Geometry.TYPES and the subtypes are defined in Geometry.SUBTYPES.

It adds also the super type of the geometry, that can be used to check if the type inherits of other type.

How to register a geometry class with a predefined type:

 
 GeometryType geomType = GeometryLocator.getGeometryManager()
     .registerBasicGeometryType(Arc3D.class, "Arc3D", Geometry.TYPES.ARC,
         Geometry.SYBTYPES.GEOM3D, Geometry.TYPES.CURVE);
 

Specified by:
registerGeometryType in interface GeometryManager
Parameters:
geomClass - Geometry subclass. It must not be null and must implement Geometry, otherwise an exception is raised.
name - Symbolic name for the geometry type, it can be null. If it is null then the symbolic name will be the simple class name.
type - Type of geometry. Must be a value defined in Geometry.TYPES
subType - SubType of geometry. Must be a value defined in Geometry.SUBTYPES
superType - Super type of a geometry. Must be a value defined in Geometry.TYPES
Returns:
Instance of GeometryType associated to the Geometry implementation class geomClass

registerGeometryType

public GeometryType registerGeometryType(Class geomClass,
                                         String name,
                                         int type,
                                         int subType,
                                         int[] superTypes,
                                         int[] superSubTypes)
Description copied from interface: GeometryManager

Registers a Geometry implementation class with a predefined geometry type and returns the associated GeometryType instance. Available predefined types are defined in Geometry.TYPES and the subtypes are defined in Geometry.SUBTYPES.

It adds also the super types and the super subTypes of the geometry, that can be used to check if the type (or the subtype) inherits of other types (or subTypes)

How to register a geometry class with a predefined type:

 
 GeometryType geomType = GeometryLocator.getGeometryManager()
     .registerBasicGeometryType(Circle3DM.class, "Circle3DM", Geometry.TYPES.CIRCLE,
         Geometry.SYBTYPES.GEOM3DM,
         new int[]{Geometry.TYPES.CURVE, Geometry.TYPES.GEOMETRY},
         new int[]{Geometry.SYBTYPES.GEOM2D, Geometry.SYBTYPES.GEOM3D});
 

Specified by:
registerGeometryType in interface GeometryManager
Parameters:
geomClass - Geometry subclass. It must not be null and must implement Geometry, otherwise an exception is raised.
name - Symbolic name for the geometry type, it can be null. If it is null then the symbolic name will be the simple class name.
type - Type of geometry. Must be a value defined in Geometry.TYPES
subType - SubType of geometry. Must be a value defined in Geometry.SUBTYPES
superTypes - List of the super types of a geometry. Must be a value defined in Geometry.TYPES
superSubTypes - List of the super subType of a geometry. Must be a value defined in Geometry.SUBTYPES
Returns:
Instance of GeometryType associated to the Geometry implementation class geomClass

registerGeometryType

public GeometryType registerGeometryType(Class geomClass,
                                         String name,
                                         int type,
                                         int subType,
                                         int[] superTypes)
Description copied from interface: GeometryManager

Registers a Geometry implementation class with a predefined geometry type and returns the associated GeometryType instance. Available predefined types are defined in Geometry.TYPES and the subtypes are defined in Geometry.SUBTYPES.

It adds also the super types and the super subTypes of the geometry, that can be used to check if the type inherits of other types.

How to register a geometry class with a predefined type:

 
 GeometryType geomType = GeometryLocator.getGeometryManager()
     .registerBasicGeometryType(Circle2D.class, "Circle2DM", Geometry.TYPES.CIRCLE,
         Geometry.SYBTYPES.GEOM2D,
         new int[]{Geometry.TYPES.CURVE, Geometry.TYPES.SURFACE});        
 

Specified by:
registerGeometryType in interface GeometryManager
Parameters:
geomClass - Geometry subclass. It must not be null and must implement Geometry, otherwise an exception is raised.
name - Symbolic name for the geometry type, it can be null. If it is null then the symbolic name will be the simple class name.
type - Type of geometry. Must be a value defined in Geometry.TYPES
subType - SubType of geometry. Must be a value defined in Geometry.SUBTYPES
superTypes - List of the super types of a geometry. Must be a value defined in Geometry.TYPES
Returns:
Instance of GeometryType associated to the Geometry implementation class geomClass

registerGeometryType

public GeometryType registerGeometryType(Class geomClass,
                                         int type,
                                         int subType)
Description copied from interface: GeometryManager

Registers a Geometry implementation class with a predefined geometry type and returns the associated GeometryType instance. Available predefined types are defined in Geometry.TYPES and the subtypes are defined in Geometry.SUBTYPES.

In this case the symbolic name will be the geometry's simple class name

How to register a new geometry type:
 
 GeometryType geomType = GeometryLocator.getGeometryManager()
     .registerBasicGeometryType(Point2D.class, Geometry.TYPES.POINT,
         Geometry.SYBTYPES.GEOM2D);
 

Specified by:
registerGeometryType in interface GeometryManager
Parameters:
geomClass - Geometry implementation class. It must not be null and must implement Geometry, otherwise an exception is thrown.
type - Type of geometry. Must be a value defined in Geometry.TYPES
subType - SubType of geometry. Must be a value defined in Geometry.SUBTYPES
Returns:
Instance of GeometryType associated to the Geometry implementation class

getGeometryType

public GeometryType getGeometryType(String className)
                             throws GeometryTypeNotSupportedException
Throws:
GeometryTypeNotSupportedException

getGeometryType

public GeometryType getGeometryType(int type,
                                    int subType)
                             throws GeometryTypeNotSupportedException,
                                    GeometryTypeNotValidException
Description copied from interface: GeometryManager

Returns an instance of GeometryType given the Geometry type and the subtype.

Specified by:
getGeometryType in interface GeometryManager
Parameters:
type - Type of geometry. Must be a value defined in Geometry.TYPES
subType - SubType of geometry. Must be a value defined in Geometry.SUBTYPES
Returns:
Instance of GeometryType associated to the type and the subtype
Throws:
GeometryTypeNotSupportedException - Returns this exception if there is not a registered geometry with these type and subtype
GeometryTypeNotValidException - Returns if the type and subtype are not valid

create

public Geometry create(GeometryType geomType)
                throws CreateGeometryException
Description copied from interface: GeometryManager

This method creates a Geometry with the type specified by this GeometryType. The geometry is empty, and all the internal attributes must be assigned to a value when the geometry has been created.

This example creates a point2D and sets the coordinates to 1,1:

 Point point =
     (Point) GeometryLocator.getGeometryManager().create(GEOMETRY.TYPES.POINT,
         GEOMETRY.SUBTYPES.GEOM2D);
 point.setX(1);
 point.setY(1);
 

Specified by:
create in interface GeometryManager
Parameters:
geomType - The geometry type
Returns:
A instance of a geometry.
Throws:
CreateGeometryException - This exception is thrown when the manager can not create the geometry.

create

public Geometry create(String name)
                throws CreateGeometryException
Description copied from interface: GeometryManager

This method creates a Geometry with the type specified by this name. If a geometry with this name doesn't exist, a IllegalArgumentException is thrown. The geometry is empty, and all the internal attributes must be assigned to a value when the geometry has been created.

This example creates a point2D and sets the coordinates to 1,1: It supposes that there is a Point2D class with name "Point2D".

 Point point = (Point) GeometryLocator.getGeometryManager().create("Point2D");
 point.setX(1);
 point.setY(1);
 

Specified by:
create in interface GeometryManager
Parameters:
name - The name of the geometry type
Returns:
A instance of a geometry.
Throws:
CreateGeometryException - This exception is thrown when the manager can not create the geometry.

create

public Geometry create(int type,
                       int subType)
                throws CreateGeometryException
Description copied from interface: GeometryManager

This method creates a Geometry with a concrete type and subtype. The geometry is empty, and all the internal attributes must be assigned to a value when the geometry has been created.

This example creates a point2D and sets the coordinates to 1,1. It supposes that there is a Point2D class with the id 1.

 Point point =
     (Point) GeometryLocator.getGeometryManager().create(Geometry.TYPES.POINT,
         Geometry.SYBTYPES.GEOM2D);
 point.setX(1);
 point.setY(1);
 

Specified by:
create in interface GeometryManager
Parameters:
type - Type of geometry. Must be a value defined in Geometry.TYPES
subType - SubType of geometry. Must be a value defined in Geometry.SUBTYPES
Returns:
A instance of a geometry.
Throws:
CreateGeometryException - This exception is thrown when the manager can not create the geometry.

createCurve

public Curve createCurve(GeneralPathX generalPathX,
                         int subType)
                  throws CreateGeometryException
Description copied from interface: GeometryManager

Create a new curve with a concrete type and sets the value for the coordinates using a GeneralPathX.

Specified by:
createCurve in interface GeometryManager
Parameters:
generalPathX - It is used to set the values for the X and Y coordinates.
subType - SubType of geometry. Must be a value defined in Geometry.SUBTYPES
Returns:
A curve
Throws:
CreateGeometryException - This exception is thrown when the manager can not create the geometry.

createNullGeometry

public NullGeometry createNullGeometry(int subType)
                                throws CreateGeometryException
Description copied from interface: GeometryManager

It creates a null geometry with a concrete subtype.

Specified by:
createNullGeometry in interface GeometryManager
Parameters:
subType - SubType of geometry. Must be a value defined in Geometry.SUBTYPES
Returns:
A NullGeometry
Throws:
CreateGeometryException - This exception is thrown when the manager can not create the geometry.

createPoint

public Point createPoint(double x,
                         double y,
                         int subType)
                  throws CreateGeometryException
Description copied from interface: GeometryManager

Create a new point with a concrete type and sets the value for the X and the Y.

Specified by:
createPoint in interface GeometryManager
Parameters:
x - The X coordinate
y - The y coordinate
subType - SubType of geometry. Must be a value defined in Geometry.SUBTYPES
Returns:
The Point
Throws:
CreateGeometryException - This exception is thrown when the manager can not create the geometry.

createSurface

public Surface createSurface(GeneralPathX generalPathX,
                             int subType)
                      throws CreateGeometryException
Description copied from interface: GeometryManager

Create a new surface with a concrete type and sets the value for the coordinates using a GeneralPathX.

Specified by:
createSurface in interface GeometryManager
Parameters:
generalPathX - It is used to set the values for the X and Y coordinates.
subType - SubType of geometry. Must be a value defined in Geometry.SUBTYPES
Returns:
A surface
Throws:
CreateGeometryException - This exception is thrown when the manager can not create the geometry.

getGeometryOperation

public GeometryOperation getGeometryOperation(int opCode,
                                              int type,
                                              int subType)
                                       throws GeometryTypeNotSupportedException,
                                              GeometryOperationNotSupportedException,
                                              GeometryTypeNotValidException
Description copied from interface: GeometryManager

Returns an operation given the Geometry type, the Geometry subtype and and the operation code. If opCode corresponds to a common operation (a common operation is an operation registered for all geometries), then this method returns the common operation.

For better performance, if you need to call an operation multiple times, use this method only once and keep the returned object in a local variable over which you can iterate. For instance:

 // Get the operation you need
 GeometryManager gm = GeometryLocator.getGeometryManager()
 GeometryOperation geomOp = null;
 try {
    geomOp = gm.getGeometryOperation(Draw2D.CODE, Geometry.TYPES.POINT, 
    Geometry.SUBTYPES.GEOM2D);
 } catch (GeometryTypeNotSupportedException gtnse) {
    // treat exception
 } catch (GeometryOperationNotSupportedException gonse) {
    // treat exception
 }
 
  // Fill the operation context with required params
 GeometryOperationContext ctx = new GeometryOperationContext();
 
  // Here is the main loop where you call the operation
 for (int i=0; i
 
 

Specified by:
getGeometryOperation in interface GeometryManager
Parameters:
opCode - The operation code
type - Type of geometry. Must be a value defined in Geometry.TYPES
subType - SubType of geometry. Must be a value defined in Geometry.SUBTYPES
Returns:
Geometry operation
Throws:
GeometryTypeNotSupportedException - Returns this exception if there is not a registered geometry with these type and subtype
GeometryOperationNotSupportedException - Returns this exception if there is not a registered operation with this operation code
GeometryTypeNotValidException - Returns this exception if the type and subtype are not valid

getGeometryOperation

public GeometryOperation getGeometryOperation(int opCode)
                                       throws GeometryOperationNotSupportedException
Description copied from interface: GeometryManager

Returns an common operation with given operation code. A common operation is an operation registered for all geometries.

For better performance, if you need to call an operation multiple times, use this method only once and keep the returned object in a local variable over which you can iterate. For instance:

 // Get the operation you need
 GeometryManager gm = GeometryLocator.getGeometryManager()
 GeometryOperation geomOp = null;
 try {
    geomOp = gm.getGeometryOperation(FromWKB.CODE);
 } catch (GeometryOperationNotSupportedException gonse) {
    // treat exception
 }
 
  // Fill the operation context with required params
 FromWKBGeometryOperationContext ctx = new FromWKBGeometryOperationContext();
 
  // Here is the main loop where you call the operation
 for (int i=0; i
 
 

Specified by:
getGeometryOperation in interface GeometryManager
Parameters:
opCode - The operation code
Returns:
Geometry operation
Throws:
GeometryOperationNotSupportedException - Returns this exception if there is not a registered operation with this operation code

invokeOperation

public Object invokeOperation(int opCode,
                              Geometry geom,
                              GeometryOperationContext ctx)
                       throws GeometryOperationNotSupportedException,
                              GeometryOperationException
Description copied from interface: GeometryManager

Invokes an operation given its code, the geometry and the operation context holding the parameters required for the operation.

Specified by:
invokeOperation in interface GeometryManager
Parameters:
opCode - Operation code.
geom - Geometry to which apply the operation
ctx - Context holding the operation parameters
Returns:
The object returned by an operation, depends on each operation.
Throws:
GeometryOperationNotSupportedException
GeometryOperationException

invokeOperation

public Object invokeOperation(String geomOpName,
                              Geometry geom,
                              GeometryOperationContext ctx)
                       throws GeometryOperationNotSupportedException,
                              GeometryOperationException
Description copied from interface: GeometryManager

Invokes an operation given its code, the geometry and the operation context holding the parameters required for the operation.

Specified by:
invokeOperation in interface GeometryManager
Parameters:
geomOpName - Operation name.
geom - Geometry to which apply the operation
ctx - Context holding the operation parameters
Returns:
The object returned by an operation, depends on each operation.
Throws:
GeometryOperationNotSupportedException
GeometryOperationException

invokeOperation

public Object invokeOperation(String geomOpName,
                              GeometryOperationContext ctx)
                       throws GeometryOperationNotSupportedException,
                              GeometryOperationException
Description copied from interface: GeometryManager

Invokes an operation given its code, and the operation context holding the parameters required for the operation.

Specified by:
invokeOperation in interface GeometryManager
Parameters:
geomOpName - Operation name.
ctx - Context holding the operation parameters
Returns:
The object returned by an operation, depends on each operation.
Throws:
GeometryOperationNotSupportedException
GeometryOperationException

unregisterGeometryType

public GeometryType unregisterGeometryType(Class geomClass)

createEnvelope

public Envelope createEnvelope(int subType)
Description copied from interface: GeometryManager

Creates a Envelope with a concrete subtype. The envelope is empty and it have to be filled with the corners once has been created.

Specified by:
createEnvelope in interface GeometryManager
Parameters:
subType - SubType of envelope. Must be a value defined in Geometry.SUBTYPES
Returns:
A Envelope

createEnvelope

public Envelope createEnvelope(double minX,
                               double minY,
                               double maxX,
                               double maxY,
                               int subType)
                        throws CreateEnvelopeException
Description copied from interface: GeometryManager

Creates a Envelope with a concrete subtype. It sets the values for the lower corner and the upper corner (in 2D) using the method parameters.

Specified by:
createEnvelope in interface GeometryManager
Parameters:
minX - The minimum value for the X coordinate.
minY - The minimum value for the Y coordinate.
maxX - The maximum value for the X coordinate.
maxY - The maximum value for the Y coordinate.
subType - SubType of envelope. Must be a value defined in Geometry.SUBTYPES
Returns:
Throws:
CreateEnvelopeException

createMultiCurve

public MultiCurve createMultiCurve(GeneralPathX generalPathX,
                                   int subType)
                            throws CreateGeometryException
Description copied from interface: GeometryManager

Create a new multicurve with a concrete type and sets the value for the coordinates using a GeneralPathX.

Specified by:
createMultiCurve in interface GeometryManager
Parameters:
generalPathX - It is used to set the values for the X and Y coordinates.
subType - SubType of geometry. Must be a value defined in Geometry.SUBTYPES
Returns:
A multicurve
Throws:
CreateGeometryException - This exception is thrown when the manager can not create the geometry.

createMultiSurface

public MultiSurface createMultiSurface(GeneralPathX generalPathX,
                                       int subType)
                                throws CreateGeometryException
Description copied from interface: GeometryManager

Create a new multisurface with a concrete type and sets the value for the coordinates using a GeneralPathX.

Specified by:
createMultiSurface in interface GeometryManager
Parameters:
generalPathX - It is used to set the values for the X and Y coordinates.
subType - SubType of geometry. Must be a value defined in Geometry.SUBTYPES
Returns:
A multisurface
Throws:
CreateGeometryException - This exception is thrown when the manager can not create the geometry.

getGeometryOperationCode

public int getGeometryOperationCode(String geomOpName)
Description copied from interface: GeometryManager

Registers the unique name of one operation. If it already exists then this method does nothing but returning the name's corresponding index.

By convention this method is used to set the value of the final and static variable that is located in the classes that implements the operation:

 
 public class MyOperation extends GeometryOperation {
 
     public static final int CODE = GeometryLocator.getGeometryManager()
         .getGeometryOperationCode("MyOperation");
 }
 

Specified by:
getGeometryOperationCode in interface GeometryManager
Parameters:
geomOpName - Name used to register the geometry operation
Returns:
Index assigned to the operation name passed as parameter

getGeometryOperationNames

public List getGeometryOperationNames()
Description copied from interface: GeometryManager
Returns a list with the name of the operations that have been registered.

Specified by:
getGeometryOperationNames in interface GeometryManager
Returns:
A list of the registered operations.

getFlatness

public double getFlatness()
Description copied from interface: GeometryManager
Returns the flatness used to convert a curve is a set of points.

Specified by:
getFlatness in interface GeometryManager
Returns:
The flatness.

setFlatness

public void setFlatness(double flatness)
Description copied from interface: GeometryManager
Sets the application flatness.

Specified by:
setFlatness in interface GeometryManager
Parameters:
flatness - The flatness to set

createFrom

public Geometry createFrom(String wkt,
                           String srs)
                    throws GeometryException
Description copied from interface: GeometryManager
Create a geometry from a WKT definition. This is a utility method to wrap the invocation to the operation GeometryManager.OPERATIONS.FROMWKT.

Specified by:
createFrom in interface GeometryManager
Parameters:
wkt - geometry in Well-known text format
Returns:
the geometry as a Geometry
Throws:
CreateGeometryException
GeometryException

createFrom

public Geometry createFrom(String wkt)
                    throws GeometryException
Specified by:
createFrom in interface GeometryManager
Throws:
GeometryException

createFrom

public Geometry createFrom(byte[] wkb)
                    throws GeometryException
Description copied from interface: GeometryManager
Create a geometry from a WKB definition. This is a utility method to wrap the invocation to the operation GeometryManager.OPERATIONS.FROMWKB.

Specified by:
createFrom in interface GeometryManager
Parameters:
wkb - geometry in well-known binary format
Returns:
the geometry as a Geometry
Throws:
CreateGeometryException
GeometryException


Copyright © 2004-2012 gvSIG. All Rights Reserved.