MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / _getPixelBbox

Method _getPixelBbox

src/mapboxgl/overlay/VideoLayer.js:214–241  ·  view source on GitHub ↗
(bounds, bbox, allContained = true)

Source from the content-addressed store, hash-verified

212 render() { }
213
214 _getPixelBbox(bounds, bbox, allContained = true) {
215 let minX = 0;
216 let minY = 0;
217 bounds.forEach((item, index) => {
218 if ((!minX || item < minX) && index % 2 === 0) {
219 minX = item;
220 }
221 if ((!minY || item < minY) && index % 2 !== 0) {
222 minY = item;
223 }
224 });
225 let maxX = 0;
226 let maxY = 0;
227 if (bbox && !allContained) {
228 let pixelLeftBottom = this.map.project([bbox[0], bbox[1]]);
229 let pixelRightTop = this.map.project([bbox[2], bbox[3]]);
230 maxX = Math.min(Math.abs(minX - pixelLeftBottom.x), Math.abs(minX - pixelRightTop.x));
231 maxY = Math.max(Math.abs(minY - pixelLeftBottom.y), Math.abs(minY - pixelRightTop.y));
232 }
233 bounds = bounds.map((item, index) => {
234 if (index % 2 === 0) {
235 return item - minX - maxX;
236 } else {
237 return item - minY + maxY;
238 }
239 });
240 return bounds;
241 }
242
243 _initParameters(parameters) {
244 if (parameters && !Object.keys(parameters).length) {

Callers 1

onAddMethod · 0.95

Calls 4

forEachMethod · 0.80
minMethod · 0.80
maxMethod · 0.80
mapMethod · 0.80

Tested by

no test coverage detected