forked from MapComplete/MapComplete
Change padding method, add max bounds, fix zoomlevels on toerisme vlaanderen theme
This commit is contained in:
parent
7576f7069b
commit
c010fb5271
5 changed files with 53 additions and 31 deletions
|
@ -39,7 +39,7 @@ export default class OverpassFeatureSource implements FeatureSource {
|
||||||
}
|
}
|
||||||
private readonly _isActive: UIEventSource<boolean>;
|
private readonly _isActive: UIEventSource<boolean>;
|
||||||
private readonly onBboxLoaded: (bbox: BBox, date: Date, layers: LayerConfig[]) => void;
|
private readonly onBboxLoaded: (bbox: BBox, date: Date, layers: LayerConfig[]) => void;
|
||||||
|
private readonly padToTiles : number
|
||||||
constructor(
|
constructor(
|
||||||
state: {
|
state: {
|
||||||
readonly locationControl: UIEventSource<Loc>,
|
readonly locationControl: UIEventSource<Loc>,
|
||||||
|
@ -49,7 +49,8 @@ export default class OverpassFeatureSource implements FeatureSource {
|
||||||
readonly overpassMaxZoom: UIEventSource<number>,
|
readonly overpassMaxZoom: UIEventSource<number>,
|
||||||
readonly currentBounds: UIEventSource<BBox>
|
readonly currentBounds: UIEventSource<BBox>
|
||||||
},
|
},
|
||||||
options?: {
|
options: {
|
||||||
|
padToTiles: number,
|
||||||
isActive?: UIEventSource<boolean>,
|
isActive?: UIEventSource<boolean>,
|
||||||
relationTracker: RelationsTracker,
|
relationTracker: RelationsTracker,
|
||||||
onBboxLoaded?: (bbox: BBox, date: Date, layers: LayerConfig[]) => void
|
onBboxLoaded?: (bbox: BBox, date: Date, layers: LayerConfig[]) => void
|
||||||
|
@ -57,6 +58,7 @@ export default class OverpassFeatureSource implements FeatureSource {
|
||||||
|
|
||||||
this.state = state
|
this.state = state
|
||||||
this._isActive = options.isActive;
|
this._isActive = options.isActive;
|
||||||
|
this.padToTiles = options.padToTiles;
|
||||||
this.onBboxLoaded = options.onBboxLoaded
|
this.onBboxLoaded = options.onBboxLoaded
|
||||||
this.relationsTracker = options.relationTracker
|
this.relationsTracker = options.relationTracker
|
||||||
const self = this;
|
const self = this;
|
||||||
|
@ -109,11 +111,14 @@ export default class OverpassFeatureSource implements FeatureSource {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bounds = this.state.currentBounds.data?.pad(this.state.layoutToUse.widenFactor)?.expandToTileBounds(14);
|
const bounds = this.state.currentBounds.data?.pad(this.state.layoutToUse.widenFactor)?.expandToTileBounds(this.padToTiles);
|
||||||
|
|
||||||
if (bounds === undefined) {
|
if (bounds === undefined) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
console.log("Current bounds are", this.state.currentBounds.data," padded with",this.state.layoutToUse.widenFactor+":",
|
||||||
|
this.state.currentBounds.data.pad(this.state.layoutToUse.widenFactor),
|
||||||
|
"Tileexpanded: ",this.state.currentBounds.data?.pad(this.state.layoutToUse.widenFactor)?.expandToTileBounds(this.padToTiles) )
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -116,16 +116,15 @@ export class BBox {
|
||||||
return this.minLat
|
return this.minLat
|
||||||
}
|
}
|
||||||
|
|
||||||
pad(factor: number): BBox {
|
pad(factor: number, maxIncrease = 2): BBox {
|
||||||
const latDiff = this.maxLat - this.minLat
|
|
||||||
const lat = (this.maxLat + this.minLat) / 2
|
const latDiff = Math.min(maxIncrease / 2, Math.abs(this.maxLat - this.minLat) * factor)
|
||||||
const lonDiff = this.maxLon - this.minLon
|
const lonDiff =Math.min(maxIncrease / 2, Math.abs(this.maxLon - this.minLon) * factor)
|
||||||
const lon = (this.maxLon + this.minLon) / 2
|
|
||||||
return new BBox([[
|
return new BBox([[
|
||||||
lon - lonDiff * factor,
|
this.minLon - lonDiff,
|
||||||
lat - latDiff * factor
|
this.minLat - latDiff
|
||||||
], [lon + lonDiff * factor,
|
], [this.maxLon + lonDiff,
|
||||||
lat + latDiff * factor]])
|
this.maxLat + latDiff]])
|
||||||
}
|
}
|
||||||
|
|
||||||
toLeaflet() {
|
toLeaflet() {
|
||||||
|
|
|
@ -58,7 +58,7 @@ export default class FeaturePipeline {
|
||||||
private readonly freshnesses = new Map<string, TileFreshnessCalculator>();
|
private readonly freshnesses = new Map<string, TileFreshnessCalculator>();
|
||||||
|
|
||||||
private readonly oldestAllowedDate: Date = new Date(new Date().getTime() - 60 * 60 * 24 * 30 * 1000);
|
private readonly oldestAllowedDate: Date = new Date(new Date().getTime() - 60 * 60 * 24 * 30 * 1000);
|
||||||
private readonly osmSourceZoomLevel = 14
|
private readonly osmSourceZoomLevel = 15
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
handleFeatureSource: (source: FeatureSourceForLayer & Tiled) => void,
|
handleFeatureSource: (source: FeatureSourceForLayer & Tiled) => void,
|
||||||
|
@ -147,7 +147,7 @@ export default class FeaturePipeline {
|
||||||
// We split them up into tiles anyway as it is an OSM source
|
// We split them up into tiles anyway as it is an OSM source
|
||||||
TiledFeatureSource.createHierarchy(src, {
|
TiledFeatureSource.createHierarchy(src, {
|
||||||
layer: src.layer,
|
layer: src.layer,
|
||||||
minZoomLevel: 14,
|
minZoomLevel: this.osmSourceZoomLevel,
|
||||||
dontEnforceMinZoom: true,
|
dontEnforceMinZoom: true,
|
||||||
registerTile: (tile) => {
|
registerTile: (tile) => {
|
||||||
new RegisteringAllFromFeatureSourceActor(tile)
|
new RegisteringAllFromFeatureSourceActor(tile)
|
||||||
|
@ -200,7 +200,7 @@ export default class FeaturePipeline {
|
||||||
new PerLayerFeatureSourceSplitter(state.filteredLayers,
|
new PerLayerFeatureSourceSplitter(state.filteredLayers,
|
||||||
(source) => TiledFeatureSource.createHierarchy(source, {
|
(source) => TiledFeatureSource.createHierarchy(source, {
|
||||||
layer: source.layer,
|
layer: source.layer,
|
||||||
minZoomLevel: 14,
|
minZoomLevel: this.osmSourceZoomLevel,
|
||||||
dontEnforceMinZoom: true,
|
dontEnforceMinZoom: true,
|
||||||
maxFeatureCount: state.layoutToUse.clustering.minNeededElements,
|
maxFeatureCount: state.layoutToUse.clustering.minNeededElements,
|
||||||
maxZoomLevel: state.layoutToUse.clustering.maxZoom,
|
maxZoomLevel: state.layoutToUse.clustering.maxZoom,
|
||||||
|
@ -333,6 +333,7 @@ export default class FeaturePipeline {
|
||||||
const self = this;
|
const self = this;
|
||||||
const updater = new OverpassFeatureSource(state,
|
const updater = new OverpassFeatureSource(state,
|
||||||
{
|
{
|
||||||
|
padToTiles: this.osmSourceZoomLevel,
|
||||||
relationTracker: this.relationTracker,
|
relationTracker: this.relationTracker,
|
||||||
isActive: useOsmApi.map(b => !b && overpassIsActive.data, [overpassIsActive]),
|
isActive: useOsmApi.map(b => !b && overpassIsActive.data, [overpassIsActive]),
|
||||||
onBboxLoaded: ((bbox, date, downloadedLayers) => {
|
onBboxLoaded: ((bbox, date, downloadedLayers) => {
|
||||||
|
|
|
@ -50,13 +50,11 @@ export default class ThemeIntroductionPanel extends Combine {
|
||||||
)
|
)
|
||||||
|
|
||||||
super([
|
super([
|
||||||
layout.description.Clone(),
|
layout.description.Clone().SetClass("blcok mb-4"),
|
||||||
"<br/><br/>",
|
|
||||||
toTheMap,
|
toTheMap,
|
||||||
loginStatus,
|
loginStatus.SetClass("block"),
|
||||||
layout.descriptionTail?.Clone(),
|
layout.descriptionTail?.Clone().SetClass("block mt-4"),
|
||||||
"<br/>",
|
languagePicker.SetClass("block mt-4"),
|
||||||
languagePicker,
|
|
||||||
...layout.CustomCodeSnippets()
|
...layout.CustomCodeSnippets()
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,10 @@
|
||||||
"nl": "Een kaart om toeristisch relevante info op aan te duiden"
|
"nl": "Een kaart om toeristisch relevante info op aan te duiden"
|
||||||
},
|
},
|
||||||
"description": {
|
"description": {
|
||||||
"nl": "Op deze kaart kan je info zien die relevant is voor toerisme, zoals:<br/><ul><li>Eetgelegenheden</li><li>Cafés en bars</li><li>(Fiets)oplaadpunten</li><li>Fietspompen, fietserverhuur en fietswinkels</li><li>Uitkijktorens</li><li>...</li></ul> Zie je fouten op de kaart? Dan kan je zelf makkelijk aanpasingen maken, die zichtbaar zijn voor iedereen. Hiervoor dien je een gratis OpenStreetMap account voor te maken.<br/><br/>Met de steun van Toerisme Vlaanderen<img src='./assets/themes/toerisme_vlaanderen/logo.png' />"
|
"nl": "Op deze kaart kan je info zien die relevant is voor toerisme, zoals:<br/><ul><li>Eetgelegenheden</li><li>Cafés en bars</li><li>(Fiets)oplaadpunten</li><li>Fietspompen, fietserverhuur en fietswinkels</li><li>Uitkijktorens</li><li>...</li></ul> Zie je fouten op de kaart? Dan kan je zelf makkelijk aanpasingen maken, die zichtbaar zijn voor iedereen. Hiervoor dien je een gratis OpenStreetMap account voor te maken."
|
||||||
|
},
|
||||||
|
"descriptionTail": {
|
||||||
|
"nl": "Met de steun van Toerisme Vlaanderen<img style='height:5rem; width: auto;' src='./assets/themes/toerisme_vlaanderen/logo.png' />"
|
||||||
},
|
},
|
||||||
"icon": "./assets/svg/star.svg",
|
"icon": "./assets/svg/star.svg",
|
||||||
"startZoom": 8,
|
"startZoom": 8,
|
||||||
|
@ -28,21 +31,37 @@
|
||||||
"cafe_pub"
|
"cafe_pub"
|
||||||
],
|
],
|
||||||
"override": {
|
"override": {
|
||||||
"minzoom": 16
|
"minzoom": 17
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"builtin": "charging_station",
|
"builtin": [
|
||||||
|
"bench",
|
||||||
|
"waste_basket"
|
||||||
|
],
|
||||||
"override": {
|
"override": {
|
||||||
"minzoom": 16
|
"minzoom": 19
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"toilet",
|
{
|
||||||
"bench",
|
"builtin": [
|
||||||
"waste_basket",
|
"charging_station",
|
||||||
"bike_repair_station",
|
"toilet",
|
||||||
"binocular",
|
"bike_repair_station"
|
||||||
"observation_tower"
|
],
|
||||||
|
"override": {
|
||||||
|
"minzoom": 14
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"builtin": [
|
||||||
|
"binocular",
|
||||||
|
"observation_tower"
|
||||||
|
],
|
||||||
|
"override": {
|
||||||
|
"minzoom": 10
|
||||||
|
}
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"hideFromOverview": true
|
"hideFromOverview": true
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue