    import { defaultValue } from './Utils'
    import GeometryType from '../base/enum/GeometryType'
    import {
      Circle,
      Extent,
      LineString,
      Log,
      MultiPolygon,
      Point,
      Polygon
    } from '../index'

    /**
     * @function createGeometry
     * @private
     * @param options 生成参数
     * @description 根据参数生成几何
     * @return Geometry 生成的几何对象
     */
    function createGeometry(options) {
      options = defaultValue(options, {})

      switch (options.type) {
        case GeometryType.circle:
          return new Circle(options)
        case GeometryType.extent:
          return new Extent(options)
        case GeometryType.lineString:
          return new LineString(options)
        case GeometryType.multiPolygon:
          return new MultiPolygon(options)
        case GeometryType.point:
          return new Point(options)
        case GeometryType.polygon:
          return new Polygon(options)
        default:
          return new Polygon(options)
      }
    }

    /**
     * @description: 获取几何中心
     * @param {*} geometry
     * @return {Point}
     */
    function getGeometryCenter(geometry) {
      if (!geometry) {
        Log.error('几何为空')
      }
      let point
      switch (geometry.type) {
        case GeometryType.point: {
          point = geometry
          break
        }
        case GeometryType.multiPoint:
        case GeometryType.lineString:
        case GeometryType.multiLineString:
        case GeometryType.multiPolygon: {
          point = geometry.extent.center
          break
        }
        case GeometryType.polygon: {
          point = geometry.centroid
          break
        }
        case GeometryType.extent: {
          point = geometry.center
          break
        }
        case GeometryType.circle: {
          point = geometry.center
          break
        }
        default: {
          point = geometry.extent.center
        }
      }
      return point
    }

    export { createGeometry, getGeometryCenter }