Skip to content

Commit 5629203

Browse files
committed
feat: update demo-maps projection example for use of layer.nativeBbox and bbox
1 parent 02ebdf0 commit 5629203

3 files changed

Lines changed: 171 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
* **@dlr-eoc/ngx-ukis-ui-clarity:**
5959
- New UKIS library for ui-clarity related things was added.
6060
- It includes all components of `@dlr-eoc/layer-control`, `@dlr-eoc/map-tools`, `@dlr-eoc/user-info` [Issue #267](https://github.com/dlr-eoc/ukis-frontend-libraries/issues/267).
61+
- Adjust `LayerentryComponent` and `LayerentryGroupComponent` to use `nativeBbox` of types `services-layers`.
6162

6263
* **@dlr-eoc/ngx-ukis-utilities:**
6364
- New UKIS library for angular utilities was added.
@@ -66,6 +67,7 @@
6667

6768
* **@dlr-eoc/map-ol:**
6869
- Remove dependency on @cds/core [Issue #267](https://github.com/dlr-eoc/ukis-frontend-libraries/issues/267).
70+
- Use `nativeBbox` of types `services-layers` to create `olLayerOptions.extent` for layers. Use it also in `CustomLayer` to create `olLayerOptions.extent` and for olLayerGroups.
6971

7072
* **@dlr-eoc/services-layers:**
7173
- Add `properties` attribute to Layer type

projects/demo-maps/src/app/route-components/route-example-projection/route-map2.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
<clr-vertical-nav-group-children class="padding title-ellipsis">
4747
<button class="btn btn-primary" (click)="setExtent()">set Extent (Antarctic)</button>
4848
<button class="btn btn-primary" (click)="setNewProjection()">set Projection and bbox (Antarctic)</button>
49+
<button class="btn btn-primary" (click)="addLayer()">Add Swiss GeoJSON Layer</button>
4950
</clr-vertical-nav-group-children>
5051
</clr-vertical-nav-group>
5152
</clr-vertical-nav>

projects/demo-maps/src/app/route-components/route-example-projection/route-map2.component.ts

Lines changed: 168 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { ClarityIcons, layersIcon, mapIcon, compassIcon } from '@cds/core/icon';
88
import { ClrVerticalNavModule, ClrStandaloneCdkTrapFocus, ClrNavigationModule, ClrIconModule } from '@clr/angular';
99
import { LayerControlComponent, ProjectionSwitchComponent, MousePositionComponent, MapNavigatorComponent } from '@dlr-eoc/ngx-ukis-ui-clarity';
1010
import { ExtentHelperComponent } from "../../components/extent-helper/extent-helper.component";
11+
import { delay } from 'rxjs/operators';
1112
ClarityIcons.addIcons(...[layersIcon, mapIcon, compassIcon]);
1213

1314
@Component({
@@ -53,7 +54,17 @@ export class RouteMap2Component implements OnInit {
5354
units: 'm'
5455
}
5556

56-
this.projections = [EPSG_3857_Def, EPSG_3995_Def, EPSG_3031_Def, SwissCH1903, ESRI_53034];
57+
const ETRS89_UTM_37N: IProjDef = {
58+
code: 'EPSG:25837',
59+
proj4js: '+proj=utm +zone=37 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs',
60+
title: 'UTM zone 37N',
61+
extent: [-4861198.58, 3680548.11, 489848.43, 9660688.94],
62+
worldExtent: [-16.1, 33.26, 38.01, 84.73],
63+
global: false,
64+
units: 'm'
65+
}
66+
67+
this.projections = [EPSG_3857_Def, EPSG_3995_Def, EPSG_3031_Def, SwissCH1903, ESRI_53034, ETRS89_UTM_37N];
5768
this.addOverlays();
5869
/**
5970
* set map extent or IMapState (zoom, center...) with the MapStateService
@@ -65,12 +76,11 @@ export class RouteMap2Component implements OnInit {
6576

6677

6778
ngOnInit(): void {
68-
this.mapStateSvc.getMapState().subscribe(state => {
69-
console.log('MapState change', state);
70-
});
71-
72-
this.mapSvc.projectionChange.subscribe(proj => {
79+
this.mapStateSvc.getProjection().pipe(delay(300)).subscribe(proj => {
7380
console.log('Map Proj change', proj);
81+
if (proj.epsg === 'EPSG:21781') {
82+
this.addLayer();
83+
}
7484
});
7585
}
7686

@@ -137,10 +147,94 @@ export class RouteMap2Component implements OnInit {
137147
}
138148
]
139149
},
140-
visible: true
150+
visible: true,
151+
bbox: [12.122762285148893, 45.75982471322655, 22.585503751196956, 52.936158926509194]
152+
});
153+
154+
const vectorLayerPolar = new VectorLayer({
155+
id: 'geojson_test_PolarDEM',
156+
name: 'GeoJSON Vector Layer (PolarDEM)',
157+
type: 'geojson',
158+
data: {
159+
type: 'FeatureCollection',
160+
features: [
161+
{
162+
"type": "Feature",
163+
"properties": {},
164+
"geometry": {
165+
"coordinates": [
166+
[
167+
[
168+
-56.610291493162265,
169+
-63.14567134729959
170+
],
171+
[
172+
-65.55445992781995,
173+
-65.42656926101324
174+
],
175+
[
176+
-73.57228421370289,
177+
-70.01891446525254
178+
],
179+
[
180+
-79.9666203974736,
181+
-72.86460180838449
182+
],
183+
[
184+
-83.04719665248149,
185+
-74.13173444180848
186+
],
187+
[
188+
-55.69191893422601,
189+
-75.70732872975574
190+
],
191+
[
192+
-59.942004469019835,
193+
-72.39072889158679
194+
],
195+
[
196+
-61.35730570181974,
197+
-67.91201652998802
198+
],
199+
[
200+
-56.610291493162265,
201+
-63.14567134729959
202+
]
203+
]
204+
],
205+
"type": "Polygon"
206+
}
207+
}
208+
]
209+
},
210+
visible: true,
211+
bbox: [-85.02702775046276, -75.78913027273286, -49.34343400046277, -62.95113726720521],
212+
nativeBbox: {
213+
epsg: 'EPSG:3031',
214+
bbox: [-2788223.8152697003, 180971.96438660682, -1093301.5018768182, 1969824.701551262]
215+
}
141216
});
142217

143-
const overlays = [osm_layer, gufLayer, vectorLayer];
218+
const TanDEMPolarDEM = new RasterLayer({
219+
type: 'wms',
220+
url: 'https://geoservice.dlr.de/eoc/elevation/wms',
221+
name: 'TanDEM-X PolarDEM Antarctica',
222+
id: 'TDM_POLARDEM90_ANT_HSC',
223+
params: {
224+
layers: 'TDM_POLARDEM90_ANT_HSC'
225+
},
226+
visible: false,
227+
description: 'A hillshade generated from the TanDEM-X PolarDEM 90m elevation layer. This shading represents a combination slope and oblique shading.',
228+
attribution: 'PolarDEM Data &copy; DLR/EOC licensed for <a href="https://geoservice.dlr.de/resources/licenses/polardem90/License_for_the_Utilization_of_TanDEM-X-PolarDEM_90m_for_Scientific_Use.pdf">scientific use</a>',
229+
legendImg: '',
230+
bbox: [-180, -90, 180, -56.22686667234951],
231+
nativeBbox: {
232+
epsg: 'EPSG:3031',
233+
bbox: [-2699955, -2532555, 2799855, 2398455]
234+
}
235+
})
236+
237+
const overlays = [osm_layer, gufLayer, vectorLayer, TanDEMPolarDEM, vectorLayerPolar];
144238
overlays.map(layer => this.layersSvc.addLayer(layer, 'Layers'));
145239
}
146240

@@ -160,4 +254,70 @@ export class RouteMap2Component implements OnInit {
160254
this.mapStateSvc.setProjection(proJ.code, 'user', { fitToNativeBbox: nativeBbox });
161255
}
162256

257+
addLayer() {
258+
const vectorLayerSwiss = new VectorLayer({
259+
id: 'geojson_test_Swiss',
260+
name: 'GeoJSON Vector Layer (Swiss)',
261+
type: 'geojson',
262+
data: {
263+
type: 'FeatureCollection',
264+
features: [
265+
{
266+
"type": "Feature",
267+
"properties": {},
268+
"geometry": {
269+
"coordinates": [
270+
[
271+
[
272+
9.476989243125104,
273+
47.48067255204134
274+
],
275+
[
276+
8.536024138082581,
277+
47.36586953083
278+
],
279+
[
280+
7.229985139825061,
281+
47.13551220276787
282+
],
283+
[
284+
6.119337802724459,
285+
46.182699028304654
286+
],
287+
[
288+
6.926613876449522,
289+
46.41361480319924
290+
],
291+
[
292+
8.07839630011074,
293+
46.7458325561617
294+
],
295+
[
296+
9.333016440167455,
297+
47.111021589561204
298+
],
299+
[
300+
9.476989243125104,
301+
47.48067255204134
302+
]
303+
]
304+
],
305+
"type": "Polygon"
306+
}
307+
}
308+
]
309+
},
310+
visible: true,
311+
bbox: [6.121699327190461, 46.05823590807236, 9.496699327190466, 47.5945721328394],
312+
nativeBbox: {
313+
epsg: 'EPSG:21781',
314+
bbox: [495592.4002543411, 97816.18720803942, 758272.4757513476, 272596.3306093862]
315+
}
316+
});
317+
318+
if (!this.layersSvc.getLayerById(vectorLayerSwiss.id)) {
319+
this.layersSvc.addLayer(vectorLayerSwiss, 'Layers');
320+
}
321+
}
322+
163323
}

0 commit comments

Comments
 (0)