schmitzm.geotools.feature
Class FeatureUtil

java.lang.Object
  extended by schmitzm.geotools.feature.FeatureUtil

public class FeatureUtil
extends Object

Diese Klasse beinhaltet statische Methoden zum Arbeiten mit Features.

Version:
1.1
Author:
Martin Schmitz (University of Bonn/Germany), Stefan Alfons Krüger

Nested Class Summary
static class FeatureUtil.GeometryForm
          The geometry type of a FeatureCollection
static class FeatureUtil.JoinType
          Join-Types.
 
Field Summary
static AttributeTypeFactory ATTRTYPE_FACTORY
          Instance of AttributeTypeFactory.
static org.opengis.filter.FilterFactory FILTER_FACTORY
          Instance of FilterFactory.
static FilterFactory2 FILTER_FACTORY2
          Instance of FilterFactory2.
static GeometryFactory GEOMETRY_FACTORY
          Instance of JTS-GeometryFactory.
static ResourceProvider RESOURCE
          ResourceProvider, der die Lokalisation fuer Komponenten des Package schmitzm.geotools.feature zur Verfuegung stellt.
 
Constructor Summary
FeatureUtil()
           
 
Method Summary
static Double calcAvgNN(StyledFeaturesInterface<?> styledFeatures)
          This method determines the average distance to next centroid.
static AttributeDescriptor cloneAttributeType(AttributeDescriptor aType, Boolean nillable)
          Clones an AttributeDescriptor.
static SimpleFeatureType cloneFeatureType(SimpleFeatureType fType, String fTypeName, Boolean nillable)
          Clones an SimpleFeatureType.
static Style createDefaultStyle( fc)
          Erzeugt einen Standard-Style fuer eine FeatureCollection Und setzt eine default namen
static Style createDefaultStyle(GeometryDescriptor geometryAttrib)
          Erzeugt einen Standard-Style fuer einen GeometryAttributeType Und setzt eine default Namen.
static SimpleFeature createFeature(SimpleFeatureType schema, boolean forceNewBuilder, String fID, Object... attrValues)
          Creates a new feature for a given schema.
static SimpleFeature createFeature(SimpleFeatureType schema, Object... attrValues)
          Creates a new feature for a given schema with a random generated id.
static SimpleFeature createFeature(SimpleFeatureType schema, String fID, Object... attrValues)
          Creates a new feature for a given schema.
static  createFeatureCollection(ResultSet rs, String... projAttr)
          Erzeugt eine FeatureCollection aus einem SQL-Result.
static SimpleFeatureType createFeatureType(Class<?> geomType)
          Creates a default SimpleFeatureType for a given Geometry class
static SimpleFeatureType createFeatureType(ResultSetMetaData metaData, String... projAttr)
          Erzeugt einen SimpleFeatureType aus einem SQL-Result.
static SimpleFeatureType createFeatureType(ResultSetMetaData metaData, String featureTypeName, Class<?> defaultAttrClass, String... projAttr)
          Erzeugt einen SimpleFeatureType aus einem SQL-Result.
static SimpleFeatureType createFeatureType(String featureTypeName, Map<String,Object> attrValues, Class<?> defaultAttrClass)
          Erzeugt einen SimpleFeatureType aus Beispiel-Attribut-Werten.
static GeometryAttributeType createGeometryAttributeType(Class<? extends Geometry> geomType, Geometry defGeom, CoordinateReferenceSystem crs)
          Erzeugt einen Geometrie-Attribut-Typ.
static GeometryAttributeType createGeometryAttributeType(String attrName, Class<? extends Geometry> geomType, Geometry defGeom, CoordinateReferenceSystem crs)
          Erzeugt einen Geometrie-Attribut-Typ.
static Style createLineStyle(Color lineColor)
          Erzeugt einen Linien-Style.
static Style createLineStyle(Color lineColor, double lineWidth)
          Erzeugt einen Linien-Style.
static  createMemoryFeatureSource( features)
          Erstellt eine FeatureSource basierend auf einem MemoryDataStore für eine übergebene FeatureCollection
static Style createPointStyle(Color fillColor)
          Erzeugt einen (randlosen) Punkt-Style in Form eines Kreises.
static Style createPointStyle(Color fillColor, Color borderColor, double width)
          Erzeugt einen (randlosen) Punkt-Style in Form eines Kreises.
static Style createPointStyle(String markStyle, Color fillColor, Color borderColor, double borderWidth, double opacity, double size, double rotation)
          Erzeugt einen Punkt-Style.
static Style createPolygonStyle(Color fillColor, Color borderColor, double borderWidth)
          Erzeugt einen Polygon-Style.
static SimpleFeature createSampleFeature(SimpleFeatureType schema, Object... values)
          Creates a sample SimpleFeature instance of the given SimpleFeatureType
static  extendFeatureCollection( fc, AttributeDescriptor... aTypes)
          Erweitert das Schema einer FeatureCollection um eine Reihe von Attributen.
static SimpleFeatureType extendFeatureType(SimpleFeatureType fType, AttributeDescriptor... aTypes)
          Erweitert das Schema einer FeatureCollection um eine Reihe von Attributen.
