Skip to content

Commit

Permalink
Merge remote-tracking branch 'Discovery-SearchUI/tyler/displacement' …
Browse files Browse the repository at this point in the history
…into andy/displacement
  • Loading branch information
artisticlight committed Aug 21, 2024
2 parents f991dcc + ae6eb70 commit 6a9ce24
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import { Store } from '@ngrx/store';
import { AppState } from '@store';
import * as uiStore from '@store/ui';
import * as mapStore from '@store/map';
import * as searchStore from '@store/search';

import { Subject } from 'rxjs';
import { tap, delay } from 'rxjs/operators';

import { menuAnimation, MapInteractionModeType } from '@models';
import { menuAnimation, MapInteractionModeType, SearchType } from '@models';
import * as services from '@services';
import { DrawNewPolygon } from '@store/map';
import { SetGeocode } from '@store/filters';
Expand All @@ -31,6 +32,9 @@ export class AoiFilterComponent implements OnInit, OnDestroy {
public isHoveringAOISelector = false;
public isAOIOptionsOpen: boolean;

public searchType$ = this.store$.select(searchStore.getSearchType);
public searchtype: SearchType;

public polygon: string;
private subs = new SubSink();

Expand All @@ -47,7 +51,9 @@ export class AoiFilterComponent implements OnInit, OnDestroy {
isAOIOptionsOpen => this.isAOIOptionsOpen = isAOIOptionsOpen
)
);

