Skip to content

Commit

Permalink
fix(geobase): more explicit calls to resolveCoordType in Feature, Fea…
Browse files Browse the repository at this point in the history
…tureCollection and GeometryCollection #188
  • Loading branch information
navispatial committed Sep 3, 2023
1 parent 84c06ed commit 4410469
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
3 changes: 1 addition & 2 deletions dart/geobase/lib/src/vector_data/model/feature/feature.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import '/src/coordinates/projection/projection.dart';
import '/src/coordinates/reference/coord_ref_sys.dart';
import '/src/utils/bounded_utils.dart';
import '/src/utils/bounds_builder.dart';
import '/src/utils/coord_type.dart';
import '/src/vector/content/feature_content.dart';
import '/src/vector/content/geometry_content.dart';
import '/src/vector/encoding/text_format.dart';
Expand Down Expand Up @@ -419,7 +418,7 @@ class Feature<T extends Geometry> extends FeatureObject {
/// Returns bounds calculated from a collection of features.
Box? _buildBoundsFrom(Geometry geometry) => BoundsBuilder.calculateBounds(
item: geometry,
type: resolveCoordTypeFrom(item: geometry),
type: geometry.coordType,
recalculateChilds: false,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,14 @@ class FeatureCollection<E extends Feature> extends FeatureObject {
(feature) => feature.bounded(recalculate: recalculate) as E,
)
.toList(growable: false);
final type = resolveCoordTypeFrom(collection: collection);

// return a new collection with processed features and populated bounds
return FeatureCollection<E>._(
collection,
type,
coordType,
custom: custom,
bounds: recalculate || bounds == null
? _buildBoundsFrom(collection, type)
? _buildBoundsFrom(collection, coordType)
: bounds,
);
}
Expand Down Expand Up @@ -319,13 +318,12 @@ class FeatureCollection<E extends Feature> extends FeatureObject {
final projected = features
.map<E>((feature) => feature.project(projection) as E)
.toList(growable: false);
final type = resolveCoordTypeFrom(collection: projected);

return FeatureCollection<E>._(
projected,
type,
coordType,
custom: custom,
bounds: bounds != null ? _buildBoundsFrom(projected, type) : null,
bounds: bounds != null ? _buildBoundsFrom(projected, coordType) : null,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,13 @@ class GeometryCollection<E extends Geometry> extends Geometry {
(geometry) => geometry.bounded(recalculate: recalculate) as E,
)
.toList(growable: false);
final type = resolveCoordTypeFrom(collection: collection);

// return a new collection with processed geometries and populated bounds
return GeometryCollection<E>._(
collection,
type,
coordType,
bounds: recalculate || bounds == null
? _buildBoundsFrom(collection, type)
? _buildBoundsFrom(collection, coordType)
: bounds,
);
}
Expand Down Expand Up @@ -244,14 +243,13 @@ class GeometryCollection<E extends Geometry> extends Geometry {
final projected = _geometries
.map<E>((geometry) => geometry.project(projection) as E)
.toList(growable: false);
final type = resolveCoordTypeFrom(collection: projected);

return GeometryCollection<E>._(
projected,
type,
coordType,

// bounds calculated from projected collection if there was bounds before
bounds: bounds != null ? _buildBoundsFrom(projected, type) : null,
bounds: bounds != null ? _buildBoundsFrom(projected, coordType) : null,
);
}

Expand Down

0 comments on commit 4410469

Please sign in to comment.