mapbox / mapbox/wellknown

empty wkt multipolygon does not roundtrip

Open
#38 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
281
Forks
47
PR merge metrics
No merged PRs in 30d

Description

If you start with
```js
const wkt = 'MULTIPOLYGON EMPTY'
```
and then try to roundtrip it using
```js
const newWkt = stringify(parse(wkt))
```
you end up with `MULTIPOLYGON ()`. which in turn parses to `null` (which cannot be stringified anymore).

So in summary:
- `MULTIPOLYGON EMPTY` parses just fine, to a geometry with empty coordinates array
- a multipolygon geometry with empty coordinates array stringifies to `MULTIPOLYGON ()` instead of `MULTIPOLYGON EMPTY`, and is treated as invalid syntax when re-parsing it, resulting in a `null` parsing result

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 by running the JavaScript parse/stringify example from the issue and inspect how empty multipolygon coordinates are handled by both entry points. Done means `MULTIPOLYGON EMPTY` parses and stringifies back to valid WKT that parses again without producing `null`.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.