geojs 1.6.2 → 1.6.6
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/.github/workflows/main.yml +1 -1
- package/.nvmrc +1 -0
- package/CHANGELOG.md +19 -1
- package/README.md +14 -9
- package/geo.js +821 -395
- package/geo.lean.js +820 -394
- package/geo.lean.min.js +3 -3
- package/geo.min.js +4 -4
- package/package.json +8 -10
- package/src/annotation.js +11 -7
- package/src/annotationLayer.js +13 -9
- package/src/camera.js +5 -5
- package/src/canvas/pixelmapFeature.js +187 -0
- package/src/choroplethFeature.js +1 -1
- package/src/domRenderer.js +2 -1
- package/src/featureLayer.js +1 -1
- package/src/fileReader.js +2 -2
- package/src/imageTile.js +2 -1
- package/src/isolineFeature.js +1 -1
- package/src/layer.js +4 -2
- package/src/lineFeature.js +3 -3
- package/src/map.js +17 -15
- package/src/mapInteractor.js +17 -17
- package/src/markerFeature.js +2 -2
- package/src/meshFeature.js +1 -1
- package/src/osmLayer.js +2 -0
- package/src/pixelmapFeature.js +52 -228
- package/src/pointFeature.js +1 -1
- package/src/polygonFeature.js +3 -3
- package/src/quadFeature.js +1 -1
- package/src/registry.js +2 -2
- package/src/svg/svgRenderer.js +3 -3
- package/src/tileCache.js +1 -1
- package/src/tileLayer.js +10 -10
- package/src/trackFeature.js +19 -19
- package/src/transform.js +8 -9
- package/src/typedef.js +2 -0
- package/src/ui/sliderWidget.js +1 -1
- package/src/util/clustering.js +3 -3
- package/src/util/color.js +1 -1
- package/src/util/common.js +7 -7
- package/src/util/throttle.js +1 -1
- package/src/vtkjs/pointFeature.js +1 -1
- package/src/webgl/index.js +2 -0
- package/src/webgl/lookupTable2D.js +122 -0
- package/src/webgl/markerFeature.js +1 -1
- package/src/webgl/pixelmapFeature.frag +47 -0
- package/src/webgl/pixelmapFeature.js +172 -0
- package/src/webgl/pointFeature.js +1 -1
- package/src/webgl/quadFeature.js +32 -1
- package/src/webgl/webglRenderer.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "geojs",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.6",
|
|
4
4
|
"description": "JavaScript Geo Visualization and Analysis Library",
|
|
5
5
|
"homepage": "https://github.com/OpenGeoscience/geojs",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"optionalDependencies": {
|
|
28
28
|
"d3": "^3.5.17",
|
|
29
29
|
"hammerjs": "^2.0.8",
|
|
30
|
-
"vtk.js": "
|
|
30
|
+
"vtk.js": "*"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@babel/core": "^7.16.5",
|
|
@@ -54,7 +54,6 @@
|
|
|
54
54
|
"glob": "^7.2.0",
|
|
55
55
|
"glslang-validator-prebuilt": "0.0.6",
|
|
56
56
|
"imports-loader": "^3.1.1",
|
|
57
|
-
"istanbul-combine": "^0.3.0",
|
|
58
57
|
"jaguarjs-jsdoc": "^1.0.2",
|
|
59
58
|
"jasmine-core": "^4.0.0",
|
|
60
59
|
"js-yaml": "^4.1.0",
|
|
@@ -62,7 +61,7 @@
|
|
|
62
61
|
"jsdoc-autoprivate": "0.0.1",
|
|
63
62
|
"jsonlint-mod": "^1.7.6",
|
|
64
63
|
"jstransformer-markdown-it": "^2.0.0",
|
|
65
|
-
"karma": "^6.3.
|
|
64
|
+
"karma": "^6.3.13",
|
|
66
65
|
"karma-chrome-launcher": "^3.1.0",
|
|
67
66
|
"karma-coverage": "^2.1.0",
|
|
68
67
|
"karma-firefox-launcher": "^2.1.2",
|
|
@@ -82,15 +81,15 @@
|
|
|
82
81
|
"semantic-release": "^19.0.2",
|
|
83
82
|
"serve-index": "^1.9.1",
|
|
84
83
|
"shader-loader": "^1.3.1",
|
|
85
|
-
"sinon": "^
|
|
84
|
+
"sinon": "^13.0.1",
|
|
86
85
|
"string-replace-webpack-plugin": "^0.1.3",
|
|
87
86
|
"style-loader": "^3.3.1",
|
|
88
87
|
"stylus": "^0.56.0",
|
|
89
88
|
"stylus-loader": "^6.2.0",
|
|
90
|
-
"terser-webpack-plugin": "^5.3.
|
|
89
|
+
"terser-webpack-plugin": "^5.3.1",
|
|
91
90
|
"touch-emulator": "^1.0.0",
|
|
92
91
|
"typeface-lato": "^1.1.13",
|
|
93
|
-
"webpack": "^5.
|
|
92
|
+
"webpack": "^5.68.0",
|
|
94
93
|
"webpack-cli": "^4.9.1",
|
|
95
94
|
"webpack-merge": "^5.8.0"
|
|
96
95
|
},
|
|
@@ -147,16 +146,15 @@
|
|
|
147
146
|
"ci": "npm run ci-build && npm run ci-test",
|
|
148
147
|
"ci-build": "bash -c '(webpack --config webpack.config.js & webpack --config webpack-lean.config.js & npm run docs & npm run get-data-files & npm run lint & npm run puglint & npm run glsllint & npm run build-examples & npm run build-tutorials & wait -n && wait -n && wait -n && wait -n && wait -n && wait -n && wait -n && wait -n && wait -n)'",
|
|
149
148
|
"ci-build-wait": "bash -c '(webpack --config webpack.config.js & webpack --config webpack-lean.config.js & npm run docs & npm run get-data-files & npm run lint & npm run puglint & npm run glsllint & npm run build-examples & npm run build-tutorials & wait -n && wait -n && wait -n && wait -n && wait -n && wait -n && wait -n && wait -n && wait -n && FAIL=0 || FAIL=1; wait; [ \"$FAIL\" == \"0\" ])'",
|
|
150
|
-
"ci-test": "npm run test-headless && npm run test-webglheadless && npm run test-headed && npm run test-tutorials
|
|
149
|
+
"ci-test": "npm run test-headless && npm run test-webglheadless && npm run test-headed && npm run test-tutorials",
|
|
151
150
|
"ci-xvfb": "npm run ci-clean && npm run ci-build && TEST_SAVE_IMAGE='all' xvfb-run -s '-ac -screen 0 1280x1024x24' npm run ci-test",
|
|
152
151
|
"start": "karma start karma.conf.js",
|
|
153
|
-
"combine-coverage": "istanbul-combine -d dist/cobertura -r cobertura 'dist/coverage/json/**/coverage-final.json'",
|
|
154
152
|
"examples": "node examples/build.js && webpack --config webpack-examples.config.js && node tutorials/build.js && webpack --config webpack-tutorials.config.js && node ./tests/runners/server.js --host \"${HOST-}\" --port ${PORT-8082} --dist",
|
|
155
153
|
"docs": "jsdoc --pedantic -d dist/apidocs -r src package.json -c jsdoc.conf.json",
|
|
156
154
|
"website": "cd website && npx hexo server",
|
|
157
155
|
"setup-website": "cd website && npm install",
|
|
158
156
|
"build-website": "npm run ci-build && npm run ci-build-website",
|
|
159
|
-
"ci-build-website": "cp -a dist/built/. website/source/built && bash -c '(npm run build-website-examples & npm run build-website-tutorials & wait -n && wait -n)' && cd dist &&
|
|
157
|
+
"ci-build-website": "cp -a dist/built/. website/source/built && bash -c '(npm run build-website-examples & npm run build-website-tutorials & wait -n && wait -n)' && cd dist && cp -ar data ../website/source/. && rm -rf ../website/source/data/tiles && rm -rf ../website/source/data/tiles.tgz && rm -rf ../website/source/data/base-images && rm -rf ../website/source/data/base-images.tgz && cp -ar apidocs/. ../website/source/apidocs && cd ../website && npm install && rm -f db.json && npx hexo generate",
|
|
160
158
|
"prepublishOnly": "webpack --config webpack.config.js && webpack --config webpack-lean.config.js && cp dist/built/*.js .",
|
|
161
159
|
"semantic-release": "semantic-release"
|
|
162
160
|
},
|
package/src/annotation.js
CHANGED
|
@@ -145,7 +145,7 @@ var annotation = function (type, args) {
|
|
|
145
145
|
/**
|
|
146
146
|
* Get or set the name of this annotation.
|
|
147
147
|
*
|
|
148
|
-
* @param {string|undefined} arg If `undefined`, return the name, otherwise
|
|
148
|
+
* @param {string|undefined} [arg] If `undefined`, return the name, otherwise
|
|
149
149
|
* change it. When setting the name, the value is trimmed of
|
|
150
150
|
* whitespace. The name will not be changed to an empty string.
|
|
151
151
|
* @returns {this|string} The current name or this annotation.
|
|
@@ -293,7 +293,7 @@ var annotation = function (type, args) {
|
|
|
293
293
|
/**
|
|
294
294
|
* Get or set the state of this annotation.
|
|
295
295
|
*
|
|
296
|
-
* @param {string|undefined} arg If `undefined`, return the state,
|
|
296
|
+
* @param {string|undefined} [arg] If `undefined`, return the state,
|
|
297
297
|
* otherwise change it. This should be one of the
|
|
298
298
|
* {@link geo.annotation.state} values.
|
|
299
299
|
* @returns {this|string} The current state or this annotation.
|
|
@@ -352,7 +352,7 @@ var annotation = function (type, args) {
|
|
|
352
352
|
* `'remove'` if the annotation should be removed, falsy to not update
|
|
353
353
|
* anything.
|
|
354
354
|
*/
|
|
355
|
-
this.processAction = function () {
|
|
355
|
+
this.processAction = function (evt) {
|
|
356
356
|
return undefined;
|
|
357
357
|
};
|
|
358
358
|
|
|
@@ -1081,8 +1081,8 @@ var annotation = function (type, args) {
|
|
|
1081
1081
|
*
|
|
1082
1082
|
* @param {object} m_this The current annotation instance.
|
|
1083
1083
|
* @param {function} s_actions The parent actions method.
|
|
1084
|
-
* @param {string}
|
|
1085
|
-
* the current state.
|
|
1084
|
+
* @param {string|undefined} state The state to return actions for. Defaults
|
|
1085
|
+
* to the current state.
|
|
1086
1086
|
* @param {string} name The name of this annotation.
|
|
1087
1087
|
* @param {Array} originalArgs arguments to original call
|
|
1088
1088
|
* @returns {geo.actionRecord[]} A list of actions.
|
|
@@ -1128,7 +1128,7 @@ function continuousVerticesProcessAction(m_this, evt, name) {
|
|
|
1128
1128
|
return;
|
|
1129
1129
|
}
|
|
1130
1130
|
var cpp = layer.options('continuousPointProximity');
|
|
1131
|
-
var cpc = layer.options('
|
|
1131
|
+
var cpc = layer.options('continuousPointCollinearity');
|
|
1132
1132
|
var ccp = layer.options('continuousCloseProximity');
|
|
1133
1133
|
if (cpp || cpp === 0) {
|
|
1134
1134
|
var vertices = m_this.options('vertices');
|
|
@@ -1140,7 +1140,7 @@ function continuousVerticesProcessAction(m_this, evt, name) {
|
|
|
1140
1140
|
}
|
|
1141
1141
|
var dist = layer.displayDistance(vertices[vertices.length - 2], null, evt.mouse.map, 'display');
|
|
1142
1142
|
if (dist && dist > cpp) {
|
|
1143
|
-
// combine nearly
|
|
1143
|
+
// combine nearly collinear points
|
|
1144
1144
|
if (vertices.length >= (m_this._lastClickVertexCount || 1) + 3) {
|
|
1145
1145
|
var d01 = layer.displayDistance(vertices[vertices.length - 3], null, vertices[vertices.length - 2], null),
|
|
1146
1146
|
d12 = dist,
|
|
@@ -1183,6 +1183,10 @@ function continuousVerticesProcessAction(m_this, evt, name) {
|
|
|
1183
1183
|
* @property {geo.polygonFeature.styleSpec} [editStyle] The style to apply to a
|
|
1184
1184
|
* rectangle in edit mode.
|
|
1185
1185
|
*/
|
|
1186
|
+
/*
|
|
1187
|
+
* @typedef {object} geo.rectangleAnnotation.subspec
|
|
1188
|
+
* @typedef {geo.annotation.spec | geo.rectangleAnnotation.subspec} geo.rectangleAnnotation.spec
|
|
1189
|
+
*/
|
|
1186
1190
|
|
|
1187
1191
|
/**
|
|
1188
1192
|
* Rectangle annotation class.
|
package/src/annotationLayer.js
CHANGED
|
@@ -21,9 +21,9 @@ var textFeature = require('./textFeature');
|
|
|
21
21
|
* @property {number} [continuousPointProximity=5] The minimum distance in
|
|
22
22
|
* display coordinates (pixels) between two adjacent points when dragging
|
|
23
23
|
* to create an annotation. `false` disables continuous drawing mode.
|
|
24
|
-
* @property {number} [
|
|
24
|
+
* @property {number} [continuousPointCollinearity=1.0deg] The minimum angle
|
|
25
25
|
* between a series of three points when dragging to not interpret them as
|
|
26
|
-
*
|
|
26
|
+
* collinear. Only applies if `continuousPointProximity` is not `false`.
|
|
27
27
|
* @property {number} [continuousCloseProximity=10] The minimum distance in
|
|
28
28
|
* display coordinates (pixels) to close a polygon or end drawing a line when
|
|
29
29
|
* dragging to create an annotation. `false` never closes at the end of a
|
|
@@ -135,8 +135,8 @@ var annotationLayer = function (arg) {
|
|
|
135
135
|
// continuous drawing modes.
|
|
136
136
|
continuousPointProximity: 5,
|
|
137
137
|
// in radians, minimum angle between continuous points to interpret them as
|
|
138
|
-
// being
|
|
139
|
-
|
|
138
|
+
// being collinear
|
|
139
|
+
continuousPointCollinearity: 1.0 * Math.PI / 180,
|
|
140
140
|
continuousCloseProximity: 10, // in pixels, 0 is exact
|
|
141
141
|
finalPointProximity: 10, // in pixels, 0 is exact
|
|
142
142
|
showLabels: true,
|
|
@@ -399,11 +399,13 @@ var annotationLayer = function (arg) {
|
|
|
399
399
|
* @param {geo.annotation} annotation The annotation to add.
|
|
400
400
|
* @param {string|geo.transform|null} [gcs] `undefined` to use the interface
|
|
401
401
|
* gcs, `null` to use the map gcs, or any other transform.
|
|
402
|
+
* @param {boolean} [update] If `false`, don't update the layer after adding
|
|
403
|
+
* the annotation.
|
|
402
404
|
* @returns {this} The current layer.
|
|
403
405
|
* @fires geo.event.annotation.add_before
|
|
404
406
|
* @fires geo.event.annotation.add
|
|
405
407
|
*/
|
|
406
|
-
this.addAnnotation = function (annotation, gcs) {
|
|
408
|
+
this.addAnnotation = function (annotation, gcs, update) {
|
|
407
409
|
var pos = $.inArray(annotation, m_annotations);
|
|
408
410
|
if (pos < 0) {
|
|
409
411
|
m_this.geoTrigger(geo_event.annotation.add_before, {
|
|
@@ -418,8 +420,10 @@ var annotationLayer = function (arg) {
|
|
|
418
420
|
annotation._coordinates(transform.transformCoordinates(
|
|
419
421
|
gcs, map.gcs(), annotation._coordinates()));
|
|
420
422
|
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
+
if (update !== false) {
|
|
424
|
+
m_this.modified();
|
|
425
|
+
m_this.draw();
|
|
426
|
+
}
|
|
423
427
|
m_this.geoTrigger(geo_event.annotation.add, {
|
|
424
428
|
annotation: annotation
|
|
425
429
|
});
|
|
@@ -431,7 +435,7 @@ var annotationLayer = function (arg) {
|
|
|
431
435
|
* Remove an annotation from the layer.
|
|
432
436
|
*
|
|
433
437
|
* @param {geo.annotation} annotation The annotation to remove.
|
|
434
|
-
* @param {boolean} update If `false`, don't update the layer after removing
|
|
438
|
+
* @param {boolean} [update] If `false`, don't update the layer after removing
|
|
435
439
|
* the annotation.
|
|
436
440
|
* @returns {boolean} `true` if an annotation was removed.
|
|
437
441
|
* @fires geo.event.annotation.remove
|
|
@@ -603,7 +607,7 @@ var annotationLayer = function (arg) {
|
|
|
603
607
|
* Return the current set of annotations as a geojson object. Alternately,
|
|
604
608
|
* add a set of annotations from a geojson object.
|
|
605
609
|
*
|
|
606
|
-
* @param {string|
|
|
610
|
+
* @param {string|object|File} [geojson] If present, add annotations based on
|
|
607
611
|
* the given geojson object. If `undefined`, return the current
|
|
608
612
|
* annotations as geojson. This may be a JSON string, a javascript
|
|
609
613
|
* object, or a File object.
|
package/src/camera.js
CHANGED
|
@@ -502,7 +502,7 @@ var camera = function (spec) {
|
|
|
502
502
|
* Project a vector from world space into viewport (display) space. The
|
|
503
503
|
* resulting vector always has the last component (`w`) equal to 1.
|
|
504
504
|
*
|
|
505
|
-
* @param {
|
|
505
|
+
* @param {vec3|vec4} point The point in world coordinates.
|
|
506
506
|
* @returns {vec4} The point in display coordinates.
|
|
507
507
|
*/
|
|
508
508
|
this.worldToDisplay4 = function (point) {
|
|
@@ -518,7 +518,7 @@ var camera = function (spec) {
|
|
|
518
518
|
* Project a vector from viewport (display) space into world space. The
|
|
519
519
|
* resulting vector always has the last component (`w`) equal to 1.
|
|
520
520
|
*
|
|
521
|
-
* @param {
|
|
521
|
+
* @param {vec3|vec4} point The point in display coordinates.
|
|
522
522
|
* @returns {vec4} The point in world space coordinates.
|
|
523
523
|
*/
|
|
524
524
|
this.displayToWorld4 = function (point) {
|
|
@@ -788,7 +788,7 @@ var camera = function (spec) {
|
|
|
788
788
|
/**
|
|
789
789
|
* Represent a glmatrix as a pretty-printed string.
|
|
790
790
|
* @param {mat4} mat A 4 x 4 matrix.
|
|
791
|
-
* @param {number} prec The number of decimal places.
|
|
791
|
+
* @param {number} [prec] The number of decimal places.
|
|
792
792
|
* @returns {string}
|
|
793
793
|
*/
|
|
794
794
|
this.ppMatrix = function (mat, prec) {
|
|
@@ -862,7 +862,7 @@ var camera = function (spec) {
|
|
|
862
862
|
|
|
863
863
|
/**
|
|
864
864
|
* Supported projection types.
|
|
865
|
-
* @enum
|
|
865
|
+
* @enum {boolean}
|
|
866
866
|
*/
|
|
867
867
|
camera.projection = {
|
|
868
868
|
perspective: true,
|
|
@@ -872,7 +872,7 @@ camera.projection = {
|
|
|
872
872
|
/**
|
|
873
873
|
* Default camera clipping bounds. Some features and renderers may rely on the
|
|
874
874
|
* far clip value being more positive than the near clip value.
|
|
875
|
-
* @enum
|
|
875
|
+
* @enum {number}
|
|
876
876
|
*/
|
|
877
877
|
camera.clipbounds = {
|
|
878
878
|
perspective: {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
var inherit = require('../inherit');
|
|
2
2
|
var registerFeature = require('../registry').registerFeature;
|
|
3
3
|
var pixelmapFeature = require('../pixelmapFeature');
|
|
4
|
+
var geo_event = require('../event');
|
|
5
|
+
var util = require('../util');
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* Create a new instance of class pixelmapFeature.
|
|
@@ -22,6 +24,191 @@ var canvas_pixelmapFeature = function (arg) {
|
|
|
22
24
|
var object = require('./object');
|
|
23
25
|
object.call(this);
|
|
24
26
|
|
|
27
|
+
var m_quadFeature,
|
|
28
|
+
s_exit = this._exit,
|
|
29
|
+
m_this = this;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* If the specified coordinates are in the rendered quad, use the basis
|
|
33
|
+
* information from the quad to determine the pixelmap index value so that it
|
|
34
|
+
* can be included in the `found` results.
|
|
35
|
+
*
|
|
36
|
+
* @param {geo.geoPosition} geo Coordinate.
|
|
37
|
+
* @param {string|geo.transform|null} [gcs] Input gcs. `undefined` to use
|
|
38
|
+
* the interface gcs, `null` to use the map gcs, or any other transform.
|
|
39
|
+
* @returns {geo.feature.searchResult} An object with a list of features and
|
|
40
|
+
* feature indices that are located at the specified point.
|
|
41
|
+
*/
|
|
42
|
+
this.pointSearch = function (geo, gcs) {
|
|
43
|
+
if (m_quadFeature && m_this.m_info) {
|
|
44
|
+
var result = m_quadFeature.pointSearch(geo, gcs);
|
|
45
|
+
if (result.index.length === 1 && result.extra && result.extra[result.index[0]].basis) {
|
|
46
|
+
var basis = result.extra[result.index[0]].basis, x, y, idx;
|
|
47
|
+
x = Math.floor(basis.x * m_this.m_info.width);
|
|
48
|
+
y = Math.floor(basis.y * m_this.m_info.height);
|
|
49
|
+
if (x >= 0 && x < m_this.m_info.width &&
|
|
50
|
+
y >= 0 && y < m_this.m_info.height) {
|
|
51
|
+
idx = m_this.m_info.indices[y * m_this.m_info.width + x];
|
|
52
|
+
result = {
|
|
53
|
+
index: [idx],
|
|
54
|
+
found: [m_this.data()[idx]]
|
|
55
|
+
};
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return {index: [], found: []};
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Compute information for this pixelmap image. It is wasteful to call this
|
|
65
|
+
* if the pixelmap has already been prepared (it is invalidated by a change
|
|
66
|
+
* in the image).
|
|
67
|
+
*
|
|
68
|
+
* @returns {geo.pixelmapFeature.info}
|
|
69
|
+
*/
|
|
70
|
+
this._preparePixelmap = function () {
|
|
71
|
+
var i, idx, pixelData;
|
|
72
|
+
|
|
73
|
+
if (!util.isReadyImage(m_this.m_srcImage)) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
m_this.m_info = {
|
|
77
|
+
width: m_this.m_srcImage.naturalWidth,
|
|
78
|
+
height: m_this.m_srcImage.naturalHeight,
|
|
79
|
+
canvas: document.createElement('canvas')
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
m_this.m_info.canvas.width = m_this.m_info.width;
|
|
83
|
+
m_this.m_info.canvas.height = m_this.m_info.height;
|
|
84
|
+
m_this.m_info.context = m_this.m_info.canvas.getContext('2d');
|
|
85
|
+
|
|
86
|
+
m_this.m_info.context.drawImage(m_this.m_srcImage, 0, 0);
|
|
87
|
+
m_this.m_info.imageData = m_this.m_info.context.getImageData(
|
|
88
|
+
0, 0, m_this.m_info.canvas.width, m_this.m_info.canvas.height);
|
|
89
|
+
pixelData = m_this.m_info.imageData.data;
|
|
90
|
+
m_this.m_info.indices = new Array(pixelData.length / 4);
|
|
91
|
+
m_this.m_info.area = pixelData.length / 4;
|
|
92
|
+
|
|
93
|
+
m_this.m_info.mappedColors = {};
|
|
94
|
+
for (i = 0; i < pixelData.length; i += 4) {
|
|
95
|
+
idx = pixelData[i] + (pixelData[i + 1] << 8) + (pixelData[i + 2] << 16);
|
|
96
|
+
m_this.m_info.indices[i / 4] = idx;
|
|
97
|
+
if (!m_this.m_info.mappedColors[idx]) {
|
|
98
|
+
m_this.m_info.mappedColors[idx] = {first: i / 4};
|
|
99
|
+
}
|
|
100
|
+
m_this.m_info.mappedColors[idx].last = i / 4;
|
|
101
|
+
}
|
|
102
|
+
return m_this.m_info;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Given the loaded pixelmap image, create a canvas the size of the image.
|
|
107
|
+
* Compute a color for each distinct index and recolor the canvas based on
|
|
108
|
+
* these colors, then draw the resultant image as a quad.
|
|
109
|
+
*
|
|
110
|
+
* @fires geo.event.pixelmap.prepared
|
|
111
|
+
*/
|
|
112
|
+
this._computePixelmap = function () {
|
|
113
|
+
var data = m_this.data() || [],
|
|
114
|
+
colorFunc = m_this.style.get('color'),
|
|
115
|
+
i, idx, lastidx, color, pixelData, indices, mappedColors,
|
|
116
|
+
updateFirst, updateLast = -1, update, prepared;
|
|
117
|
+
|
|
118
|
+
if (!m_this.m_info) {
|
|
119
|
+
if (!m_this._preparePixelmap()) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
prepared = true;
|
|
123
|
+
}
|
|
124
|
+
mappedColors = m_this.m_info.mappedColors;
|
|
125
|
+
updateFirst = m_this.m_info.area;
|
|
126
|
+
for (idx in mappedColors) {
|
|
127
|
+
if (mappedColors.hasOwnProperty(idx)) {
|
|
128
|
+
color = colorFunc(data[idx], +idx) || {};
|
|
129
|
+
color = [
|
|
130
|
+
(color.r || 0) * 255,
|
|
131
|
+
(color.g || 0) * 255,
|
|
132
|
+
(color.b || 0) * 255,
|
|
133
|
+
color.a === undefined ? 255 : (color.a * 255)
|
|
134
|
+
];
|
|
135
|
+
mappedColors[idx].update = (
|
|
136
|
+
!mappedColors[idx].color ||
|
|
137
|
+
mappedColors[idx].color[0] !== color[0] ||
|
|
138
|
+
mappedColors[idx].color[1] !== color[1] ||
|
|
139
|
+
mappedColors[idx].color[2] !== color[2] ||
|
|
140
|
+
mappedColors[idx].color[3] !== color[3]);
|
|
141
|
+
if (mappedColors[idx].update) {
|
|
142
|
+
mappedColors[idx].color = color;
|
|
143
|
+
updateFirst = Math.min(mappedColors[idx].first, updateFirst);
|
|
144
|
+
updateLast = Math.max(mappedColors[idx].last, updateLast);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/* If nothing was updated, we are done */
|
|
149
|
+
if (updateFirst >= updateLast) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
/* Update only the extent that has changed */
|
|
153
|
+
pixelData = m_this.m_info.imageData.data;
|
|
154
|
+
indices = m_this.m_info.indices;
|
|
155
|
+
for (i = updateFirst; i <= updateLast; i += 1) {
|
|
156
|
+
idx = indices[i];
|
|
157
|
+
if (idx !== lastidx) {
|
|
158
|
+
lastidx = idx;
|
|
159
|
+
color = mappedColors[idx].color;
|
|
160
|
+
update = mappedColors[idx].update;
|
|
161
|
+
}
|
|
162
|
+
if (update) {
|
|
163
|
+
pixelData[i * 4] = color[0];
|
|
164
|
+
pixelData[i * 4 + 1] = color[1];
|
|
165
|
+
pixelData[i * 4 + 2] = color[2];
|
|
166
|
+
pixelData[i * 4 + 3] = color[3];
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/* Place the updated area into the canvas */
|
|
170
|
+
m_this.m_info.context.putImageData(
|
|
171
|
+
m_this.m_info.imageData, 0, 0, 0, Math.floor(updateFirst / m_this.m_info.width),
|
|
172
|
+
m_this.m_info.width, Math.ceil((updateLast + 1) / m_this.m_info.width));
|
|
173
|
+
|
|
174
|
+
/* If we haven't made a quad feature, make one now. The quad feature needs
|
|
175
|
+
* to have the canvas capability. */
|
|
176
|
+
if (!m_quadFeature) {
|
|
177
|
+
m_quadFeature = m_this.layer().createFeature('quad', {
|
|
178
|
+
selectionAPI: false,
|
|
179
|
+
gcs: m_this.gcs(),
|
|
180
|
+
visible: m_this.visible(undefined, true)
|
|
181
|
+
});
|
|
182
|
+
m_this.dependentFeatures([m_quadFeature]);
|
|
183
|
+
m_quadFeature.style({
|
|
184
|
+
image: m_this.m_info.canvas,
|
|
185
|
+
position: m_this.style.get('position')})
|
|
186
|
+
.data([{}])
|
|
187
|
+
.draw();
|
|
188
|
+
}
|
|
189
|
+
/* If we prepared the pixelmap and rendered it, send a prepared event */
|
|
190
|
+
if (prepared) {
|
|
191
|
+
m_this.geoTrigger(geo_event.pixelmap.prepared, {
|
|
192
|
+
pixelmap: m_this
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Destroy. Deletes the associated quadFeature.
|
|
199
|
+
*
|
|
200
|
+
* @returns {this}
|
|
201
|
+
*/
|
|
202
|
+
this._exit = function () {
|
|
203
|
+
if (m_quadFeature && m_this.layer()) {
|
|
204
|
+
m_this.layer().deleteFeature(m_quadFeature);
|
|
205
|
+
m_quadFeature = null;
|
|
206
|
+
m_this.dependentFeatures([]);
|
|
207
|
+
}
|
|
208
|
+
s_exit();
|
|
209
|
+
return m_this;
|
|
210
|
+
};
|
|
211
|
+
|
|
25
212
|
this._init(arg);
|
|
26
213
|
return this;
|
|
27
214
|
};
|
package/src/choroplethFeature.js
CHANGED
|
@@ -185,7 +185,7 @@ var choroplethFeature = function (arg) {
|
|
|
185
185
|
/**
|
|
186
186
|
* Add a geojson polygon feature to the current layer.
|
|
187
187
|
*
|
|
188
|
-
* @param {geojsonFeature} feature A geojson parsed feature.
|
|
188
|
+
* @param {geo.geojsonFeature} feature A geojson parsed feature.
|
|
189
189
|
* @param {geo.geoColor} fillColor The fill color for the feature.
|
|
190
190
|
* @returns {geo.polygonFeature}
|
|
191
191
|
*/
|
package/src/domRenderer.js
CHANGED
|
@@ -38,9 +38,10 @@ var domRenderer = function (arg) {
|
|
|
38
38
|
/**
|
|
39
39
|
* Initialize.
|
|
40
40
|
*
|
|
41
|
+
* @param {object} [arg] Optional arguments.
|
|
41
42
|
* @returns {this}
|
|
42
43
|
*/
|
|
43
|
-
this._init = function () {
|
|
44
|
+
this._init = function (arg) {
|
|
44
45
|
var layer = m_this.layer().node();
|
|
45
46
|
|
|
46
47
|
if (!m_this.canvas() && layer && layer.length) {
|
package/src/featureLayer.js
CHANGED
|
@@ -109,7 +109,7 @@ var featureLayer = function (arg) {
|
|
|
109
109
|
/**
|
|
110
110
|
* Get/Set drawables.
|
|
111
111
|
*
|
|
112
|
-
* @param {geo.feature[]} val A list of features, or unspecified to return
|
|
112
|
+
* @param {geo.feature[]} [val] A list of features, or unspecified to return
|
|
113
113
|
* the current feature list. If a list is provided, features are added or
|
|
114
114
|
* removed as needed.
|
|
115
115
|
* @returns {geo.feature[]|this} The current features associated with the
|
package/src/fileReader.js
CHANGED
|
@@ -6,7 +6,7 @@ var object = require('./object');
|
|
|
6
6
|
* Object specification for a fileReader.
|
|
7
7
|
*
|
|
8
8
|
* @typedef {object} geo.fileReader.spec
|
|
9
|
-
* @property {geo.featureLayer} layer The target feature layer.
|
|
9
|
+
* @property {geo.featureLayer} [layer] The target feature layer.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -15,7 +15,7 @@ var object = require('./object');
|
|
|
15
15
|
* @class
|
|
16
16
|
* @alias geo.fileReader
|
|
17
17
|
* @extends geo.object
|
|
18
|
-
* @param {geo.fileReader.spec} arg
|
|
18
|
+
* @param {geo.fileReader.spec} [arg]
|
|
19
19
|
* @returns {geo.fileReader}
|
|
20
20
|
*/
|
|
21
21
|
var fileReader = function (arg) {
|
package/src/imageTile.js
CHANGED
|
@@ -11,7 +11,8 @@ var tile = require('./tile');
|
|
|
11
11
|
* @property {object} [size] The size of each tile.
|
|
12
12
|
* @property {number} [size.x=256] Width in pixels.
|
|
13
13
|
* @property {number} [size.y=256] Height in pixels.
|
|
14
|
-
* @property {string} [crossDomain='anonymous'] Image CORS attribute.
|
|
14
|
+
* @property {string} [crossDomain='anonymous'] Image CORS attribute. This is
|
|
15
|
+
* used for the `crossorigin` property when loading images.
|
|
15
16
|
*/
|
|
16
17
|
|
|
17
18
|
/**
|
package/src/isolineFeature.js
CHANGED
|
@@ -657,7 +657,7 @@ var isolineFeature = function (arg) {
|
|
|
657
657
|
* the generated labels. The viewport calculation is conservative, as the
|
|
658
658
|
* map could be rotated, changed size, or have other modifications.
|
|
659
659
|
*
|
|
660
|
-
* @returns {
|
|
660
|
+
* @returns {this}
|
|
661
661
|
*/
|
|
662
662
|
this._updateLabelPositions = function () {
|
|
663
663
|
var last = m_lastLabelPositions;
|
package/src/layer.js
CHANGED
|
@@ -291,7 +291,7 @@ var layer = function (arg) {
|
|
|
291
291
|
/**
|
|
292
292
|
* Get root node of the layer.
|
|
293
293
|
*
|
|
294
|
-
* @returns {
|
|
294
|
+
* @returns {HTMLDivElement}
|
|
295
295
|
*/
|
|
296
296
|
this.node = function () {
|
|
297
297
|
return m_node;
|
|
@@ -579,9 +579,11 @@ var layer = function (arg) {
|
|
|
579
579
|
* Update layer.
|
|
580
580
|
*
|
|
581
581
|
* This is a stub that should be subclassed.
|
|
582
|
+
*
|
|
583
|
+
* @param {object} [arg] An object, possibly with an ``event`` key and value.
|
|
582
584
|
* @returns {this}
|
|
583
585
|
*/
|
|
584
|
-
this._update = function () {
|
|
586
|
+
this._update = function (arg) {
|
|
585
587
|
return m_this;
|
|
586
588
|
};
|
|
587
589
|
|
package/src/lineFeature.js
CHANGED
|
@@ -396,9 +396,9 @@ var lineFeature = function (arg) {
|
|
|
396
396
|
*
|
|
397
397
|
* @param {array} data A new data array.
|
|
398
398
|
* @param {number} [tolerance] The maximum variation allowed in map.gcs
|
|
399
|
-
* units. A value of zero will only remove perfectly
|
|
400
|
-
* not specified, this is set to a half display pixel at the map's
|
|
401
|
-
* zoom level.
|
|
399
|
+
* units. A value of zero will only remove perfectly collinear points.
|
|
400
|
+
* If not specified, this is set to a half display pixel at the map's
|
|
401
|
+
* current zoom level.
|
|
402
402
|
* @param {function} [posFunc=this.style.get('position')] The function to
|
|
403
403
|
* get the position of each vertex.
|
|
404
404
|
* @param {function} [lineFunc=this.style.get('line')] The function to get
|
package/src/map.js
CHANGED
|
@@ -517,7 +517,7 @@ var map = function (arg) {
|
|
|
517
517
|
* view center. Rotation mostly ignores `clampBoundsX`, as the behavior
|
|
518
518
|
* feels peculiar otherwise.
|
|
519
519
|
*
|
|
520
|
-
* @param {number} rotation Absolute angle in radians (positive is
|
|
520
|
+
* @param {number} [rotation] Absolute angle in radians (positive is
|
|
521
521
|
* clockwise).
|
|
522
522
|
* @param {object} [origin] If specified, rotate about this origin.
|
|
523
523
|
* @param {geo.geoPosition} origin.geo The gcs coordinates of the
|
|
@@ -830,7 +830,7 @@ var map = function (arg) {
|
|
|
830
830
|
* coordinate to convert.
|
|
831
831
|
* @param {string|geo.transform|null} [gcs] Output gcs. `undefined` to use
|
|
832
832
|
* the interface gcs, `null` to use the map gcs, or any other transform.
|
|
833
|
-
* @returns {geo.geoPosition|geoPosition[]} GCS space coordinates.
|
|
833
|
+
* @returns {geo.geoPosition|geo.geoPosition[]} GCS space coordinates.
|
|
834
834
|
*/
|
|
835
835
|
this.displayToGcs = function (c, gcs) {
|
|
836
836
|
c = m_this.displayToWorld(c); // done via camera
|
|
@@ -954,9 +954,10 @@ var map = function (arg) {
|
|
|
954
954
|
/**
|
|
955
955
|
* Initialize the map.
|
|
956
956
|
*
|
|
957
|
+
* @param {object} [arg] Optional arguments.
|
|
957
958
|
* @returns {this} The map object.
|
|
958
959
|
*/
|
|
959
|
-
this._init = function () {
|
|
960
|
+
this._init = function (arg) {
|
|
960
961
|
|
|
961
962
|
if (m_node === undefined || m_node === null) {
|
|
962
963
|
throw new Error('Map require DIV node');
|
|
@@ -1296,7 +1297,7 @@ var map = function (arg) {
|
|
|
1296
1297
|
y: p[1]
|
|
1297
1298
|
}, null, true, true);
|
|
1298
1299
|
} else {
|
|
1299
|
-
m_center = m_this.gcsToWorld({x: p[0], y: p[1]}, null
|
|
1300
|
+
m_center = m_this.gcsToWorld({x: p[0], y: p[1]}, null);
|
|
1300
1301
|
m_this.zoom(p[2], m_transition.zoomOrigin, true);
|
|
1301
1302
|
}
|
|
1302
1303
|
m_this.rotation(p[3], undefined, true);
|
|
@@ -1494,7 +1495,7 @@ var map = function (arg) {
|
|
|
1494
1495
|
* @param {number} rotation The requested rotation in clockwise radians.
|
|
1495
1496
|
* @param {string|geo.transform|null} [gcs] `undefined` to use the interface
|
|
1496
1497
|
* gcs, `null` to use the map gcs, or any other transform.
|
|
1497
|
-
* @param {boolean} ignoreDiscreteZoom If `true`, ignore the `discreteZoom`
|
|
1498
|
+
* @param {boolean} [ignoreDiscreteZoom] If `true`, ignore the `discreteZoom`
|
|
1498
1499
|
* option when determining the new view.
|
|
1499
1500
|
* @param {boolean} [ignoreClampBounds] If `true` and `clampBoundsX` or
|
|
1500
1501
|
* `clampBoundsY` is set, allow the bounds to be less clamped.
|
|
@@ -1728,11 +1729,11 @@ var map = function (arg) {
|
|
|
1728
1729
|
* @param {boolean|null} [opts.attribution=null] If `null` or unspecified,
|
|
1729
1730
|
* include the attribution only if all layers are used. If false, never
|
|
1730
1731
|
* include the attribution. If `true`, always include it.
|
|
1731
|
-
* @param {
|
|
1732
|
+
* @param {HTMLElement[]|string[]} [opts.html] A list of additional HTML
|
|
1732
1733
|
* elements, selectors, or jQuery elements to render on top of the map.
|
|
1733
1734
|
* These are rendered in order, with the last one topmost.
|
|
1734
|
-
* @returns {
|
|
1735
|
-
* either a data URL or an `HTMLCanvasElement` with the result.
|
|
1735
|
+
* @returns {jQueryDeferred} A jQuery Deferred object. The done function
|
|
1736
|
+
* receives either a data URL or an `HTMLCanvasElement` with the result.
|
|
1736
1737
|
* @fires geo.event.screenshot.ready
|
|
1737
1738
|
*/
|
|
1738
1739
|
this.screenshot = function (layers, type, encoderOptions, opts) {
|
|
@@ -1916,7 +1917,7 @@ var map = function (arg) {
|
|
|
1916
1917
|
/**
|
|
1917
1918
|
* Return the nearest valid zoom level to the requested zoom.
|
|
1918
1919
|
* @param {number} zoom A zoom level to adjust to current settings
|
|
1919
|
-
* @param {boolean} ignoreDiscreteZoom If `true`, ignore the `discreteZoom`
|
|
1920
|
+
* @param {boolean} [ignoreDiscreteZoom] If `true`, ignore the `discreteZoom`
|
|
1920
1921
|
* option when determining the new view.
|
|
1921
1922
|
* @returns {number} The zoom level clamped to the allowed zoom range and
|
|
1922
1923
|
* with other settings applied.
|
|
@@ -1960,10 +1961,11 @@ var map = function (arg) {
|
|
|
1960
1961
|
* Draw a layer image to a canvas context. The layer's opacity and transform
|
|
1961
1962
|
* are applied. This is used as part of making a screenshot.
|
|
1962
1963
|
*
|
|
1963
|
-
* @param {
|
|
1964
|
+
* @param {CanvasRenderingContext2D} context The 2d canvas context to draw
|
|
1965
|
+
* into.
|
|
1964
1966
|
* @param {number} opacity The opacity in the range [0, 1].
|
|
1965
1967
|
* @param {object} elem A jQuery element that might have a transform.
|
|
1966
|
-
* @param {
|
|
1968
|
+
* @param {HTMLImageElement} img The image or canvas to draw to the canvas.
|
|
1967
1969
|
* @param {string} [mixBlendMode] the mix-blend-mode used to add this layer.
|
|
1968
1970
|
* @private
|
|
1969
1971
|
*/
|
|
@@ -2155,12 +2157,12 @@ var map = function (arg) {
|
|
|
2155
2157
|
* Return a valid rotation angle.
|
|
2156
2158
|
*
|
|
2157
2159
|
* @param {number} rotation Proposed rotation.
|
|
2158
|
-
* @param {boolean} ignoreRotationFunc If truthy and rotations are allowed,
|
|
2160
|
+
* @param {boolean} [ignoreRotationFunc] If truthy and rotations are allowed,
|
|
2159
2161
|
* allow any rotation. Otherwise, the rotation is passed through the
|
|
2160
2162
|
* `allowRotation` function.
|
|
2161
|
-
* @param {boolean} noRangeLimit If falsy, ensure that the rotation is in
|
|
2162
|
-
* range [0, 2*PI). If it is very close to zero, it is snapped to
|
|
2163
|
-
* If true, the rotation can have any value.
|
|
2163
|
+
* @param {boolean} [noRangeLimit] If falsy, ensure that the rotation is in
|
|
2164
|
+
* the range [0, 2*PI). If it is very close to zero, it is snapped to
|
|
2165
|
+
* zero. If true, the rotation can have any value.
|
|
2164
2166
|
* @returns {number} the validated rotation
|
|
2165
2167
|
* @private
|
|
2166
2168
|
*/
|