this.subs.add(
this.searchType$.subscribe( searchtype => this.searchtype = searchtype)
);
this.subs.add(
this.mapService.searchPolygon$.subscribe(
p => {
Expand Down Expand Up @@ -83,7 +89,7 @@ export class AoiFilterComponent implements OnInit, OnDestroy {
const polygon = (event.target as HTMLInputElement).value;
const didLoad = this.mapService.loadPolygonFrom(polygon);

if (!didLoad) {
if (!didLoad || (this.searchtype === SearchType.DISPLACEMENT && !(polygon.toLowerCase().includes('point')))) {
this.aoiErrors$.next();
} else {
this.store$.dispatch(new SetGeocode(''));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="breadcrumb scene-selector" [class.scene-selector]="breakpoint === breakpoints.FULL"
[class.medium-scene-selector]="breakpoint === breakpoints.MEDIUM"
[class.small-scene-selector]="breakpoint === breakpoints.SMALL">
<app-burst-selector></app-burst-selector>
<app-aoi-filter></app-aoi-filter>
</div>

<div class="breadcrumb search-button-layout">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Component, OnInit, Input, OnDestroy, ViewChild, ElementRef } from '@angular/core';
import { Observable, Subject } from 'rxjs';
import { first, Observable, Subject } from 'rxjs';
import { ResizeEvent } from 'angular-resizable-element';

import { Store } from '@ngrx/store';
import { AppState } from '@store';
import * as uiStore from '@store/ui';
import * as searchStore from '@store/search';

import { Breakpoints, LonLat, SearchType } from '@models';
import { Breakpoints, SearchType } from '@models';
import { DrawService, MapService, NetcdfService, PointHistoryService, ScreenSizeService } from '@services';

import { SubSink } from 'subsink';
Expand Down Expand Up @@ -72,11 +72,11 @@ export class TimeseriesResultsMenuComponent implements OnInit, OnDestroy {
searchType => this.searchType = searchType
)
);
this.pointHistoryService.history$.subscribe(history => {
this.subs.add(this.pointHistoryService.history$.subscribe(history => {
this.pointHistory = history;
this.mapService.setDisplacementLayer(history);
})
this.drawService.polygon$.subscribe(polygon => {
}));
this.subs.add(this.drawService.polygon$.subscribe(polygon => {
if(polygon) {
let temp = polygon.getGeometry().clone() as Point;
temp.transform('EPSG:3857', 'EPSG:4326')
Expand All @@ -85,9 +85,9 @@ export class TimeseriesResultsMenuComponent implements OnInit, OnDestroy {
} else {
this.passDraw = false;
}
this.updateChart({'lon': temp.getFlatCoordinates()[0], 'lat': temp.getFlatCoordinates()[1]});
this.updateChart(temp);
}
})
}))
}

public onResizeEnd(event: ResizeEvent): void {
Expand Down Expand Up @@ -129,8 +129,8 @@ export class TimeseriesResultsMenuComponent implements OnInit, OnDestroy {
var wktRepresenation = format.writeGeometry(this.pointHistory[index]);
this.mapService.loadPolygonFrom(wktRepresenation.toString())
}
public updateChart(lonlat: LonLat): void {
this.netcdfService.getTimeSeries(lonlat).subscribe(data => {
public updateChart(geometry): void {
this.netcdfService.getTimeSeries(geometry).pipe(first()).subscribe(data => {
this.chartData.next(data);
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class AoiOptionsComponent implements OnInit, OnDestroy {
const polygon = (event.target as HTMLInputElement).value;
const didLoad = this.mapService.loadPolygonFrom(polygon);

if (!didLoad) {
if (!didLoad || (this.searchtype === SearchType.DISPLACEMENT && !(polygon.toLowerCase().includes('point')))) {
this.aoiErrors$.next();
} else {
if (this.searchtype === SearchType.DATASET && this.isResultsMenuOpen && !this.isFiltersMenuOpen) {
Expand All @@ -111,7 +111,7 @@ export class AoiOptionsComponent implements OnInit, OnDestroy {
public onInputGeocodePolygon(event: {wkt: string, geocode: string}): void {
const didLoad = this.mapService.loadPolygonFrom(event.wkt);
this.store$.dispatch(new SetGeocode(event.geocode));
if (!didLoad) {
if (!didLoad || (this.searchtype === SearchType.DISPLACEMENT && !(event.wkt.toLowerCase().includes('point')))) {
this.aoiErrors$.next();
} else {
if (this.searchtype === SearchType.DATASET && this.isResultsMenuOpen && !this.isFiltersMenuOpen) {
Expand Down
68 changes: 21 additions & 47 deletions src/app/services/netcdf-service.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ import { Observable, first, map, of, tap } from 'rxjs';
// import WebGLTileLayer from 'ol/layer/WebGLTile';
import ImageLayer from 'ol/layer/Image';
// import Static from 'ol/source/ImageStatic';
import { LonLat, TimeSeriesResult } from '@models';
import { TimeSeriesResult } from '@models';
import ImageSource from 'ol/source/Image';
import Feature from 'ol/Feature';
import Geometry from 'ol/geom/Geometry';
import WKT from 'ol/format/WKT';

@Injectable({
providedIn: 'root'
})
export class NetcdfService {
private url: string = 'http://127.0.0.1:8080/'
private url: string = 'https://ztcnv66fekaaijerj5hhytfrdu0xcuho.lambda-url.us-east-1.on.aws/'
private itemsEndpoint: string = 'items/'
private timeSeriesEndpoint: string = 'timeseries'
private files: string[] = [""] //, "20221107_20230130.unw.nc", "20221107_20230106.unw.nc", "20221107_20230729.unw.nc", "20221107_20230319.unw.nc", "20221107_20221213.unw.nc", "20221107_20230530.unw.nc", "20221107_20230717.unw.nc", "20221107_20230412.unw.nc", "20221107_20230506.unw.nc", "20221107_20230223.unw.nc", "20221107_20230211.unw.nc", "20221107_20230331.unw.nc", "20221107_20230705.unw.nc"]
Expand Down Expand Up @@ -66,57 +67,30 @@ export class NetcdfService {
return output
}

public getTimeSeries(coords: LonLat) {
let index_id = `${coords.lat}-${coords.lon}`
public getTimeSeries(geometry) {

var format = new WKT();
var wktRepresenation = format.writeGeometry(geometry);
let index_id = wktRepresenation;
console.log(`getting ${index_id}`)
if(this.cache.hasOwnProperty(index_id)) {
return of(this.cache[index_id])
} else {
return of({
"20221107_20221213.unw.nc": {
"time": "2022-12-13T14:07:50.748",
"unwrapped_phase": -7.1020755768,
"interferometric_correlation": 0.9609375,
"temporal_coherence": 0.8041992188,
"bytes": 331350016.0
},
"20221107_20230106.unw.nc": {
"time": "2023-01-06T14:07:49.520",
"unwrapped_phase": 25.0342712402,
"interferometric_correlation": 0.9604492188,
"temporal_coherence": 0.8041992188,
"bytes": 318767104.0
},
"20221107_20230130.unw.nc": {
"time": "2023-01-30T14:07:48.874",
"unwrapped_phase": 11.7699642181,
"interferometric_correlation": 0.9711914062,
"temporal_coherence": 0.8041992188,
"bytes": 335544320.0
},
"mean": {
"time": null,
"unwrapped_phase": 9.9007196426,
"interferometric_correlation": 0.9641926885,
"temporal_coherence": 0.8041992188,
"bytes": 328553813.3333333135
}
}).pipe(map(
response => {
this.cache[index_id] = response;
this.totalKeys.push(index_id)
if(this.totalKeys.length > this.maxCacheSize) {
let deleted = this.totalKeys.splice(0);
delete this.cache[deleted[0]];
}
return response
return this.http.post(`${this.url}${this.timeSeriesEndpoint}`, {
"wkt": wktRepresenation,
"file_store": "s3://kfbx-opera-disp-test-bucket/11114.json"
}, { responseType: 'json' }).pipe(
first(),
map( response => {
this.cache[index_id] = response;
this.totalKeys.push(index_id)
if(this.totalKeys.length > this.maxCacheSize) {
let deleted = this.totalKeys.splice(0);
delete this.cache[deleted[0]];
}
return response as TimeSeriesResult
}
))
this.http.get(`${this.url}${this.timeSeriesEndpoint}?layer=unwrapped_phase&x=${coords.lat}&y=${coords.lon}`, { responseType: 'json' }).pipe(first(),
).pipe(
map(response => response as TimeSeriesResult),
)
// get data, then set things
}

}
Expand Down

0 comments on commit 6a9ce24

Please sign in to comment.