当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript proj.transformExtent函数代码示例

本文整理汇总了TypeScript中ol/proj.transformExtent函数的典型用法代码示例。如果您正苦于以下问题:TypeScript transformExtent函数的具体用法?TypeScript transformExtent怎么用?TypeScript transformExtent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了transformExtent函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: extentWrapped

export function extentWrapped(map: ol.Map, extent: Extent) {
  // Return an extent that's wrapped so that it follows the camera as it pans across a looping map.
  let extentWgs = OLProj.transformExtent(extent, WEB_MERCATOR, WGS84)
  const centroid = [
    (extentWgs[0] + extentWgs[2]) / 2,
    (extentWgs[1] + extentWgs[3]) / 2,
  ] as Point

  const wrapIndex = getWrapIndex(map, centroid)
  extentWgs[0] += wrapIndex * 360
  extentWgs[2] += wrapIndex * 360

  return OLProj.transformExtent(extentWgs, WGS84, WEB_MERCATOR)
}
开发者ID:venicegeo,项目名称:bf-ui,代码行数:14,代码来源:geometries.ts

示例2: Error

    map.once('postcompose', (event: ol.render.Event) => {
      const canvas = event.context.canvas
      const imageData = event.context.getImageData(0, 0, canvas.width, canvas.height)
      const newCanvas = document.createElement('canvas')
      const context = newCanvas.getContext('2d')
      if (!context) {
        throw new Error('Could not get context!')
      }

      newCanvas.width = canvas.width
      newCanvas.height = canvas.height
      context.putImageData(imageData, 0, 0)

      const extent = map.getView().calculateExtent(map.getSize())
      const transformedExtent = proj.transformExtent(extent, 'EPSG:3857', 'EPSG:4326')
      const truncatedExtent = transformedExtent.map(n => n.toFixed(2))

      context.fillStyle = 'white'
      context.fillRect(0, newCanvas.height - 50, newCanvas.width, 50)
      context.font = '12pt monospace'
      context.fillStyle = 'black'
      context.textAlign = 'left'
      context.fillText(timestamp, 10, (newCanvas.height - 20))
      context.textAlign = 'right'
      context.fillText('Viewport: ' + truncatedExtent, newCanvas.width - 10, (newCanvas.height - 20))
      hyperlink.href = newCanvas.toDataURL()
    })
开发者ID:venicegeo,项目名称:bf-ui,代码行数:27,代码来源:openlayers.ExportControl.ts

示例3: calculateExtent

export function calculateExtent(geometry: OLGeometry) {
  if (geometry instanceof OLMultiPolygon && crossesMeridian(geometry)) {
    const extents = geometry.getPolygons().map(g => OLProj.transformExtent(g.getExtent(), WEB_MERCATOR, WGS84))
    let [, minY, , maxY] = OLProj.transformExtent(geometry.getExtent(), WEB_MERCATOR, WGS84)
    let width = 0
    let minX = 180

    for (const [polygonMinX, , polygonMaxX] of extents) {
      width += polygonMaxX - polygonMinX

      if (polygonMaxX > 0) {
        minX -= polygonMaxX - polygonMinX
      }
    }

    return OLProj.transformExtent([minX, minY, minX + width, maxY], WGS84, WEB_MERCATOR)
  }

  return geometry.getExtent()  // Use as-is
}
开发者ID:venicegeo,项目名称:bf-ui,代码行数:20,代码来源:geometries.ts

示例4: serializeBbox

export function serializeBbox(extent: Extent) {
  const bbox = OLProj.transformExtent(extent, WEB_MERCATOR, WGS84)
  const p1 = bbox.slice(0, 2)
  const p2 = bbox.slice(2, 4)
  return p1.concat(p2).map(truncate) as Extent
}
开发者ID:venicegeo,项目名称:bf-ui,代码行数:6,代码来源:geometries.ts

示例5: deserializeBbox

export function deserializeBbox(serialized: Extent | null) {
  if (serialized && serialized.length === 4) {
    return OLProj.transformExtent(serialized, WGS84, WEB_MERCATOR)
  }
  return null
}
开发者ID:venicegeo,项目名称:bf-ui,代码行数:6,代码来源:geometries.ts

示例6: crossesMeridian

export function crossesMeridian(geometry: OLGeometry) {
  const [minX, , maxX] = OLProj.transformExtent(geometry.getExtent(), WEB_MERCATOR, WGS84)
  return minX === -180 && maxX === 180
}
开发者ID:venicegeo,项目名称:bf-ui,代码行数:4,代码来源:geometries.ts

示例7:

 const extents = geometry.getPolygons().map(g => OLProj.transformExtent(g.getExtent(), WEB_MERCATOR, WGS84))
开发者ID:venicegeo,项目名称:bf-ui,代码行数:1,代码来源:geometries.ts


注:本文中的ol/proj.transformExtent函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。