Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typescript, 2.x #46

Merged
merged 6 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: js
on: [push]
env:
NODE_VERSION: 20.x
jobs:
tests:
runs-on: ubuntu-latest

permissions:
id-token: write
contents: read

steps:
- name: checkout commit
uses: actions/checkout@v4

- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm

- name: install node deps
run: npm ci

- name: run tests
run: npm test

- name: run benchmarks
run: npm run bench
28 changes: 2 additions & 26 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,27 +1,3 @@
# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# Deployed apps should consider commenting this line out:
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
node_modules

.nyc_output
dist
coverage
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
4 changes: 0 additions & 4 deletions .travis.yml

This file was deleted.

10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## 2.0.0

```js
import * as tilebelt from '@mapbox/tilebelt';
```

- Migrate to typescript
- No default export
- Use GitHub Actions
- Test with vitest and Node.js 20.x
77 changes: 44 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
tilebelt
====
[![Build Status](https://travis-ci.org/mapbox/tilebelt.svg?branch=master)](https://travis-ci.org/mapbox/tilebelt) [![Coverage Status](https://coveralls.io/repos/mapbox/tilebelt/badge.svg?branch=use-tap)](https://coveralls.io/r/mapbox/tilebelt?branch=use-tap)
# tilebelt

[![Run tests](https://github.com/mapbox/tilebelt/actions/workflows/test.yml/badge.svg)](https://github.com/mapbox/tilebelt/actions/workflows/test.yml)

simple [tile](http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames) utilities

Expand All @@ -13,40 +13,51 @@ npm install @mapbox/tilebelt
## usage

```js
var tilebelt = require('@mapbox/tilebelt');

var tile = [10,15,8] // x,y,z

console.log(tilebelt.tileToGeoJSON(tile));
console.log(tilebelt.getParent(tile));
import * as tilebelt from '@mapbox/tilebelt';

const tile = [10, 15, 8] // x,y,z

tilebelt.tileToGeoJSON(tile);
// {
// "type": "Polygon",
// "coordinates": [
// [
// [ -165.9375, 82.8533822917608 ],
// [ -165.9375, 82.67628497834903 ],
// [ -164.53125, 82.67628497834903 ],
// [ -164.53125, 82.8533822917608 ],
// [ -165.9375, 82.8533822917608 ]
// ]
// ]
// }

tilebelt.getParent(tile);
// [ 5, 7, 7 ]
```

## features

function | description
---|---
tileToGeoJSON(tile) | get a geojson representation of a tile
tileToBBOX(tile) | get the bbox of a tile
bboxToTile(bbox) | get the smallest tile to cover a bbox
getChildren(tile) | get the 4 tiles one zoom level higher
getParent(tile) | get the tile one zoom level lower
getSiblings(tile) | get the 3 sibling tiles for a tile
hasSiblings(tiles, tile) | check to see if an array of tiles contains a tiles siblings
hasTile(tiles, tile) | check to see if an array of tiles contains a particular tile
tilesEqual(tile1, tile2) | check to see if two tiles are the same
tileToQuadkey(tile) | get the quadkey for a tile
quadkeyToTile(quadkey) | get the tile for a quadkey
pointToTile(lon, lat, zoom) | get the tile for a point at a specified zoom level
pointToTileFraction(lon, lat, zoom) | get the precise fractional tile location for a point at a zoom level

## tests

```bash
npm test
```

## benchmarks

```bash
npm run bench
`tileToGeoJSON(tile)` | get a geojson representation of a tile
`tileToBBOX(tile)` | get the bbox of a tile
`bboxToTile(bbox)` | get the smallest tile to cover a bbox
`getChildren(tile)` | get the 4 tiles one zoom level higher
`getParent(tile)` | get the tile one zoom level lower
`getSiblings(tile)` | get the 3 sibling tiles for a tile
`hasSiblings(tiles, tile)` | check to see if an array of tiles contains a tiles siblings
`hasTile(tiles, tile)` | check to see if an array of tiles contains a particular tile
`tilesEqual(tile1, tile2)` | check to see if two tiles are the same
`tileToQuadkey(tile)` | get the quadkey for a tile
`quadkeyToTile(quadkey)` | get the tile for a quadkey
`pointToTile(lon, lat, zoom)` | get the tile for a point at a specified zoom level
`pointToTileFraction(lon, lat, zoom)` | get the precise fractional tile location for a point at a zoom level

## developing

```sh
npm ci # install deps
npm test # tests
npm run bench # run benchmarks
npm run format # format using prettier
```
74 changes: 0 additions & 74 deletions bench.js

This file was deleted.

Loading
Loading