coordsFromBbox enlarge width and height twice
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 128
- Forks
- 33
- PR merge metrics
- No merged PRs in 30d
Description
The width calculated by coordsFromBbox() is base_width \* scale *scale, which should be base_width \* scale. Let check out:
```
console.log(abaculus.coordsFromBbox(0, 2, [-180, -85.0511, 180, 85.0511], 19000, 256))
console.log(abaculus.coordsFromCenter(0, 2, {x: 0, y: 0, w: 256, h: 256}, 19000, 256))
```
What I got is :
```
{ w: 1024, h: 1024, x: 256, y: 256 }
{ w: 512, h: 512, x: 256, y: 256 }
```
We have already get the right size from here: https://github.com/mapbox/abaculus/blob/master/index.js#L42-L43
But we enlarged the size again at here: https://github.com/mapbox/abaculus/blob/master/index.js#L50-L51
And `x: 256, y: 256` is definitely not the center of `w: 1024, h: 1024`, which proves the results calculated by coordsFromBbox is wrong.
If this problem is confirmed. I will send a PR.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in index.js at lines 42-43 and 50-51, where the issue identifies the initial size calculation and the second enlargement. Reproduce the two console.log examples, then verify that coordsFromBbox no longer doubles the width and height and agrees with coordsFromCenter for the same bounds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100