populated method
Feature<Geometry>
populated({
- int traverse = 0,
- bool onBounds = true,
- PositionScheme scheme = Position.scheme,
override
Returns a feature object of the same subtype as this with certain data members populated.
If nothing is populated then this is returned.
If onBounds is true (as by default):
- The
boundsin a returned feature object is ensured to be populated (expect when cannot be calculated, for example in the case of an empty geometry). - If
traverse> 0, then also bounding boxes of child feature or geometry objects of this feature object are populated for child levels indicated bytraverse(0: no childs, 1: only direct childs, 2: direct childs and childs of them, ..).
Use scheme to set the position scheme:
Position.schemefor generic position data (geographic, projected or any other), this is also the defaultProjected.schemefor projected position dataGeographic.schemefor geographic position data
See also unpopulated.
Implementation
@override
Feature populated({
int traverse = 0,
bool onBounds = true,
PositionScheme scheme = Position.scheme,
}) {
if (onBounds) {
// populate a geometry when traversing is asked
final geom = traverse > 0
? geometry?.populated(
traverse: traverse - 1,
onBounds: onBounds,
scheme: scheme,
)
: geometry;
// create a new feature if geometry changed or bounds was unpopulated
// or of other scheme
final b = bounds;
if (geom != geometry ||
(b == null && geom != null) ||
(b != null && !b.conforming.conformsWith(scheme))) {
return Feature(
id: id,
geometry: geom,
properties: properties,
bounds: geom?.getBounds(scheme: scheme),
custom: custom,
);
}
}
return this;
}