本文整理汇总了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)
}
示例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()
})
示例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
}
示例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
}
示例5: deserializeBbox
export function deserializeBbox(serialized: Extent | null) {
if (serialized && serialized.length === 4) {
return OLProj.transformExtent(serialized, WGS84, WEB_MERCATOR)
}
return null
}
示例6: crossesMeridian
export function crossesMeridian(geometry: OLGeometry) {
const [minX, , maxX] = OLProj.transformExtent(geometry.getExtent(), WEB_MERCATOR, WGS84)
return minX === -180 && maxX === 180
}
示例7:
const extents = geometry.getPolygons().map(g => OLProj.transformExtent(g.getExtent(), WEB_MERCATOR, WGS84))