All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
34 lines
1.3 KiB
TypeScript
34 lines
1.3 KiB
TypeScript
import { Component, Injectable,ViewChild,AfterViewInit} from '@angular/core';
|
|
import { Feature } from 'ol';
|
|
import { Store } from '@ngrx/store';
|
|
import * as mapReducers from '../../reducers/map.reducer';
|
|
import { commonReducers,ItemTypeService,AppConfig } from '@farmmaps/common';
|
|
import { AbstractFeatureListFeatureComponent } from '../feature-list-feature/feature-list-feature.component';
|
|
import { ForItemType } from '../for-item/for-itemtype.decorator';
|
|
import {getArea} from 'ol/sphere';
|
|
|
|
|
|
|
|
@ForItemType("vnd.farmmaps.itemtype.cropfield")
|
|
@Injectable()
|
|
@Component({
|
|
selector: 'fm-map-feature-list-feature-cropfield',
|
|
templateUrl: './feature-list-feature-cropfield.component.html',
|
|
styleUrls: ['./feature-list-feature-cropfield.component.scss']
|
|
})
|
|
export class FeatureListFeatureCropfieldComponent extends AbstractFeatureListFeatureComponent {
|
|
|
|
|
|
constructor(store: Store<mapReducers.State | commonReducers.State>, itemTypeService: ItemTypeService,config:AppConfig) {
|
|
super(store, itemTypeService,config);
|
|
}
|
|
|
|
areaInHa(feature:Feature):number {
|
|
if(!feature) return 0;
|
|
// get area from faeture if 0 calculate from polygon
|
|
let a = feature.get('area');
|
|
if(a) return a;
|
|
return getArea(feature.getGeometry(),{projectio:"EPSG:3857"}) / 10000;
|
|
}
|
|
}
|