@openglobus/og 0.11.1 → 0.11.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/package.json +18 -20
- package/src/og/Clock.js +11 -11
- package/src/og/Deferred.js +1 -1
- package/src/og/Events.js +9 -7
- package/src/og/Extent.js +117 -72
- package/src/og/Globe.js +35 -22
- package/src/og/ImageCanvas.js +24 -18
- package/src/og/Lock.js +2 -2
- package/src/og/LonLat.js +40 -37
- package/src/og/Popup.js +21 -15
- package/src/og/QueueArray.js +7 -3
- package/src/og/Rectangle.js +11 -6
- package/src/og/Stack.js +8 -5
- package/src/og/ajax.js +21 -33
- package/src/og/astro/astro.js +5 -5
- package/src/og/astro/earth.js +23 -17
- package/src/og/astro/jd.js +44 -39
- package/src/og/astro/orbit.js +20 -18
- package/src/og/astro/rotation.js +17 -8
- package/src/og/bv/Box.js +7 -3
- package/src/og/bv/Sphere.js +17 -9
- package/src/og/camera/Camera.js +137 -86
- package/src/og/camera/Frustum.js +30 -19
- package/src/og/camera/PlanetCamera.js +30 -26
- package/src/og/control/CompassButton.js +8 -2
- package/src/og/control/Control.js +13 -11
- package/src/og/control/DebugInfo.js +4 -1
- package/src/og/control/EarthCoordinates.js +62 -41
- package/src/og/control/EarthNavigation.js +20 -22
- package/src/og/control/GeoImageDragControl.js +1 -1
- package/src/og/control/KeyboardNavigation.js +12 -12
- package/src/og/control/LayerSwitcher.js +24 -23
- package/src/og/control/Lighting.js +1 -1
- package/src/og/control/MouseNavigation.js +1 -1
- package/src/og/control/ScaleControl.js +1 -1
- package/src/og/control/SegmentBoundVisualization.js +8 -9
- package/src/og/control/ShowFps.js +15 -10
- package/src/og/control/SimpleNavigation.js +8 -10
- package/src/og/control/Sun.js +25 -15
- package/src/og/control/ToggleWireframe.js +5 -5
- package/src/og/control/TouchNavigation.js +58 -45
- package/src/og/control/ZoomControl.js +41 -25
- package/src/og/control/index.js +4 -0
- package/src/og/ellipsoid/Ellipsoid.js +181 -85
- package/src/og/ellipsoid/wgs84.js +4 -4
- package/src/og/entity/BaseBillboard.js +97 -44
- package/src/og/entity/Billboard.js +15 -11
- package/src/og/entity/BillboardHandler.js +314 -64
- package/src/og/entity/Entity.js +106 -74
- package/src/og/entity/EntityCollection.js +72 -49
- package/src/og/entity/GeoObject.js +228 -0
- package/src/og/entity/GeoObjectHandler.js +910 -0
- package/src/og/entity/Geometry.js +29 -26
- package/src/og/entity/GeometryHandler.js +598 -126
- package/src/og/entity/Label.js +74 -40
- package/src/og/entity/LabelHandler.js +47 -246
- package/src/og/entity/LabelWorker.js +213 -0
- package/src/og/entity/Object3d.js +504 -0
- package/src/og/entity/PointCloud.js +81 -33
- package/src/og/entity/PointCloudHandler.js +9 -9
- package/src/og/entity/Polyline.js +39 -39
- package/src/og/entity/Ray.js +61 -28
- package/src/og/entity/ShapeHandler.js +1 -1
- package/src/og/entity/Strip.js +77 -48
- package/src/og/entity/StripHandler.js +27 -27
- package/src/og/entity/index.js +8 -16
- package/src/og/input/KeyboardHandler.js +107 -104
- package/src/og/input/MouseHandler.js +81 -78
- package/src/og/input/TouchHandler.js +55 -51
- package/src/og/layer/BaseGeoImage.js +61 -30
- package/src/og/layer/CanvasTiles.js +26 -24
- package/src/og/layer/GeoImage.js +10 -10
- package/src/og/layer/GeoTexture2d.js +1 -1
- package/src/og/layer/GeoVideo.js +3 -3
- package/src/og/layer/KML.js +66 -40
- package/src/og/layer/Layer.js +27 -17
- package/src/og/layer/Material.js +93 -61
- package/src/og/layer/Vector.js +118 -72
- package/src/og/layer/WMS.js +36 -19
- package/src/og/layer/XYZ.js +55 -48
- package/src/og/light/LightSource.js +47 -40
- package/src/og/math/Line2.js +24 -24
- package/src/og/math/Line3.js +103 -102
- package/src/og/math/Mat3.js +134 -121
- package/src/og/math/Mat4.js +603 -459
- package/src/og/math/Plane.js +21 -20
- package/src/og/math/Quat.js +980 -927
- package/src/og/math/Ray.js +195 -187
- package/src/og/math/Vec2.js +127 -117
- package/src/og/math/Vec3.js +206 -176
- package/src/og/math/Vec4.js +49 -53
- package/src/og/math/coder.js +18 -18
- package/src/og/math.js +12 -12
- package/src/og/mercator.js +11 -11
- package/src/og/proj/EPSG3857.js +4 -4
- package/src/og/proj/EPSG4326.js +4 -4
- package/src/og/proj/Proj.js +31 -31
- package/src/og/quadTree/EntityCollectionNode.js +310 -300
- package/src/og/quadTree/Node.js +1008 -993
- package/src/og/renderer/Renderer.js +768 -747
- package/src/og/renderer/RendererEvents.js +9 -6
- package/src/og/scene/Axes.js +1 -1
- package/src/og/scene/BaseNode.js +8 -9
- package/src/og/scene/Planet.js +115 -87
- package/src/og/scene/RenderNode.js +29 -22
- package/src/og/scene/SkyBox.js +1 -1
- package/src/og/segment/Segment.js +1886 -1878
- package/src/og/segment/SegmentLonLat.js +298 -268
- package/src/og/segment/segmentHelper.js +11 -11
- package/src/og/shaders/bloom.js +1 -1
- package/src/og/shaders/blur.js +2 -2
- package/src/og/shaders/depth.js +1 -1
- package/src/og/shaders/geoObject.js +211 -0
- package/src/og/shaders/label.js +1 -1
- package/src/og/shaders/lumFilter.js +1 -1
- package/src/og/shaders/pointCloud.js +42 -42
- package/src/og/shaders/screenFrame.js +1 -1
- package/src/og/shaders/shape.js +15 -21
- package/src/og/shaders/skybox.js +37 -37
- package/src/og/shaders/toneMapping.js +1 -1
- package/src/og/shapes/BaseShape.js +129 -57
- package/src/og/shapes/Icosphere.js +30 -15
- package/src/og/shapes/Sphere.js +13 -16
- package/src/og/terrain/BilTerrain.js +2 -1
- package/src/og/terrain/EmptyTerrain.js +2 -2
- package/src/og/terrain/Geoid.js +2 -2
- package/src/og/terrain/GlobusTerrain.js +10 -10
- package/src/og/terrain/MapboxTerrain.js +1 -1
- package/src/og/utils/GeoImageCreator.js +9 -9
- package/src/og/utils/Loader.js +6 -6
- package/src/og/utils/NormalMapCreator.js +13 -13
- package/src/og/utils/TerrainWorker.js +1 -1
- package/src/og/utils/TextureAtlas.js +20 -22
- package/src/og/utils/VectorTileCreator.js +5 -5
- package/src/og/utils/earcut.js +1 -1
- package/src/og/utils/shared.js +15 -15
- package/src/og/webgl/Framebuffer.js +101 -53
- package/src/og/webgl/Handler.js +125 -85
- package/src/og/webgl/Multisample.js +55 -27
- package/src/og/webgl/Program.js +80 -35
- package/src/og/webgl/ProgramController.js +27 -23
- package/src/og/webgl/callbacks.js +8 -8
- package/types/Clock.d.ts +6 -2
- package/types/Deferred.d.ts +1 -1
- package/types/Events.d.ts +8 -4
- package/types/Extent.d.ts +37 -33
- package/types/Globe.d.ts +15 -13
- package/types/ImageCanvas.d.ts +5 -3
- package/types/LonLat.d.ts +24 -24
- package/types/Popup.d.ts +4 -0
- package/types/QueueArray.d.ts +6 -2
- package/types/Rectangle.d.ts +10 -4
- package/types/Stack.d.ts +4 -0
- package/types/ajax.d.ts +1 -1
- package/types/astro/earth.d.ts +3 -2
- package/types/bv/Box.d.ts +10 -5
- package/types/bv/Sphere.d.ts +13 -7
- package/types/camera/Camera.d.ts +90 -81
- package/types/camera/Frustum.d.ts +26 -22
- package/types/camera/PlanetCamera.d.ts +49 -53
- package/types/control/CompassButton.d.ts +4 -4
- package/types/control/Control.d.ts +7 -4
- package/types/control/DebugInfo.d.ts +3 -4
- package/types/control/EarthCoordinates.d.ts +6 -6
- package/types/control/EarthNavigation.d.ts +42 -0
- package/types/control/KeyboardNavigation.d.ts +3 -4
- package/types/control/LayerSwitcher.d.ts +3 -5
- package/types/control/Lighting.d.ts +3 -3
- package/types/control/MouseNavigation.d.ts +47 -0
- package/types/control/ScaleControl.d.ts +3 -3
- package/types/control/ShowFps.d.ts +3 -4
- package/types/control/SimpleNavigation.d.ts +3 -6
- package/types/control/Sun.d.ts +8 -10
- package/types/control/ToggleWireframe.d.ts +3 -3
- package/types/control/TouchNavigation.d.ts +48 -0
- package/types/control/ZoomControl.d.ts +3 -4
- package/types/control/index.d.ts +3 -1
- package/types/ellipsoid/Ellipsoid.d.ts +47 -43
- package/types/ellipsoid/wgs84.d.ts +3 -2
- package/types/entity/BaseBillboard.d.ts +41 -34
- package/types/entity/Billboard.d.ts +7 -7
- package/types/entity/BillboardHandler.d.ts +4 -0
- package/types/entity/Entity.d.ts +101 -83
- package/types/entity/EntityCollection.d.ts +57 -43
- package/types/entity/GeoObject.d.ts +111 -0
- package/types/entity/GeoObjectHandler.d.ts +77 -0
- package/types/entity/Geometry.d.ts +9 -7
- package/types/entity/GeometryHandler.d.ts +2 -2
- package/types/entity/Label.d.ts +24 -29
- package/types/entity/LabelHandler.d.ts +9 -2
- package/types/entity/LabelWorker.d.ts +9 -0
- package/types/entity/PointCloud.d.ts +8 -8
- package/types/entity/PointCloudHandler.d.ts +3 -3
- package/types/entity/Polyline.d.ts +58 -55
- package/types/entity/Ray.d.ts +19 -18
- package/types/entity/Strip.d.ts +8 -7
- package/types/entity/StripHandler.d.ts +3 -3
- package/types/entity/index.d.ts +7 -7
- package/types/input/KeyboardHandler.d.ts +10 -0
- package/types/input/MouseHandler.d.ts +5 -0
- package/types/input/TouchHandler.d.ts +5 -0
- package/types/layer/BaseGeoImage.d.ts +23 -35
- package/types/layer/CanvasTiles.d.ts +15 -22
- package/types/layer/GeoImage.d.ts +5 -18
- package/types/layer/GeoVideo.d.ts +5 -30
- package/types/layer/KML.d.ts +20 -15
- package/types/layer/Layer.d.ts +326 -0
- package/types/layer/Material.d.ts +45 -0
- package/types/layer/Vector.d.ts +208 -0
- package/types/layer/WMS.d.ts +4 -7
- package/types/layer/XYZ.d.ts +19 -25
- package/types/light/LightSource.d.ts +54 -53
- package/types/math/Line2.d.ts +11 -0
- package/types/math/Line3.d.ts +10 -0
- package/types/math/Mat3.d.ts +30 -18
- package/types/math/Mat4.d.ts +71 -52
- package/types/math/Plane.d.ts +5 -4
- package/types/math/Quat.d.ts +379 -0
- package/types/math/Ray.d.ts +82 -0
- package/types/math/Vec2.d.ts +102 -101
- package/types/math/Vec3.d.ts +143 -142
- package/types/math/Vec4.d.ts +40 -39
- package/types/math/coder.d.ts +12 -11
- package/types/math.d.ts +8 -8
- package/types/mercator.d.ts +3 -3
- package/types/proj/EPSG3857.d.ts +3 -2
- package/types/proj/EPSG4326.d.ts +3 -2
- package/types/proj/Proj.d.ts +42 -0
- package/types/quadTree/EntityCollectionNode.d.ts +34 -0
- package/types/quadTree/Node.d.ts +61 -0
- package/types/renderer/Renderer.d.ts +300 -0
- package/types/renderer/RendererEvents.d.ts +10 -7
- package/types/scene/BaseNode.d.ts +9 -9
- package/types/scene/Planet.d.ts +131 -126
- package/types/scene/RenderNode.d.ts +22 -23
- package/types/segment/Segment.d.ts +279 -0
- package/types/segment/SegmentLonLat.d.ts +16 -0
- package/types/shaders/geoObject.d.ts +3 -0
- package/types/shapes/BaseShape.d.ts +43 -40
- package/types/shapes/Sphere.d.ts +7 -7
- package/types/terrain/BilTerrain.d.ts +0 -1
- package/types/terrain/EmptyTerrain.d.ts +4 -4
- package/types/terrain/GlobusTerrain.d.ts +17 -54
- package/types/terrain/MapboxTerrain.d.ts +0 -1
- package/types/utils/GeoImageCreator.d.ts +3 -2
- package/types/utils/TextureAtlas.d.ts +8 -8
- package/types/utils/shared.d.ts +25 -24
- package/types/webgl/Framebuffer.d.ts +5 -5
- package/types/webgl/Handler.d.ts +68 -43
- package/types/webgl/Multisample.d.ts +5 -5
- package/types/webgl/Program.d.ts +8 -2
- package/types/webgl/ProgramController.d.ts +18 -13
- package/src/og/inherits.js +0 -8
- package/src/og/utils/polylabel.js +0 -176
- package/types/inherits.d.ts +0 -4
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-mixed-operators */
|
|
2
|
-
goog.provide('og.utils.getPolyCenter');
|
|
3
|
-
|
|
4
|
-
/*
|
|
5
|
-
ISC License
|
|
6
|
-
Copyright (c) 2016 Mapbox
|
|
7
|
-
|
|
8
|
-
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
9
|
-
with or without fee is hereby granted, provided that the above copyright notice
|
|
10
|
-
and this permission notice appear in all copies.
|
|
11
|
-
|
|
12
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
|
13
|
-
THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
|
|
14
|
-
IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
|
|
15
|
-
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA
|
|
16
|
-
OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
|
17
|
-
ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
18
|
-
SOFTWARE.
|
|
19
|
-
|
|
20
|
-
https://github.com/mapbox/polylabel
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
og.utils.getPolyCenter = function (polygon) {
|
|
24
|
-
|
|
25
|
-
function polylabel(polygon, precision, debug) {
|
|
26
|
-
precision = precision || 1.0;
|
|
27
|
-
|
|
28
|
-
// find the bounding box of the outer ring
|
|
29
|
-
var minX, minY, maxX, maxY;
|
|
30
|
-
for (var i = 0; i < polygon[0].length; i++) {
|
|
31
|
-
var p = polygon[0][i];
|
|
32
|
-
if (!i || p[0] < minX) minX = p[0];
|
|
33
|
-
if (!i || p[1] < minY) minY = p[1];
|
|
34
|
-
if (!i || p[0] > maxX) maxX = p[0];
|
|
35
|
-
if (!i || p[1] > maxY) maxY = p[1];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
var width = maxX - minX;
|
|
39
|
-
var height = maxY - minY;
|
|
40
|
-
var cellSize = Math.min(width, height);
|
|
41
|
-
var h = cellSize / 2;
|
|
42
|
-
|
|
43
|
-
// a priority queue of cells in order of their "potential" (max distance to polygon)
|
|
44
|
-
var cellQueue = new Queue(null, compareMax);
|
|
45
|
-
|
|
46
|
-
if (cellSize === 0) return [minX, minY];
|
|
47
|
-
|
|
48
|
-
// cover polygon with initial cells
|
|
49
|
-
for (var x = minX; x < maxX; x += cellSize) {
|
|
50
|
-
for (var y = minY; y < maxY; y += cellSize) {
|
|
51
|
-
cellQueue.push(new Cell(x + h, y + h, h, polygon));
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// take centroid as the first best guess
|
|
56
|
-
var bestCell = getCentroidCell(polygon);
|
|
57
|
-
|
|
58
|
-
// special case for rectangular polygons
|
|
59
|
-
var bboxCell = new Cell(minX + width / 2, minY + height / 2, 0, polygon);
|
|
60
|
-
if (bboxCell.d > bestCell.d) bestCell = bboxCell;
|
|
61
|
-
|
|
62
|
-
var numProbes = cellQueue.length;
|
|
63
|
-
|
|
64
|
-
while (cellQueue.length) {
|
|
65
|
-
// pick the most promising cell from the queue
|
|
66
|
-
var cell = cellQueue.pop();
|
|
67
|
-
|
|
68
|
-
// update the best cell if we found a better one
|
|
69
|
-
if (cell.d > bestCell.d) {
|
|
70
|
-
bestCell = cell;
|
|
71
|
-
if (debug) console.log('found best %d after %d probes', Math.round(1e4 * cell.d) / 1e4, numProbes);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// do not drill down further if there's no chance of a better solution
|
|
75
|
-
if (cell.max - bestCell.d <= precision) continue;
|
|
76
|
-
|
|
77
|
-
// split the cell into four cells
|
|
78
|
-
h = cell.h / 2;
|
|
79
|
-
cellQueue.push(new Cell(cell.x - h, cell.y - h, h, polygon));
|
|
80
|
-
cellQueue.push(new Cell(cell.x + h, cell.y - h, h, polygon));
|
|
81
|
-
cellQueue.push(new Cell(cell.x - h, cell.y + h, h, polygon));
|
|
82
|
-
cellQueue.push(new Cell(cell.x + h, cell.y + h, h, polygon));
|
|
83
|
-
numProbes += 4;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (debug) {
|
|
87
|
-
console.log('num probes: ' + numProbes);
|
|
88
|
-
console.log('best distance: ' + bestCell.d);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return [bestCell.x, bestCell.y];
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function compareMax(a, b) {
|
|
95
|
-
return b.max - a.max;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function Cell(x, y, h, polygon) {
|
|
99
|
-
this.x = x; // cell center x
|
|
100
|
-
this.y = y; // cell center y
|
|
101
|
-
this.h = h; // half the cell size
|
|
102
|
-
this.d = pointToPolygonDist(x, y, polygon); // distance from cell center to polygon
|
|
103
|
-
this.max = this.d + this.h * Math.SQRT2; // max distance to polygon within a cell
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// signed distance from point to polygon outline (negative if point is outside)
|
|
107
|
-
function pointToPolygonDist(x, y, polygon) {
|
|
108
|
-
var inside = false;
|
|
109
|
-
var minDistSq = Infinity;
|
|
110
|
-
|
|
111
|
-
for (var k = 0; k < polygon.length; k++) {
|
|
112
|
-
var ring = polygon[k];
|
|
113
|
-
|
|
114
|
-
for (var i = 0, len = ring.length, j = len - 1; i < len; j = i++) {
|
|
115
|
-
var a = ring[i];
|
|
116
|
-
var b = ring[j];
|
|
117
|
-
|
|
118
|
-
if ((a[1] > y !== b[1] > y) &&
|
|
119
|
-
(x < (b[0] - a[0]) * (y - a[1]) / (b[1] - a[1]) + a[0])) inside = !inside;
|
|
120
|
-
|
|
121
|
-
minDistSq = Math.min(minDistSq, getSegDistSq(x, y, a, b));
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return (inside ? 1 : -1) * Math.sqrt(minDistSq);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// get polygon centroid
|
|
129
|
-
function getCentroidCell(polygon) {
|
|
130
|
-
var area = 0;
|
|
131
|
-
var x = 0;
|
|
132
|
-
var y = 0;
|
|
133
|
-
var points = polygon[0];
|
|
134
|
-
|
|
135
|
-
for (var i = 0, len = points.length, j = len - 1; i < len; j = i++) {
|
|
136
|
-
var a = points[i];
|
|
137
|
-
var b = points[j];
|
|
138
|
-
var f = a[0] * b[1] - b[0] * a[1];
|
|
139
|
-
x += (a[0] + b[0]) * f;
|
|
140
|
-
y += (a[1] + b[1]) * f;
|
|
141
|
-
area += f * 3;
|
|
142
|
-
}
|
|
143
|
-
if (area === 0) return new Cell(points[0][0], points[0][1], 0, polygon);
|
|
144
|
-
return new Cell(x / area, y / area, 0, polygon);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// get squared distance from a point to a segment
|
|
148
|
-
function getSegDistSq(px, py, a, b) {
|
|
149
|
-
|
|
150
|
-
var x = a[0];
|
|
151
|
-
var y = a[1];
|
|
152
|
-
var dx = b[0] - x;
|
|
153
|
-
var dy = b[1] - y;
|
|
154
|
-
|
|
155
|
-
if (dx !== 0 || dy !== 0) {
|
|
156
|
-
|
|
157
|
-
var t = ((px - x) * dx + (py - y) * dy) / (dx * dx + dy * dy);
|
|
158
|
-
|
|
159
|
-
if (t > 1) {
|
|
160
|
-
x = b[0];
|
|
161
|
-
y = b[1];
|
|
162
|
-
|
|
163
|
-
} else if (t > 0) {
|
|
164
|
-
x += dx * t;
|
|
165
|
-
y += dy * t;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
dx = px - x;
|
|
170
|
-
dy = py - y;
|
|
171
|
-
|
|
172
|
-
return dx * dx + dy * dy;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
return polylabel(polygon, 1);
|
|
176
|
-
};
|
package/types/inherits.d.ts
DELETED