maplibre-gl-js icon indicating copy to clipboard operation
maplibre-gl-js copied to clipboard

`Point.convert()` with `{x: number, y: number}`

Open wipfli opened this issue 3 years ago • 2 comments

The convert function of @mapbox/point-geometry:

https://github.com/mapbox/point-geometry/blob/bf471dc7ceb56299d4f5152c4badbeba193b0903/index.js#L304-L312

Point.convert = function (a) {
    if (a instanceof Point) {
        return a;
    }
    if (Array.isArray(a)) {
        return new Point(a[0], a[1]);
    }
    return a;
};

does not do the same as our v2.0.0 convert function that we made in the TypeScript migration:

    static convert(a: PointLike | {x: number; y: number}): Point {
        if (a instanceof Point) {
            return a;
        }
        if (Array.isArray(a)) {
            return new Point(a[0], a[1]);
        }
        if (typeof a.x === 'number') {
            return new Point(a.x, a.y);
        }
        throw new Error(`Unable to convert to point: ${JSON.stringify(a)}`);
    }

With pull request #800, we roll back from our Point class to the mapbox one. Let's keep an eye on this change.

wipfli avatar Jan 22 '22 09:01 wipfli

The following is the original code before typescript changes: https://github.com/maplibre/maplibre-gl-js/blob/cb3a4200bfbc113969e9dcbedae2aa7655f9aa98/src/ui/camera.js#L574 We might consider creating a PR for the point-geomerty package to support this :-)

HarelM avatar Jan 22 '22 10:01 HarelM

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Jul 22 '22 02:07 github-actions[bot]

@wipfli do we want to do something here or can this be closed?

HarelM avatar Aug 21 '22 13:08 HarelM

Thanks for the issue triage, @HarelM. Can be closed since no problems were reported.

wipfli avatar Aug 22 '22 06:08 wipfli