Skip to content

Commit

Permalink
Renamed repository
Browse files Browse the repository at this point in the history
  • Loading branch information
Torsten Schlieder committed Feb 27, 2024
1 parent eeaee8d commit 66eed6a
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 25 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Tile Math
# Tiles Math

This library provides algorithms and data structures to map your rides and runs to [slippy map tiles](https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames).
It then groups the tiles in various ways, similar to what
[VeloViewer](https://veloviewer.com/explorer), [StatsHunters](https://www.statshunters.com),
[Squadrats](https://squadrats.com/activities), and [RideEveryTile](https://rideeverytile.com) do.

Specifically, `tile-math`
Specifically, `tiles-math`
* maps geo positions (latitude, longitude) to map tiles of a given zoom level,
* combines adjacent tiles to connected clusters,
* selects the maximum-size tile cluster,
Expand All @@ -21,22 +21,22 @@ In particular, the map coordinates calculated for the various artifacts are comp
types, and can thus directly used for drawing Leaflet [Rectangles](https://leafletjs.com/reference.html#rectangle),
[Polylines](https://leafletjs.com/reference.html#polyline), and similar map overlays.

The [demo](./demo) folder shows an example of applying `tile-math` to a [React Leaflet](https://react-leaflet.js.org) map.
The [demo](./demo) folder shows an example of applying `tiles-math` to a [React Leaflet](https://react-leaflet.js.org) map.
Red squares represent tiles of zoom level 14 touched by (fake) rides,
purple regions show smaller clusters (i.e. tiles with four neighbors),
the blue area depicts the maximum cluster (with the orange circle as its [centroid](https://en.wikipedia.org/wiki/Centroid)),
and the yellow frame shows the maximum square:

<img src="demo.png" alt="Screenshot of the demo integration into React Leaflet" style="width:700px;"/>

Because `tile-math` is a pure Javascript library (written in Typescript) without dependencies
Because `tiles-math` is a pure Javascript library (written in Typescript) without dependencies
and without reference to a specific map framework, it can be used in the browser and in Node servers.
The latter is very useful to pre-compute all tiles for all your rides and runs, and then deliver
the resulting tile set via API to the browser.

# Installation
```
npm install tile-math
npm install tiles-math
```

# Usage
Expand All @@ -48,7 +48,7 @@ and deliver them via API.

```typescript jsx
import { Rectangle } from 'react-leaflet'
import { coords2tile, TileSet } from 'tile-math'
import { coords2tile, TileSet } from 'tiles-math'

const zoom = 14 // VeloViewer and others use zoom-level 14 tiles
const coords = [[51.492084, 0.010122], ...] // The latitude-longitude pairs or your rides
Expand All @@ -72,7 +72,7 @@ computes the max cluster, all minor clusters, and the remaining set of detached

```typescript jsx
import { Rectangle } from 'react-leaflet'
import { tiles2clusters, TileSet } from 'tile-math'
import { tiles2clusters, TileSet } from 'tiles-math'

const zoom = 14
const tiles = new TileSet().addAll([...]) // The input tile set
Expand Down Expand Up @@ -107,7 +107,7 @@ and multiple inner boundary polylines for cut-out areas.

```typescript jsx
import { Polyline, Rectangle } from 'react-leaflet'
import { cluster2boundaries, tiles2clusters, TileSet } from 'tile-math'
import { cluster2boundaries, tiles2clusters, TileSet } from 'tiles-math'

const zoom = 14
const tiles = new TileSet().addAll([...]) // The input tile set
Expand Down Expand Up @@ -139,7 +139,7 @@ that is closest to the [centroid](https://en.wikipedia.org/wiki/Centroid) of the

```typescript jsx
import { Rectangle } from 'react-leaflet'
import { cluster2square, tiles2clusters, TileSet } from 'tile-math'
import { cluster2square, tiles2clusters, TileSet } from 'tiles-math'

const zoom = 14
const tiles = new TileSet().addAll([...]) // The input tile set
Expand Down
2 changes: 1 addition & 1 deletion demo/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Demonstration of tile-math Calculations
# Demonstration of `tiles-math` Calculations

TODO: Description
2 changes: 1 addition & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/png" href="/tm.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Demonstration of tile-math Features</title>
<title>Demonstration of tiles-math Features</title>
</head>
<body>
<div id="root"></div>
Expand Down
2 changes: 1 addition & 1 deletion demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"react-dom": "^18.2.0",
"react-leaflet": "^4.2.1",
"react-router-dom": "^6.22.1",
"tile-math": "file:.."
"tiles-math": "file:.."
},
"devDependencies": {
"@types/leaflet": "^1.9.8",
Expand Down
2 changes: 1 addition & 1 deletion demo/src/DemoAllFeatures.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useState } from 'react'
import { Circle, Polyline, Rectangle } from 'react-leaflet'
import { coords2tile, cluster2boundaries, cluster2square, tiles2clusters, Coords, TileSet } from 'tile-math'
import { coords2tile, cluster2boundaries, cluster2square, tiles2clusters, Coords, TileSet } from 'tiles-math'
import { OSMContainer } from './OSMContainer'

// Constants controlling the map view and tile generation
Expand Down
2 changes: 1 addition & 1 deletion demo/src/DemoBoundaries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//

import { Polyline, Rectangle } from 'react-leaflet'
import { cluster2boundaries, tiles2clusters, TileSet } from 'tile-math'
import { cluster2boundaries, tiles2clusters, TileSet } from 'tiles-math'
import { OSMContainer } from './OSMContainer'
import { sampleCoords } from './sample-coords'

Expand Down
2 changes: 1 addition & 1 deletion demo/src/DemoClustering.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//

import { Rectangle } from 'react-leaflet'
import { tiles2clusters, TileSet } from 'tile-math'
import { tiles2clusters, TileSet } from 'tiles-math'
import { OSMContainer } from './OSMContainer'
import { sampleCoords } from './sample-coords'

Expand Down
2 changes: 1 addition & 1 deletion demo/src/DemoMaxSquare.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//

import { Rectangle } from 'react-leaflet'
import { cluster2square, tiles2clusters, TileSet } from 'tile-math'
import { cluster2square, tiles2clusters, TileSet } from 'tiles-math'
import { OSMContainer } from './OSMContainer'
import { sampleCoords } from './sample-coords'

Expand Down
2 changes: 1 addition & 1 deletion demo/src/DemoTrackTiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//

import { Rectangle, Polyline } from 'react-leaflet'
import { TileSet } from 'tile-math'
import { TileSet } from 'tiles-math'
import { OSMContainer } from './OSMContainer'
import { sampleCoords } from './sample-coords'

Expand Down
2 changes: 1 addition & 1 deletion demo/src/OSMContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ReactElement } from 'react'
import { MapContainer, TileLayer } from 'react-leaflet'
import { Coords } from 'tile-math'
import { Coords } from 'tiles-math'

const defaultCenter : Coords = [51.479, -0.008]

Expand Down
2 changes: 1 addition & 1 deletion demo/src/sample-coords.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Coords } from 'tile-math'
import { Coords } from 'tiles-math'

// Example coordinates (latitude, longitude).
// Such coordinates could be taken from a GPX file (where track points would be much denser).
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "tile-math",
"name": "tiles-math",
"version": "1.0.0",
"description": "Algorithms and data structures for mapping geo coordinates to slippy-map tiles, clustering of adjacent tiles, and finding largest squares included in clusters",
"main": "./dist/index.js",
Expand All @@ -10,14 +10,14 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/mouton0815/tile-math.git"
"url": "git+https://github.com/mouton0815/tiles-math.git"
},
"author": "torsten.schlieder@gmx.net",
"license": "MIT",
"bugs": {
"url": "https://github.com/mouton0815/tile-math/issues"
"url": "https://github.com/mouton0815/tiles-math/issues"
},
"homepage": "https://github.com/mouton0815/tile-math#readme",
"homepage": "https://github.com/mouton0815/tiles-math#readme",
"devDependencies": {
"@types/jest": "^29.5.12",
"jest": "^29.7.0",
Expand Down
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"exclude": [
"node_modules",
"dist",
"demo",
//"src/**/__test__/**"
"demo"
]
}

0 comments on commit 66eed6a

Please sign in to comment.