Skip to content

Commit

Permalink
feat: add priority to map
Browse files Browse the repository at this point in the history
  • Loading branch information
tylercchase committed Oct 22, 2024
1 parent 9722d8f commit f126588
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@
</mat-menu>
</button>

<button mat-menu-item
class="control-mat-checkbox-toggle"
(click)="togglePriority()">
<mat-checkbox class="checkbox"
[disabled]="true"
[checked]="priorityEnabled">
</mat-checkbox>
Displacement Priority
</button>
<button mat-menu-item
class="control-mat-checkbox-toggle"
(click)="onToggleGridlines()">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class LayerSelectorComponent implements OnInit, OnDestroy {
public breakpoints = models.Breakpoints;
private coherenceLayerOpacity: number;
public displacementOverview;
public priorityEnabled = false;


private subs = new SubSink();
Expand Down Expand Up @@ -131,6 +132,16 @@ export class LayerSelectorComponent implements OnInit, OnDestroy {

this.clearCoherenceLayer();
}
public togglePriority(): void {
if(!this.priorityEnabled) {
this.mapService.enablePriority();
this.priorityEnabled = true;
}
else {
this.priorityEnabled = false;
this.mapService.disablePriority();
}
}

public onToggleOverviewMap(isOpen: boolean): void {
this.store$.dispatch(new mapStore.ToggleOverviewMap(!isOpen));
Expand Down
46 changes: 45 additions & 1 deletion src/app/services/map/map.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import SimpleGeometry from 'ol/geom/SimpleGeometry';
import { SetGeocode } from '@store/filters';
import { Extent } from 'ol/extent';
import { MultiPolygon } from 'ol/geom';
import GeoJSON from 'ol/format/GeoJSON.js';

@Injectable({
providedIn: 'root'
Expand Down Expand Up @@ -73,6 +74,7 @@ export class MapService {
private localBrowseImageURL: string;

private displacementOverview: TileLayer;
private priorityOverview: VectorLayer<VectorSource>;

private selectClick = new Select({
condition: click,
Expand Down Expand Up @@ -816,7 +818,49 @@ export class MapService {
this.layerService.coherenceLayer = null;
this.hasCoherenceLayer$.next(null);
}

public enablePriority(): void {
const source = new VectorSource({
url: '/assets/priority_rollout.json',
format: new GeoJSON({})
},
)
const colorTable = [
'rgba(092, 174, 099, 0.9)',
'rgba(195, 164, 207, 0.9)',
'rgba(152, 110, 172, 0.8)',
'rgba(116, 040, 129, 0.4)',
]
this.priorityOverview = new VectorLayer({
source: source,
style: function(feature, _resolution) {
const test = feature.getProperties();
const priority= +test['priority'];
let color = '#FF0000';
if(priority === 0) {
color = colorTable[0];
} else if(priority <= 5) {
color = colorTable[1];
} else if(priority <= 20) {
color = colorTable[2];
} else {
color = colorTable[3]
}
return new Style({
fill: new Fill({
color: color
}),
stroke: new Stroke({
color: 'black',
})
});
}
})
this.map.addLayer(this.priorityOverview)
}
public disablePriority(): void {
this.map.removeLayer(this.priorityOverview);
this.priorityOverview = null;
}
public createBrowseRasterCanvas(scenes: models.CMRProduct[]) {
const scenesWithBrowse = scenes.filter(scene => scene.browses?.length > 0).slice(0, 10);

Expand Down
Loading

0 comments on commit f126588

Please sign in to comment.