mapbox / mapbox/mercantile

GeoJSON specification RFC 7946 conformity

Open
#148 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
453
Forks
70
PR merge metrics
No merged PRs in 30d

Description

Per updated GeoJSON spec: https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.6

Polygon specification now indicates:
```
A linear ring MUST follow the right-hand rule with respect to the
area it bounds, i.e., exterior rings are counterclockwise, and
holes are clockwise.
```

Problem:
`mercantile` utilizes clockwise pattern which is the inverse of specified counter-clockwise pattern for polygon feature creation.

Impacted LoC: https://github.com/mapbox/mercantile/blob/fe3762d14001ca400caf7462f59433b906fc25bd/mercantile/__init__.py#L835

Short term workaround for my use case:
```
def as_geom(qk: str):
t = mercantile.quadkey_to_tile(qk)
west, south, east, north = mercantile.bounds(t)
return {
"type": "Polygon",
"coordinates": [[
[east, north],
[west, north],
[west, south],
[east, south],
[east, north],
]],
}
```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with mercantile/__init__.py at line 835 and compare the polygon coordinate order with RFC 7946 section 3.1.6. Check the existing test suite for polygon or geometry expectations. Done means polygon features created by mercantile use the RFC-specified exterior-ring winding without breaking existing tile-boundary behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.