MCPcopy Create free account
hub / github.com/beutton/browser-flight-simulator / getTile

Method getTile

packages/core/src/TilingScheme.ts:39–65  ·  view source on GitHub ↗
(
    geodetic: GeodeticLike,
    z: number,
    result = new TileCoordinate()
  )

Source from the content-addressed store, hash-verified

37
38 // Reference: https://github.com/CesiumGS/cesium/blob/1.122/packages/engine/Source/Core/GeographicTilingScheme.js#L210
39 getTile(
40 geodetic: GeodeticLike,
41 z: number,
42 result = new TileCoordinate()
43 ): TileCoordinate {
44 const size = this.getSize(z, vectorScratch)
45 const { rectangle } = this
46 const width = rectangle.width / size.x
47 const height = rectangle.height / size.y
48 const { west, south, east } = rectangle
49 let longitude = geodetic.longitude
50 if (east < west) {
51 longitude += Math.PI * 2
52 }
53 let x = Math.floor((longitude - west) / width)
54 if (x >= size.x) {
55 x = size.x - 1
56 }
57 let y = Math.floor((geodetic.latitude - south) / height)
58 if (y >= size.y) {
59 y = size.y - 1
60 }
61 result.x = x
62 result.y = y
63 result.z = z
64 return result
65 }
66
67 // Reference: https://github.com/CesiumGS/cesium/blob/1.122/packages/engine/Source/Core/GeographicTilingScheme.js#L169
68 getRectangle(tile: TileCoordinateLike, result = new Rectangle()): Rectangle {

Calls 1

getSizeMethod · 0.95

Tested by

no test coverage detected