static SimpleFeatureType extendFeatureType(SimpleFeatureType fType, List<AttributeDescriptor> aTypes)
          Erweitert das Schema einer FeatureCollection um eine Reihe von Attributen.
static Vector<Geometry> extractGeometries( fc, Vector<Geometry> result)
          Extrahiert alle Default-Geometrien aus einer FeatureCollection.
static Geometry[] extractGeometriesToGeometry(SimpleFeature f)
          Extrahiert alle Geometrien aus einem SimpleFeature.
static SimpleFeature[] featuresToArray( fc)
          Erzeugt einen Array von Features auf einer FeatureCollection.
static SimpleFeature[] featuresToArray( fc, boolean includeNullFeatures)
          Erzeugt einen Array von Features auf einer FeatureCollection.
static Name findBestMatchingAttribute(SimpleFeatureType schema, String localName)
          Checks whether the given attribute local name exists in the schema.
static Name findBestMatchingAttributeFallBackFirst(SimpleFeatureType schema, String localName)
          Checks whether the given attribute local name exists in the schema.
static Map<String,Object> getAttributeValues(SimpleFeature f, Map<String,Object> destMap, String... attrName)
          Liefert eine Reihen von Attributwerten eines Features.
static Object[] getAttributeValues(SimpleFeature f, Object[] destArray, int destStartIdx, String... attrName)
          Liefert eine Reihen von Attributwerten eines Features.
static Object[] getAttributeValues(SimpleFeature f, String... attrName)
          Liefert eine Reihen von Attributwerten eines Features.
static AutoValueGenerator<?> getAutoValueGenerator(AttributeDescriptor aType)
          Liefert den AutoValueGenerator fuer einen AttributeDescriptor.
static Object getDefaultAttributeValue(AttributeDescriptor attrType)
          Liefert den Default-Wert fuer ein Attribut.
static Object getDefaultAttributeValue(AttributeDescriptor attrType, boolean allowNull)
          Liefert den Default-Wert fuer ein Attribut.
static Object[] getDefaultAttributeValues(SimpleFeatureType ft)
          Liefert die Default-Werte fuer alle Attribute eines SimpleFeatureType.
static Object[] getDefaultAttributeValues(SimpleFeatureType ft, Object[] destArray, int destStartIdx, String... attrName)
          Liefert die Default-Werte fuer eine Reihen von Attributwerten eines FeatureTypes.
static FeatureUtil.GeometryForm getGeometryForm( fc)
          Determines the kind of geometry of a FeatureCollection.
static FeatureUtil.GeometryForm getGeometryForm( fs)
          Determines the kind of geometry of a FeatureSource.
static FeatureUtil.GeometryForm getGeometryForm(GeometryAttributeType geometryType)
          Determines the kind of geometry of a GeometryAttributeType.
static FeatureUtil.GeometryForm getGeometryForm(GeometryDescriptor gDesc)
          Determines the kind of geometry of a GeometryDescriptor.
static FeatureUtil.GeometryForm getGeometryForm(MapLayer layer)
          Determines the kind of geometry of a MapLayer.
static FeatureUtil.GeometryForm getGeometryForm(SimpleFeatureType fType)
          Determines the kind of geometry of a SimpleFeatureType.
static Object getLayerSourceObject(MapLayer mapLayer)
           
static Object getNextAutoValue(AttributeDescriptor aType)
          Liefert den naechsten Auto-Wert fuer einen AttributeDescriptor.
