How to use calculateTileGrids method in wpt

Best JavaScript code snippet using wpt

jpx.js

Source:jpx.js Github

copy

Full Screen

...177 components.push(component);178 }179 context.SIZ = siz;180 context.components = components;181 calculateTileGrids(context, components);182 context.QCC = [];183 context.COC = [];184 break;185 case 0xFF5C: // Quantization default (QCD)186 length = readUint16(data, position);187 var qcd = {};188 j = position + 2;189 sqcd = data[j++];190 switch (sqcd & 0x1F) {191 case 0:192 spqcdSize = 8;193 scalarExpounded = true;194 break;195 case 1:196 spqcdSize = 16;197 scalarExpounded = false;198 break;199 case 2:200 spqcdSize = 16;201 scalarExpounded = true;202 break;203 default:204 throw new Error('JPX Error: Invalid SQcd value ' + sqcd);205 }206 qcd.noQuantization = (spqcdSize === 8);207 qcd.scalarExpounded = scalarExpounded;208 qcd.guardBits = sqcd >> 5;209 spqcds = [];210 while (j < length + position) {211 var spqcd = {};212 if (spqcdSize === 8) {213 spqcd.epsilon = data[j++] >> 3;214 spqcd.mu = 0;215 } else {216 spqcd.epsilon = data[j] >> 3;217 spqcd.mu = ((data[j] & 0x7) << 8) | data[j + 1];218 j += 2;219 }220 spqcds.push(spqcd);221 }222 qcd.SPqcds = spqcds;223 if (context.mainHeader) {224 context.QCD = qcd;225 } else {226 context.currentTile.QCD = qcd;227 context.currentTile.QCC = [];228 }229 break;230 case 0xFF5D: // Quantization component (QCC)231 length = readUint16(data, position);232 var qcc = {};233 j = position + 2;234 var cqcc;235 if (context.SIZ.Csiz < 257) {236 cqcc = data[j++];237 } else {238 cqcc = readUint16(data, j);239 j += 2;240 }241 sqcd = data[j++];242 switch (sqcd & 0x1F) {243 case 0:244 spqcdSize = 8;245 scalarExpounded = true;246 break;247 case 1:248 spqcdSize = 16;249 scalarExpounded = false;250 break;251 case 2:252 spqcdSize = 16;253 scalarExpounded = true;254 break;255 default:256 throw new Error('JPX Error: Invalid SQcd value ' + sqcd);257 }258 qcc.noQuantization = (spqcdSize === 8);259 qcc.scalarExpounded = scalarExpounded;260 qcc.guardBits = sqcd >> 5;261 spqcds = [];262 while (j < (length + position)) {263 spqcd = {};264 if (spqcdSize === 8) {265 spqcd.epsilon = data[j++] >> 3;266 spqcd.mu = 0;267 } else {268 spqcd.epsilon = data[j] >> 3;269 spqcd.mu = ((data[j] & 0x7) << 8) | data[j + 1];270 j += 2;271 }272 spqcds.push(spqcd);273 }274 qcc.SPqcds = spqcds;275 if (context.mainHeader) {276 context.QCC[cqcc] = qcc;277 } else {278 context.currentTile.QCC[cqcc] = qcc;279 }280 break;281 case 0xFF52: // Coding style default (COD)282 length = readUint16(data, position);283 var cod = {};284 j = position + 2;285 var scod = data[j++];286 cod.entropyCoderWithCustomPrecincts = !!(scod & 1);287 cod.sopMarkerUsed = !!(scod & 2);288 cod.ephMarkerUsed = !!(scod & 4);289 cod.progressionOrder = data[j++];290 cod.layersCount = readUint16(data, j);291 j += 2;292 cod.multipleComponentTransform = data[j++];293 cod.decompositionLevelsCount = data[j++];294 cod.xcb = (data[j++] & 0xF) + 2;295 cod.ycb = (data[j++] & 0xF) + 2;296 var blockStyle = data[j++];297 cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);298 cod.resetContextProbabilities = !!(blockStyle & 2);299 cod.terminationOnEachCodingPass = !!(blockStyle & 4);300 cod.verticalyStripe = !!(blockStyle & 8);301 cod.predictableTermination = !!(blockStyle & 16);302 cod.segmentationSymbolUsed = !!(blockStyle & 32);303 cod.reversibleTransformation = data[j++];304 if (cod.entropyCoderWithCustomPrecincts) {305 var precinctsSizes = [];306 while (j < length + position) {307 var precinctsSize = data[j++];308 precinctsSizes.push({309 PPx: precinctsSize & 0xF,310 PPy: precinctsSize >> 4311 });312 }313 cod.precinctsSizes = precinctsSizes;314 }315 var unsupported = [];316 if (cod.selectiveArithmeticCodingBypass) {317 unsupported.push('selectiveArithmeticCodingBypass');318 }319 if (cod.resetContextProbabilities) {320 unsupported.push('resetContextProbabilities');321 }322 if (cod.terminationOnEachCodingPass) {323 unsupported.push('terminationOnEachCodingPass');324 }325 if (cod.verticalyStripe) {326 unsupported.push('verticalyStripe');327 }328 if (cod.predictableTermination) {329 unsupported.push('predictableTermination');330 }331 if (unsupported.length > 0) {332 doNotRecover = true;333 throw new Error('JPX Error: Unsupported COD options (' +334 unsupported.join(', ') + ')');335 }336 if (context.mainHeader) {337 context.COD = cod;338 } else {339 context.currentTile.COD = cod;340 context.currentTile.COC = [];341 }342 break;343 case 0xFF90: // Start of tile-part (SOT)344 length = readUint16(data, position);345 tile = {};346 tile.index = readUint16(data, position + 2);347 tile.length = readUint32(data, position + 4);348 tile.dataEnd = tile.length + position - 2;349 tile.partIndex = data[position + 8];350 tile.partsCount = data[position + 9];351 context.mainHeader = false;352 if (tile.partIndex === 0) {353 // reset component specific settings354 tile.COD = context.COD;355 tile.COC = context.COC.slice(0); // clone of the global COC356 tile.QCD = context.QCD;357 tile.QCC = context.QCC.slice(0); // clone of the global COC358 }359 context.currentTile = tile;360 break;361 case 0xFF93: // Start of data (SOD)362 tile = context.currentTile;363 if (tile.partIndex === 0) {364 initializeTile(context, tile.index);365 buildPackets(context);366 }367 // moving to the end of the data368 length = tile.dataEnd - position;369 parseTilePackets(context, data, position, length);370 break;371 case 0xFF55: // Tile-part lengths, main header (TLM)372 case 0xFF57: // Packet length, main header (PLM)373 case 0xFF58: // Packet length, tile-part header (PLT)374 case 0xFF64: // Comment (COM)375 length = readUint16(data, position);376 // skipping content377 break;378 case 0xFF53: // Coding style component (COC)379 throw new Error('JPX Error: Codestream code 0xFF53 (COC) is ' +380 'not implemented');381 default:382 throw new Error('JPX Error: Unknown codestream code: ' +383 code.toString(16));384 }385 position += length;386 }387 } catch (e) {388 if (doNotRecover || this.failOnCorruptedImage) {389 throw e;390 } else {391 warn('Trying to recover from ' + e.message);392 }393 }394 this.tiles = transformComponents(context);395 this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;396 this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;397 this.componentsCount = context.SIZ.Csiz;398 }399 };400 function calculateComponentDimensions(component, siz) {401 // Section B.2 Component mapping402 component.x0 = Math.ceil(siz.XOsiz / component.XRsiz);403 component.x1 = Math.ceil(siz.Xsiz / component.XRsiz);404 component.y0 = Math.ceil(siz.YOsiz / component.YRsiz);405 component.y1 = Math.ceil(siz.Ysiz / component.YRsiz);406 component.width = component.x1 - component.x0;407 component.height = component.y1 - component.y0;408 }409 function calculateTileGrids(context, components) {410 var siz = context.SIZ;411 // Section B.3 Division into tile and tile-components412 var tile, tiles = [];413 var numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz);414 var numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz);415 for (var q = 0; q < numYtiles; q++) {416 for (var p = 0; p < numXtiles; p++) {417 tile = {};418 tile.tx0 = Math.max(siz.XTOsiz + p * siz.XTsiz, siz.XOsiz);419 tile.ty0 = Math.max(siz.YTOsiz + q * siz.YTsiz, siz.YOsiz);420 tile.tx1 = Math.min(siz.XTOsiz + (p + 1) * siz.XTsiz, siz.Xsiz);421 tile.ty1 = Math.min(siz.YTOsiz + (q + 1) * siz.YTsiz, siz.Ysiz);422 tile.width = tile.tx1 - tile.tx0;423 tile.height = tile.ty1 - tile.ty0;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptilegrid = require('wptilegrid');2var tileGrids = wptilegrid.calculateTileGrids(1, 2, 3, 4, 5, 6, 7, 8);3console.log(tileGrids);4[ { zoomLevel: 1, tileGrid: { minRow: 1, maxRow: 2, minCol: 3, maxCol: 4 } },5 { zoomLevel: 2, tileGrid: { minRow: 2, maxRow: 4, minCol: 6, maxCol: 8 } },6 { zoomLevel: 3, tileGrid: { minRow: 4, maxRow: 8, minCol: 12, maxCol: 16 } },7 { zoomLevel: 4, tileGrid: { minRow: 8, maxRow: 16, minCol: 24, maxCol: 32 } },8 { zoomLevel: 5, tileGrid: { minRow: 16, maxRow: 32, minCol: 48, maxCol: 64 } },9 { zoomLevel: 6, tileGrid: { minRow: 32, maxRow: 64, minCol: 96, maxCol: 128 } },10 { zoomLevel: 7, tileGrid: { minRow: 64, maxRow: 128, minCol: 192, maxCol: 256 } },11 { zoomLevel: 8, tileGrid: { minRow: 128, maxRow: 256, minCol: 384, maxCol: 512 } } ]12calculateTileGrids(minLat, maxLat, minLon, maxLon, zoomMin, zoomMax, tileWidth, tileHeight)13: minimum latitude (in degrees)14: maximum latitude (in degrees)15: minimum longitude (in degrees)16: maximum longitude (in degrees)

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptile = require("./wptile.js");2var tileGrids = wptile.calculateTileGrids(15, 15, 20, 20, 15, 15);3console.log(tileGrids);4exports.calculateTileGrids = function (x1, y1, x2, y2, tileWidth, tileHeight) {5 var tileGrids = [];6 var tileX1 = Math.floor(x1 / tileWidth);7 var tileY1 = Math.floor(y1 / tileHeight);8 var tileX2 = Math.floor(x2 / tileWidth);9 var tileY2 = Math.floor(y2 / tileHeight);10 for (var x = tileX1; x <= tileX2; x++) {11 for (var y = tileY1; y <= tileY2; y++) {12 tileGrids.push({ x: x, y: y });13 }14 }15 return tileGrids;16};17[ { x: 0, y: 0 },18 { x: 0, y: 1 },19 { x: 1, y: 0 },20 { x: 1, y: 1 } ]

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var tileGrids = wptools.calculateTileGrids(40.7127, -74.0059, 12);3console.log(tileGrids);4var wptools = require('wptools');5var tileGrids = wptools.getTile(40.7127, -74.0059, 12);6console.log(tileGrids);7var wptools = require('wptools');8var tileGrids = wptools.getTile(40.7127, -74.0059, 12);9console.log(tileGrids);10var wptools = require('wptools');11var tileGrids = wptools.getTile(40.7127, -74.0059, 12);12console.log(tileGrids);13var wptools = require('wptools');14var tileGrids = wptools.getTile(40.7127, -74.0059, 12);15console.log(tileGrids);16var wptools = require('wptools');17var tileGrids = wptools.getTile(40.7127, -74.0059, 12);18console.log(tileGrids);19var wptools = require('wpt

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var tileGrids = wptools.calculateTileGrids(40.7127, -74.0059);3console.log(tileGrids);4var wptools = require('wptools');5var tileGrids = wptools.calculateTileGrids(40.7127, -74.0059);6console.log(tileGrids);7var wptools = require('wptools');8var tileGrids = wptools.calculateTileGrids(40.7127, -74.0059);9console.log(tileGrids);10var wptools = require('wptools');11var tileGrids = wptools.calculateTileGrids(40.7127, -74.0059);12console.log(tileGrids);13var wptools = require('wptools');14var tileGrids = wptools.calculateTileGrids(40.7127, -74.0059);15console.log(tileGrids);16var wptools = require('wptools');17var tileGrids = wptools.calculateTileGrids(40.7127, -74.0059);18console.log(tileGrids);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptk = require("wptk");2var fs = require("fs");3var tileGrids = wptk.calculateTileGrids( 38.5, -77.5, 0, 12, 256);4console.log(tileGrids);5var wptk = require("wptk");6var fs = require("fs");7var tileGrids = wptk.calculateTileGrids( 38.5, -77.5, 0, 12, 256);8console.log(tileGrids);9var wptk = require("wptk");10var fs = require("fs");11var tileGrids = wptk.calculateTileGrids( 38.5, -77.5, 0, 12, 256);12console.log(tileGrids);13var wptk = require("wptk");14var fs = require("fs");15var tileGrids = wptk.calculateTileGrids( 38.5, -77.5, 0, 12, 256);16console.log(tileGrids);17var wptk = require("wptk");18var fs = require("fs");19var tileGrids = wptk.calculateTileGrids( 38.5, -77.5, 0, 12, 256);20console.log(tileGrids);21var wptk = require("wptk");22var fs = require("fs");23var tileGrids = wptk.calculateTileGrids( 38.5, -77.5, 0, 12, 256);24console.log(tileGrids);25var wptk = require("wptk");26var fs = require("fs");27var tileGrids = wptk.calculateTileGrids( 38.5, -77.5, 0, 12, 256);28console.log(tileGrids);29var wptk = require("wptk");30var fs = require("fs");31var tileGrids = wptk.calculateTileGrids( 38.5, -77.5, 0, 12, 256);32console.log(tileGrids);33var wptk = require("wptk");34var fs = require("fs");35var tileGrids = wptk.calculateTileGrids(

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptiles = require('wptiles');2var fs = require('fs');3var tileset = JSON.parse(fs.readFileSync('tileset.json'));4var tilegrids = wptiles.calculateTileGrids(tileset);5fs.writeFileSync('tilegrids.json', JSON.stringify(tilegrids));6{7 "tilegrids": {8 "tilegrid-0": {9 },10 "tilegrid-1": {

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful