Skip to content

Commit

Permalink
update readme and badge
Browse files Browse the repository at this point in the history
  • Loading branch information
mapsam committed Oct 2, 2024
1 parent cc80aa5 commit 6904ea6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run tests
name: js
on: [push]
env:
NODE_VERSION: 20.x
Expand Down
30 changes: 20 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
[![Build Status](https://travis-ci.com/mapbox/sphericalmercator.svg?branch=master)](http://travis-ci.com/mapbox/sphericalmercator)
[![Run tests](https://github.com/mapbox/sphericalmercator/actions/workflows/test.yml/badge.svg)](https://github.com/mapbox/sphericalmercator/actions/workflows/test.yml)

# sphericalmercator

Provides projection math for converting between mercator meters, screen pixels (of 256x256 or configurable-size tiles), and latitude/longitude. Compatible with nodejs packages and in-browser.

See also

* [tilebelt](https://github.com/mapbox/tilebelt) provides ZXY tile math utilities in javascript
* [mercantile](https://github.com/sgillies/mercantile) provides similar utilities for projection and tile math in Python

`sphericalmercator` provides projection math for converting between mercator meters, screen pixels (of 256x256 or configurable-size tiles), and latitude/longitude. Compatible with nodejs packages and in-browser.

## Installation

Expand All @@ -11,6 +19,8 @@
Some datatypes are assumed to be arrays: `ll` is `[lon, lat]`, `xy` and `px` are `[x, y]`.

```javascript
import { SphericalMercator } from '@mapbox/sphericalmercator';

// By default, precomputes up to z30
const merc = new SphericalMercator({
size: 256,
Expand All @@ -20,15 +30,11 @@ const merc = new SphericalMercator({

### `px(ll, zoom)`

Convert lon, lat to screen pixel x, y from 0, 0 origin, at a certain zoom level.
The inverse of `ll`

If `antimeridian: true` is passed on initialization of the `SphericalMercator` object, this method will support converting longitude values up to 360°.
Convert lon, lat to screen pixel x, y from 0, 0 origin, at a certain zoom level. The inverse of `ll`. If `antimeridian: true` is passed on initialization of the `SphericalMercator` object, this method will support converting longitude values up to 360°.

### `ll(px, zoom)`

Convert screen pixel value to lon, lat, at a certain zoom level. The inverse
of `px`
Convert screen pixel value to lon, lat, at a certain zoom level. The inverse of `px`.

### `bbox(x, y, zoom, tms_style, srs)`

Expand Down Expand Up @@ -70,6 +76,10 @@ Convert lon, lat values to mercator x, y

Convert mercator x, y values to lon, lat

## See Also
## Developing

* [mercantile](https://github.com/sgillies/mercantile) provides similar utilities for projection and tile math in Python
```sh
npm ci # install
npm test # run tests
npm run format # format files with prettier
```
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"url": "https://mapbox.com/",
"email": "info@mapbox.com"
},
"main": "./dist/index.js",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"devDependencies": {
"@vitest/coverage-v8": "^2.1.1",
"ts-node": "^10.9.2",
Expand Down

0 comments on commit 6904ea6

Please sign in to comment.