org.geotools.geometry.jts
Enum Geometries

java.lang.Object
  extended by java.lang.Enum<Geometries>
      extended by org.geotools.geometry.jts.Geometries
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Geometries>

public enum Geometries
extends java.lang.Enum<Geometries>

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 aClass = ...
 Geometries type = Geometries.getForBinding( aClass );
 

Since:
2.6
Version:
$Id: Geometries.java 34588 2009-12-01 13:58:21Z jdeolive $
Author:
Justin Deoliveira, The Open Planning Project, Michael Bedward

Enum Constant Summary
GEOMETRY
           
GEOMETRYCOLLECTION
           
LINESTRING
           
MULTILINESTRING
           
MULTIPOINT
           
MULTIPOLYGON
           
POINT
           
POLYGON
           
 
Method Summary
static Geometries get(com.vividsolutions.jts.geom.Geometry geom)
          Get the Geometries for the given object.
 java.lang.Class<? extends com.vividsolutions.jts.geom.Geometry> getBinding()
          Return the Geometry class associated with this type.
static Geometries getForBinding(java.lang.Class<? extends com.vividsolutions.jts.geom.Geometry> geomClass)
          Get the Geometries for the given Geometry class.
static Geometries getForName(java.lang.String name)
          Get the Geometries for the specified name.
static Geometries getForSQLType(int sqlType)
          Get the Geometries with the given integer SQL type code.
 java.lang.String getName()
          Return a name for this type that is suitable for text descriptions.
 java.lang.String getSimpleName()
          Get the 'simple name'.
 java.lang.Integer getSQLType()
          Return the integer SQL type code for this geometry type.
 java.lang.String toString()
          Equivalent to getName().
static Geometries valueOf(java.lang.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.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

POINT

public static final Geometries POINT

LINESTRING

public static final Geometries LINESTRING

POLYGON

public static final Geometries POLYGON

MULTIPOINT

public static final Geometries MULTIPOINT

MULTILINESTRING

public static final Geometries MULTILINESTRING

MULTIPOLYGON

public static final Geometries MULTIPOLYGON

GEOMETRY

public static final Geometries GEOMETRY

GEOMETRYCOLLECTION

public static final Geometries GEOMETRYCOLLECTION
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(java.lang.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:
java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
java.lang.NullPointerException - if the argument is null

getBinding

public java.lang.Class<? extends com.vividsolutions.jts.geom.Geometry> getBinding()
Return the Geometry class associated with this type.

Returns:
the Geometry class

getSQLType

public java.lang.Integer getSQLType()
Return the integer SQL type code for this geometry type.

Returns:
integer code

toString

public java.lang.String toString()
Equivalent to getName().

Overrides:
toString in class java.lang.Enum<Geometries>
Returns:
the name of this type

getName

public java.lang.String getName()
Return a name for this type that is suitable for text descriptions.

Returns:
the name

getSimpleName

public java.lang.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(com.vividsolutions.jts.geom.Geometry geom)
Get the Geometries for the given object.

Parameters:
geom - a JTS Geometry object
Returns:
the Geometries for the argument's class, or null if the argument is null

getForBinding

public static Geometries getForBinding(java.lang.Class<? extends com.vividsolutions.jts.geom.Geometry> geomClass)
Get the Geometries for the given Geometry class.

Parameters:
geomClass - the class
Returns:
the constant for this class

getForName

public static Geometries getForName(java.lang.String name)
Get the Geometries for 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 the Geometries with the given integer SQL type code.

Parameters:
sqlType - the code to look up.
Returns:
the matching type or null if no match was found


Copyright © 1996-2010 Geotools. All Rights Reserved.