LayerServer: fix some bugs in build_db-script, decode MVT-tilesource for more features

This commit is contained in:
Pieter Vander Vennet 2024-02-02 20:04:39 +01:00
parent ee3e000cd1
commit 5b318236bf
8 changed files with 327 additions and 103 deletions

View file

@ -1,5 +1,5 @@
import { Store } from "../../UIEventSource"
import DynamicTileSource, { PolygonSourceMerger } from "./DynamicTileSource"
import DynamicTileSource from "./DynamicTileSource"
import { Utils } from "../../../Utils"
import { BBox } from "../../BBox"
import LayerConfig from "../../../Models/ThemeConfig/LayerConfig"
@ -7,6 +7,8 @@ import MvtSource from "../Sources/MvtSource"
import { Tiles } from "../../../Models/TileRange"
import Constants from "../../../Models/Constants"
import FeatureSourceMerger from "../Sources/FeatureSourceMerger"
import { LineSourceMerger } from "./LineSourceMerger"
import { PolygonSourceMerger } from "./PolygonSourceMerger"
class PolygonMvtSource extends PolygonSourceMerger{
@ -39,6 +41,36 @@ class PolygonMvtSource extends PolygonSourceMerger{
}
class LineMvtSource extends LineSourceMerger{
constructor( layer: LayerConfig,
mapProperties: {
zoom: Store<number>
bounds: Store<BBox>
},
options?: {
isActive?: Store<boolean>
}) {
const roundedZoom = mapProperties.zoom.mapD(z => Math.min(Math.floor(z/2)*2, 14))
super(
roundedZoom,
layer.minzoom,
(zxy) => {
const [z, x, y] = Tiles.tile_from_index(zxy)
const url = Utils.SubstituteKeys(Constants.VectorTileServer,
{
z, x, y, layer: layer.id,
type: "lines",
})
return new MvtSource(url, x, y, z)
},
mapProperties,
{
isActive: options?.isActive,
})
}
}
class PointMvtSource extends DynamicTileSource {
constructor(
@ -84,9 +116,9 @@ export default class DynamicMvtileSource extends FeatureSourceMerger {
isActive?: Store<boolean>
},
) {
const roundedZoom = mapProperties.zoom.mapD(z => Math.floor(z))
super(
new PointMvtSource(layer, mapProperties, options),
new LineMvtSource(layer, mapProperties, options),
new PolygonMvtSource(layer, mapProperties, options)
)