Commit 71c3de83 authored by alain's avatar alain 🐙
Browse files

fix stations with same location offsets

parent 2626b512
......@@ -14,9 +14,11 @@ import IconInfo from "../Modal/IconInfo"
import { GridLayer } from '@deck.gl/aggregation-layers';
import Tooltip from "./Tooltip"
import { doOffsets } from 'util/plot';
class DeckLayers extends React.Component {
constructor(props){
......@@ -43,24 +45,30 @@ class DeckLayers extends React.Component {
const count = {}
Object.keys(deckLayers).forEach(deckLayer => {
let previousData = []
Object.keys(deckLayers[deckLayer]).forEach(source => {
if(!count[source]) {
count[source] = { current: 0, total: 0 }
if(deckLayers[deckLayer][source].layerDefinition && deckLayers[deckLayer][source].layerDefinition.type === 'StationLayer') {
if(!count[source]) {
count[source] = { current: 0, total: 0 }
}
count[source].total++
deckLayers[deckLayer][source].data = doOffsets([...previousData, deckLayers[deckLayer][source].data])
previousData.push(deckLayers[deckLayer][source].data)
}
count[source].total++
})
})
Object.keys(deckLayers).forEach(deckLayer => {
Object.keys(deckLayers[deckLayer]).forEach(sourceName => {
const { layerDefinition, source, data } = deckLayers[deckLayer][sourceName]
count[sourceName].current++
if(!layerDefinition) return
count[sourceName].current++
switch(layerDefinition.type) {
case "StationLayer":
const unit = (layerDefinition.units ? layerDefinition.units.find(x => x.id === unitStatus[layerDefinition.id]) : null)
......
......@@ -96,7 +96,7 @@ class StationLayer extends CompositeLayer {
},
updateTriggers: {
getElevation: [zoom],
getPosition: [radius]
getPosition: [radius, count]
}
})
]
......
......@@ -15,7 +15,6 @@ import { initialLayers, dataGroups } from "../../config/data.js"
import { mapDefaults, mapLocations, mapControlSettings, mapStyle } from "../../config/map.js"
import { inArray } from "util/data.js"
import { doOffsets } from "util/plot.js"
import MapGL, { FlyToInterpolator } from "react-map-gl"
import WebMercatorViewport from 'viewport-mercator-project'
......@@ -121,22 +120,19 @@ class App extends React.Component {
loadingError: true
})
} else {
const previousData = []
Object.keys(deckLayers[layer]).forEach(source => {
if(deckLayers[layer][source].data) previousData.push(deckLayers[layer][source].data)
})
//const previousData = Object.values(deckLayers[layer]).map(source => source.data)
// const previousData = []
// Object.keys(deckLayers[layer]).forEach(source => {
// if(deckLayers[layer][source].data) previousData.push(deckLayers[layer][source].data)
// })
deckLayers[layer][source.name] = {
layerDefinition,
source,
//data: (previousData.length > 0 ? doOffsets([...previousData, data]) : data)
data: doOffsets([...previousData, data])
data
}
this.setState({
deckLayers,
//loaded: this.state.loaded + 1,
loading: this.state.loading - 1
})
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment