-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
load tile layer from separate tile server
- Loading branch information
1 parent
d72080c
commit 2dd1174
Showing
5 changed files
with
72 additions
and
4 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
public/dengue/may24/resources/geojson/admin2/gadm41_BRA_2_100pc_for_tippecanoe.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// For the tiling proof of concept: | ||
// We want each feature in our geojson to become a layer in the mbtiles database, and for this we need to | ||
// inject the tippecanoe.layer property so that tippecanoe generates these layers. We'll set the value | ||
// of this prop to the feature id | ||
// Currently doing proof of concept for Brazil level 2 only! | ||
// In future we will probably include this processing in our tile server repo | ||
|
||
/* eslint-disable import/no-dynamic-require */ | ||
const path = require("path"); | ||
const fs = require("fs"); | ||
|
||
const dir = `${__dirname}/../public/dengue/may24/resources/geojson/admin2/`; | ||
const inputFile = path.normalize(`${dir}gadm41_BRA_2_100pc.json`); | ||
const outputFile = path.normalize(`${dir}gadm41_BRA_2_100pc_for_tippecanoe.json`); | ||
console.log(`Transforming geojson at ${inputFile}`); | ||
|
||
const input = require(inputFile); | ||
const features = input.features; | ||
console.log(`found ${features.length} features`); | ||
features.forEach((feature) => { | ||
const id = feature.properties.GID_2; | ||
feature.tippecanoe = { | ||
layer: id | ||
}; | ||
}); | ||
|
||
const output = JSON.stringify(input); | ||
fs.writeFile(outputFile, output, (err) => { | ||
if (err) { | ||
throw err; | ||
} | ||
console.log(`Saved to ${outputFile}`); | ||
}); | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.