Browse Source

💄 display zoom warning dependently on zoom level

jmacura 3 years ago
parent
commit
3276bb1a7c

+ 2 - 2
src/app/app.service.ts

@@ -218,7 +218,7 @@ export class AppService {
             },
             },
             //path: 'User generated',
             //path: 'User generated',
           },
           },
-          minZoom: 15,
+          minZoom: this.calcService.MIN_LPIS_VISIBLE_ZOOM,
           opacity: 0.7,
           opacity: 0.7,
           source: lpisSource,
           source: lpisSource,
         }),
         }),
@@ -227,7 +227,7 @@ export class AppService {
             title: 'LPIS (WMS)',
             title: 'LPIS (WMS)',
             queryCapabilities: false,
             queryCapabilities: false,
           },
           },
-          maxZoom: 15,
+          maxZoom: this.calcService.MIN_LPIS_VISIBLE_ZOOM,
           source: new TileWMS({
           source: new TileWMS({
             url: 'https://gis.lesprojekt.cz/cgi-bin/mapserv?map=/home/dima/maps/foodie/lpis.map',
             url: 'https://gis.lesprojekt.cz/cgi-bin/mapserv?map=/home/dima/maps/foodie/lpis.map',
             params: {
             params: {

+ 1 - 1
src/app/calculator/calculator.component.html

@@ -27,7 +27,7 @@
       <ng-template #noField>
       <ng-template #noField>
         <div>
         <div>
           <p class="p-1 text-info">{{ 'CALCULATOR.selectField' | translate}}</p>
           <p class="p-1 text-info">{{ 'CALCULATOR.selectField' | translate}}</p>
-          <p class="p-1 text-warning" *ngIf="!lpisWfsVisible()"><i class="icon-warning-sign"></i>&nbsp;{{ 'CALCULATOR.zoomIn' | translate}}</p>
+          <p class="p-1 text-warning" *ngIf="!lpisWfsVisible"><i class="icon-warning-sign"></i>&nbsp;{{ 'CALCULATOR.zoomIn' | translate}}</p>
         </div>
         </div>
       </ng-template>
       </ng-template>
       <div>
       <div>

+ 8 - 4
src/app/calculator/calculator.component.ts

@@ -20,6 +20,7 @@ export class CalculatorComponent implements HsPanelComponent {
     selectedProduct: Index;
     selectedProduct: Index;
     selectedFieldsProperties: {[x: string]: any}[];
     selectedFieldsProperties: {[x: string]: any}[];
   };
   };
+  lpisWfsVisible: boolean;
   name: 'calculator';
   name: 'calculator';
   viewRef: ViewRef;
   viewRef: ViewRef;
 
 
@@ -35,16 +36,19 @@ export class CalculatorComponent implements HsPanelComponent {
         this.data.selectedFieldsProperties.push(feature.getProperties());
         this.data.selectedFieldsProperties.push(feature.getProperties());
       }
       }
     });
     });
+    this.calcService.viewChanges.subscribe((view) => {
+      if (view.getZoom() > this.calcService.MIN_LPIS_VISIBLE_ZOOM) {
+        this.lpisWfsVisible = true;
+        return;
+      }
+      this.lpisWfsVisible = false;
+    });
   }
   }
 
 
   isVisible(): boolean {
   isVisible(): boolean {
     return this.hsLayoutService.panelVisible('calculator');
     return this.hsLayoutService.panelVisible('calculator');
   }
   }
 
 
-  lpisWfsVisible(): boolean {
-    return this.calcService.lpisWfsVisible();
-  }
-
   noFieldSelected(): boolean {
   noFieldSelected(): boolean {
     return this.fieldService.noFieldSelected();
     return this.fieldService.noFieldSelected();
   }
   }

+ 5 - 8
src/app/calculator/calculator.service.ts

@@ -22,6 +22,7 @@ export class CalculatorService {
   AVAILABLE_PRODUCTS = ['EVI', 'RVI4S1'] as const;
   AVAILABLE_PRODUCTS = ['EVI', 'RVI4S1'] as const;
   BLUR_MIN_VALUE = 0 as const;
   BLUR_MIN_VALUE = 0 as const;
   BLUR_MAX_VALUE = 5 as const;
   BLUR_MAX_VALUE = 5 as const;
+  MIN_LPIS_VISIBLE_ZOOM = 15 as const;
   SERVICE_BASE_URL = 'https://fieldcalc.lesprojekt.cz/' as const;
   SERVICE_BASE_URL = 'https://fieldcalc.lesprojekt.cz/' as const;
   availableDates: Array<string>;
   availableDates: Array<string>;
   blurValue = 0;
   blurValue = 0;
@@ -30,6 +31,7 @@ export class CalculatorService {
   lpisLoading = false;
   lpisLoading = false;
   quantileCount = 4;
   quantileCount = 4;
   selectedDate: string;
   selectedDate: string;
+  viewChanges: Subject<any> = new Subject();
   //selectedProduct;
   //selectedProduct;
   private _datesLoading: boolean;
   private _datesLoading: boolean;
   private _zonesLoading: boolean;
   private _zonesLoading: boolean;
@@ -55,11 +57,10 @@ export class CalculatorService {
       this.selectedDate = undefined;
       this.selectedDate = undefined;
     });
     });
     this.hsEventBus.olMapLoads.subscribe((map) => {
     this.hsEventBus.olMapLoads.subscribe((map) => {
-      console.log(map);
+      map.getView().on('change:resolution', (evt) => {
+        this.viewChanges.next(evt.target);
+      });
     });
     });
-    this.hsEventBus.mapExtentChanges.subscribe((obj) => {
-      console.log(obj);
-    })
   }
   }
 
 
   noDates(): boolean {
   noDates(): boolean {
@@ -170,10 +171,6 @@ export class CalculatorService {
     }
     }
   }
   }
 
 
-  lpisWfsVisible(): boolean {
-    return;
-  }
-
   /**
   /**
    * Updates WMS-t layer with the source image
    * Updates WMS-t layer with the source image
    * @param date - ISO date
    * @param date - ISO date