Skip to content

Commit

Permalink
Fix polling
Browse files Browse the repository at this point in the history
  • Loading branch information
newmanw committed Jul 29, 2024
1 parent 90d6800 commit a032cb3
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 45 deletions.
21 changes: 12 additions & 9 deletions web-app/src/app/event/event.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable } from "@angular/core";
import { Observable, catchError, finalize, of, tap, zip } from "rxjs";
import { Observable, ObservableInput, catchError, finalize, forkJoin, of, tap, zip } from "rxjs";
import * as moment from 'moment'
import { FilterService } from "../filter/filter.service";
import { PollingService } from "./polling.service";
Expand Down Expand Up @@ -214,7 +214,7 @@ export class EventService {
}

removeUsersChangedListener(listener) {
this.usersChangedListeners = this.usersChangedListeners.forEach((l: any) => {
this.usersChangedListeners = this.usersChangedListeners.filter((l: any) => {
return listener !== l;
});
}
Expand Down Expand Up @@ -459,9 +459,7 @@ export class EventService {

fetch(): Observable<any> {
const event = this.filterService.getEvent();
if (!event) {
return of()
}
if (!event) { return of()}

const parameters: any = {};
const interval = this.filterService.getInterval();
Expand All @@ -470,10 +468,10 @@ export class EventService {
parameters.interval = time;
}

return zip(
this.fetchObservations(event, parameters),
this.fetchLocations(event, parameters)
)
return forkJoin({
locations: this.fetchLocations(event, parameters),
observations: this.fetchObservations(event, parameters)
})
}

fetchLayers(event) {
Expand Down Expand Up @@ -558,6 +556,8 @@ export class EventService {
this.eventsById[event.id].filteredObservationsById = observationsById;

this.observationsChanged({ added: added, updated: updated, removed: removed });

console.log('got observations', observations.length)
});

return observable
Expand Down Expand Up @@ -618,6 +618,9 @@ export class EventService {
this.eventsById[event.id].filteredUsersById = usersById;

this.usersChanged({ added: added, updated: updated, removed: removed });

console.log('got locations', userLocations.length)

});

return observable
Expand Down
6 changes: 1 addition & 5 deletions web-app/src/app/map/map.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
}

.map-container {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 100%;
}

.map-controls-left {
Expand Down
66 changes: 36 additions & 30 deletions web-app/src/app/map/map.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import * as moment from 'moment'
import 'leaflet-editable'
import 'leaflet.markercluster'
import { FeatureEditor } from './edit/FeatureEditor'
import GeoPackageLayers from './geopackage/GeoPackageLayers'
import { FilterService } from '../filter/filter.service'

Icon.Default.imagePath = '/'

Expand All @@ -44,6 +46,7 @@ export class MapComponent implements OnDestroy, AfterViewInit {
map: any
groups: any = {}
layers: any = {}
geoPackageLayers: any
temporalLayers: any = []
spiderfyState: any = null
currentLocation: any = null
Expand All @@ -58,8 +61,9 @@ export class MapComponent implements OnDestroy, AfterViewInit {

constructor(
private mapService: MapService,
layerService: MapLayerService,
private layerService: MapLayerService,
private eventService: EventService,
private filterService: FilterService,
private localStorageService: LocalStorageService
) {
this.groups['base'] = {
Expand Down Expand Up @@ -103,6 +107,10 @@ export class MapComponent implements OnDestroy, AfterViewInit {
}

ngAfterViewInit() {
const screenHeight = window.innerHeight;
const screenWidth = window.innerWidth;
console.log(`height ${screenHeight} width ${screenWidth}`);

let mapPosition = this.localStorageService.getMapPosition()
if (!mapPosition) {
this.localStorageService.setMapPosition({
Expand Down Expand Up @@ -177,13 +185,12 @@ export class MapComponent implements OnDestroy, AfterViewInit {
}
this.map.on('moveend', saveMapPosition, this)

// this.geoPackageLayers = new GeoPackageLayers(
// this.map,
// this.layerControl,
// this.LayerService,
// this.FilterService,
// this.LocalStorageService
// )
this.geoPackageLayers = new GeoPackageLayers(
this.map,
this.layerService,
this.filterService,
this.localStorageService
)

this.map.on('baselayerchange', baseLayer => {
const layer = this.layers[baseLayer.id]
Expand Down Expand Up @@ -356,7 +363,7 @@ export class MapComponent implements OnDestroy, AfterViewInit {
added.forEach(added => {
switch (added.type) {
case 'GeoPackage':
// this.createGeoPackageLayer(added)
this.createGeoPackageLayer(added)
break
case 'Imagery':
this.createRasterLayer(added)
Expand Down Expand Up @@ -386,6 +393,11 @@ export class MapComponent implements OnDestroy, AfterViewInit {

// TODO move into leaflet service, this and map clip both use it
createRasterLayer(layerInfo) {
console.log('create raster layer', layerInfo)
const screenHeight = window.innerHeight;
const screenWidth = window.innerWidth;
console.log(`create raster layer height ${screenHeight} width ${screenWidth}`);

let paneName = this.BASE_LAYER_PANE
if (!layerInfo.base) {
paneName = `pane-${layerInfo.id}`
Expand Down Expand Up @@ -422,16 +434,10 @@ export class MapComponent implements OnDestroy, AfterViewInit {
this.featurePanes.push(pane)
}

// table.layer = this.geoPackageLayers.createGeoPackageLayer(table, layerInfo.id, pane)
table.layer = this.geoPackageLayers.createGeoPackageLayer(table, layerInfo.id, pane)
this.layers[layerInfo.id + table.name] = table

// TODO output
// this.onAddLayer({
// type: 'GeoPackage',
// name: table.name,
// table: table,
// layer: table.layer
// })
this.addLayer(layerInfo)
})
}

Expand Down Expand Up @@ -689,18 +695,18 @@ export class MapComponent implements OnDestroy, AfterViewInit {
}

removeGeoPackage(layer) {
// layer.tables.forEach(table => {
// const id = layer.id + table.name
// const layerInfo = this.layers[id]
// if (layerInfo) {
// this.map.removeLayer(table.layer)
// delete this.layers[id]

// // this.onRemoveLayer({ // TODO
// // layer: table
// // })
// }
// })
layer.tables.forEach(table => {
const id = layer.id + table.name
const layerInfo = this.layers[id]
if (layerInfo) {
this.map.removeLayer(table.layer)
delete this.layers[id]

// this.onRemoveLayer({ // TODO
// layer: table
// })
}
})
}

onHideFeed() {
Expand Down Expand Up @@ -807,7 +813,7 @@ export class MapComponent implements OnDestroy, AfterViewInit {
}
}

baseToggled(event: ToggleEvent): void {
baseToggled(event: ToggleEvent): void {
const baseLayers = this.groups['base'].layers
const previousBaseLayer = baseLayers.find((layer: any) => layer.selected)
if (previousBaseLayer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ export class PollingIntervalComponent implements OnInit, OnDestroy {
}

public compareOption = function (option, value): boolean {
return option.interval === value.interval
return option?.interval === value?.interval
}
}

0 comments on commit a032cb3

Please sign in to comment.