Skip to content

Commit

Permalink
feat(geobase): new methods for Projection mixin to directly project P…
Browse files Browse the repository at this point in the history
…osition or PositionArray #199, #200
  • Loading branch information
navispatial committed Sep 9, 2023
1 parent a13c014 commit 713efa4
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion dart/geobase/lib/src/coordinates/projection/projection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand All @@ -23,7 +24,7 @@ mixin Projection {
required CreatePosition<T> 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.
///
Expand All @@ -42,4 +43,19 @@ mixin Projection {
List<double>? 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,
);
}

0 comments on commit 713efa4

Please sign in to comment.