소스 검색

♻️ move projection definitions inside a class

+ rename app
jmacura 2 년 전
부모
커밋
0cea3b8dae
2개의 변경된 파일13개의 추가작업 그리고 12개의 파일을 삭제
  1. 1 1
      src/app/app.component.ts
  2. 12 11
      src/app/app.service.ts

+ 1 - 1
src/app/app.component.ts

@@ -20,7 +20,7 @@ import {FcCalculatorComponent} from './calculator/calculator-panel.component';
 })
 export class AppComponent {
   /* You can name your app as you like or not at all */
-  title = 'hslayers-application';
+  title = 'fieldcalc';
   constructor(
     private appService: AppService,
     /* Inject here all modules from HSLayers-NG which you intend to use */

+ 12 - 11
src/app/app.service.ts

@@ -23,19 +23,9 @@ import i18n from './translations.json';
 import {FcCalculatorService} from './calculator/calculator.service';
 import {imageWmsTLayer} from './calculator/image-wms-t-layer';
 
-proj4.defs(
-  'EPSG:3045',
-  '+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs'
-);
-proj4.defs(
-  'EPSG:5514',
-  '+proj=krovak +lat_0=49.5 +lon_0=24.83333333333333 +alpha=30.28813972222222 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +towgs84=542.5,89.2,456.9,5.517,2.275,5.516,6.96 +units=m +no_defs'
-);
-register(proj4);
-
 @Injectable({providedIn: 'root'})
 export class AppService {
-  sjtskProjection = getProjection('EPSG:5514');
+  sjtskProjection;
   constructor(
     public calcService: FcCalculatorService,
     public hsConfig: HsConfig,
@@ -46,6 +36,17 @@ export class AppService {
     public hsPanelContainerService: HsPanelContainerService,
     public hsSidebarService: HsSidebarService
   ) {
+    /* Define projections */
+    proj4.defs(
+      'EPSG:3045',
+      '+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs'
+    );
+    proj4.defs(
+      'EPSG:5514',
+      '+proj=krovak +lat_0=49.5 +lon_0=24.83333333333333 +alpha=30.28813972222222 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +towgs84=542.5,89.2,456.9,5.517,2.275,5.516,6.96 +units=m +no_defs'
+    );
+    register(proj4);
+    this.sjtskProjection = getProjection('EPSG:5514');
     /* Define the polygon's style using SLD */
     const fieldSld = `<?xml version="1.0" encoding="ISO-8859-1"?>
       <StyledLayerDescriptor version="1.0.0"