geojs 1.6.6 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/geo.js +320 -57
- package/geo.lean.js +320 -57
- package/geo.lean.min.js +2 -2
- package/geo.min.js +2 -2
- package/package.json +1 -1
- package/src/canvas/pixelmapFeature.js +21 -0
- package/src/index.js +1 -0
- package/src/pixelmapFeature.js +45 -21
- package/src/pixelmapLayer.js +145 -0
- package/src/tileLayer.js +3 -2
- package/src/webgl/pixelmapFeature.js +62 -31
- package/src/webgl/quadFeature.js +3 -1
package/geo.lean.js
CHANGED
|
@@ -6364,6 +6364,25 @@ var pixelmapFeature = __webpack_require__(6374);
|
|
|
6364
6364
|
var geo_event = __webpack_require__(5108);
|
|
6365
6365
|
|
|
6366
6366
|
var util = __webpack_require__(4634);
|
|
6367
|
+
/**
|
|
6368
|
+
* Pixelmap feature information record.
|
|
6369
|
+
*
|
|
6370
|
+
* @typedef {object} geo.pixelmapFeature.info
|
|
6371
|
+
* @property {number} width The width of the source image.
|
|
6372
|
+
* @property {number} height The width of the source image.
|
|
6373
|
+
* @property {CanvasRenderingContext2D} context The HTMLCanvasElement context
|
|
6374
|
+
* used for handling the pixelmap.
|
|
6375
|
+
* @property {ImageData} imageData The context's image data.
|
|
6376
|
+
* @property {number[]} indices An array, one per pixel, of the index value in
|
|
6377
|
+
* the image. This decodes the pixel value to the corresponding integer.
|
|
6378
|
+
* @property number} area The number of pixels in the image. This is
|
|
6379
|
+
* `width * height`.
|
|
6380
|
+
* @property {object[]} mappedColors This has one entry for each distinct index
|
|
6381
|
+
* value. Each entry has `first` and `last` with the first and last pixel
|
|
6382
|
+
* locations where that index occurs. Note that last is the inclusive value
|
|
6383
|
+
* of the location (so its maximum possible value is `size - 1`).
|
|
6384
|
+
*/
|
|
6385
|
+
|
|
6367
6386
|
/**
|
|
6368
6387
|
* Create a new instance of class pixelmapFeature.
|
|
6369
6388
|
*
|
|
@@ -6501,6 +6520,8 @@ var canvas_pixelmapFeature = function canvas_pixelmapFeature(arg) {
|
|
|
6501
6520
|
prepared;
|
|
6502
6521
|
|
|
6503
6522
|
if (!m_this.m_info) {
|
|
6523
|
+
m_this.indexModified(undefined, 'clear');
|
|
6524
|
+
|
|
6504
6525
|
if (!m_this._preparePixelmap()) {
|
|
6505
6526
|
return;
|
|
6506
6527
|
}
|
|
@@ -6508,6 +6529,7 @@ var canvas_pixelmapFeature = function canvas_pixelmapFeature(arg) {
|
|
|
6508
6529
|
prepared = true;
|
|
6509
6530
|
}
|
|
6510
6531
|
|
|
6532
|
+
m_this.indexModified(undefined, 'clear');
|
|
6511
6533
|
mappedColors = m_this.m_info.mappedColors;
|
|
6512
6534
|
updateFirst = m_this.m_info.area;
|
|
6513
6535
|
|
|
@@ -12252,6 +12274,7 @@ module.exports = $.extend({
|
|
|
12252
12274
|
polygonFeature: __webpack_require__(4343),
|
|
12253
12275
|
quadFeature: __webpack_require__(5017),
|
|
12254
12276
|
pixelmapFeature: __webpack_require__(6374),
|
|
12277
|
+
pixelmapLayer: __webpack_require__(809),
|
|
12255
12278
|
renderer: __webpack_require__(3234),
|
|
12256
12279
|
sceneObject: __webpack_require__(5358),
|
|
12257
12280
|
textFeature: __webpack_require__(9757),
|
|
@@ -22228,25 +22251,6 @@ var util = __webpack_require__(4634);
|
|
|
22228
22251
|
* transformations for those two triangles.
|
|
22229
22252
|
*/
|
|
22230
22253
|
|
|
22231
|
-
/**
|
|
22232
|
-
* Pixelmap feature information record.
|
|
22233
|
-
*
|
|
22234
|
-
* @typedef {object} geo.pixelmapFeature.info
|
|
22235
|
-
* @property {number} width The width of the source image.
|
|
22236
|
-
* @property {number} height The width of the source image.
|
|
22237
|
-
* @property {context} context The HTMLCanvasElement context used for handling
|
|
22238
|
-
* the pixelmap.
|
|
22239
|
-
* @property {ImageData} imageData The context's image data.
|
|
22240
|
-
* @property {number[]} indices An array, one per pixel, of the index value in
|
|
22241
|
-
* the image. This decodes the pixel value to the corresponding integer.
|
|
22242
|
-
* @property number} area The number of pixels in the image. This is
|
|
22243
|
-
* `width * height`.
|
|
22244
|
-
* @property {object[]} mappedColors This has one entry for each distinct index
|
|
22245
|
-
* value. Each entry has `first` and `last` with the first and last pixel
|
|
22246
|
-
* locations where that index occurs. Note that last is the inclusive value
|
|
22247
|
-
* of the location (so its maximum possible value is `size - 1`).
|
|
22248
|
-
*/
|
|
22249
|
-
|
|
22250
22254
|
/**
|
|
22251
22255
|
* Create a new instance of class pixelmapFeature
|
|
22252
22256
|
*
|
|
@@ -22273,6 +22277,7 @@ var pixelmapFeature = function pixelmapFeature(arg) {
|
|
|
22273
22277
|
|
|
22274
22278
|
var m_this = this,
|
|
22275
22279
|
s_update = this._update,
|
|
22280
|
+
m_modifiedIndexRange,
|
|
22276
22281
|
s_init = this._init;
|
|
22277
22282
|
this.featureType = 'pixelmap';
|
|
22278
22283
|
/**
|
|
@@ -22338,6 +22343,50 @@ var pixelmapFeature = function pixelmapFeature(arg) {
|
|
|
22338
22343
|
|
|
22339
22344
|
return m_this;
|
|
22340
22345
|
};
|
|
22346
|
+
/**
|
|
22347
|
+
* Mark that an index's data value (and hence its color) has changed without
|
|
22348
|
+
* marking all of the data array as changed. If this function is called
|
|
22349
|
+
* without any parameters, it clears the tracked changes.
|
|
22350
|
+
*
|
|
22351
|
+
* @param {number} [idx] The lowest data index that has changed. If
|
|
22352
|
+
* `undefined`, return the current tracked changed range.
|
|
22353
|
+
* @param {number|'clear'} [idx2] If an index was specified in `idx` and
|
|
22354
|
+
* this is specified, the highest index (inclusive) that has changed. If
|
|
22355
|
+
* returning the tracked changed range and this is `clear`, clear the
|
|
22356
|
+
* tracked range.
|
|
22357
|
+
* @returns {this|number[]} When returning a range, this is the lowest and
|
|
22358
|
+
* highest index values that have changed (inclusive), so their range is
|
|
22359
|
+
* `[0, data.length)`.
|
|
22360
|
+
*/
|
|
22361
|
+
|
|
22362
|
+
|
|
22363
|
+
this.indexModified = function (idx, idx2) {
|
|
22364
|
+
if (idx === undefined) {
|
|
22365
|
+
var range = m_modifiedIndexRange;
|
|
22366
|
+
|
|
22367
|
+
if (idx2 === 'clear') {
|
|
22368
|
+
m_modifiedIndexRange = undefined;
|
|
22369
|
+
}
|
|
22370
|
+
|
|
22371
|
+
return range;
|
|
22372
|
+
}
|
|
22373
|
+
|
|
22374
|
+
m_this.modified();
|
|
22375
|
+
|
|
22376
|
+
if (m_modifiedIndexRange === undefined) {
|
|
22377
|
+
m_modifiedIndexRange = [idx, idx];
|
|
22378
|
+
}
|
|
22379
|
+
|
|
22380
|
+
if (idx < m_modifiedIndexRange[0]) {
|
|
22381
|
+
m_modifiedIndexRange[0] = idx;
|
|
22382
|
+
}
|
|
22383
|
+
|
|
22384
|
+
if ((idx2 || idx) > m_modifiedIndexRange[1]) {
|
|
22385
|
+
m_modifiedIndexRange[1] = idx2 || idx;
|
|
22386
|
+
}
|
|
22387
|
+
|
|
22388
|
+
return m_this;
|
|
22389
|
+
};
|
|
22341
22390
|
/**
|
|
22342
22391
|
* Update.
|
|
22343
22392
|
*
|
|
@@ -22402,8 +22451,6 @@ var pixelmapFeature = function pixelmapFeature(arg) {
|
|
|
22402
22451
|
* drawing a quad, which can trigger a full layer update, which in turn
|
|
22403
22452
|
* checks if this feature is built. Setting the build time avoids calling
|
|
22404
22453
|
* this a second time. */
|
|
22405
|
-
m_this.buildTime().modified();
|
|
22406
|
-
|
|
22407
22454
|
if (!m_this.m_srcImage) {
|
|
22408
22455
|
var src = m_this.style.get('url')();
|
|
22409
22456
|
|
|
@@ -22468,6 +22515,7 @@ var pixelmapFeature = function pixelmapFeature(arg) {
|
|
|
22468
22515
|
m_this._computePixelmap();
|
|
22469
22516
|
}
|
|
22470
22517
|
|
|
22518
|
+
m_this.buildTime().modified();
|
|
22471
22519
|
return m_this;
|
|
22472
22520
|
};
|
|
22473
22521
|
/**
|
|
@@ -22509,6 +22557,13 @@ var pixelmapFeature = function pixelmapFeature(arg) {
|
|
|
22509
22557
|
|
|
22510
22558
|
m_this.style(style);
|
|
22511
22559
|
m_this.dataTime().modified();
|
|
22560
|
+
|
|
22561
|
+
if (arg.quadFeature) {
|
|
22562
|
+
m_this.m_srcImage = true;
|
|
22563
|
+
|
|
22564
|
+
m_this._computePixelmap();
|
|
22565
|
+
}
|
|
22566
|
+
|
|
22512
22567
|
return m_this;
|
|
22513
22568
|
};
|
|
22514
22569
|
|
|
@@ -22534,13 +22589,182 @@ pixelmapFeature.create = function (layer, spec) {
|
|
|
22534
22589
|
|
|
22535
22590
|
pixelmapFeature.capabilities = {
|
|
22536
22591
|
/* core feature name -- support in any manner */
|
|
22537
|
-
feature: 'pixelmap'
|
|
22592
|
+
feature: 'pixelmap',
|
|
22593
|
+
|
|
22594
|
+
/* support for image-based lookup */
|
|
22595
|
+
lookup: 'pixelmap.lookup'
|
|
22538
22596
|
};
|
|
22539
22597
|
inherit(pixelmapFeature, feature);
|
|
22540
22598
|
module.exports = pixelmapFeature;
|
|
22541
22599
|
|
|
22542
22600
|
/***/ }),
|
|
22543
22601
|
|
|
22602
|
+
/***/ 809:
|
|
22603
|
+
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
22604
|
+
|
|
22605
|
+
var $ = __webpack_require__(5638);
|
|
22606
|
+
|
|
22607
|
+
var inherit = __webpack_require__(5699);
|
|
22608
|
+
|
|
22609
|
+
var tileLayer = __webpack_require__(1940);
|
|
22610
|
+
|
|
22611
|
+
var registry = __webpack_require__(4647);
|
|
22612
|
+
|
|
22613
|
+
var quadFeature = __webpack_require__(5017);
|
|
22614
|
+
|
|
22615
|
+
var pixelmapFeature = __webpack_require__(6374);
|
|
22616
|
+
/**
|
|
22617
|
+
* Object specification for a pixelmap layer.
|
|
22618
|
+
*
|
|
22619
|
+
* @typedef {geo.tileLayer.spec} geo.pixelmapLayer.spec
|
|
22620
|
+
* @extends {geo.tileLayer.spec}
|
|
22621
|
+
* @property {geo.geoColor|function} [color] The color that should be used
|
|
22622
|
+
* for each data element. Data elements correspond to the indices in the
|
|
22623
|
+
* pixel map. If an index is larger than the number of data elements, it will
|
|
22624
|
+
* be transparent. If there is more data than there are indices, it is
|
|
22625
|
+
* ignored.
|
|
22626
|
+
* @property {object} [style] An optional style object that could contain
|
|
22627
|
+
* `color` or other style values.
|
|
22628
|
+
* @property {array} [data] A new data array.
|
|
22629
|
+
* @property {string} [crossDomain='anonymous'] Image CORS attribute. This is
|
|
22630
|
+
* used for the `crossorigin` property when loading images.
|
|
22631
|
+
*/
|
|
22632
|
+
|
|
22633
|
+
/**
|
|
22634
|
+
* Create a new instance of pixelmapLayer. This is a {@link geo.tileLayer} with
|
|
22635
|
+
* an OSM url and attribution defaults and with the tiles centered on the
|
|
22636
|
+
* origin.
|
|
22637
|
+
*
|
|
22638
|
+
* @class
|
|
22639
|
+
* @alias geo.pixelmapLayer
|
|
22640
|
+
* @extends geo.tileLayer
|
|
22641
|
+
*
|
|
22642
|
+
* @param {geo.pixelmapLayer.spec} [arg] Specification for the layer.
|
|
22643
|
+
*/
|
|
22644
|
+
|
|
22645
|
+
|
|
22646
|
+
var pixelmapLayer = function pixelmapLayer(arg) {
|
|
22647
|
+
var imageTile = __webpack_require__(4665);
|
|
22648
|
+
|
|
22649
|
+
if (!(this instanceof pixelmapLayer)) {
|
|
22650
|
+
return new pixelmapLayer(arg);
|
|
22651
|
+
}
|
|
22652
|
+
|
|
22653
|
+
arg = arg || {};
|
|
22654
|
+
arg = $.extend(true, {}, this.constructor.defaults, arg);
|
|
22655
|
+
tileLayer.call(this, arg);
|
|
22656
|
+
var s_init = this._init,
|
|
22657
|
+
m_pixelmapFeature,
|
|
22658
|
+
m_this = this;
|
|
22659
|
+
/**
|
|
22660
|
+
* Returns an instantiated imageTile object with the given indices. This
|
|
22661
|
+
* method always returns a new tile object. Use `_getTileCached` to use
|
|
22662
|
+
* the caching layer.
|
|
22663
|
+
*
|
|
22664
|
+
* @param {object} index The tile index.
|
|
22665
|
+
* @param {number} index.x
|
|
22666
|
+
* @param {number} index.y
|
|
22667
|
+
* @param {number} index.level
|
|
22668
|
+
* @param {object} source The tile index used for constructing the url.
|
|
22669
|
+
* @param {number} source.x
|
|
22670
|
+
* @param {number} source.y
|
|
22671
|
+
* @param {number} source.level
|
|
22672
|
+
* @returns {geo.tile}
|
|
22673
|
+
*/
|
|
22674
|
+
|
|
22675
|
+
this._getTile = function (index, source) {
|
|
22676
|
+
var urlParams = source || index;
|
|
22677
|
+
return imageTile({
|
|
22678
|
+
index: index,
|
|
22679
|
+
size: {
|
|
22680
|
+
x: m_this._options.tileWidth,
|
|
22681
|
+
y: m_this._options.tileHeight
|
|
22682
|
+
},
|
|
22683
|
+
queue: m_this._queue,
|
|
22684
|
+
overlap: m_this._options.tileOverlap,
|
|
22685
|
+
scale: m_this._options.tileScale,
|
|
22686
|
+
url: m_this._options.url.call(m_this, urlParams.x, urlParams.y, urlParams.level || 0, m_this._options.subdomains),
|
|
22687
|
+
crossDomain: m_this._options.crossDomain
|
|
22688
|
+
});
|
|
22689
|
+
};
|
|
22690
|
+
/**
|
|
22691
|
+
* Initialize.
|
|
22692
|
+
*
|
|
22693
|
+
* @returns {this} The current layer.
|
|
22694
|
+
*/
|
|
22695
|
+
|
|
22696
|
+
|
|
22697
|
+
this._init = function () {
|
|
22698
|
+
// Call super class init
|
|
22699
|
+
s_init.apply(m_this, arguments);
|
|
22700
|
+
var pixelmapArgs = {
|
|
22701
|
+
quadFeature: m_this.features()[0]
|
|
22702
|
+
};
|
|
22703
|
+
|
|
22704
|
+
if (arg.style) {
|
|
22705
|
+
pixelmapArgs.style = arg.style;
|
|
22706
|
+
}
|
|
22707
|
+
|
|
22708
|
+
if (arg.color) {
|
|
22709
|
+
pixelmapArgs.color = arg.color;
|
|
22710
|
+
}
|
|
22711
|
+
|
|
22712
|
+
m_pixelmapFeature = m_this.createFeature('pixelmap', pixelmapArgs);
|
|
22713
|
+
|
|
22714
|
+
if (arg.data) {
|
|
22715
|
+
m_pixelmapFeature.data(arg.data);
|
|
22716
|
+
}
|
|
22717
|
+
|
|
22718
|
+
m_this.style = m_pixelmapFeature.style;
|
|
22719
|
+
m_this.data = m_pixelmapFeature.data;
|
|
22720
|
+
m_this.indexModified = m_pixelmapFeature.indexModified;
|
|
22721
|
+
var s_dataTimeModified = m_this.dataTime().modified;
|
|
22722
|
+
|
|
22723
|
+
m_this.dataTime().modified = function () {
|
|
22724
|
+
m_pixelmapFeature.dataTime().modified();
|
|
22725
|
+
return s_dataTimeModified();
|
|
22726
|
+
};
|
|
22727
|
+
|
|
22728
|
+
['modified', 'geoOn', 'geoOff', 'geoOnce'].forEach(function (funcName) {
|
|
22729
|
+
var superFunc = m_this[funcName];
|
|
22730
|
+
|
|
22731
|
+
m_this[funcName] = function () {
|
|
22732
|
+
m_pixelmapFeature[funcName].apply(this, arguments);
|
|
22733
|
+
return superFunc.apply(this, arguments);
|
|
22734
|
+
};
|
|
22735
|
+
});
|
|
22736
|
+
return m_this;
|
|
22737
|
+
};
|
|
22738
|
+
|
|
22739
|
+
return m_this;
|
|
22740
|
+
};
|
|
22741
|
+
/**
|
|
22742
|
+
* This object contains the default options used to initialize the
|
|
22743
|
+
* pixelmapLayer.
|
|
22744
|
+
*/
|
|
22745
|
+
|
|
22746
|
+
|
|
22747
|
+
pixelmapLayer.defaults = $.extend({}, tileLayer.defaults, {
|
|
22748
|
+
features: [quadFeature.capabilities.image, pixelmapFeature.capabilities.lookup],
|
|
22749
|
+
tileOffset: function tileOffset(level) {
|
|
22750
|
+
var s = Math.pow(2, level - 1) * 256;
|
|
22751
|
+
return {
|
|
22752
|
+
x: s,
|
|
22753
|
+
y: s
|
|
22754
|
+
};
|
|
22755
|
+
},
|
|
22756
|
+
url: ''
|
|
22757
|
+
});
|
|
22758
|
+
inherit(pixelmapLayer, tileLayer);
|
|
22759
|
+
/* By default, ask to support image quads. If the user needs full
|
|
22760
|
+
* reprojection, they will need to require the
|
|
22761
|
+
* quadFeature.capabilities.imageFull feature */
|
|
22762
|
+
|
|
22763
|
+
registry.registerLayer('pixelmap', pixelmapLayer, [quadFeature.capabilities.image]);
|
|
22764
|
+
module.exports = pixelmapLayer;
|
|
22765
|
+
|
|
22766
|
+
/***/ }),
|
|
22767
|
+
|
|
22544
22768
|
/***/ 2557:
|
|
22545
22769
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
22546
22770
|
|
|
@@ -26028,7 +26252,7 @@ module.exports = sceneObject;
|
|
|
26028
26252
|
* @constant
|
|
26029
26253
|
* @type {string}
|
|
26030
26254
|
*/
|
|
26031
|
-
module.exports = "
|
|
26255
|
+
module.exports = "1d12f116c34ea5a1423ecb767df24b2291e53b06";
|
|
26032
26256
|
|
|
26033
26257
|
/***/ }),
|
|
26034
26258
|
|
|
@@ -29623,7 +29847,7 @@ var tileLayer = function tileLayer(arg) {
|
|
|
29623
29847
|
changed = false,
|
|
29624
29848
|
old,
|
|
29625
29849
|
level,
|
|
29626
|
-
minLevel = m_this._options.keepLower ? m_this._options.minLevel : maxLevel;
|
|
29850
|
+
minLevel = m_this._options.keepLower ? m_this._options.minLevel : Math.max(maxLevel, m_this._options.minLevel);
|
|
29627
29851
|
|
|
29628
29852
|
if (maxLevel < minLevel) {
|
|
29629
29853
|
maxLevel = minLevel;
|
|
@@ -30563,7 +30787,7 @@ var tileLayer = function tileLayer(arg) {
|
|
|
30563
30787
|
/* For tile layers that should only keep one layer, if loading is
|
|
30564
30788
|
* finished, purge all but the current layer. This is important for
|
|
30565
30789
|
* semi-transparent layers. */
|
|
30566
|
-
if ((doneLoading || m_this._isCovered(tile)) && zoom !== tile.index.level) {
|
|
30790
|
+
if ((doneLoading || m_this._isCovered(tile)) && zoom !== tile.index.level && (zoom >= m_this._options.minLevel || tile.index.level !== m_this._options.minLevel)) {
|
|
30567
30791
|
return true;
|
|
30568
30792
|
}
|
|
30569
30793
|
}
|
|
@@ -38492,7 +38716,7 @@ module.exports = vectorFeature;
|
|
|
38492
38716
|
* @constant
|
|
38493
38717
|
* @type {string}
|
|
38494
38718
|
*/
|
|
38495
|
-
module.exports = "1.
|
|
38719
|
+
module.exports = "1.7.0";
|
|
38496
38720
|
|
|
38497
38721
|
/***/ }),
|
|
38498
38722
|
|
|
@@ -41321,6 +41545,7 @@ var webgl_pixelmapFeature = function webgl_pixelmapFeature(arg) {
|
|
|
41321
41545
|
var fragmentShader = __webpack_require__(3953);
|
|
41322
41546
|
|
|
41323
41547
|
var m_quadFeature,
|
|
41548
|
+
m_quadFeatureInit,
|
|
41324
41549
|
s_exit = this._exit,
|
|
41325
41550
|
m_lookupTable,
|
|
41326
41551
|
m_this = this;
|
|
@@ -41338,24 +41563,29 @@ var webgl_pixelmapFeature = function webgl_pixelmapFeature(arg) {
|
|
|
41338
41563
|
|
|
41339
41564
|
this.pointSearch = function (geo, gcs) {
|
|
41340
41565
|
if (m_quadFeature && m_this.m_info) {
|
|
41341
|
-
var result = m_quadFeature.pointSearch(geo, gcs);
|
|
41342
|
-
|
|
41343
|
-
|
|
41344
|
-
|
|
41345
|
-
|
|
41346
|
-
|
|
41347
|
-
|
|
41348
|
-
|
|
41349
|
-
|
|
41350
|
-
|
|
41351
|
-
|
|
41352
|
-
|
|
41353
|
-
|
|
41354
|
-
|
|
41355
|
-
|
|
41356
|
-
|
|
41357
|
-
|
|
41358
|
-
|
|
41566
|
+
var result = m_quadFeature.pointSearch(geo, gcs); // use the last index by preference, since for tile layers, this is the
|
|
41567
|
+
// topmosttile
|
|
41568
|
+
|
|
41569
|
+
var idxIdx = result.index.length - 1;
|
|
41570
|
+
|
|
41571
|
+
for (; idxIdx >= 0; idxIdx -= 1) {
|
|
41572
|
+
if (result.extra[result.index[idxIdx]]._quad && result.extra[result.index[idxIdx]]._quad.image) {
|
|
41573
|
+
var img = result.extra[result.index[idxIdx]]._quad.image;
|
|
41574
|
+
var basis = result.extra[result.index[idxIdx]].basis;
|
|
41575
|
+
var x = Math.floor(basis.x * img.width);
|
|
41576
|
+
var y = Math.floor(basis.y * img.height);
|
|
41577
|
+
var canvas = document.createElement('canvas');
|
|
41578
|
+
canvas.width = canvas.height = 1;
|
|
41579
|
+
var context = canvas.getContext('2d');
|
|
41580
|
+
context.drawImage(img, x, y, 1, 1, 0, 0, 1, 1);
|
|
41581
|
+
var pixel = context.getImageData(0, 0, 1, 1).data;
|
|
41582
|
+
var idx = pixel[0] + pixel[1] * 256 + pixel[2] * 256 * 256;
|
|
41583
|
+
result = {
|
|
41584
|
+
index: [idx],
|
|
41585
|
+
found: [m_this.data()[idx]]
|
|
41586
|
+
};
|
|
41587
|
+
return result;
|
|
41588
|
+
}
|
|
41359
41589
|
}
|
|
41360
41590
|
}
|
|
41361
41591
|
|
|
@@ -41373,10 +41603,13 @@ var webgl_pixelmapFeature = function webgl_pixelmapFeature(arg) {
|
|
|
41373
41603
|
this._computePixelmap = function () {
|
|
41374
41604
|
var data = m_this.data() || [],
|
|
41375
41605
|
colorFunc = m_this.style.get('color');
|
|
41606
|
+
var indexRange = m_this.indexModified(undefined, 'clear');
|
|
41607
|
+
var fullUpdate = m_this.dataTime().timestamp() >= m_this.buildTime().timestamp() || indexRange === undefined;
|
|
41376
41608
|
|
|
41377
41609
|
if (!m_lookupTable) {
|
|
41378
41610
|
m_lookupTable = lookupTable2D();
|
|
41379
41611
|
m_lookupTable.setTextureUnit(1);
|
|
41612
|
+
fullUpdate = true;
|
|
41380
41613
|
}
|
|
41381
41614
|
|
|
41382
41615
|
var clrLen = Math.max(1, data.length);
|
|
@@ -41386,14 +41619,29 @@ var webgl_pixelmapFeature = function webgl_pixelmapFeature(arg) {
|
|
|
41386
41619
|
clrLen += maxWidth - clrLen % maxWidth;
|
|
41387
41620
|
}
|
|
41388
41621
|
|
|
41389
|
-
var colors
|
|
41390
|
-
|
|
41622
|
+
var colors;
|
|
41623
|
+
|
|
41624
|
+
if (!fullUpdate) {
|
|
41625
|
+
colors = m_lookupTable.colorTable();
|
|
41626
|
+
fullUpdate = colors.length !== clrLen * 4;
|
|
41627
|
+
indexRange[0] = Math.max(0, indexRange[0]);
|
|
41628
|
+
indexRange[1] = Math.min(data.length, indexRange[1] + 1);
|
|
41629
|
+
}
|
|
41630
|
+
|
|
41631
|
+
if (fullUpdate) {
|
|
41632
|
+
colors = new Uint8Array(clrLen * 4);
|
|
41633
|
+
indexRange = [0, data.length];
|
|
41634
|
+
}
|
|
41635
|
+
|
|
41636
|
+
for (var i = indexRange[0]; i < indexRange[1]; i += 1) {
|
|
41637
|
+
var d = data[i];
|
|
41391
41638
|
var color = util.convertColor(colorFunc.call(m_this, d, i));
|
|
41392
41639
|
colors[i * 4] = color.r * 255;
|
|
41393
41640
|
colors[i * 4 + 1] = color.g * 255;
|
|
41394
41641
|
colors[i * 4 + 2] = color.b * 255;
|
|
41395
41642
|
colors[i * 4 + 3] = color.a === undefined ? 255 : color.a * 255;
|
|
41396
|
-
}
|
|
41643
|
+
}
|
|
41644
|
+
|
|
41397
41645
|
m_this.m_info = {
|
|
41398
41646
|
colors: colors
|
|
41399
41647
|
}; // check if colors haven't changed
|
|
@@ -41401,15 +41649,15 @@ var webgl_pixelmapFeature = function webgl_pixelmapFeature(arg) {
|
|
|
41401
41649
|
var oldcolors = m_lookupTable.colorTable();
|
|
41402
41650
|
|
|
41403
41651
|
if (oldcolors && oldcolors.length === colors.length) {
|
|
41404
|
-
var idx = 0;
|
|
41652
|
+
var idx = indexRange[0] * 4;
|
|
41405
41653
|
|
|
41406
|
-
for (; idx <
|
|
41654
|
+
for (; idx < indexRange[1] * 4; idx += 1) {
|
|
41407
41655
|
if (colors[idx] !== oldcolors[idx]) {
|
|
41408
41656
|
break;
|
|
41409
41657
|
}
|
|
41410
41658
|
}
|
|
41411
41659
|
|
|
41412
|
-
if (idx ===
|
|
41660
|
+
if (idx === indexRange[1] * 4) {
|
|
41413
41661
|
return;
|
|
41414
41662
|
}
|
|
41415
41663
|
}
|
|
@@ -41423,6 +41671,10 @@ var webgl_pixelmapFeature = function webgl_pixelmapFeature(arg) {
|
|
|
41423
41671
|
gcs: m_this.gcs(),
|
|
41424
41672
|
visible: m_this.visible(undefined, true)
|
|
41425
41673
|
});
|
|
41674
|
+
m_quadFeatureInit = false;
|
|
41675
|
+
}
|
|
41676
|
+
|
|
41677
|
+
if (!m_quadFeatureInit) {
|
|
41426
41678
|
m_this.dependentFeatures([m_quadFeature]);
|
|
41427
41679
|
m_quadFeature.setShader('image_fragment', fragmentShader);
|
|
41428
41680
|
|
|
@@ -41447,10 +41699,14 @@ var webgl_pixelmapFeature = function webgl_pixelmapFeature(arg) {
|
|
|
41447
41699
|
m_lookupTable.bind(renderState, quads);
|
|
41448
41700
|
};
|
|
41449
41701
|
|
|
41450
|
-
|
|
41451
|
-
|
|
41452
|
-
|
|
41453
|
-
|
|
41702
|
+
if (m_quadFeatureInit === false) {
|
|
41703
|
+
m_quadFeature.style({
|
|
41704
|
+
image: m_this.m_srcImage,
|
|
41705
|
+
position: m_this.style.get('position')
|
|
41706
|
+
}).data([{}]).draw();
|
|
41707
|
+
}
|
|
41708
|
+
|
|
41709
|
+
m_quadFeatureInit = true;
|
|
41454
41710
|
}
|
|
41455
41711
|
};
|
|
41456
41712
|
/**
|
|
@@ -41471,6 +41727,10 @@ var webgl_pixelmapFeature = function webgl_pixelmapFeature(arg) {
|
|
|
41471
41727
|
return m_this;
|
|
41472
41728
|
};
|
|
41473
41729
|
|
|
41730
|
+
if (arg.quadFeature) {
|
|
41731
|
+
m_quadFeature = arg.quadFeature;
|
|
41732
|
+
}
|
|
41733
|
+
|
|
41474
41734
|
this._init(arg);
|
|
41475
41735
|
|
|
41476
41736
|
return this;
|
|
@@ -41478,7 +41738,9 @@ var webgl_pixelmapFeature = function webgl_pixelmapFeature(arg) {
|
|
|
41478
41738
|
|
|
41479
41739
|
inherit(webgl_pixelmapFeature, pixelmapFeature); // Now register it
|
|
41480
41740
|
|
|
41481
|
-
|
|
41741
|
+
var capabilities = {};
|
|
41742
|
+
capabilities[pixelmapFeature.capabilities.lookup] = true;
|
|
41743
|
+
registerFeature('webgl', 'pixelmap', webgl_pixelmapFeature, capabilities);
|
|
41482
41744
|
module.exports = webgl_pixelmapFeature;
|
|
41483
41745
|
|
|
41484
41746
|
/***/ }),
|
|
@@ -43078,9 +43340,10 @@ var webgl_quadFeature = function webgl_quadFeature(arg) {
|
|
|
43078
43340
|
return;
|
|
43079
43341
|
}
|
|
43080
43342
|
|
|
43081
|
-
quad.texture.bind(renderState);
|
|
43343
|
+
quad.texture.bind(renderState); // only check if the context is out of memory when using modestly large
|
|
43344
|
+
// textures. The check is slow.
|
|
43082
43345
|
|
|
43083
|
-
if (context.getError() === context.OUT_OF_MEMORY) {
|
|
43346
|
+
if ((quad.image.width > 4096 || quad.image.height > 4096 || quad.image.width * quad.image.height > 4194304) && context.getError() === context.OUT_OF_MEMORY) {
|
|
43084
43347
|
console.log('Insufficient GPU memory for texture');
|
|
43085
43348
|
}
|
|
43086
43349
|
|