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

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

Closed
wipfli opened this issue Jan 22, 2022 · 4 comments
Closed

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

wipfli opened this issue Jan 22, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@wipfli
Copy link
Contributor

wipfli commented Jan 22, 2022

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.

@HarelM
Copy link
Collaborator

HarelM commented Jan 22, 2022

The following is the original code before typescript changes:

const offset = (typeof options.offset.x === 'number') ? new Point(options.offset.x, options.offset.y) : Point.convert(options.offset);

We might consider creating a PR for the point-geomerty package to support this :-)

@github-actions
Copy link
Contributor

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 github-actions bot added the stale label Jul 22, 2022
@birkskyum birkskyum removed the stale label Aug 10, 2022
@HarelM
Copy link
Collaborator

HarelM commented Aug 21, 2022

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

@HarelM HarelM added enhancement New feature or request need more info Further information is requested labels Aug 21, 2022
@wipfli
Copy link
Contributor Author

wipfli commented Aug 22, 2022

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

@wipfli wipfli closed this as completed Aug 22, 2022
@HarelM HarelM removed the need more info Further information is requested label Aug 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants