public abstract class GridFeatureBuilder extends Object
GridFeatureBuilder builder = new GridFeatureBuilder(myFeatureType) {
private int id = 0;
public setAttributes(GridElement el, Map attributes) {
// assumes "id" and "value" are valid property names for
// the feature type
attributes.put("id", ++id);
attributes.put("value", myValueGettingFunction(el.toPolygon()));
}
};
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_GEOMETRY_ATTRIBUTE_NAME
Default name for the geometry attribute: "element"
|
Constructor and Description |
---|
GridFeatureBuilder(SimpleFeatureType type)
Creates a
GridFeatureBuilder to work with the given feature type. |
Modifier and Type | Method and Description |
---|---|
boolean |
getCreateFeature(GridElement el)
Tests whether a feature will be constructed for the given
GridElement . |
String |
getFeatureID(GridElement el)
Gets the
FeatureID as a String for a new SimpleFeature being
constructed from the given GridElement . |
SimpleFeatureType |
getType()
Gets the feature type.
|
abstract void |
setAttributes(GridElement el,
Map<String,Object> attributes)
Sets the values of attributes for a new
SimpleFeature being constructed from the
given GridElement . |
public static final String DEFAULT_GEOMETRY_ATTRIBUTE_NAME
public GridFeatureBuilder(SimpleFeatureType type)
GridFeatureBuilder
to work with the given feature type.type
- the feature typepublic SimpleFeatureType getType()
public abstract void setAttributes(GridElement el, Map<String,Object> attributes)
SimpleFeature
being constructed from the
given GridElement
.
This method must be overridden by the user. It is called by the grid building classes as each new feature is constructed.
el
- the element from which the new feature is being constructedattributes
- a Map
with attribute names as keys and attribute values as valuespublic String getFeatureID(GridElement el)
FeatureID
as a String
for a new SimpleFeature
being
constructed from the given GridElement
.
It is optional to override this method. The base implementation returns null
.
el
- the element from which the new feature is being constructedpublic boolean getCreateFeature(GridElement el)
GridElement
. This can be
overriden to create vector grids with 'holes' where elements are not required, for example,
based on location or the relationship to other data layers.
The base implementation always returns true
.
el
- the element from which the new feature would be constructedtrue
to create a feature for the element; false
to skip the elementCopyright © 1996–2023 Geotools. All rights reserved.