Package org.geotools.geometry.jts
Enum Geometries
- Object
-
- Enum<Geometries>
-
- Geometries
-
- All Implemented Interfaces:
Serializable,Comparable<Geometries>
public enum Geometries extends Enum<Geometries>
Constants to identify JTS geometry types, reducing the need for boiler-plate code such as this...
Instead you can do 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 .... }
You can also work withGeometries 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; }Classobjects...Class extends Geometry> aClass = ... Geometries type = Geometries.getForBinding( aClass );- Since:
- 2.6
- Author:
- Justin Deoliveira, The Open Planning Project, Michael Bedward
-
-
Enum Constant Summary
Enum Constants Enum Constant Description GEOMETRYRepresentGeometryGEOMETRYCOLLECTIONRepresentGeometryCollectionLINESTRINGRepresenting ,SingleCurvedGeometryandCompoundCurvedGeometryMULTILINESTRINGRepresentMultiLineStringMULTIPOINTRepresentMultiPointMULTIPOLYGONRepresentMultiPolygonPOINTRepresentingPointPOLYGONRepresentPolygon
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Geometriesget(Geometry geom)Get theGeometriesfor the given object.Class<? extends Geometry>getBinding()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.StringgetName()Return a name for this type that is suitable for text descriptions.StringgetSimpleName()Get the 'simple name'.IntegergetSQLType()Return the integer SQL type code for this geometry type.StringtoString()Equivalent to getName().static GeometriesvalueOf(String name)Returns the enum constant of this type with the specified name.static Geometries[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
POINT
public static final Geometries POINT
RepresentingPoint
-
LINESTRING
public static final Geometries LINESTRING
Representing ,SingleCurvedGeometryandCompoundCurvedGeometry
-
POLYGON
public static final Geometries POLYGON
RepresentPolygon
-
MULTIPOINT
public static final Geometries MULTIPOINT
RepresentMultiPoint
-
MULTILINESTRING
public static final Geometries MULTILINESTRING
RepresentMultiLineString
-
MULTIPOLYGON
public static final Geometries MULTIPOLYGON
RepresentMultiPolygon
-
GEOMETRY
public static final Geometries GEOMETRY
RepresentGeometry
-
GEOMETRYCOLLECTION
public static final Geometries GEOMETRYCOLLECTION
RepresentGeometryCollection
-
-
Method Detail
-
values
public static Geometries[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (Geometries c : Geometries.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static Geometries valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type has no constant with the specified nameNullPointerException- if the argument is null
-
getBinding
public Class<? extends Geometry> getBinding()
Return theGeometryclass associated with this type.- Returns:
- the
Geometryclass
-
getSQLType
public Integer getSQLType()
Return the integer SQL type code for this geometry type.- Returns:
- integer code
-
toString
public String toString()
Equivalent to getName().- Overrides:
toStringin classEnum<Geometries>- Returns:
- the name of this type
-
getName
public String getName()
Return a name for this type that is suitable for text descriptions.- Returns:
- the name
-
getSimpleName
public String 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
public static Geometries get(Geometry geom)
Get theGeometriesfor the given object.- Parameters:
geom- a JTS Geometry object- Returns:
- the
Geometriesfor the argument's class, ornullif the argument isnull
-
getForBinding
public static Geometries getForBinding(Class<? extends Geometry> geomClass)
Get theGeometriesfor the givenGeometryclass.- Parameters:
geomClass- the class- Returns:
- the constant for this class
-
getForName
public static Geometries getForName(String name)
Get theGeometriesfor the specified name.- Parameters:
name- The name of the geometry, eg: "POINT"- Returns:
- The constant for the name.
-
getForSQLType
public static Geometries getForSQLType(int sqlType)
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
-
-