From 713efa48fcee01a26f9352ef7d884ee2efb2f0db Mon Sep 17 00:00:00 2001 From: navibyte <88932567+navispatial@users.noreply.github.com> Date: Sat, 9 Sep 2023 12:33:32 +0300 Subject: [PATCH] feat(geobase): new methods for Projection mixin to directly project Position or PositionArray #199, #200 --- .../src/coordinates/projection/projection.dart | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/dart/geobase/lib/src/coordinates/projection/projection.dart b/dart/geobase/lib/src/coordinates/projection/projection.dart index e1241994..18629f9f 100644 --- a/dart/geobase/lib/src/coordinates/projection/projection.dart +++ b/dart/geobase/lib/src/coordinates/projection/projection.dart @@ -6,6 +6,7 @@ import '/src/codes/coords.dart'; import '/src/coordinates/base/position.dart'; +import '/src/coordinates/base/position_series.dart'; /// A mixin defining an interface for (geospatial) projections. /// @@ -23,7 +24,7 @@ mixin Projection { required CreatePosition to, }); - /// Projects positions from [source] and returs a list of projected values. + /// Projects positions from [source] and returns a list of projected values. /// /// Use the required [type] to explicitely specify the type of coordinates. /// @@ -42,4 +43,19 @@ mixin Projection { List? target, required Coords type, }); + + /// Projects the [source] position to a position of [Position]. + /// + /// Throws FormatException if cannot project. + Position projectPosition(Position source) => + project(source, to: Position.create); + + /// Projects positions from [source] and returns a series of projected + /// positions. + /// + /// Throws FormatException if cannot project. + PositionSeries projectSeries(PositionSeries source) => PositionSeries.view( + projectCoords(source.values, type: source.type), + type: source.type, + ); }