-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'expander-component' of github.com:OurPlanscape/Planscap…
…e into expander-component
- Loading branch information
Showing
18 changed files
with
156 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/interface/src/app/treatments/map-project-areas/map-project-areas.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<mgl-vector-source | ||
id="scenarioProjectAreas" | ||
[tiles]="[vectorLayerUrl]"></mgl-vector-source> | ||
|
||
<mgl-layer | ||
id="map-project-areas-line" | ||
type="line" | ||
source="scenarioProjectAreas" | ||
[sourceLayer]="layerName" | ||
[paint]="{ | ||
'line-color': '#333', | ||
'line-width': 2 | ||
}"></mgl-layer> | ||
|
||
<mgl-layer | ||
id="map-project-areas-fill" | ||
type="fill" | ||
source="scenarioProjectAreas" | ||
[sourceLayer]="layerName" | ||
[paint]="paint"></mgl-layer> | ||
|
||
<mgl-layer | ||
id="map-project-areas-labels" | ||
type="symbol" | ||
source="scenarioProjectAreas" | ||
[sourceLayer]="layerName" | ||
[layout]="{ | ||
'text-field': ['get', 'rank'], | ||
'text-size': 14, | ||
'text-anchor': 'center', | ||
'text-justify': 'center' | ||
}" | ||
[paint]="{ | ||
'text-color': '#000', | ||
'text-halo-color': '#fff', | ||
'text-halo-width': 2 | ||
}"></mgl-layer> |
Empty file.
28 changes: 28 additions & 0 deletions
28
src/interface/src/app/treatments/map-project-areas/map-project-areas.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { MapProjectAreasComponent } from './map-project-areas.component'; | ||
import { MockDeclarations } from 'ng-mocks'; | ||
import { | ||
LayerComponent, | ||
VectorSourceComponent, | ||
} from '@maplibre/ngx-maplibre-gl'; | ||
|
||
describe('MapProjectAreasComponent', () => { | ||
let component: MapProjectAreasComponent; | ||
let fixture: ComponentFixture<MapProjectAreasComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [MapProjectAreasComponent], | ||
declarations: MockDeclarations(VectorSourceComponent, LayerComponent), | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(MapProjectAreasComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
56 changes: 56 additions & 0 deletions
56
src/interface/src/app/treatments/map-project-areas/map-project-areas.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { Component, Input } from '@angular/core'; | ||
import { | ||
FeatureComponent, | ||
GeoJSONSourceComponent, | ||
LayerComponent, | ||
VectorSourceComponent, | ||
} from '@maplibre/ngx-maplibre-gl'; | ||
import { getColorForProjectPosition } from '../../plan/plan-helpers'; | ||
import { LayerSpecification, Map as MapLibreMap } from 'maplibre-gl'; | ||
import { environment } from '../../../environments/environment'; | ||
|
||
@Component({ | ||
selector: 'app-map-project-areas', | ||
standalone: true, | ||
imports: [ | ||
FeatureComponent, | ||
GeoJSONSourceComponent, | ||
LayerComponent, | ||
VectorSourceComponent, | ||
], | ||
templateUrl: './map-project-areas.component.html', | ||
styleUrl: './map-project-areas.component.scss', | ||
}) | ||
export class MapProjectAreasComponent { | ||
@Input() scenarioId!: number; | ||
@Input() mapLibreMap!: MapLibreMap; | ||
|
||
readonly layerName = 'project_areas_by_scenario'; | ||
readonly tilesUrl = | ||
environment.martin_server + 'project_areas_by_scenario/{z}/{x}/{y}'; | ||
|
||
constructor() {} | ||
|
||
get vectorLayerUrl() { | ||
return this.tilesUrl + `?scenario_id=${this.scenarioId}`; | ||
} | ||
|
||
paint: LayerSpecification['paint'] = { | ||
'fill-outline-color': '#000', | ||
'fill-color': this.getFillColors() as any, | ||
'fill-opacity': 0.5, | ||
}; | ||
|
||
getFillColors() { | ||
const defaultColor = '#00000050'; | ||
const matchExpression: (number | string | string[])[] = [ | ||
'match', | ||
['get', 'rank'], | ||
]; | ||
for (let i = 1; i < 11; i++) { | ||
matchExpression.push(i.toString(), getColorForProjectPosition(i)); | ||
} | ||
matchExpression.push(defaultColor); | ||
return matchExpression; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
src/interface/src/app/treatments/map-rectangle/map-rectangle.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
src/interface/src/app/treatments/treatment-overview/treatment-overview.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
<app-treatment-summary | ||
[treatmentPlanId]="treatmentPlanId"></app-treatment-summary> | ||
|
||
<app-treatment-map [treatmentPlanId]="treatmentPlanId"></app-treatment-map> | ||
<app-treatment-map | ||
[treatmentPlanId]="treatmentPlanId" | ||
[scenarioId]="scenarioId"></app-treatment-map> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters