Package org.geotools.grid
Class GridFeatureBuilder
- Object
-
- GridFeatureBuilder
-
- Direct Known Subclasses:
DefaultGridFeatureBuilder
,LineFeatureBuilder
,OrthoLineFeatureBuilder
public abstract class GridFeatureBuilder extends Object
Controls the creating of features representing grid elements during vector grid construction.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())); } }; - Since:
- 2.7
- Author:
- mbedward
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_GEOMETRY_ATTRIBUTE_NAME
Default name for the geometry attribute: "element"
-
Constructor Summary
Constructors Constructor Description GridFeatureBuilder(SimpleFeatureType type)
Creates aGridFeatureBuilder
to work with the given feature type.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
getCreateFeature(GridElement el)
Tests whether a feature will be constructed for the givenGridElement
.String
getFeatureID(GridElement el)
Gets theFeatureID
as aString
for a newSimpleFeature
being constructed from the givenGridElement
.SimpleFeatureType
getType()
Gets the feature type.abstract void
setAttributes(GridElement el, Map<String,Object> attributes)
Sets the values of attributes for a newSimpleFeature
being constructed from the givenGridElement
.
-
-
-
Field Detail
-
DEFAULT_GEOMETRY_ATTRIBUTE_NAME
public static final String DEFAULT_GEOMETRY_ATTRIBUTE_NAME
Default name for the geometry attribute: "element"- See Also:
- Constant Field Values
-
-
Constructor Detail
-
GridFeatureBuilder
public GridFeatureBuilder(SimpleFeatureType type)
Creates aGridFeatureBuilder
to work with the given feature type.- Parameters:
type
- the feature type
-
-
Method Detail
-
getType
public SimpleFeatureType getType()
Gets the feature type.- Returns:
- the feature type
-
setAttributes
public abstract void setAttributes(GridElement el, Map<String,Object> attributes)
Sets the values of attributes for a newSimpleFeature
being constructed from the givenGridElement
.This method must be overridden by the user. It is called by the grid building classes as each new feature is constructed.
- Parameters:
el
- the element from which the new feature is being constructedattributes
- aMap
with attribute names as keys and attribute values as values
-
getFeatureID
public String getFeatureID(GridElement el)
Gets theFeatureID
as aString
for a newSimpleFeature
being constructed from the givenGridElement
.It is optional to override this method. The base implementation returns
null
.- Parameters:
el
- the element from which the new feature is being constructed- Returns:
- value to use as the feature ID
-
getCreateFeature
public boolean getCreateFeature(GridElement el)
Tests whether a feature will be constructed for the givenGridElement
. 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
.- Parameters:
el
- the element from which the new feature would be constructed- Returns:
true
to create a feature for the element;false
to skip the element
-
-