|
|
|
@ -1,30 +1,43 @@
|
|
|
|
|
import { Component, Input, Injectable, OnInit } from '@angular/core';
|
|
|
|
|
import { Location } from '@angular/common';
|
|
|
|
|
import { Feature } from 'ol';
|
|
|
|
|
import { Store } from '@ngrx/store';
|
|
|
|
|
import * as mapReducers from '../../reducers/map.reducer';
|
|
|
|
|
import { commonReducers, ItemTypeService, IItem, Item, ItemService, FolderService, IListItem} from '@farmmaps/common';
|
|
|
|
|
import { Router, ActivatedRoute, ParamMap, Event } from '@angular/router';
|
|
|
|
|
import { ForItemType } from '../for-item/for-itemtype.decorator';
|
|
|
|
|
import { AbstractSelectedItemComponent } from '../selected-item/selected-item.component';
|
|
|
|
|
import { Observable } from 'rxjs';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ForItemType("vnd.farmmaps.itemtype.cropfield")
|
|
|
|
|
@Injectable()
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'fm-map-selected-item-cropfield',
|
|
|
|
|
templateUrl: './selected-item-cropfield.component.html',
|
|
|
|
|
styleUrls: ['./selected-item-cropfield.component.scss']
|
|
|
|
|
})
|
|
|
|
|
export class SelectedItemCropfieldComponent extends AbstractSelectedItemComponent implements OnInit{
|
|
|
|
|
|
|
|
|
|
public items: Observable<IListItem[]>;
|
|
|
|
|
|
|
|
|
|
constructor(store: Store<mapReducers.State | commonReducers.State>, itemTypeService: ItemTypeService, location: Location, router: Router, private itemService$: ItemService,private folderService$: FolderService) {
|
|
|
|
|
super(store, itemTypeService,location,router);
|
|
|
|
|
}
|
|
|
|
|
ngOnInit() {
|
|
|
|
|
this.items = this.folderService$.getItems(this.item.code, 0, 1000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
import { Component, Input, Injectable, OnInit } from '@angular/core';
|
|
|
|
|
import { Location } from '@angular/common';
|
|
|
|
|
import { Feature } from 'ol';
|
|
|
|
|
import { Store } from '@ngrx/store';
|
|
|
|
|
import * as mapReducers from '../../reducers/map.reducer';
|
|
|
|
|
import { commonReducers, ItemTypeService, IItem, Item, ItemService, FolderService, IListItem} from '@farmmaps/common';
|
|
|
|
|
import { Router, ActivatedRoute, ParamMap, Event } from '@angular/router';
|
|
|
|
|
import { ForItemType } from '../for-item/for-itemtype.decorator';
|
|
|
|
|
import { AbstractSelectedItemComponent } from '../selected-item/selected-item.component';
|
|
|
|
|
import { Observable } from 'rxjs';
|
|
|
|
|
import {GeoJSON} from 'ol/format';
|
|
|
|
|
import {getArea} from 'ol/sphere';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ForItemType("vnd.farmmaps.itemtype.cropfield")
|
|
|
|
|
@Injectable()
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'fm-map-selected-item-cropfield',
|
|
|
|
|
templateUrl: './selected-item-cropfield.component.html',
|
|
|
|
|
styleUrls: ['./selected-item-cropfield.component.scss']
|
|
|
|
|
})
|
|
|
|
|
export class SelectedItemCropfieldComponent extends AbstractSelectedItemComponent implements OnInit{
|
|
|
|
|
|
|
|
|
|
public items: Observable<IListItem[]>;
|
|
|
|
|
|
|
|
|
|
constructor(store: Store<mapReducers.State | commonReducers.State>, itemTypeService: ItemTypeService, location: Location, router: Router, private itemService$: ItemService,private folderService$: FolderService) {
|
|
|
|
|
super(store, itemTypeService,location,router);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
areaInHa(item:IItem):number {
|
|
|
|
|
if(!item) return 0;
|
|
|
|
|
// get area from faeture if 0 calculate from polygon
|
|
|
|
|
let a = item.data.area;
|
|
|
|
|
if(a) return a;
|
|
|
|
|
let format = new GeoJSON();
|
|
|
|
|
let polygon = format.readGeometry(item.geometry);
|
|
|
|
|
return getArea(polygon,{projection:"EPSG:4326"}) / 10000;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
|
this. items = this.folderService$.getItems(this.item.code, 0, 1000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|