Skip to content

Extent polygon should return coordinates wound counterclockwise #296

@bhousel

Description

@bhousel

Because GeoJSON expects polygons to have outer ring wound counterclockwise our code should generate polygons like this.

Extent.polygon is the one place that I found just now that should be switched, but there are probably others.

/** Returns a polygon representing the extent wound clockwise.
* @returns Polygon array
* @example
* new Extent([0, 0], [5, 10]).polygon(); // returns [[0, 0], [0, 10], [5, 10], [5, 0], [0, 0]]
*/
polygon(): Vec2[] {

We can assume that the Extent coordinates are WGS84 aka [longitude,latitude], even though in practice we use Extents for other screen and mercator coordinate systems where Y is flipped.
We can also assume that we are winding the polygons the way most people wind them (looking down at the earth), and not how d3 does it (looking out from the center). 😆

My goal here is to just let me stuff the coordinates into a GeoJSON polygon and have the least surprising thing happen.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions