net.refractions.udig.tools.edit.support
Class GeometryCreationUtil
java.lang.Object
net.refractions.udig.tools.edit.support.GeometryCreationUtil
public class GeometryCreationUtil
- extends java.lang.Object
Some helper methods for creating geometries.
- Since:
- 1.1.0
- Author:
- jones
Field Summary |
static RobustCGAlgorithms |
cga
|
Method Summary |
static Geometry |
ceateGeometryCollection(java.util.List<Geometry> geoms,
java.lang.Class<Geometry> schemaDeclaredType)
Creates a GeometryCollection if the schemaDeclaredType is a subclass of GeometryCollection. |
static java.util.Map<java.lang.String,GeometryCreationUtil.Bag> |
createAllGeoms(EditGeom currentGeom,
java.lang.Class geomToCreate,
GeometryAttributeType geomAttribute)
Searches an EditBlackboard and creates 1 geometry for each EditGeom in the
Blackboard. |
static
|
createGeom(java.lang.Class<T> geomToCreate,
PrimitiveShape shape)
Creates a geometry for a primitive shape. |
static Polygon |
createPolygon(EditGeom currentGeom)
|
static java.lang.Class |
determineGeometryType(EditGeom currentGeom,
EditGeom editGeom,
java.lang.Class geomToCreate,
GeometryAttributeType geomAttribute)
The way the type of geometry is determined is as follows:
If the geometry has the same FID as the currentGeom then its type will be of type geomToCreate.
Otherwise the ShapeType of the EditGeom will be compared to the geomAttribute and if that type is legal for that attribute then that is the type of geometry that will be created
If ShapeType is UNKOWN and it does not have the same FID as the curentGeom then the geomAttribute is used to determine the geometry type.
Finally if the geomType is geometry then a Polygon will be created... |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
cga
public static final RobustCGAlgorithms cga
GeometryCreationUtil
public GeometryCreationUtil()
createAllGeoms
public static java.util.Map<java.lang.String,GeometryCreationUtil.Bag> createAllGeoms(EditGeom currentGeom,
java.lang.Class geomToCreate,
GeometryAttributeType geomAttribute)
- Searches an EditBlackboard and creates 1 geometry for each EditGeom in the
Blackboard. Only simple geoms are created. IE no MultiPolygons. That processing
must come later.
The way the type of geometry is determined is as follows:
- If the geometry has the same FID as the currentGeom then its type will be of type geomToCreate.
- Otherwise the ShapeType of the EditGeom will be compared to the geomAttribute and if that type is legal for that attribute then that is the type of geometry that will be created
- If ShapeType is UNKOWN and it does not have the same FID as the curentGeom then the geomAttribute is used to determine the geometry type.
- Finally if the geomType is geometry then a Polygon will be created... unless the endpoints are not the same. In that case a Line will be created. Unless it is a single point.
- Parameters:
currentGeom
- the shape that will be created as a geomToCreate type.geomToCreate
- the type of geometry that will be created for the currentShape in the handler. Must be one of Point, LineString, LinearRing or Polygon.geomAttribute
- The AttributeType of the geometry attribute that will be assist in determining the type of geometry created.
- Returns:
- a mapping between the FeatureID of a bag of geoms that map to that id. This mapping
can be used to later create complex geometries such as multigeoms.
determineGeometryType
public static java.lang.Class determineGeometryType(EditGeom currentGeom,
EditGeom editGeom,
java.lang.Class geomToCreate,
GeometryAttributeType geomAttribute)
- The way the type of geometry is determined is as follows:
- If the geometry has the same FID as the currentGeom then its type will be of type geomToCreate.
- Otherwise the ShapeType of the EditGeom will be compared to the geomAttribute and if that type is legal for that attribute then that is the type of geometry that will be created
- If ShapeType is UNKOWN and it does not have the same FID as the curentGeom then the geomAttribute is used to determine the geometry type.
- Finally if the geomType is geometry then a Polygon will be created... unless the endpoints are not the same. In that case a Line will be created. Unless it is a single point.
- Parameters:
currentGeom
- the handler's current Geom. If == editGeom then geomToCreate will be returnededitGeom
- the editGeom that will be used to create a geometry.geomToCreate
- A default value to use if nothing else can be decided.geomAttribute
- The geometry attribute type of the feature that will be set using the created geometry.
- Returns:
createGeom
public static <T extends Geometry> T createGeom(java.lang.Class<T> geomToCreate,
PrimitiveShape shape)
- Creates a geometry for a primitive shape.
- Parameters:
geomToCreate
- the type of geometry to create. Must be one of Point, LineString, LinearRing or Polygon.shape
- the shape to use. If type is Polygon the shapes EditGeom is used.
- Returns:
- A geometry of type geomToCreate
createPolygon
public static Polygon createPolygon(EditGeom currentGeom)
ceateGeometryCollection
public static Geometry ceateGeometryCollection(java.util.List<Geometry> geoms,
java.lang.Class<Geometry> schemaDeclaredType)
- Creates a GeometryCollection if the schemaDeclaredType is a subclass of GeometryCollection. Otherwise
it will just return the first of the list.
- Parameters:
geoms
- list of goemtries that will be added to the GeometryCollection.schemaDeclaredType
- The type that the resulting geometry has to be compatible with
- Returns:
- geometry that is compatible with schemaDeclaredType (IE can be assigned to).