Package org.geotools.geometry.jts
Enum Class Geometries
- All Implemented Interfaces:
Serializable,Comparable<Geometries>,Constable
Constants to identify JTS geometry types, reducing the need for boiler-plate code such as this...
if (Polygon.class.isAssignableFrom(myObject.getClass()) ||
MultiPolygon.class.isAssignableFrom(myObject.getClass())) {
// do polygon thing
...
} else if (LineString.class.isAssignableFrom(myObject.getClass()) ||
MultiLineString.class.isAssignableFrom(myObject.getClass())) {
// do line thing
....
} else {
// do point thing
....
}
Instead you can do this...
Geometries geomType = Geometries.get(myObject);
switch (geomType) {
case POLYGON:
case MULTIPOLYGON:
// do polygon thing
break;
case LINESTRING:
case MULTILINESTRING:
// do line thing
break;
case POINT:
case MULTIPOINT:
// do point thing
break;
default:
// e.g. unspecified Geometry, GeometryCollection
break;
}
You can also work with Class objects...
Class<? extends Geometry> aClass = ...
Geometries type = Geometries.getForBinding( aClass );
- Since:
- 2.6
- Author:
- Justin Deoliveira, The Open Planning Project, Michael Bedward
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionRepresentGeometryRepresentGeometryCollectionRepresenting ,SingleCurvedGeometryandCompoundCurvedGeometryRepresentMultiLineStringRepresentMultiPointRepresentMultiPolygonRepresentingPointRepresentPolygon -
Method Summary
Modifier and TypeMethodDescriptionstatic GeometriesGet theGeometriesfor the given object.Return theGeometryclass associated with this type.static GeometriesgetForBinding(Class<? extends Geometry> geomClass) Get theGeometriesfor the givenGeometryclass.static GeometriesgetForName(String name) Get theGeometriesfor the specified name.static GeometriesgetForSQLType(int sqlType) Get theGeometrieswith the given integer SQL type code.getName()Return a name for this type that is suitable for text descriptions.Get the 'simple name'.Return the integer SQL type code for this geometry type.toString()Equivalent to getName().static GeometriesReturns the enum constant of this class with the specified name.static Geometries[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
POINT
RepresentingPoint -
LINESTRING
Representing ,SingleCurvedGeometryandCompoundCurvedGeometry -
POLYGON
RepresentPolygon -
MULTIPOINT
RepresentMultiPoint -
MULTILINESTRING
RepresentMultiLineString -
MULTIPOLYGON
RepresentMultiPolygon -
GEOMETRY
RepresentGeometry -
GEOMETRYCOLLECTION
RepresentGeometryCollection
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
getBinding
Return theGeometryclass associated with this type.- Returns:
- the
Geometryclass
-
getSQLType
Return the integer SQL type code for this geometry type.- Returns:
- integer code
-
toString
Equivalent to getName().- Overrides:
toStringin classEnum<Geometries>- Returns:
- the name of this type
-
getName
Return a name for this type that is suitable for text descriptions.- Returns:
- the name
-
getSimpleName
Get the 'simple name'. Returns the same value as getName() except for MULTIPOINT, MULTILINESTRING and MULTIPOLYGON, for which it returns the name without the 'Multi' prefix.- Returns:
- the simple name
-
get
Get theGeometriesfor the given object.- Parameters:
geom- a JTS Geometry object- Returns:
- the
Geometriesfor the argument's class, ornullif the argument isnull
-
getForBinding
Get theGeometriesfor the givenGeometryclass.- Parameters:
geomClass- the class- Returns:
- the constant for this class
-
getForName
Get theGeometriesfor the specified name.- Parameters:
name- The name of the geometry, eg: "POINT"- Returns:
- The constant for the name.
-
getForSQLType
Get theGeometrieswith the given integer SQL type code.- Parameters:
sqlType- the code to look up.- Returns:
- the matching type or
nullif no match was found
-