forked from MapComplete/MapComplete
Chore: housekeeping
This commit is contained in:
parent
cd9e03dd6f
commit
b300fffdc5
156 changed files with 4436 additions and 1318 deletions
|
|
@ -77,21 +77,34 @@ export default class SaveFeatureSourceToLocalStorage {
|
|||
this.storage = storage
|
||||
const singleTileSavers: Map<number, SingleTileSaver> = new Map<number, SingleTileSaver>()
|
||||
features.features.addCallbackAndRunD((features) => {
|
||||
if (features.some(f => {
|
||||
let totalPoints = 0
|
||||
if (f.geometry.type === "MultiPolygon") {
|
||||
totalPoints = f.geometry.coordinates.map(rings => rings.map(ring => ring.length).reduce((a, b) => a + b)).reduce((a, b) => a + b)
|
||||
} else if (f.geometry.type === "Polygon" || f.geometry.type === "MultiLineString") {
|
||||
totalPoints = f.geometry.coordinates.map(ring => ring.length).reduce((a, b) => a + b)
|
||||
} else if (f.geometry.type === "LineString") {
|
||||
totalPoints = f.geometry.coordinates.length
|
||||
}
|
||||
if (totalPoints > 1000) {
|
||||
console.warn(`Not caching tiles, detected a big object (${totalPoints} points for ${f.properties.id})`)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
})) {
|
||||
if (
|
||||
features.some((f) => {
|
||||
let totalPoints = 0
|
||||
if (f.geometry.type === "MultiPolygon") {
|
||||
totalPoints = f.geometry.coordinates
|
||||
.map((rings) =>
|
||||
rings.map((ring) => ring.length).reduce((a, b) => a + b)
|
||||
)
|
||||
.reduce((a, b) => a + b)
|
||||
} else if (
|
||||
f.geometry.type === "Polygon" ||
|
||||
f.geometry.type === "MultiLineString"
|
||||
) {
|
||||
totalPoints = f.geometry.coordinates
|
||||
.map((ring) => ring.length)
|
||||
.reduce((a, b) => a + b)
|
||||
} else if (f.geometry.type === "LineString") {
|
||||
totalPoints = f.geometry.coordinates.length
|
||||
}
|
||||
if (totalPoints > 1000) {
|
||||
console.warn(
|
||||
`Not caching tiles, detected a big object (${totalPoints} points for ${f.properties.id})`
|
||||
)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
})
|
||||
) {
|
||||
// Has big objects
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,8 +37,11 @@ export default class DynamicGeoJsonTileSource extends UpdatableDynamicTileSource
|
|||
if (DynamicGeoJsonTileSource.whitelistCache.has(whitelistUrl)) {
|
||||
whitelist = DynamicGeoJsonTileSource.whitelistCache.get(whitelistUrl)
|
||||
} else {
|
||||
Utils.downloadJsonCached<Record<string | number, number[]>>(whitelistUrl, 1000 * 60 * 60)
|
||||
.then(json => {
|
||||
Utils.downloadJsonCached<Record<string | number, number[]>>(
|
||||
whitelistUrl,
|
||||
1000 * 60 * 60
|
||||
)
|
||||
.then((json) => {
|
||||
const data = new Map<number, Set<number>>()
|
||||
for (const x in json) {
|
||||
if (x === "zoom") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue