Skip to content

Commit

Permalink
fix(links): use network center
Browse files Browse the repository at this point in the history
  • Loading branch information
billyc committed Sep 30, 2021
1 parent e10e355 commit 7a7d86a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/plugins/links-gl/ConfigPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ export default class VueComponent extends Vue {
.config-panel {
margin-top: 0.5rem;
margin-bottom: 0.5rem;
display: flex;
flex-direction: row;
}
Expand Down
31 changes: 24 additions & 7 deletions src/plugins/links-gl/LinkVolumes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ class MyPlugin extends Vue {
private buildColumnValues: Float32Array[] = []
private baseColumnValues: Float32Array[] = []
private mapState = { center: [0, 0], zoom: 10, bearing: 0, pitch: 20 }
private isButtonActiveColumn = false
private scaleWidth = 250
Expand Down Expand Up @@ -304,8 +302,29 @@ class MyPlugin extends Vue {
this.isButtonActiveColumn = false
}
private findCenter(data: any[]): [number, number] {
return [9, 53.53]
private async setMapCenter(data: any[]) {
let samples = 0
let longitude = 0
let latitude = 0
let gap = Math.floor(data.length / 512)
for (let i = 0; i < data.length; i += gap) {
longitude += data[i][1][0]
latitude += data[i][1][1]
samples++
}
longitude = longitude / samples
latitude = latitude / samples
this.$store.commit('setMapCamera', {
longitude,
latitude,
bearing: 0,
pitch: 0,
zoom: 7,
jump: true,
})
}
private async mounted() {
Expand All @@ -327,8 +346,7 @@ class MyPlugin extends Vue {
this.isLoaded = true
// runs in background
this.mapState.center = this.findCenter([])
this.setMapCenter(allLinks)
this.buildThumbnail()
this.myState.statusMessage = ''
Expand Down Expand Up @@ -419,7 +437,6 @@ class MyPlugin extends Vue {
const allLinks: Float32Array[] = []
const numColumns = parsed.data[0].length - (this.vizDetails.useSlider ? 0 : 1)
console.log('number of columns', numColumns)
for (let i = 0; i < numColumns; i++) {
allLinks.push(new Float32Array(this.numLinks))
}
Expand Down
8 changes: 4 additions & 4 deletions src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import SVNFileSystem from './js/HTTPFileSystem'
// ----------------------------------------

const initialViewState = () => ({
// start with berlin for now
// start with western europe for now
initial: true,
// longitude: 3.4,
// latitude: 45.5,
// zoom: 4,
pitch: 0,
longitude: 13.4,
latitude: 52.5,
zoom: 9,
longitude: 10,
latitude: 50,
zoom: 5,
bearing: 0,
})

Expand Down

0 comments on commit 7a7d86a

Please sign in to comment.