Skip to content

Commit

Permalink
Merge pull request #1991 from asfadmin/tyler/displacement-overview
Browse files Browse the repository at this point in the history
feat: disp overviews in layer selector
  • Loading branch information
williamh890 authored Oct 21, 2024
2 parents d5c886e + f547bd2 commit d75ab71
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,29 @@
</button>
</mat-menu>
</button>
<button mat-menu-item class="control-mat-checkbox-toggle" [matMenuTriggerFor]="timeseriesCoherence"
(click)="clearDisplacementLayer()"
>
<mat-checkbox class="checkbox" [disabled]="true" [checked]="displacementOverview">
</mat-checkbox>
Displacement Overview
<mat-menu #timeseriesCoherence="matMenu">
<button class="control-mat-checkbox-toggle" mat-menu-item (click)="onSetDisplacementLayer('ASC')">
<mat-radio-button
[disabled]="true"
[checked]="displacementOverview === 'ASC'"
></mat-radio-button>
ASC
</button>
<button class="control-mat-checkbox-toggle" mat-menu-item (click)="onSetDisplacementLayer('DESC')">
<mat-radio-button
[disabled]="true"
[checked]="displacementOverview === 'DESC'"
></mat-radio-button>
DESC
</button>
</mat-menu>
</button>

<button mat-menu-item
class="control-mat-checkbox-toggle"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class LayerSelectorComponent implements OnInit, OnDestroy {
public breakpoint: models.Breakpoints;
public breakpoints = models.Breakpoints;
private coherenceLayerOpacity: number;
public displacementOverview;


private subs = new SubSink();
Expand Down Expand Up @@ -105,6 +106,14 @@ export class LayerSelectorComponent implements OnInit, OnDestroy {
this.onSetCoherenceLayer(months);
}
}
public onSetDisplacementLayer(type: string) {
this.displacementOverview = type;
this.mapService.setDisplacementOverview(type);
}
public clearDisplacementLayer() {
this.displacementOverview = null;
this.mapService.clearDisplacementOverview();
}

public onSetCoherenceLayer(months: string): void {
this.mapService.setCoherenceLayer(months);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,10 @@ label {
vertical-align: super;
}

::ng-deep .mdc-radio__inner-circle {
:host ::ng-deep .mdc-radio__inner-circle {
border-color: #236192 !important; /*change radio button color when selected*/
}

::ng-deep .mdc-radio__outer-circle {
:host ::ng-deep .mdc-radio__outer-circle {
border-color: #ffcc33 !important; /*change radio button color when selected*/
}
45 changes: 34 additions & 11 deletions src/app/services/map/map.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';

import { BehaviorSubject, Subject } from 'rxjs';
import { map, sampleTime, tap } from 'rxjs/operators';
import { first, map, sampleTime, tap } from 'rxjs/operators';

import { Collection, Feature, Map, View } from 'ol';
import { Layer, Vector as VectorLayer } from 'ol/layer';
Expand Down Expand Up @@ -72,6 +72,8 @@ export class MapService {

private localBrowseImageURL: string;

private displacementOverview: TileLayer;

private selectClick = new Select({
condition: click,
style: polygonStyle.hidden,
Expand Down Expand Up @@ -481,16 +483,7 @@ export class MapService {
collapsed: true,
className: 'ol-overviewmap ol-custom-overviewmap',
});
let test_url: string = 'https://d1riv60tezqha9.cloudfront.net/asjohnston/tiles/{z}/{x}/{-y}.png';
const test_source = new XYZ({
'url': test_url,
wrapX: models.mapOptions.wrapX,
tileSize: [256,256]
});

const test_layer = new TileLayer({ 'source': test_source,
extent: [-13914936.349159, 2753366.075619,-7235730.950894, 6274861.394007]
});

const newMap = new Map({
layers: [
Expand All @@ -500,7 +493,6 @@ export class MapService {
this.selectedLayer,
this.mapView?.gridlines,
this.pinnedProducts,
test_layer
],
target: 'map',
view: this.mapView.view,
Expand Down Expand Up @@ -743,6 +735,37 @@ export class MapService {
this.hasCoherenceLayer$.next(months);
}

public setDisplacementOverview(type: string) {

let base_url = `https://opera-disp-tms-dev.s3.amazonaws.com/${type.toLowerCase()}/mask`;

this.http.get(`${base_url}/extent.json`).pipe(
first()
).subscribe((response: any) => {
if (this.displacementOverview) {
this.map.removeLayer(this.displacementOverview);
this.displacementOverview = null;
}

const overview_source = new XYZ({
'url': `${base_url}/{z}/{x}/{y}.png`,
wrapX: models.mapOptions.wrapX,
tileSize: [256,256]
});

this.displacementOverview = new TileLayer({ 'source': overview_source,
'extent': response['extent']
});

this.map.addLayer(this.displacementOverview);
})

}
public clearDisplacementOverview() {
this.map.removeLayer(this.displacementOverview);
this.displacementOverview = null;
}

public setDisplacementLayer(points: Point[]) {
if (!!this.displacmentLayer) {
this.map.removeLayer(this.displacmentLayer);
Expand Down

0 comments on commit d75ab71

Please sign in to comment.