public enum Geometries extends Enum<Geometries>
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 );
| Enum Constant and Description |
|---|
GEOMETRY
Represent
Geometry |
GEOMETRYCOLLECTION
Represent
GeometryCollection |
LINESTRING
Representing ,
SingleCurvedGeometry and CompoundCurvedGeometry |
MULTILINESTRING
Represent
MultiLineString |
MULTIPOINT
Represent
MultiPoint |
MULTIPOLYGON
Represent
MultiPolygon |
POINT
Representing
Point |
POLYGON
Represent
Polygon |
| Modifier and Type | Method and Description |
|---|---|
static Geometries |
get(Geometry geom)
Get the
Geometries for the given object. |
Class<? extends Geometry> |
getBinding()
Return the
Geometry class associated with this type. |
static Geometries |
getForBinding(Class<? extends Geometry> geomClass)
Get the
Geometries for the given Geometry class. |
static Geometries |
getForName(String name)
Get the
Geometries for the specified name. |
static Geometries |
getForSQLType(int sqlType)
Get the
Geometries with the given integer SQL type code. |
String |
getName()
Return a name for this type that is suitable for text descriptions.
|
String |
getSimpleName()
Get the 'simple name'.
|
Integer |
getSQLType()
Return the integer SQL type code for this geometry type.
|
String |
toString()
Equivalent to getName().
|
static Geometries |
valueOf(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.
|
public static final Geometries POINT
Pointpublic static final Geometries LINESTRING
SingleCurvedGeometry and CompoundCurvedGeometrypublic static final Geometries POLYGON
Polygonpublic static final Geometries MULTIPOINT
MultiPointpublic static final Geometries MULTILINESTRING
MultiLineStringpublic static final Geometries MULTIPOLYGON
MultiPolygonpublic static final Geometries GEOMETRY
Geometrypublic static final Geometries GEOMETRYCOLLECTION
GeometryCollectionpublic static Geometries[] values()
for (Geometries c : Geometries.values()) System.out.println(c);
public static Geometries valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic Class<? extends Geometry> getBinding()
Geometry class associated with this type.Geometry classpublic Integer getSQLType()
public String toString()
toString in class Enum<Geometries>public String getName()
public String getSimpleName()
public static Geometries get(Geometry geom)
Geometries for the given object.geom - a JTS Geometry objectGeometries for the argument's class, or null if the argument is
nullpublic static Geometries getForBinding(Class<? extends Geometry> geomClass)
Geometries for the given Geometry class.geomClass - the classpublic static Geometries getForName(String name)
Geometries for the specified name.name - The name of the geometry, eg: "POINT"public static Geometries getForSQLType(int sqlType)
Geometries with the given integer SQL type code.sqlType - the code to look up.null if no match was foundCopyright © 1996–2019 Geotools. All rights reserved.