FarmMapsLib/projects/common-map/src/fm-map/components/feature-list-feature-cropfield/feature-list-feature-cropfi...

35 lines
1.3 KiB
TypeScript
Raw Normal View History

import { Component, Injectable,ViewChild,AfterViewInit} from '@angular/core';
import { Feature } from 'ol';
2021-10-05 11:46:10 +00:00
import { Geometry } from 'ol/geom';
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';
2020-02-25 14:14:29 +00:00
import {getArea} from 'ol/sphere';
2021-03-20 11:00:04 +00:00
@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']
})
2021-03-20 11:00:04 +00:00
export class FeatureListFeatureCropfieldComponent extends AbstractFeatureListFeatureComponent {
constructor(store: Store<mapReducers.State | commonReducers.State>, itemTypeService: ItemTypeService,config:AppConfig) {
super(store, itemTypeService,config);
}
2021-10-05 11:46:10 +00:00
areaInHa(feature:Feature<Geometry>):number {
if(!feature) return 0;
// get area from faeture if 0 calculate from polygon
2023-03-06 13:04:14 +00:00
const a = feature.get('area');
if(a) return a;
2021-10-05 11:46:10 +00:00
return getArea(feature.getGeometry(),{projection:"EPSG:3857"}) / 10000;
}
}