Skip to content
This repository was archived by the owner on Jun 4, 2026. It is now read-only.
This repository was archived by the owner on Jun 4, 2026. It is now read-only.

Add transform algorithm #31

Open
Open

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
    });
}

Activity

  1. jfirebaugh commented on May 26, 2016

    @jfirebaugh
    ContributorAuthor

    The use case in geojson-vt-cpp requires transforming from the default geometry.hpp geometry variant type to a parallel variant type where some of the options are custom geometry types (inheriting from std::vector<...> with some additional members). A transform algorithm that's generic enough to support this scenario probably requires #26 plus some additional work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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