static Object getWrappedGeoObject( featureSource)
          Liefert das Objekt (GridCoverage2D oder FeatureCollection oder GridCoverager oder GridCoverageReader auf dem ein Layer basiert.
static Object getWrappedGeoObject( fc)
          Liefert das Objekt (GridCoverage2D oder FeatureCollection oder GridCoverager oder GridCoverageReader auf dem ein Layer basiert.
static  joinFeatureCollection( fc1, String joinAttr1,  fc2, String joinAttr2, String... projAttr)
          Fuehrt eine (Full-Outer-) Equi-Join-Operation zwischen zwei FeatureCollection durch.
static  joinFeatureCollection( fc1, String joinAttr1, AttributeFilter compareOp,  fc2, String joinAttr2, String... projAttr)
          Fuehrt eine (Full-Outer-) Join-Operation zwischen zwei FeatureCollection durch.
static  joinFeatureCollection( fc, String fcJoinAttr, AttributeFilter compareOp, ResultSet rs, String rsJoinAttr, String... projAttr)
          Fuehrt eine Join-Operation zwischen einer FeatureCollection und einem ResultSet durch, in dem Zusatz-Informationen hinterlegt.
static  joinFeatureCollection( fc, String fcJoinAttr, ResultSet rs, String rsJoinAttr, String... projAttr)
          Fuehrt eine Join-Operation zwischen einer FeatureCollection und einem ResultSet durch, in dem Zusatz-Informationen hinterlegt.
static  joinFeatureCollection(FeatureUtil.JoinType joinType,  fc1, String joinAttr1, AttributeFilter compareOp,  fc2, String joinAttr2, String... projAttr)
          Fuehrt eine Join-Operation zwischen zwei FeatureCollection durch.
static  joinFeatureCollection(FeatureUtil.JoinType joinType,  fc, String fcJoinAttr, AttributeFilter compareOp, ResultSet rs, String rsJoinAttr, String... projAttr)
          Fuehrt eine Join-Operation zwischen einer FeatureCollection und einem ResultSet durch, in dem Zusatz-Informationen hinterlegt.
static String R(String key, Object... values)
          Convenience method to access the ResourceProvider.
static void registerAutoValueGenerator(AttributeDescriptor aType, AutoValueGenerator<?> generator)
          Registriert einen AutoValueGenerator fuer einen AttributeDescriptor, so dass getNextAutoValue(AttributeDescriptor) fuer diesen AttributeDescriptor verwendet werden kann.
static Vector<SimpleFeature> sortFeatures( fc, String attrName)
          Orderes Features according to an attribute (ascending).
protected static Vector<SimpleFeature> sortFeatures( fi, String attrName)
          Orderes Features according to an attribute (ascending).
static void unregisterAutoValueGenerator(AttributeDescriptor aType)
          Entfernt einen AutoValueGenerator fuer einen AttributeDescriptor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE

public static ResourceProvider RESOURCE
ResourceProvider, der die Lokalisation fuer Komponenten des Package schmitzm.geotools.feature zur Verfuegung stellt. Diese sind in properties-Dateien unter schmitzm.geotools.feature.resource.locales hinterlegt.


GEOMETRY_FACTORY

public static final GeometryFactory GEOMETRY_FACTORY
Instance of JTS-GeometryFactory.


ATTRTYPE_FACTORY

public static final AttributeTypeFactory ATTRTYPE_FACTORY
Instance of AttributeTypeFactory.


FILTER_FACTORY

public static final org.opengis.filter.FilterFactory FILTER_FACTORY
Instance of FilterFactory.


FILTER_FACTORY2

public static final FilterFactory2 FILTER_FACTORY2
Instance of FilterFactory2.

Constructor Detail

FeatureUtil

public FeatureUtil()
Method Detail

R

public static String R(String key,
                       Object... values)
Convenience method to access the ResourceProvider.


getGeometryForm

public static FeatureUtil.GeometryForm getGeometryForm(SimpleFeatureType fType)
Determines the kind of geometry of a SimpleFeatureType.

Parameters:
fType - a feature type

getGeometryForm

public static FeatureUtil.GeometryForm getGeometryForm(GeometryDescriptor gDesc)
Determines the kind of geometry of a GeometryDescriptor.


getGeometryForm

public static FeatureUtil.GeometryForm getGeometryForm(GeometryAttributeType geometryType)
Determines the kind of geometry of a GeometryAttributeType.

Parameters:
geometryType - a GeometryAttributeType

getGeometryForm

public static FeatureUtil.GeometryForm getGeometryForm( fc)
Determines the kind of geometry of a FeatureCollection.

Parameters:
fc - a feature collection

getGeometryForm

public static FeatureUtil.GeometryForm getGeometryForm( fs)
Determines the kind of geometry of a FeatureSource.

Parameters:
fs - a feature source

getGeometryForm

public static FeatureUtil.GeometryForm getGeometryForm(MapLayer layer)
Determines the kind of geometry of a MapLayer.

Parameters:
layer - a map layer

extractGeometriesToGeometry

public static Geometry[] extractGeometriesToGeometry(SimpleFeature f)
Extrahiert alle Geometrien aus einem SimpleFeature.

Parameters:
f - SimpleFeature
Returns:
Array aller Geometrien im SimpleFeature.

extractGeometries

public static Vector<Geometry> extractGeometries( fc,
                                                 Vector<Geometry> result)
Extrahiert alle Default-Geometrien aus einer FeatureCollection.

Parameters:
fc - FeatureCollection
Returns:
Array aller Geometrien in der FeatureCollection.

createDefaultStyle

public static Style createDefaultStyle( fc)
Erzeugt einen Standard-Style fuer eine FeatureCollection Und setzt eine default namen

Parameters:
fc - FeatureCollection

createDefaultStyle

public static Style createDefaultStyle(GeometryDescriptor geometryAttrib)
Erzeugt einen Standard-Style fuer einen GeometryAttributeType Und setzt eine default Namen.

Parameters:
geometryAttrib - GeometryAttributeType

createPolygonStyle

public static Style createPolygonStyle(Color fillColor,
                                       Color borderColor,
                                       double borderWidth)
Erzeugt einen Polygon-Style.

Parameters:
fillColor - Fuell-Farbe
borderColor - Rand-Farbe
borderWidth - Breite des Rands

createPointStyle

public static Style createPointStyle(Color fillColor)
Erzeugt einen (randlosen) Punkt-Style in Form eines Kreises.

Parameters:
color - Farbe des Punkts

createPointStyle

public static Style createPointStyle(Color fillColor,
                                     Color borderColor,
                                     double width)
Erzeugt einen (randlosen) Punkt-Style in Form eines Kreises.

Parameters:
fillColor - Fuell-Farbe des Punkts
borderColor - Rand-Farbe des Punkts
width - Groesse des Punkts

createPointStyle

public static Style createPointStyle(String markStyle,
                                     Color fillColor,
                                     Color borderColor,
                                     double borderWidth,
                                     double opacity,
                                     double size,
                                     double rotation)
Erzeugt einen Punkt-Style.

Parameters:
color - Farbe des Punkts
markStyle - Darstellungsweise des Punkts
opacity -
See Also:
StyleBuilder#MARK_ARROW;, StyleBuilder#MARK_CIRCLE;, StyleBuilder#MARK_CROSS;, StyleBuilder#MARK_SQUARE;, StyleBuilder#MARK_STAR;, StyleBuilder#MARK_TRIANGLE;, StyleBuilder#MARK_X;

createLineStyle

public static Style createLineStyle(Color lineColor)
Erzeugt einen Linien-Style.

Parameters:
lineColor - Farbe der Linie

createLineStyle

public static Style createLineStyle(Color lineColor,
                                    double lineWidth)
Erzeugt einen Linien-Style.

Parameters:
lineColor - Farbe der Linie
lineWidth - Breite der Linie

featuresToArray

public static SimpleFeature[] featuresToArray( fc)
Erzeugt einen Array von Features auf einer FeatureCollection.
Aufgrund von Problemen bei der Verwendung von Filtern (.size() liefert nicht die Anzahl der gefilterten Features; .toArray liefert manchmal null), wird der Array "naiv" ueber Durchlaufen eines FeatureIterator kopiert.

Parameters:
fc - eine SimpleFeature Collection
Returns:
einen leeren Array, wenn die Collection leer oder null ist

featuresToArray

public static SimpleFeature[] featuresToArray( fc,
                                              boolean includeNullFeatures)
Erzeugt einen Array von Features auf einer FeatureCollection.

Parameters:
fc - eine SimpleFeature Collection
includeNullFeatures - wenn false werden NULL-Features in der Collection nicht in den Array kopiert
Returns:
einen leeren Array, wenn die Collection leer oder null ist

cloneFeatureType

public static SimpleFeatureType cloneFeatureType(SimpleFeatureType fType,
                                                 String fTypeName,
                                                 Boolean nillable)
                                          throws SchemaException
Clones an SimpleFeatureType.

Parameters:
fType - type to clone
fTypeName - the name for the clone (if null the name is taken from fType)
nillable - nillable property for all attributes (if null the nillable property is taken individually from the source attributes)
Throws:
SchemaException

cloneAttributeType

public static AttributeDescriptor cloneAttributeType(AttributeDescriptor aType,
                                                     Boolean nillable)
Clones an AttributeDescriptor.

Parameters:
aType - type to clone
nillable - the clone gets this value for its nillable property independently of aType.isNillable() (if null the nillable property is taken from aType)

extendFeatureType

public static SimpleFeatureType extendFeatureType(SimpleFeatureType fType,
                                                  List<AttributeDescriptor> aTypes)
                                           throws SchemaException
Erweitert das Schema einer FeatureCollection um eine Reihe von Attributen.

Parameters:
fType - zu erweiterndes SimpleFeature-Schema
aTypes - Typen der neuen Attribute
Returns:
eine neue Instanz von SimpleFeatureType
Throws:
SchemaException - falls das Erweitern des SimpleFeature-Schemas scheitert
NullPointerException - falls fType = null

extendFeatureType

public static SimpleFeatureType extendFeatureType(SimpleFeatureType fType,
                                                  AttributeDescriptor... aTypes)
                                           throws SchemaException
Erweitert das Schema einer FeatureCollection um eine Reihe von Attributen.

Parameters:
fType - zu erweiterndes SimpleFeature-Schema
aTypes - Typen der neuen Attribute
Returns:
eine neue Instanz von SimpleFeatureType
Throws:
SchemaException - falls das Erweitern des SimpleFeature-Schemas scheitert
NullPointerException - falls fType = null

sortFeatures

public static Vector<SimpleFeature> sortFeatures( fc,
                                                 String attrName)
Orderes Features according to an attribute (ascending).

Parameters:
fi - the features to order
attrName - the attribute to order by
Returns:
a list of ordered features

sortFeatures

protected static Vector<SimpleFeature> sortFeatures( fi,
                                                    String attrName)
Orderes Features according to an attribute (ascending).

Parameters:
fi - an iterator for the features
attrName - the attribute to order by
Returns:
a list of ordered features
See Also:
#sortFeatures(FeatureCollection, String)

extendFeatureCollection

public static  extendFeatureCollection( fc,
                                            AttributeDescriptor... aTypes)
                                     throws SchemaException,
                                            IllegalAttributeException
Erweitert das Schema einer FeatureCollection um eine Reihe von Attributen.

Parameters:
fc - zu erweiternde FeatureCollection
aTypes - Typen der neuen Attribute
Returns:
eine neue Instanz von FeatureCollection
Throws:
SchemaException - falls das Erweitern des SimpleFeature-Schemas scheitert
IllegalAttributeException - falls das Einfuegen der Features in die neue FeatureCollection scheitert

joinFeatureCollection

public static  joinFeatureCollection(FeatureUtil.JoinType joinType,
                                           fc1,
                                          String joinAttr1,
                                          AttributeFilter compareOp,
                                           fc2,
                                          String joinAttr2,
                                          String... projAttr)
                                   throws SchemaException,
                                          IllegalAttributeException
Fuehrt eine Join-Operation zwischen zwei FeatureCollection durch. Hierfuer wird eine einfacher Nested-Loop-Join durchgefuehrt. In den optionalen Parametern koennen Attribut-Namen angegeben werden, die in die Ergebnis-Colletion uebernommen werden (Projektion).
Achtung: Wird diese Option verwendet, sollte sichergestellt sein, dass fc1 und fc2 KEINE gleichen Attributnamen hat! Ansonsten wird (aus technischen Gruenden) das Attribut von fc2 uebernommen.

Parameters:
fc1 - erste FeatureCollection
joinAttr1 - Attribut-Name in der ersten FeatureCollection
compareOp - Operation, mit der der JOIN-Vergleich durchgefuehrt wird
fc2 - zweiten FeatureCollection
joinAttr2 - Attribut-Name in der zweiten FeatureCollection
projAttr - Attribute (von fc1 und fc2), die in das Ergebnis übernommen werden (Projektion)
Returns:
eine neue Instanz von FeatureCollection
Throws:
SchemaException - falls das Erweitern des SimpleFeature-Schemas scheitert
IllegalAttributeException - falls das Einfuegen der Features in die neue FeatureCollection scheitert

joinFeatureCollection

public static  joinFeatureCollection( fc1,
                                          String joinAttr1,
                                          AttributeFilter compareOp,
                                           fc2,
                                          String joinAttr2,
                                          String... projAttr)
                                   throws SchemaException,
                                          IllegalAttributeException
Fuehrt eine (Full-Outer-) Join-Operation zwischen zwei FeatureCollection durch. Hierfuer wird eine einfacher Nested-Loop-Join durchgefuehrt. In den optionalen Parametern koennen Attribut-Namen angegeben werden, die in die Ergebnis-Colletion uebernommen werden (Projektion).
Achtung: Wird diese Option verwendet, sollte sichergestellt sein, dass fc1 und fc2 KEINE gleichen Attributnamen hat! Ansonsten wird (aus technischen Gruenden) das Attribut von fc2 uebernommen.

Parameters:
fc1 - erste FeatureCollection
joinAttr1 - Attribut-Name in der ersten FeatureCollection
compareOp - Operation, mit der der JOIN-Vergleich durchgefuehrt wird
fc2 - zweiten FeatureCollection
joinAttr2 - Attribut-Name in der zweiten FeatureCollection
projAttr - Attribute (von fc1 und fc2), die in das Ergebnis übernommen werden (Projektion)
Returns:
eine neue Instanz von FeatureCollection
Throws:
SchemaException - falls das Erweitern des SimpleFeature-Schemas scheitert
IllegalAttributeException - falls das Einfuegen der Features in die neue FeatureCollection scheitert

joinFeatureCollection

public static  joinFeatureCollection( fc1,
                                          String joinAttr1,
                                           fc2,
                                          String joinAttr2,
                                          String... projAttr)
                                   throws SchemaException,
                                          IllegalAttributeException
Fuehrt eine (Full-Outer-) Equi-Join-Operation zwischen zwei FeatureCollection durch.

Parameters:
fc1 - erste FeatureCollection
joinAttr1 - Attribut-Name in der ersten FeatureCollection
fc2 - zweiten FeatureCollection
joinAttr2 - Attribut-Name in der zweiten FeatureCollection
projAttr - Attribute (von fc1 und fc2), die in das Ergebnis übernommen werden (Projektion)
Returns:
eine neue Instanz von FeatureCollection
Throws:
SchemaException - falls das Erweitern des SimpleFeature-Schemas scheitert
IllegalAttributeException - falls das Einfuegen der Features in die neue FeatureCollection scheitert
See Also:
#joinFeatureCollection(FeatureCollection, String, AttributeFilter, FeatureCollection, String), #AttributeFilter

getDefaultAttributeValues

public static Object[] getDefaultAttributeValues(SimpleFeatureType ft)
Liefert die Default-Werte fuer alle Attribute eines SimpleFeatureType.

Parameters:
ft - ein SimpleFeature-Type

getDefaultAttributeValues

public static Object[] getDefaultAttributeValues(SimpleFeatureType ft,
                                                 Object[] destArray,
                                                 int destStartIdx,
                                                 String... attrName)
Liefert die Default-Werte fuer eine Reihen von Attributwerten eines FeatureTypes.

Parameters:
ft - ein SimpleFeature-Type
destArray - Array, in dem die Objekte abgelegt werden (wenn null, wird ein neuer Array erzeugt)
destStartIdx - Start-Index in destArray ab dem die Attributwerte abgelegt werden
attrName - Attribute aus f
Returns:
destArray oder einen neuen Array Object[destStartIdx + attrName.length]

getDefaultAttributeValue

public static Object getDefaultAttributeValue(AttributeDescriptor attrType)
Liefert den Default-Wert fuer ein Attribut.

Parameters:
attrType - Attribut-Typ
Returns:
null, wenn das Attribut NILLABLE ist

getDefaultAttributeValue

public static Object getDefaultAttributeValue(AttributeDescriptor attrType,
                                              boolean allowNull)
Liefert den Default-Wert fuer ein Attribut.

Parameters:
attrType - Attribut-Typ
allowNull - wenn false, wird in jedem Fall ein Wert ungleich null geliefert, auch wenn das Attribut NILLABLE ist

getAttributeValues

public static Object[] getAttributeValues(SimpleFeature f,
                                          Object[] destArray,
                                          int destStartIdx,
                                          String... attrName)
Liefert eine Reihen von Attributwerten eines Features.

Parameters:
f - ein SimpleFeature
destArray - Array, in dem die Objekte abgelegt werden (wenn null, wird ein neuer Array erzeugt)
destStartIdx - Start-Index in destArray ab dem die Attributwerte abgelegt werden
attrName - Attribute des Features, deren Werte geliefert werden (wenn null werden alle Attribute geliefert)
Returns:
destArray oder einen neuen Array Object[destStartIdx + attrName.length]

getAttributeValues

public static Object[] getAttributeValues(SimpleFeature f,
                                          String... attrName)
Liefert eine Reihen von Attributwerten eines Features.

Parameters:
f - ein SimpleFeature
attrName - Attribute des Features, deren Werte geliefert werden (wenn null werden alle Attribute geliefert)
Returns:
neuer Array Object[attrName.length]

getAttributeValues

public static Map<String,Object> getAttributeValues(SimpleFeature f,
                                                    Map<String,Object> destMap,
                                                    String... attrName)
Liefert eine Reihen von Attributwerten eines Features.

Parameters:
f - ein SimpleFeature
destMap - Map, in dem die Objekte abgelegt werden (wenn null, wird eine neue HashMap erzeugt)
attrName - Attribute des Features, deren Werte geliefert werden (wenn null werden alle Attribute geliefert)
Returns:
destArray oder einen neuen Array Object[destStartIdx + attrName.length]

joinFeatureCollection

public static  joinFeatureCollection( fc,
                                          String fcJoinAttr,
                                          ResultSet rs,
                                          String rsJoinAttr,
                                          String... projAttr)
                                   throws SchemaException,
                                          IllegalAttributeException,
                                          SQLException
Fuehrt eine Join-Operation zwischen einer FeatureCollection und einem ResultSet durch, in dem Zusatz-Informationen hinterlegt. Hierzu wird das ResultSet zunaecht in eine FeatureCollection umgewandelt und anschliessend ein Left-Outer-EquiJoin zwischen den beiden Collections ausgewertet.

Parameters:
fc - eine FeatureCollection
fcJoinAttr - JOIN-Attribut in der FeatureCollection
rs - ResultSet mit Zusatz-Informationen
rsJoinAttr - JOIN-Attribut im ResultSet
Returns:
eine neue Instanz von FeatureCollection
Throws:
SchemaException - falls das Erweitern des SimpleFeature-Schemas scheitert
IllegalAttributeException - falls das Einfuegen der Features in die neue FeatureCollection scheitert
SQLException

joinFeatureCollection

public static  joinFeatureCollection( fc,
                                          String fcJoinAttr,
                                          AttributeFilter compareOp,
                                          ResultSet rs,
                                          String rsJoinAttr,
                                          String... projAttr)
                                   throws SchemaException,
                                          IllegalAttributeException,
                                          SQLException
Fuehrt eine Join-Operation zwischen einer FeatureCollection und einem ResultSet durch, in dem Zusatz-Informationen hinterlegt. Hierzu wird das ResultSet zunaecht in eine FeatureCollection umgewandelt und anschliessend ein Left-Outer-Join zwischen den beiden Collections ausgewertet.

Parameters:
fc - eine FeatureCollection
fcJoinAttr - JOIN-Attribut in der FeatureCollection
compareOp - Operation, mit der der JOIN-Vergleich durchgefuehrt wird
rs - ResultSet mit Zusatz-Informationen
rsJoinAttr - JOIN-Attribut im ResultSet
Returns:
eine neue Instanz von FeatureCollection
Throws:
SchemaException - falls das Erweitern des SimpleFeature-Schemas scheitert
IllegalAttributeException - falls das Einfuegen der Features in die neue FeatureCollection scheitert
SQLException

joinFeatureCollection

public static  joinFeatureCollection(FeatureUtil.JoinType joinType,
                                           fc,
                                          String fcJoinAttr,
                                          AttributeFilter compareOp,
                                          ResultSet rs,
                                          String rsJoinAttr,
                                          String... projAttr)
                                   throws SchemaException,
                                          IllegalAttributeException,
                                          SQLException
Fuehrt eine Join-Operation zwischen einer FeatureCollection und einem ResultSet durch, in dem Zusatz-Informationen hinterlegt. Hierzu wird das ResultSet zunaecht in eine FeatureCollection umgewandelt und anschliessend ein Join zwischen den beiden Collections ausgewertet.

Parameters:
joinType - Join-Typ
fc - eine FeatureCollection
fcJoinAttr - JOIN-Attribut in der FeatureCollection
compareOp - Operation, mit der der JOIN-Vergleich durchgefuehrt wird
rs - ResultSet mit Zusatz-Informationen
rsJoinAttr - JOIN-Attribut im ResultSet
Returns:
eine neue Instanz von FeatureCollection
Throws:
SchemaException - falls das Erweitern des SimpleFeature-Schemas scheitert
IllegalAttributeException - falls das Einfuegen der Features in die neue FeatureCollection scheitert
SQLException

createFeatureCollection

public static  createFeatureCollection(ResultSet rs,
                                            String... projAttr)
                                     throws SchemaException,
                                            IllegalAttributeException,
                                            SQLException
Erzeugt eine FeatureCollection aus einem SQL-Result.

Parameters:
rs - SQL-Result
projAttr - nur diese Attribute des ResultSet werden in die FeatureCollection uebernommen (wenn nicht angegeben, werden ALLE Attribute uebernommen)
Throws:
SQLException - falls der Zugriff auf die SQL-Metadaten scheitert
SchemaException - falls das Erzeugen des SimpleFeatureType scheitert
IllegalAttributeException - falls das Erzeugen eines Features scheitert

createFeatureType

public static SimpleFeatureType createFeatureType(ResultSetMetaData metaData,
                                                  String... projAttr)
                                           throws SQLException,
                                                  SchemaException
Erzeugt einen SimpleFeatureType aus einem SQL-Result.

Parameters:
metaData - SQL-Metadaten des ResultSet
projAttr - nur diese Attribute des ResultSet werden in den SimpleFeatureType uebernommen (wenn nicht angegeben, werden ALLE Attribute uebernommen)
Throws:
SQLException - falls der Zugriff auf die SQL-Metadaten scheitert
SchemaException - falls das Erzeugen des SimpleFeatureType scheitert

createFeatureType

public static SimpleFeatureType createFeatureType(ResultSetMetaData metaData,
                                                  String featureTypeName,
                                                  Class<?> defaultAttrClass,
                                                  String... projAttr)
                                           throws SQLException,
                                                  SchemaException,
                                                  ClassNotFoundException
Erzeugt einen SimpleFeatureType aus einem SQL-Result.

Parameters:
metaData - SQL-Metadaten des ResultSet
featureTypeName - Name fuer den SimpleFeatureType (kann null sein)
defaultAttrClass - Klasse, die verwendet als Attribut-Typ wird, wenn die entsprechende Klasse des ResultSet nicht zur Verfuegung steht (wenn null, wird eine Exception geworfen)
projAttr - nur diese Attribute des ResultSet werden in den SimpleFeatureType uebernommen (wenn nicht angegeben, werden ALLE Attribute uebernommen)
Throws:
SQLException - falls der Zugriff auf die SQL-Metadaten scheitert
SchemaException - falls das Erzeugen des SimpleFeatureType scheitert
ClassNotFoundException - falls eine Attribut-Klasse aus dem ResultSet nicht erzeugt werden kann und keine Default-Klasse angegeben ist

createFeatureType

public static SimpleFeatureType createFeatureType(String featureTypeName,
                                                  Map<String,Object> attrValues,
                                                  Class<?> defaultAttrClass)
                                           throws SchemaException
Erzeugt einen SimpleFeatureType aus Beispiel-Attribut-Werten.

Parameters:
featureTypeName - Name fuer den SimpleFeatureType (kann null sein)
attrValues - Attribut-Werte
defaultAttrClass - Standard-Typ, der fuer ein Attribut verwendet wird, wenn der angegebene Attribut-Wert null ist.
Throws:
SchemaException - falls das Erzeugen des SimpleFeatureType scheitert

createFeatureType

public static SimpleFeatureType createFeatureType(Class<?> geomType)
Creates a default SimpleFeatureType for a given Geometry class

Parameters:
geomType - LineString.class, Point.class or Polygon.class from com.jts...

createGeometryAttributeType

public static GeometryAttributeType createGeometryAttributeType(Class<? extends Geometry> geomType,
                                                                Geometry defGeom,
                                                                CoordinateReferenceSystem crs)
Erzeugt einen Geometrie-Attribut-Typ.

Parameters:
geomType - Art der Geometrie
defGeom - Standard-Wert
crs - Koordinatensystem

createGeometryAttributeType

public static GeometryAttributeType createGeometryAttributeType(String attrName,
                                                                Class<? extends Geometry> geomType,
                                                                Geometry defGeom,
                                                                CoordinateReferenceSystem crs)
Erzeugt einen Geometrie-Attribut-Typ.

Parameters:
attrName - Name des attribute (wenn null, wird "the_geom" verwendet)
geomType - Art der Geometrie
defGeom - Standard-Wert
crs - Koordinatensystem

registerAutoValueGenerator

public static void registerAutoValueGenerator(AttributeDescriptor aType,
                                              AutoValueGenerator<?> generator)
Registriert einen AutoValueGenerator fuer einen AttributeDescriptor, so dass getNextAutoValue(AttributeDescriptor) fuer diesen AttributeDescriptor verwendet werden kann.

Parameters:
aType - ein AttributeDescriptor
generator - generiert automatische Attribut-Werte

unregisterAutoValueGenerator

public static void unregisterAutoValueGenerator(AttributeDescriptor aType)
Entfernt einen AutoValueGenerator fuer einen AttributeDescriptor.

Parameters:
aType - ein AttributeDescriptor

getAutoValueGenerator

public static AutoValueGenerator<?> getAutoValueGenerator(AttributeDescriptor aType)
Liefert den AutoValueGenerator fuer einen AttributeDescriptor.

Parameters:
aType - ein AttributeDescriptor
Returns:
null, wenn fuer den AttributeDescriptor noch kein AutoValueGenerator registriert worden ist

getNextAutoValue

public static Object getNextAutoValue(AttributeDescriptor aType)
Liefert den naechsten Auto-Wert fuer einen AttributeDescriptor.

Parameters:
aType - ein AttributeDescriptor
Throws:
UnsupportedOperationException - falls fuer das Attribut noch kein AutoValueGenerator registriert ist

createFeature

public static SimpleFeature createFeature(SimpleFeatureType schema,
                                          boolean forceNewBuilder,
                                          String fID,
                                          Object... attrValues)
Creates a new feature for a given schema.

Parameters:
schema - schema for the feature
forceNewBuilder - forces the creation of a new SimpleFeatureBuilder
fID - feature id for the new feature
attrValues - values of the attributes

createFeature

public static SimpleFeature createFeature(SimpleFeatureType schema,
                                          String fID,
                                          Object... attrValues)
Creates a new feature for a given schema.

Parameters:
schema - schema for the feature
fID - feature id for the new feature
attrValues - values of the attributes

createFeature

public static SimpleFeature createFeature(SimpleFeatureType schema,
                                          Object... attrValues)
Creates a new feature for a given schema with a random generated id.

Parameters:
schema - schema for the feature
attrValues - values of the attributes

createSampleFeature

public static SimpleFeature createSampleFeature(SimpleFeatureType schema,
                                                Object... values)
Creates a sample SimpleFeature instance of the given SimpleFeatureType

Parameters:
schema - the schema for which to create a sample SimpleFeature instance
Throws:
org.opengis.feature.IllegalAttributeException

createMemoryFeatureSource

public static  createMemoryFeatureSource( features)
Erstellt eine FeatureSource basierend auf einem MemoryDataStore für eine übergebene FeatureCollection

Parameters:
features -

getWrappedGeoObject

public static Object getWrappedGeoObject( featureSource)
Liefert das Objekt (GridCoverage2D oder FeatureCollection oder GridCoverager oder GridCoverageReader auf dem ein Layer basiert. Ein Raster-Layer zeichnen sich dadurch aus, dass die zugrunde liegende FeatureCollection nur ein SimpleFeature enthaelt, das genau ein Attribut mit Namen "GridCoverage" und Typ GridCoverage2D oder AbstractGridCoverageReader hat. Sind diese Bedingungen erfuellt, wird das 2. Attribut zurueckgegeben, ansonsten die FeatureCollection.

Parameters:
styledFeatures - ein Layer
featureSource -
Returns:
null, falls das Objekt nicht ermittelt werden kann (da ein Fehler aufgetreten ist).
See Also:
FeatureUtilities#wrapGridCoverage(GridCoverage2D)} and {@link FeatureUtilities#wrapGridCoverageReader(AbstractGridCoverage2DReader, GeneralParameterValue[])}

getWrappedGeoObject

public static Object getWrappedGeoObject( fc)
Liefert das Objekt (GridCoverage2D oder FeatureCollection oder GridCoverager oder GridCoverageReader auf dem ein Layer basiert. Ein Raster-Layer zeichnen sich dadurch aus, dass die zugrunde liegende FeatureCollection nur ein SimpleFeature enthaelt, das genau ein Attribut mit Namen "GridCoverage" und Typ GridCoverage2D oder AbstractGridCoverageReader hat. Sind diese Bedingungen erfuellt, wird das 2. Attribut zurueckgegeben, ansonsten die FeatureCollection.

Parameters:
styledFeatures - ein Layer
featureSource -
Returns:
null, falls das Objekt nicht ermittelt werden kann (da ein Fehler aufgetreten ist).
See Also:
FeatureUtilities#wrapGridCoverage(GridCoverage2D)} and {@link FeatureUtilities#wrapGridCoverageReader(AbstractGridCoverage2DReader, GeneralParameterValue[])}

calcAvgNN

public static Double calcAvgNN(StyledFeaturesInterface<?> styledFeatures)
This method determines the average distance to next centroid.

Parameters:
styledFeatures -

getLayerSourceObject

public static Object getLayerSourceObject(MapLayer mapLayer)

findBestMatchingAttributeFallBackFirst

public static Name findBestMatchingAttributeFallBackFirst(SimpleFeatureType schema,
                                                          String localName)
Checks whether the given attribute local name exists in the schema. If no exact match is found, an ingnoreCase match is performed. If the schema has no attributes, an exception is thrown.

Parameters:
schema - SimpleFeatureType to check against
name - localname of an attribte to look for
Returns:
If no match is found, the first attribute is returned.

findBestMatchingAttribute

public static Name findBestMatchingAttribute(SimpleFeatureType schema,
                                             String localName)
Checks whether the given attribute local name exists in the schema. If no exact match is found, an ingnoreCase match is performed. If the schema has no attributes, an exception is thrown.

Parameters:
schema - SimpleFeatureType to check against
name - localname of an attribte to look for
Returns:
If no match is found, null is returned.