geojs 1.8.4 → 1.8.7
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 +18 -0
- package/geo.js +1316 -1084
- package/geo.lean.js +1316 -1084
- package/geo.lean.min.js +2 -2
- package/geo.min.js +2 -2
- package/package.json +1 -1
- package/src/{annotation.js → annotation/annotation.js} +38 -1374
- package/src/annotation/circleAnnotation.js +33 -0
- package/src/annotation/ellipseAnnotation.js +80 -0
- package/src/annotation/index.js +21 -0
- package/src/annotation/lineAnnotation.js +344 -0
- package/src/annotation/pointAnnotation.js +208 -0
- package/src/annotation/polygonAnnotation.js +313 -0
- package/src/annotation/rectangleAnnotation.js +402 -0
- package/src/annotation/squareAnnotation.js +33 -0
- package/src/fetchQueue.js +25 -11
- package/src/index.js +1 -1
- package/src/transform.js +15 -0
- package/src/typedef.js +9 -0
- package/src/webgl/lineFeature.js +7 -3
- package/src/webgl/polygonFeature.js +11 -8
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const $ = require('jquery');
|
|
2
|
+
const inherit = require('../inherit');
|
|
3
|
+
const registerAnnotation = require('../registry').registerAnnotation;
|
|
4
|
+
const polygonFeature = require('../polygonFeature');
|
|
5
|
+
|
|
6
|
+
const rectangleAnnotation = require('./rectangleAnnotation');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Square annotation class.
|
|
10
|
+
*
|
|
11
|
+
* Squares are a subset of rectangles with a fixed aspect ratio.
|
|
12
|
+
*
|
|
13
|
+
* @class
|
|
14
|
+
* @alias geo.squareAnnotation
|
|
15
|
+
* @extends geo.annotation
|
|
16
|
+
*
|
|
17
|
+
* @param {geo.squareAnnotation.spec?} [args] Options for the annotation.
|
|
18
|
+
* @param {string} [annotationName='square'] Override the annotation name.
|
|
19
|
+
*/
|
|
20
|
+
var squareAnnotation = function (args, annotationName) {
|
|
21
|
+
'use strict';
|
|
22
|
+
args = $.extend({}, args, {constraint: 1});
|
|
23
|
+
if (!(this instanceof squareAnnotation)) {
|
|
24
|
+
return new squareAnnotation(args, annotationName);
|
|
25
|
+
}
|
|
26
|
+
rectangleAnnotation.call(this, args, annotationName || 'square');
|
|
27
|
+
};
|
|
28
|
+
inherit(squareAnnotation, rectangleAnnotation);
|
|
29
|
+
var squareRequiredFeatures = {};
|
|
30
|
+
squareRequiredFeatures[polygonFeature.capabilities.feature] = true;
|
|
31
|
+
registerAnnotation('square', squareAnnotation, squareRequiredFeatures);
|
|
32
|
+
|
|
33
|
+
module.exports = squareAnnotation;
|
package/src/fetchQueue.js
CHANGED
|
@@ -146,8 +146,8 @@ var fetchQueue = function (options) {
|
|
|
146
146
|
if (defer.__fetchQueue) {
|
|
147
147
|
var pos = $.inArray(defer, m_this._queue);
|
|
148
148
|
if (pos >= 0) {
|
|
149
|
-
m_this._queue.splice(pos, 1);
|
|
150
|
-
m_this._addToQueue(defer, atEnd);
|
|
149
|
+
// m_this._queue.splice(pos, 1);
|
|
150
|
+
m_this._addToQueue(defer, atEnd, pos);
|
|
151
151
|
return defer;
|
|
152
152
|
}
|
|
153
153
|
}
|
|
@@ -177,20 +177,34 @@ var fetchQueue = function (options) {
|
|
|
177
177
|
* @param {boolean} atEnd If falsy, add the item to the front of the queue
|
|
178
178
|
* if batching is turned off or at the end of the current batch if it is
|
|
179
179
|
* turned on. If truthy, always add the item to the end of the queue.
|
|
180
|
+
* @param {number} [pos] If specified, the current location in the queue of
|
|
181
|
+
* the object being added. This avoids having to splice, push, or unshift
|
|
182
|
+
* the queue.
|
|
180
183
|
*/
|
|
181
|
-
this._addToQueue = function (defer, atEnd) {
|
|
184
|
+
this._addToQueue = function (defer, atEnd, pos) {
|
|
185
|
+
let move = atEnd ? m_this._queue.length - 1 : 0;
|
|
182
186
|
defer.__fetchQueue._batch = m_this._batch;
|
|
183
|
-
if (atEnd) {
|
|
184
|
-
m_this._queue.
|
|
185
|
-
|
|
186
|
-
m_this._queue.unshift(defer);
|
|
187
|
-
} else {
|
|
188
|
-
for (var i = 0; i < m_this._queue.length; i += 1) {
|
|
189
|
-
if (m_this._queue[i].__fetchQueue._batch !== m_this._batch) {
|
|
187
|
+
if (!atEnd && m_this._batch) {
|
|
188
|
+
for (move = 0; move < m_this._queue.length - (pos === undefined ? 0 : 1); move += 1) {
|
|
189
|
+
if (m_this._queue[move].__fetchQueue._batch !== m_this._batch) {
|
|
190
190
|
break;
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
|
-
|
|
193
|
+
}
|
|
194
|
+
if (pos === undefined) {
|
|
195
|
+
if (atEnd) {
|
|
196
|
+
m_this._queue.push(defer);
|
|
197
|
+
} else if (!move) {
|
|
198
|
+
m_this._queue.unshift(defer);
|
|
199
|
+
} else {
|
|
200
|
+
m_this._queue.splice(move, 0, defer);
|
|
201
|
+
}
|
|
202
|
+
} else if (pos !== move) {
|
|
203
|
+
const dir = pos < move ? 1 : -1;
|
|
204
|
+
for (let i = pos; i !== move; i += dir) {
|
|
205
|
+
m_this._queue[i] = m_this._queue[i + dir];
|
|
206
|
+
}
|
|
207
|
+
m_this._queue[move] = defer;
|
|
194
208
|
}
|
|
195
209
|
};
|
|
196
210
|
|
package/src/index.js
CHANGED
|
@@ -46,7 +46,6 @@ $.htmlPrefilter = function (html) {
|
|
|
46
46
|
require('./main.styl');
|
|
47
47
|
|
|
48
48
|
module.exports = $.extend({
|
|
49
|
-
annotation: require('./annotation'),
|
|
50
49
|
annotationLayer: require('./annotationLayer'),
|
|
51
50
|
camera: require('./camera'),
|
|
52
51
|
choroplethFeature: require('./choroplethFeature'),
|
|
@@ -93,6 +92,7 @@ module.exports = $.extend({
|
|
|
93
92
|
version: require('./version'),
|
|
94
93
|
sha: require('./sha'),
|
|
95
94
|
|
|
95
|
+
annotation: require('./annotation'),
|
|
96
96
|
util: require('./util'),
|
|
97
97
|
jQuery: $,
|
|
98
98
|
canvas: require('./canvas'),
|
package/src/transform.js
CHANGED
|
@@ -767,6 +767,21 @@ transform.vincentyDistance = function (pt1, pt2, gcs, baseGcs, ellipsoid, maxIte
|
|
|
767
767
|
};
|
|
768
768
|
};
|
|
769
769
|
|
|
770
|
+
/**
|
|
771
|
+
* Return a boolean indicating if the projections only differ in their y
|
|
772
|
+
* coordinate.
|
|
773
|
+
*
|
|
774
|
+
* @param {string} srcPrj The source projection.
|
|
775
|
+
* @param {string} tgtPrj The destination projection.
|
|
776
|
+
* @returns {boolean} truthy if only the y coordinate is different between
|
|
777
|
+
* projections.
|
|
778
|
+
*/
|
|
779
|
+
transform.onlyInvertedY = function (srcPrj, tgtPrj) {
|
|
780
|
+
const smatch = srcPrj.match(axisPattern),
|
|
781
|
+
tmatch = tgtPrj.match(axisPattern);
|
|
782
|
+
return smatch && tmatch && smatch[1] === tmatch[1] && smatch[3] === tmatch[3];
|
|
783
|
+
};
|
|
784
|
+
|
|
770
785
|
/* Expose proj4 to make it easier to debug */
|
|
771
786
|
transform.proj4 = proj4;
|
|
772
787
|
|
package/src/typedef.js
CHANGED
|
@@ -74,6 +74,15 @@
|
|
|
74
74
|
* @property {number} [z=0] Altitude coordinate, often zero.
|
|
75
75
|
*/
|
|
76
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Represention of a size in gcs coordinates.
|
|
79
|
+
*
|
|
80
|
+
* @typedef geo.geoSize
|
|
81
|
+
* @type {object}
|
|
82
|
+
* @property {number} width Width in gcs coordinates.
|
|
83
|
+
* @property {number} height Height in gcs coordinates.
|
|
84
|
+
*/
|
|
85
|
+
|
|
77
86
|
/**
|
|
78
87
|
* Represention of a size in pixels.
|
|
79
88
|
*
|
package/src/webgl/lineFeature.js
CHANGED
|
@@ -134,6 +134,9 @@ var webgl_lineFeature = function (arg) {
|
|
|
134
134
|
strokeOffset: 0, posStrokeOffset: 0, negStrokeOffset: 0
|
|
135
135
|
}],
|
|
136
136
|
v = vert[1],
|
|
137
|
+
target_gcs = m_this.gcs(),
|
|
138
|
+
map_gcs = m_this.layer().map().gcs(),
|
|
139
|
+
simpleInverse = transform.onlyInvertedY(target_gcs, map_gcs),
|
|
137
140
|
pos, posIdx3, firstpos, firstPosIdx3,
|
|
138
141
|
lineFunc = m_this.line(),
|
|
139
142
|
strokeWidthFunc = m_this.style.get('strokeWidth'), strokeWidthVal,
|
|
@@ -188,7 +191,7 @@ var webgl_lineFeature = function (arg) {
|
|
|
188
191
|
for (j = 0; j < lineItem.length; j += 1) {
|
|
189
192
|
pos = posFunc(lineItem[j], j, d, i);
|
|
190
193
|
position.push(pos.x);
|
|
191
|
-
position.push(pos.y);
|
|
194
|
+
position.push(simpleInverse ? -pos.y : pos.y);
|
|
192
195
|
position.push(pos.z || 0.0);
|
|
193
196
|
if (!j) {
|
|
194
197
|
firstpos = pos;
|
|
@@ -208,8 +211,9 @@ var webgl_lineFeature = function (arg) {
|
|
|
208
211
|
}
|
|
209
212
|
}
|
|
210
213
|
|
|
211
|
-
|
|
212
|
-
|
|
214
|
+
if (!simpleInverse) {
|
|
215
|
+
position = transform.transformCoordinates(target_gcs, map_gcs, position, 3);
|
|
216
|
+
}
|
|
213
217
|
m_origin = new Float32Array(m_this.style.get('origin')(position));
|
|
214
218
|
if (m_origin[0] || m_origin[1] || m_origin[2]) {
|
|
215
219
|
for (i = 0; i < position.length; i += 3) {
|
|
@@ -82,6 +82,7 @@ var webgl_polygonFeature = function (arg) {
|
|
|
82
82
|
items = [],
|
|
83
83
|
target_gcs = m_this.gcs(),
|
|
84
84
|
map_gcs = m_this.layer().map().gcs(),
|
|
85
|
+
simpleInverse = transform.onlyInvertedY(target_gcs, map_gcs),
|
|
85
86
|
numPts = 0,
|
|
86
87
|
geom = m_mapper.geometryData(),
|
|
87
88
|
color, opacity, fill, d, d3, vertices, i, j, k, n,
|
|
@@ -117,7 +118,7 @@ var webgl_polygonFeature = function (arg) {
|
|
|
117
118
|
for (i = d3 = 0; i < outer.length; i += 1, d3 += 3) {
|
|
118
119
|
c = posFunc(outer[i], i, item, itemIndex);
|
|
119
120
|
geometry[d3] = c.x;
|
|
120
|
-
geometry[d3 + 1] = c.y;
|
|
121
|
+
geometry[d3 + 1] = simpleInverse ? -c.y : c.y;
|
|
121
122
|
// ignore the z values until we support them
|
|
122
123
|
geometry[d3 + 2] = 0; // c.z || 0;
|
|
123
124
|
}
|
|
@@ -134,7 +135,7 @@ var webgl_polygonFeature = function (arg) {
|
|
|
134
135
|
for (i = 0; i < hole.length; i += 1, d3 += 3) {
|
|
135
136
|
c = posFunc(hole[i], i, item, itemIndex);
|
|
136
137
|
geometry.vertices[d3] = c.x;
|
|
137
|
-
geometry.vertices[d3 + 1] = c.y;
|
|
138
|
+
geometry.vertices[d3 + 1] = simpleInverse ? -c.y : c.y;
|
|
138
139
|
// ignore the z values until we support them
|
|
139
140
|
geometry.vertices[d3 + 2] = 0; // c.z || 0;
|
|
140
141
|
}
|
|
@@ -142,12 +143,14 @@ var webgl_polygonFeature = function (arg) {
|
|
|
142
143
|
}
|
|
143
144
|
|
|
144
145
|
// transform to map gcs
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
146
|
+
if (!simpleInverse) {
|
|
147
|
+
geometry.vertices = transform.transformCoordinates(
|
|
148
|
+
target_gcs,
|
|
149
|
+
map_gcs,
|
|
150
|
+
geometry.vertices,
|
|
151
|
+
geometry.dimensions
|
|
152
|
+
);
|
|
153
|
+
}
|
|
151
154
|
|
|
152
155
|
record = {
|
|
153
156
|
// triangulate
|