import { LayerType } from '@mapgis/webclient-common/base/enum'
import IGSVectorTileLayerView from './IGSVectorTileLayerView'
import WMSLayerView from './WMSLayerView'
import WMTSLayerView from './WMTSLayerView'
import IGSTileLayerView from './IGSTileLayerView'
import IGSMapImageLayerView from './IGSMapImageLayerView'
import IGSM3DLayerView from './IGSM3DLayerView'
import Cesium3DTilesLayerView from './Cesium3DTilesLayerView'
import IGSSceneLayerView from './IGSSceneLayerView'
import TerrainCacheLayerView from './TerrainCacheLayerView'
import EchartsLayerView from './EchartsLayerView'
import MapVLayerView from './MapVLayerView'
import GroupLayerView from './GroupLayerView'
import GraphicsLayerView from './GraphicsLayerView'
import IGSFeatureLayerView from './IGSFeatureLayerView'
import GeoJSONLayerView from './GeoJSONLayerView'
import WFSLayerView from './WFSLayerView'
import TDTLayerView from './TDTLayerView'
import M3DCacheLayerView from './M3DCacheLayerView'
import ArcGISMapImageLayerView from './ArcGISMapImageLayerView'
import ArcGISTileLayerView from './ArcGISTileLayerView'
import CesiumFeatureRender from '../util/CesiumFeatureRender'

function getLayerView(view, layer) {
  let instance = null
  const type = layer.type
  switch (type) {
    case LayerType.igsVectorTile: {
      instance = new IGSVectorTileLayerView({
        view,
        layer
      })
      break
    }
    case LayerType.wmts:
      instance = new WMTSLayerView({
        view,
        layer
      })
      break
    case LayerType.igsMapImage:
      instance = new IGSMapImageLayerView({
        view,
        layer
      })
      break
    case LayerType.igsTile:
      instance = new IGSTileLayerView({
        view,
        layer
      })
      break
    case LayerType.wms:
      instance = new WMSLayerView({
        view,
        layer
      })
      break
    case LayerType.m3d:
      instance = new IGSM3DLayerView({
        view,
        layer
      })
      break
    case LayerType.cesium3DTiles:
      instance = new Cesium3DTilesLayerView({
        view,
        layer
      })
      break
    case LayerType.scene:
      instance = new IGSSceneLayerView({
        view,
        layer
      })
      break
    case LayerType.terrain:
      instance = new TerrainCacheLayerView({
        view,
        layer
      })
      break
    case LayerType.echarts:
      instance = new EchartsLayerView({
        view,
        layer
      })
      break
    case LayerType.mapv:
      instance = new MapVLayerView({
        view,
        layer
      })
      break
    case LayerType.group:
      instance = new GroupLayerView({
        view,
        layer
      })
      break
    case LayerType.graphics:
      instance = new GraphicsLayerView({
        view,
        layer,
        render: new CesiumFeatureRender()
      })
      break
    case LayerType.igsFeature:
      instance = new IGSFeatureLayerView({
        view,
        layer,
        render: new CesiumFeatureRender()
      })
      break
    case LayerType.geojson:
      instance = new GeoJSONLayerView({
        view,
        layer,
        render: new CesiumFeatureRender()
      })
      break
    case LayerType.wfs:
      instance = new WFSLayerView({
        view,
        layer,
        render: new CesiumFeatureRender()
      })
      break
    case LayerType.tdt:
      instance = new TDTLayerView({
        view,
        layer
      })
      break
    case LayerType.m3dCache:
      instance = new M3DCacheLayerView({
        view,
        layer
      })
      break
    case LayerType.arcgisMapImage:
      instance = new ArcGISMapImageLayerView({
        view,
        layer
      })
      break
    case LayerType.arcgisTile:
      instance = new ArcGISTileLayerView({
        view,
        layer
      })
      break
    default: {
      break
    }
  }
  return instance
}

export { IGSVectorTileLayerView, getLayerView }
