Merge upstream

This commit is contained in:
Pieter Vander Vennet 2024-01-31 11:37:09 +01:00
parent bc826bebed
commit aa89d4120c
2 changed files with 21 additions and 24 deletions

View file

@ -6,11 +6,14 @@ import { BBox } from "../../BBox"
export interface SnappingOptions { export interface SnappingOptions {
/** /**
* If the distance is bigger then this amount, don't snap. * If the distance to the line is bigger then this amount, don't snap.
* In meter * In meter
*/ */
maxDistance: number maxDistance: number
/**
* If set to true, no value will be given if no snapping was made
*/
allowUnsnapped?: false | boolean allowUnsnapped?: false | boolean
/** /**

View file

@ -7,7 +7,10 @@
import { BBox } from "../../Logic/BBox" import { BBox } from "../../Logic/BBox"
import type { MapProperties } from "../../Models/MapProperties" import type { MapProperties } from "../../Models/MapProperties"
import ShowDataLayer from "../Map/ShowDataLayer" import ShowDataLayer from "../Map/ShowDataLayer"
import type { FeatureSource, FeatureSourceForLayer } from "../../Logic/FeatureSource/FeatureSource" import type {
FeatureSource,
FeatureSourceForLayer,
} from "../../Logic/FeatureSource/FeatureSource"
import SnappingFeatureSource from "../../Logic/FeatureSource/Sources/SnappingFeatureSource" import SnappingFeatureSource from "../../Logic/FeatureSource/Sources/SnappingFeatureSource"
import FeatureSourceMerger from "../../Logic/FeatureSource/Sources/FeatureSourceMerger" import FeatureSourceMerger from "../../Logic/FeatureSource/Sources/FeatureSourceMerger"
import LayerConfig from "../../Models/ThemeConfig/LayerConfig" import LayerConfig from "../../Models/ThemeConfig/LayerConfig"
@ -40,14 +43,7 @@
coordinate = value.data coordinate = value.data
} }
export let snapToLayers: string[] | undefined export let snapToLayers: string[] | undefined
export let targetLayer: LayerConfig | LayerConfig[] | undefined export let targetLayer: LayerConfig | undefined
let targetLayers: LayerConfig[] | undefined
if (Array.isArray(targetLayers)) {
targetLayers = <LayerConfig[]>targetLayer
} else if (targetLayer) {
targetLayers = [<LayerConfig>targetLayer]
}
export let maxSnapDistance: number = undefined export let maxSnapDistance: number = undefined
export let snappedTo: UIEventSource<string | undefined> export let snappedTo: UIEventSource<string | undefined>
@ -61,7 +57,7 @@
const xyz = Tiles.embedded_tile(coordinate.lat, coordinate.lon, 16) const xyz = Tiles.embedded_tile(coordinate.lat, coordinate.lon, 16)
const map: UIEventSource<MlMap> = new UIEventSource<MlMap>(undefined) const map: UIEventSource<MlMap> = new UIEventSource<MlMap>(undefined)
let initialMapProperties: Partial<MapProperties> = { let initialMapProperties: Partial<MapProperties> & {location} = {
zoom: new UIEventSource<number>(19), zoom: new UIEventSource<number>(19),
maxbounds: new UIEventSource(undefined), maxbounds: new UIEventSource(undefined),
/*If no snapping needed: the value is simply the map location; /*If no snapping needed: the value is simply the map location;
@ -78,15 +74,15 @@
rasterLayer: UIEventSource.feedFrom(state.mapProperties.rasterLayer), rasterLayer: UIEventSource.feedFrom(state.mapProperties.rasterLayer),
} }
targetLayers?.forEach(layer => { if (targetLayer) {
const featuresForLayer = state.perLayer.get(layer.id) const featuresForLayer = state.perLayer.get(targetLayer.id)
if (featuresForLayer) { if (featuresForLayer) {
new ShowDataLayer(map, { new ShowDataLayer(map, {
layer, layer: targetLayer,
features: featuresForLayer, features: featuresForLayer,
}) })
} }
}) }
if (snapToLayers?.length > 0) { if (snapToLayers?.length > 0) {
const snapSources: FeatureSource[] = [] const snapSources: FeatureSource[] = []
@ -111,25 +107,23 @@
allowUnsnapped: true, allowUnsnapped: true,
snappedTo, snappedTo,
snapLocation: value, snapLocation: value,
}, }
) )
targetLayers.forEach(layer => { new ShowDataLayer(map, {
new ShowDataLayer(map, { layer: targetLayer,
layer, features: snappedLocation,
features: snappedLocation,
})
}) })
} }
</script> </script>
<LocationInput <LocationInput
initialCoordinate={coordinate}
{map} {map}
mapProperties={initialMapProperties}
maxDistanceInMeters={50}
on:click={(data) => dispatch("click", data)} on:click={(data) => dispatch("click", data)}
mapProperties={initialMapProperties}
value={preciseLocation} value={preciseLocation}
initialCoordinate={coordinate}
maxDistanceInMeters={50}
> >
<slot name="image" slot="image"> <slot name="image" slot="image">
<Move_arrows class="h-full max-h-24" /> <Move_arrows class="h-full max-h-24" />