AW-4860
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
<li class="border-top pt-1 pb-1 value" *ngFor="let layerValue of layers">
|
||||
<div>{{layerValue.layerName}}</div>
|
||||
<div>{{layerValue.date|date}}</div>
|
||||
<div><span *ngIf="layerValue.quantity"><span class="me-1">{{layerValue.quantity}}</span> </span><span class="me-1 font-weight-bold">{{layerValue.value}}</span><span>{{layerValue.unit}}</span></div>
|
||||
<div><span *ngIf="layerValue.quantity"><span class="me-1">{{layerValue.quantity}}</span> </span><span class="me-1 font-weight-bold">{{getScaledValue(layerValue)}}</span><span>{{layerValue.unit}}</span></div>
|
||||
</li>
|
||||
</ul>
|
||||
<ng-template #no_data>
|
||||
@@ -15,4 +15,4 @@
|
||||
</ng-template>
|
||||
</div>
|
||||
</div>
|
||||
</div>>
|
||||
</div>
|
||||
|
@@ -1,16 +1,16 @@
|
||||
import { Component, OnInit,Input,ViewChild,ElementRef,AfterViewInit } from '@angular/core';
|
||||
import {IItemLayer} from '../../../models/item.layer';
|
||||
import { Component, OnInit, Input, ViewChild, ElementRef, AfterViewInit } from '@angular/core';
|
||||
import { IItemLayer } from '../../../models/item.layer';
|
||||
import { Store } from '@ngrx/store';
|
||||
import * as mapReducers from '../../../reducers/map.reducer';
|
||||
import * as mapActions from '../../../actions/map.actions';
|
||||
import { MapComponent } from 'ngx-openlayers';
|
||||
import { ILayervalue } from '../../../models/layer.value';
|
||||
import { Observable,interval,Subject } from 'rxjs';
|
||||
import { Observable, interval, Subject } from 'rxjs';
|
||||
import { debounce, throttle } from 'rxjs/operators';
|
||||
import { toLonLat } from 'ol/proj';
|
||||
import { toStringHDMS } from 'ol/coordinate';
|
||||
import { ClipboardService } from 'ngx-clipboard'
|
||||
import {GeoJSON,WKT} from 'ol/format';
|
||||
import { GeoJSON, WKT } from 'ol/format';
|
||||
import { Point } from 'ol/geom';
|
||||
|
||||
@Component({
|
||||
@@ -18,45 +18,53 @@ import { Point } from 'ol/geom';
|
||||
templateUrl: './layer-values.component.html',
|
||||
styleUrls: ['./layer-values.component.scss']
|
||||
})
|
||||
export class LayerValuesComponent implements OnInit,AfterViewInit {
|
||||
export class LayerValuesComponent implements OnInit, AfterViewInit {
|
||||
|
||||
@ViewChild('layerValues') containerRef:ElementRef;
|
||||
offsetX$ =0;
|
||||
offsetY$ =0;
|
||||
lonlat$="";
|
||||
wkt$= "";
|
||||
layerValues$:Observable<Array<ILayervalue>> = this.store.select(mapReducers.selectGetLayerValues);
|
||||
enabled$:Observable<boolean> = this.store.select(mapReducers.selectGetLayerValuesEnabled);
|
||||
wktFormat$:WKT;
|
||||
@ViewChild('layerValues') containerRef: ElementRef;
|
||||
offsetX$ = 0;
|
||||
offsetY$ = 0;
|
||||
lonlat$ = "";
|
||||
wkt$ = "";
|
||||
layerValues$: Observable<Array<ILayervalue>> = this.store.select(mapReducers.selectGetLayerValues);
|
||||
enabled$: Observable<boolean> = this.store.select(mapReducers.selectGetLayerValuesEnabled);
|
||||
wktFormat$: WKT;
|
||||
|
||||
constructor( private store: Store<mapReducers.State>,private map: MapComponent,private clipboardService$:ClipboardService) {
|
||||
this.wktFormat$=new WKT();
|
||||
constructor(private store: Store<mapReducers.State>, private map: MapComponent, private clipboardService$: ClipboardService) {
|
||||
this.wktFormat$ = new WKT();
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
|
||||
|
||||
}
|
||||
|
||||
moveEndSubject = new Subject<any>();
|
||||
|
||||
ngAfterViewInit():void {
|
||||
ngAfterViewInit(): void {
|
||||
this.offsetY$ = this.containerRef.nativeElement.offsetTop;
|
||||
this.offsetX$ = this.containerRef.nativeElement.offsetLeft;
|
||||
this.map.instance.on('moveend', () => {
|
||||
this.moveEndSubject.next({});
|
||||
this.moveEndSubject.next({});
|
||||
});
|
||||
this.moveEndSubject.pipe(throttle(ev => interval(100))).subscribe(() => this.updateValuesLocation());
|
||||
this.moveEndSubject.pipe(throttle(ev => interval(100))).subscribe(() => this.updateValuesLocation());
|
||||
}
|
||||
|
||||
updateValuesLocation() {
|
||||
const xy = this.map.instance.getCoordinateFromPixel([this.offsetX$,this.offsetY$])
|
||||
const xy = this.map.instance.getCoordinateFromPixel([this.offsetX$, this.offsetY$])
|
||||
const lonlat = toLonLat(xy);
|
||||
this.wkt$ = this.wktFormat$.writeGeometry(new Point(lonlat))
|
||||
this.lonlat$ = toStringHDMS(lonlat);
|
||||
this.store.dispatch(new mapActions.SetLayerValuesLocation(xy[0],xy[1]));
|
||||
}
|
||||
this.store.dispatch(new mapActions.SetLayerValuesLocation(xy[0], xy[1]));
|
||||
}
|
||||
|
||||
copyToClipboard() {
|
||||
this.clipboardService$.copy(this.wkt$);
|
||||
}
|
||||
|
||||
public getScaledValue(layerValue: ILayervalue): number {
|
||||
let v = layerValue.value;
|
||||
if (layerValue.scale && layerValue.scale != 0) {
|
||||
v = layerValue.scale * layerValue.value;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user