Skip to content

Commit

Permalink
feat: point history list updates selection
Browse files Browse the repository at this point in the history
  • Loading branch information
tylercchase committed Aug 26, 2024
1 parent 751757e commit 189269f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
17 changes: 13 additions & 4 deletions src/app/components/map/map.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import * as mapStore from '@store/map';
import * as uiStore from '@store/ui';

import * as models from '@models';
import { MapService, WktService, ScreenSizeService, ScenesService, SarviewsEventsService } from '@services';
import { MapService, WktService, ScreenSizeService, ScenesService, SarviewsEventsService, PointHistoryService } from '@services';
import * as polygonStyle from '@services/map/polygon.style';
import { CMRProduct, SarviewsEvent } from '@models';
import { StyleLike } from 'ol/style/Style';
Expand Down Expand Up @@ -97,7 +97,8 @@ export class MapComponent implements OnInit, OnDestroy {
private screenSize: ScreenSizeService,
private scenesService: ScenesService,
private eventMonitoringService: SarviewsEventsService,
public dialog: MatDialog
public dialog: MatDialog,
private pointHistoryService: PointHistoryService
) {}

ngOnInit(): void {
Expand Down Expand Up @@ -244,8 +245,16 @@ export class MapComponent implements OnInit, OnDestroy {

this.subs.add(
this.mapService.newSelectedDisplacement$.subscribe(point => {
var format = new WKT();
var wktRepresenation = format.writeGeometry(point);
let format = new WKT();
let wktRepresenation = format.writeGeometry(point);

let pointIndex = this.pointHistoryService.getHistory().findIndex((thing) => {
if(thing === point) {
return true
}
})
this.pointHistoryService.selectedPoint = pointIndex;

this.mapService.loadPolygonFrom(wktRepresenation.toString())
})
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@if(pointHistory.length !== 0) {
<mat-radio-group>
@for (point of pointHistory; track $index) {
<mat-radio-button color="primary" (click)="onPointClick($index)">
<mat-radio-button color="primary" (click)="onPointClick($index)" [checked]="$index === pointHistoryService.selectedPoint">
{{point.flatCoordinates[0] | floatPrecision: 4}}, {{point.flatCoordinates[1] | floatPrecision: 4}}
</mat-radio-button>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { DrawService, MapService, NetcdfService, PointHistoryService, ScreenSize

import { SubSink } from 'subsink';

import { Point} from 'ol/geom';
import { Point} from 'ol/geom';
import { WKT } from 'ol/format';
import moment2 from 'moment';
import { SetScenes } from '@store/scenes';
Expand All @@ -28,6 +28,7 @@ export class TimeseriesResultsMenuComponent implements OnInit, OnDestroy {

@ViewChild('listCard', {read: ElementRef}) listCardView: ElementRef;
@ViewChild('chartCard', {read: ElementRef}) chartCardView: ElementRef;
@ViewChild('radio-group', {read: ElementRef}) radioGroup: ElementRef;

@Input() resize$: Observable<void>;
public searchType: SearchType;
Expand All @@ -49,13 +50,14 @@ export class TimeseriesResultsMenuComponent implements OnInit, OnDestroy {
public pointHistory = [];


public chartData = new Subject<any>
public chartData = new Subject<any>;
public selectedPoint: number;


constructor(
private store$: Store<AppState>,
private screenSize: ScreenSizeService,
private pointHistoryService: PointHistoryService,
public pointHistoryService: PointHistoryService,
private drawService: DrawService,
private mapService: MapService,
private netcdfService: NetcdfService
Expand Down Expand Up @@ -83,6 +85,7 @@ export class TimeseriesResultsMenuComponent implements OnInit, OnDestroy {
temp.transform('EPSG:3857', 'EPSG:4326')
if (polygon.getGeometry().getType() === 'Point') {
this.pointHistoryService.addPoint(temp);
// this.selectedPoint = temp;
}
this.updateChart(temp);
}
Expand Down Expand Up @@ -123,9 +126,10 @@ export class TimeseriesResultsMenuComponent implements OnInit, OnDestroy {
window.open(url);
}
public onPointClick(index: number) {
this.pointHistoryService.selectedPoint = index;
this.pointHistoryService.passDraw = true;
var format = new WKT();
var wktRepresenation = format.writeGeometry(this.pointHistory[index]);
let format = new WKT();
let wktRepresenation = format.writeGeometry(this.pointHistory[index]);
this.mapService.loadPolygonFrom(wktRepresenation.toString())
}
public updateChart(geometry): void {
Expand Down
4 changes: 2 additions & 2 deletions src/app/services/netcdf-service.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ export class NetcdfService {

public getTimeSeries(geometry): Observable<any> {

var format = new WKT();
var wktRepresenation = format.writeGeometry(geometry);
let format = new WKT();
let wktRepresenation = format.writeGeometry(geometry);
let index_id = wktRepresenation;
console.log(`getting ${index_id}`)
if(this.cache.hasOwnProperty(index_id)) {
Expand Down
1 change: 1 addition & 0 deletions src/app/services/point-history.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export class PointHistoryService {
private history : Point[] = [];
public history$ = new Subject<Point[]>();
public passDraw: boolean = false;
public selectedPoint: number = 0;
constructor(
) {
}
Expand Down

0 comments on commit 189269f

Please sign in to comment.