Skip to content

Add transform algorithm #31

@jfirebaugh

Description

@jfirebaugh
  • For points, takes a points and a callable, and returns the result of calling the callable on the point.
  • For collections, takes a collection and a callable, and returns a collection of the same collection type but with an element type that's the return type of calling transform on an element of the input collection, containing the result of calling transform on each element of the input. And if the collection supports reserve(), use it.
  • For variants, takes a variant and a callable, and returns a variant whose option types consist of the return types of calling transform on each input variant option type.

Basically, it should support succinct definitions of other algorithms like:

template <class T>
auto project(const T& geometry) {
    return mapbox::geometry::transform(geometry, [] (const point<double>& p) -> point<int64_t> {
        // projection math
    });
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions