import { Component, Injectable } from '@angular/core';
import { Location } from '@angular/common';
import { Store } from '@ngrx/store';
import * as mapReducers from '../../reducers/map.reducer';
import { commonReducers, ItemTypeService, ItemService, FolderService } from '@farmmaps/common';
import { Router } from '@angular/router';
import { ForItemType } from '../for-item/for-itemtype.decorator';
import { AbstractSelectedItemComponent } from '../selected-item/selected-item.component';
import * as mapActions from '../../actions/map.actions';


@ForItemType("vnd.farmmaps.itemtype.geotiff.processed")
@Injectable()
@Component({
  selector: 'fm-map-selected-item-geotiff',
  templateUrl: './selected-item-geotiff.component.html',
  styleUrls: ['./selected-item-geotiff.component.scss']
})
export class SelectedItemGeotiffComponent extends AbstractSelectedItemComponent {

  constructor(store: Store<mapReducers.State | commonReducers.State>, itemTypeService: ItemTypeService, location: Location, router: Router, private itemService$: ItemService,private folderService$: FolderService) {
    super(store, itemTypeService,location,router);
  }

  onLayerChanged(layerIndex: number) {
    this.store.dispatch(new mapActions.SetLayerIndex(layerIndex));
  }

  layer(layers:any,layerIndex:number) {
    return layers.find(l => l.index == layerIndex);
  }
}
