Skip to content

Commit ab673fe

Browse files
committed
Tracking documentation files
1 parent be5153f commit ab673fe

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed

docs/TilesMaking.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Introduction
2+
3+
This will guide on how to turn geojson to pdf tiles which can be used with the map conpomenet. These instrutions are for Mac OS
4+
5+
# Steps
6+
7+
1. Get valid geojson. It should looks something like this
8+
9+
```json
10+
{
11+
"type": "FeatureCollection",
12+
"features": [
13+
{
14+
"type": "Feature",
15+
"properties": { "name": "Sample Point" },
16+
"geometry": {
17+
"type": "Point",
18+
"coordinates": [-0.1257, 51.5085]
19+
}
20+
}
21+
]
22+
}
23+
```
24+
25+
At this stage geographic dataa can be added so it can be visulised without need futher external jsons. Hoever if you
26+
27+
2. Convert Geojson to .mbTiles
28+
29+
Install home brew
30+
31+
Install tippe cannoe
32+
33+
run tippe cannoe
34+
35+
3. Convert .mbTiles to .pbf
36+
37+
install mbtiles
38+
39+
```python
40+
pip install mbtiles
41+
```

docs/TilesServer.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Tile server
2+
3+
Set up tile-server to serve the tiles locally
4+
5+
Make a server.cjs file that looks like this:
6+
7+
```javascript
8+
const express = require("express");
9+
const path = require("path");
10+
const fs = require("fs");
11+
const mime = require("mime-types");
12+
const cors = require("cors");
13+
14+
const app = express();
15+
const PORT = 8080;
16+
const TILE_DIR = path.join(__dirname, "tiles-with-imd-data"); // your z/x/y.pbf folder
17+
18+
app.use(cors()); // Enables CORS for all routes
19+
20+
// Set correct headers for .pbf files
21+
app.get("/:z/:x/:y.pbf", (req, res) => {
22+
const { z, x, y } = req.params;
23+
const tilePath = path.join(TILE_DIR, z, x, `${y}.pbf`);
24+
25+
if (!fs.existsSync(tilePath)) {
26+
return res.status(404).send("Tile not found");
27+
}
28+
res.setHeader("Access-Control-Allow-Origin", "*");
29+
res.setHeader("Content-Type", "application/x-protobuf");
30+
res.setHeader("Content-Encoding", "gzip");
31+
32+
fs.createReadStream(tilePath).pipe(res);
33+
});
34+
35+
// Optional: serve an index or static frontend here
36+
37+
app.listen(PORT, () => {
38+
console.log(`Tile server running at http://localhost:${PORT}/`);
39+
});
40+
```
41+
42+
Then from the terminal run:
43+
44+
```console
45+
node server.cjs
46+
```

0 commit comments

Comments
 (0)