Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Positions as iterable of coordinate values on geobase #136

Closed
navispatial opened this issue Jul 17, 2022 · 1 comment
Closed

Positions as iterable of coordinate values on geobase #136

navispatial opened this issue Jul 17, 2022 · 1 comment
Labels
enhancement New feature or request 🌐 geobase Related to the code package "geobase"

Comments

@navispatial
Copy link
Member

Related to #129, #133 and #134.

The geobase package has position class hiearchy:

  • Position
    • Projected (x, y, z, m)
    • Geographic (lon, lat, elev, m)

In some interfaces position coordinates are handled as Iterable<num> (a list or other iterable implementation).

For data management it might be handy if some classes support at the same both both representations.

For this a new set of coordinate classes:

/// A geospatial position as an iterable collection of coordinate values.
///
/// Such position is a valid [Position] implementation and represents
/// coordinate values also as a collection of `Iterable<num>` (containing 2, 3,
/// or 4 items).
abstract class PositionCoords extends Position implements Iterable<num>;

/// A projected position as an iterable collection of coordinate values.
abstract class ProjectedCoords extends PositionCoords
    with IterableWrapperMixin<num>
    implements Projected;

... and also implementations.

@navispatial
Copy link
Member Author

Implemented in 0.3.0-dev.1 with main parts as:

/// Geospatial coordinate values as an iterable collection of double values.
///
/// See also sub classes:
/// * [PositionArray]: coordinate values of 0 to N positions in a flat structure
/// * [PositionCoords]: coordinate values of a single position
/// * [BoxCoords]: coordinate values of a single bounding box
abstract class Coordinates extends Iterable<double> implements Positionable {}

/// Coordinate values of geospatial positions as an iterable collection.
///
/// The collection implements `Iterable<double>` with coordinate values of
/// positions as a flat structure (each position containing  2, 3, or 4 values).
///
/// Position data is also accessible as position coordinates via [data]. You can
/// also use [dataTo] to map coordinate values to custom position types.
///
/// See [Position] for description about supported coordinate values.
class PositionArray implements Coordinates {}

/// A base class for positions as an iterable collection of coordinate values.
///
/// See [PositionCoords] for a concrete implementation.
///
/// See also specialized sub classes for projected coordinates:
///
/// Class  | 2D/3D | Coords | Values   | x | y | z | m
/// ------ | ----- | ------ | -------- | - | - | - | -
/// `XY`   | 2D    | 2      | `double` | + | + |   |
/// `XYZ`  | 3D    | 3      | `double` | + | + | + |
/// `XYM`  | 2D    | 3      | `double` | + | + |   | +
/// `XYZM` | 3D    | 4      | `double` | + | + | + | +
///
/// And there are also specialized sub classes for geographic coordinates:
///
/// Class         | 2D/3D | Coords | Values   | lon (x) | lat (y) | elev (z) | m
/// ------------- | ----- | ------ | -------- | ------- | ------- | -------- | -
/// `LonLat`      | 2D    | 2      | `double` |    +    |    +    |          |
/// `LonLatElev`  | 3D    | 3      | `double` |    +    |    +    |    +     |
/// `LonLatM`     | 2D    | 3      | `double` |    +    |    +    |          | +
/// `LonLatElevM` | 3D    | 4      | `double` |    +    |    +    |    +     | +
abstract class BasePositionCoords extends Position implements Coordinates {}

/// A geospatial position as an iterable collection of coordinate values.
///
/// Such position is a valid [Position] implementation and represents
/// coordinate values also as a collection of `Iterable<double>` (containing 2,
/// 3, or 4 items).
///
/// See [Position] for description about supported coordinate values.
@immutable
class PositionCoords extends BasePositionCoords {}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request 🌐 geobase Related to the code package "geobase"
Projects
None yet
Development

No branches or pull requests

1 participant