MCPcopy Create free account
hub / github.com/carbonplan/maps / getOffsets

Function getOffsets

src/utils.js:90–106  ·  view source on GitHub ↗
(length, tileSize, cameraOffset, order)

Source from the content-addressed store, hash-verified

88}
89
90const getOffsets = (length, tileSize, cameraOffset, order) => {
91 const siblingCount = (length - tileSize) / tileSize
92
93 // Do not add offset for very small fraction of tile
94 if (Math.abs(siblingCount) < 0.001) {
95 return [0, 0]
96 }
97
98 const prev = siblingCount / 2 + 0.5 - cameraOffset
99 const next = siblingCount - prev
100
101 let result = [-1 * Math.ceil(prev), Math.ceil(next)]
102 if (order === -1) {
103 result = [-1 * Math.ceil(next), Math.ceil(prev)]
104 }
105 return result
106}
107
108const getTileOffsets = (length, tileSize, camera, order) => {
109 const cameraOffset = camera - Math.floor(camera)

Callers 2

getTileOffsetsFunction · 0.85
getLatBasedOffsetsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected