From 4410469eb251865604acbf0c41dda094766f2882 Mon Sep 17 00:00:00 2001 From: navibyte <88932567+navispatial@users.noreply.github.com> Date: Sun, 3 Sep 2023 10:24:38 +0300 Subject: [PATCH] fix(geobase): more explicit calls to resolveCoordType in Feature, FeatureCollection and GeometryCollection #188 --- .../lib/src/vector_data/model/feature/feature.dart | 3 +-- .../vector_data/model/feature/feature_collection.dart | 10 ++++------ .../model/geometry/geometry_collection.dart | 10 ++++------ 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/dart/geobase/lib/src/vector_data/model/feature/feature.dart b/dart/geobase/lib/src/vector_data/model/feature/feature.dart index 16f7149a..670932c4 100644 --- a/dart/geobase/lib/src/vector_data/model/feature/feature.dart +++ b/dart/geobase/lib/src/vector_data/model/feature/feature.dart @@ -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'; @@ -419,7 +418,7 @@ class Feature 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, ); diff --git a/dart/geobase/lib/src/vector_data/model/feature/feature_collection.dart b/dart/geobase/lib/src/vector_data/model/feature/feature_collection.dart index e82f861b..6f6caef1 100644 --- a/dart/geobase/lib/src/vector_data/model/feature/feature_collection.dart +++ b/dart/geobase/lib/src/vector_data/model/feature/feature_collection.dart @@ -244,15 +244,14 @@ class FeatureCollection 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._( collection, - type, + coordType, custom: custom, bounds: recalculate || bounds == null - ? _buildBoundsFrom(collection, type) + ? _buildBoundsFrom(collection, coordType) : bounds, ); } @@ -319,13 +318,12 @@ class FeatureCollection extends FeatureObject { final projected = features .map((feature) => feature.project(projection) as E) .toList(growable: false); - final type = resolveCoordTypeFrom(collection: projected); return FeatureCollection._( projected, - type, + coordType, custom: custom, - bounds: bounds != null ? _buildBoundsFrom(projected, type) : null, + bounds: bounds != null ? _buildBoundsFrom(projected, coordType) : null, ); } diff --git a/dart/geobase/lib/src/vector_data/model/geometry/geometry_collection.dart b/dart/geobase/lib/src/vector_data/model/geometry/geometry_collection.dart index e6f6a275..df9d7cfa 100644 --- a/dart/geobase/lib/src/vector_data/model/geometry/geometry_collection.dart +++ b/dart/geobase/lib/src/vector_data/model/geometry/geometry_collection.dart @@ -175,14 +175,13 @@ class GeometryCollection 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._( collection, - type, + coordType, bounds: recalculate || bounds == null - ? _buildBoundsFrom(collection, type) + ? _buildBoundsFrom(collection, coordType) : bounds, ); } @@ -244,14 +243,13 @@ class GeometryCollection extends Geometry { final projected = _geometries .map((geometry) => geometry.project(projection) as E) .toList(growable: false); - final type = resolveCoordTypeFrom(collection: projected); return GeometryCollection._( 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, ); }