Class FeatureModelBuilder
- All Implemented Interfaces:
AutoCloseable
IFeatureModel given a list of features, model metadata, feature model metadata, and optionally bounds.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSets the bounds of the feature model.build()Creates a new in-memoryIFeatureModelinstance, based on the given model metadata, feature model metadata and the list of features.voidclose()Sets the data model that describes the features.editable(boolean editable) Sets whether the model allows editing or not.featureModelMetadata(FeatureModelMetadata featureModelMetadata) Sets theFeatureModelMetadataof the feature model.Sets the features of the feature model.protected voidfinalize()modelMetadata(ModelMetadata modelMetadata) Sets theModelMetadataof the feature model.static FeatureModelBuilderReturns the builder class for the creation of theIFeatureModel.reference(CoordinateReference reference) Sets the preferred reference of the feature model.spatialIndex(boolean spatialIndex) Sets whether the model spatially indexes its features or not.Sets the title of the feature model.
-
Constructor Details
-
FeatureModelBuilder
Copy constructor.- Parameters:
other- the builder to copy.
-
-
Method Details
-
finalize
protected void finalize() -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
newBuilder
Returns the builder class for the creation of theIFeatureModel.- Returns:
- the builder class for the creation of the
IFeatureModel.
-
build
Creates a new in-memoryIFeatureModelinstance, based on the given model metadata, feature model metadata and the list of features.Depending on the setting of the
editableflag, it is possible to add,remove, or update the features of this model after it has been created.The metadata can be supplied in two ways. Either pass the metadata objects themselves with
modelMetadata()andfeatureModelMetadata(), or use thetitle(),reference()anddataModel()shortcuts and let this function assemble the metadata. The two ways cannot be mixed.- Returns:
- An in-memory
IFeatureModelinstance. - Throws:
IllegalStateException- If the metadata is supplied in both ways at once, or if there is not enough information to assemble it. WithoutfeatureModelMetadata(), eitherdataModel()or at least one feature is required, so that the data model can be determined.
-
bounds
Sets the bounds of the feature model.Calling this function is optional.
If no bounds are provided, the model will attempt to derive the bounds by itself. It does so by calculating the union of the geometries of its features, as specified by
Feature#findGeometry.- Parameters:
bounds- The model bounds. Cannot benull.- Returns:
- this
- Throws:
NullPointerException- when passingnull.
-
featureModelMetadata
@NotNull public FeatureModelBuilder featureModelMetadata(@NotNull FeatureModelMetadata featureModelMetadata) Sets theFeatureModelMetadataof the feature model.Calling this function is optional:
reference()anddataModel()are shortcuts that make this builder assemble theFeatureModelMetadatainstead. Use this function for metadata that the shortcut cannot express, such as a model of which the feature types are a subset of the data model's types.- Parameters:
featureModelMetadata- The model feature model metadata.- Returns:
- this
-
features
Sets the features of the feature model.Calling this function is optional.
The given features may or may not have an ID
assigned. If the ID is missing, an ID will be assigned to the feature by the resulting model.- Parameters:
features- The model features.- Returns:
- this
-
modelMetadata
Sets theModelMetadataof the feature model.Calling this function is optional:
title()is a shortcut that makes this builder assemble theModelMetadatainstead.- Parameters:
modelMetadata- The model metadata.- Returns:
- this
-
editable
Sets whether the model allows editing or not.An editable model exposes an
IFeatureModelUpdater, through which you can add, remove, or update the model's features. Calling this function is optional. By default, this value is false.- Parameters:
editable- whether the model allows editing or not.- Returns:
- this
-
spatialIndex
Sets whether the model spatially indexes its features or not.Enabling this flag can improve performance when you are querying a
specific area, or when you are using this model in aFeatureLayerwith thespatial loading strategy. Spatial indexing may also cause a small performance penalty for feature additions, updates, and removals.Calling this function is optional. By default, this value is false.
- Parameters:
spatialIndex- whether the model spatially indexes its features or not.- Returns:
- this
- Since:
- 2025.0.04
-
reference
@NotNull public FeatureModelBuilder reference(@NotNull CoordinateReference reference) throws NullPointerException Sets the preferred reference of the feature model.Calling this function is optional.
This is a shortcut that makes this builder assemble the
FeatureModelMetadata, sofeatureModelMetadata()does not have to be called. It is an alternative tofeatureModelMetadata(), not an addition: neither one wins when both are set,build()throws a java.lang.IllegalStateException instead.- Parameters:
reference- the preferred reference of the feature model. Cannot benull.- Returns:
- this
- Throws:
NullPointerException- when passingnull.- Since:
- 2026.1
-
dataModel
Sets the data model that describes the features.Calling this function is optional.
This is a shortcut that makes this builder assemble the
FeatureModelMetadata, sofeatureModelMetadata()does not have to be called. It is an alternative tofeatureModelMetadata(), not an addition: neither wins when both are set,build()throws a java.lang.IllegalStateException instead.Without this call the data model is derived from the
DataTypeof the features passed tofeatures(), and is named after the model's title. Set it explicitly for a model that starts out without features, or to control the data model's name.- Parameters:
dataModel- the data model that describes the features.- Returns:
- this
- Since:
- 2026.1
-
title
Sets the title of the feature model.Calling this function is optional.
This is a shortcut that makes this builder assemble the
ModelMetadata, with the title as its only content, somodelMetadata()does not have to be called. It is an alternative tomodelMetadata(), not an addition: neither wins when both are set,build()throws a java.lang.IllegalStateException instead.When neither this function nor
modelMetadata()is called, the model gets the title"Feature model", so that it is never nameless.- Parameters:
title- the title of the feature model.- Returns:
- this
- Since:
- 2026.1
-