@openglobus/og 0.10.4 → 0.11.1

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.
Files changed (172) hide show
  1. package/css/og.css +1 -1
  2. package/package.json +11 -9
  3. package/src/og/Extent.js +274 -273
  4. package/src/og/Globe.js +11 -3
  5. package/src/og/LonLat.js +152 -146
  6. package/src/og/Popup.js +2 -1
  7. package/src/og/camera/PlanetCamera.js +112 -38
  8. package/src/og/control/EarthNavigation.js +259 -0
  9. package/src/og/control/MouseNavigation.js +68 -40
  10. package/src/og/entity/EntityCollection.js +1 -1
  11. package/src/og/entity/LabelHandler.js +366 -74
  12. package/src/og/entity/Polyline.js +3 -2
  13. package/src/og/layer/CanvasTiles.js +32 -30
  14. package/src/og/layer/KML.js +159 -0
  15. package/src/og/layer/Vector.js +5 -0
  16. package/src/og/layer/index.js +2 -1
  17. package/src/og/math/Vec2.js +448 -448
  18. package/src/og/math/Vec3.js +759 -757
  19. package/src/og/math/Vec4.js +216 -215
  20. package/src/og/quadTree/Node.js +67 -13
  21. package/src/og/renderer/RendererEvents.js +21 -16
  22. package/src/og/scene/Planet.js +25 -10
  23. package/src/og/segment/Segment.js +3 -3
  24. package/src/og/segment/SegmentLonLat.js +7 -0
  25. package/src/og/terrain/GlobusTerrain.js +4 -0
  26. package/src/og/utils/FontAtlas.js +1 -0
  27. package/src/og/utils/GeoImageCreator.js +123 -121
  28. package/src/og/utils/Loader.js +81 -80
  29. package/src/og/utils/NormalMapCreator.js +320 -318
  30. package/src/og/utils/VectorTileCreator.js +251 -250
  31. package/src/og/webgl/Framebuffer.js +265 -264
  32. package/src/og/webgl/Handler.js +1022 -1001
  33. package/src/og/webgl/Multisample.js +169 -168
  34. package/src/og/webgl/ProgramController.js +113 -112
  35. package/types/Clock.d.ts +90 -0
  36. package/types/Deferred.d.ts +6 -0
  37. package/types/Events.d.ts +73 -0
  38. package/types/Extent.d.ts +162 -0
  39. package/types/Globe.d.ts +80 -0
  40. package/types/ImageCanvas.d.ts +121 -0
  41. package/types/Lock.d.ts +12 -0
  42. package/types/LonLat.d.ts +108 -0
  43. package/types/Popup.d.ts +38 -0
  44. package/types/QueueArray.d.ts +15 -0
  45. package/types/Rectangle.d.ts +74 -0
  46. package/types/Stack.d.ts +15 -0
  47. package/types/ajax.d.ts +24 -0
  48. package/types/arial.d.ts +48 -0
  49. package/types/astro/astro.d.ts +38 -0
  50. package/types/astro/earth.d.ts +6 -0
  51. package/types/astro/jd.d.ts +254 -0
  52. package/types/bv/Box.d.ts +25 -0
  53. package/types/bv/Sphere.d.ts +32 -0
  54. package/types/bv/index.d.ts +3 -0
  55. package/types/camera/Camera.d.ts +303 -0
  56. package/types/camera/Frustum.d.ts +129 -0
  57. package/types/camera/PlanetCamera.d.ts +222 -0
  58. package/types/camera/index.d.ts +3 -0
  59. package/types/cons.d.ts +40 -0
  60. package/types/control/CompassButton.d.ts +17 -0
  61. package/types/control/Control.d.ts +101 -0
  62. package/types/control/DebugInfo.d.ts +16 -0
  63. package/types/control/EarthCoordinates.d.ts +47 -0
  64. package/types/control/GeoImageDragControl.d.ts +6 -0
  65. package/types/control/KeyboardNavigation.d.ts +22 -0
  66. package/types/control/LayerSwitcher.d.ts +23 -0
  67. package/types/control/Lighting.d.ts +16 -0
  68. package/types/control/ScaleControl.d.ts +22 -0
  69. package/types/control/ShowFps.d.ts +12 -0
  70. package/types/control/SimpleNavigation.d.ts +28 -0
  71. package/types/control/Sun.d.ts +52 -0
  72. package/types/control/ToggleWireframe.d.ts +12 -0
  73. package/types/control/ZoomControl.d.ts +28 -0
  74. package/types/control/index.d.ts +15 -0
  75. package/types/ellipsoid/Ellipsoid.d.ts +142 -0
  76. package/types/ellipsoid/index.d.ts +3 -0
  77. package/types/ellipsoid/wgs84.d.ts +5 -0
  78. package/types/entity/BaseBillboard.d.ts +208 -0
  79. package/types/entity/Billboard.d.ts +94 -0
  80. package/types/entity/BillboardHandler.d.ts +74 -0
  81. package/types/entity/Entity.d.ts +330 -0
  82. package/types/entity/EntityCollection.d.ts +303 -0
  83. package/types/entity/Geometry.d.ts +72 -0
  84. package/types/entity/GeometryHandler.d.ts +76 -0
  85. package/types/entity/Label.d.ts +194 -0
  86. package/types/entity/LabelHandler.d.ts +24 -0
  87. package/types/entity/PointCloud.d.ts +174 -0
  88. package/types/entity/PointCloudHandler.d.ts +38 -0
  89. package/types/entity/Polyline.d.ts +303 -0
  90. package/types/entity/PolylineHandler.d.ts +18 -0
  91. package/types/entity/Ray.d.ts +123 -0
  92. package/types/entity/RayHandler.d.ts +67 -0
  93. package/types/entity/ShapeHandler.d.ts +22 -0
  94. package/types/entity/Strip.d.ts +118 -0
  95. package/types/entity/StripHandler.d.ts +38 -0
  96. package/types/entity/index.d.ts +8 -0
  97. package/types/index.core.d.ts +65 -0
  98. package/types/index.d.ts +45 -0
  99. package/types/index.webgl.d.ts +7 -0
  100. package/types/inherits.d.ts +4 -0
  101. package/types/input/input.d.ts +34 -0
  102. package/types/layer/BaseGeoImage.d.ts +106 -0
  103. package/types/layer/CanvasTiles.d.ts +75 -0
  104. package/types/layer/GeoImage.d.ts +65 -0
  105. package/types/layer/GeoTexture2d.d.ts +8 -0
  106. package/types/layer/GeoVideo.d.ts +80 -0
  107. package/types/layer/KML.d.ts +58 -0
  108. package/types/layer/WMS.d.ts +66 -0
  109. package/types/layer/XYZ.d.ts +126 -0
  110. package/types/layer/index.d.ts +10 -0
  111. package/types/light/LightSource.d.ts +177 -0
  112. package/types/math/Mat3.d.ts +53 -0
  113. package/types/math/Mat4.d.ts +157 -0
  114. package/types/math/Plane.d.ts +17 -0
  115. package/types/math/Vec2.d.ts +308 -0
  116. package/types/math/Vec3.d.ts +459 -0
  117. package/types/math/Vec4.d.ts +161 -0
  118. package/types/math/coder.d.ts +42 -0
  119. package/types/math/index.d.ts +11 -0
  120. package/types/math.d.ts +261 -0
  121. package/types/mercator.d.ts +92 -0
  122. package/types/proj/EPSG3857.d.ts +5 -0
  123. package/types/proj/EPSG4326.d.ts +5 -0
  124. package/types/quadTree/quadTree.d.ts +40 -0
  125. package/types/renderer/RendererEvents.d.ts +230 -0
  126. package/types/res/images.d.ts +3 -0
  127. package/types/scene/Axes.d.ts +11 -0
  128. package/types/scene/BaseNode.d.ts +60 -0
  129. package/types/scene/Planet.d.ts +572 -0
  130. package/types/scene/RenderNode.d.ts +143 -0
  131. package/types/scene/SkyBox.d.ts +10 -0
  132. package/types/scene/index.d.ts +4 -0
  133. package/types/segment/segmentHelper.d.ts +13 -0
  134. package/types/shaders/billboard.d.ts +3 -0
  135. package/types/shaders/depth.d.ts +2 -0
  136. package/types/shaders/drawnode.d.ts +7 -0
  137. package/types/shaders/label.d.ts +4 -0
  138. package/types/shaders/pointCloud.d.ts +2 -0
  139. package/types/shaders/polyline.d.ts +3 -0
  140. package/types/shaders/ray.d.ts +2 -0
  141. package/types/shaders/screenFrame.d.ts +2 -0
  142. package/types/shaders/shape.d.ts +4 -0
  143. package/types/shaders/skybox.d.ts +2 -0
  144. package/types/shaders/toneMapping.d.ts +2 -0
  145. package/types/shapes/BaseShape.d.ts +247 -0
  146. package/types/shapes/Sphere.d.ts +41 -0
  147. package/types/terrain/BilTerrain.d.ts +8 -0
  148. package/types/terrain/EmptyTerrain.d.ts +72 -0
  149. package/types/terrain/Geoid.d.ts +26 -0
  150. package/types/terrain/GlobusTerrain.d.ts +153 -0
  151. package/types/terrain/MapboxTerrain.d.ts +8 -0
  152. package/types/terrain/index.d.ts +5 -0
  153. package/types/utils/FontAtlas.d.ts +14 -0
  154. package/types/utils/GeoImageCreator.d.ts +29 -0
  155. package/types/utils/ImagesCacheManager.d.ts +10 -0
  156. package/types/utils/Loader.d.ts +25 -0
  157. package/types/utils/NormalMapCreator.d.ts +39 -0
  158. package/types/utils/PlainSegmentWorker.d.ts +10 -0
  159. package/types/utils/TerrainWorker.d.ts +9 -0
  160. package/types/utils/TextureAtlas.d.ts +111 -0
  161. package/types/utils/VectorTileCreator.d.ts +16 -0
  162. package/types/utils/colorTable.d.ts +143 -0
  163. package/types/utils/earcut.d.ts +6 -0
  164. package/types/utils/shared.d.ts +230 -0
  165. package/types/webgl/Framebuffer.d.ts +135 -0
  166. package/types/webgl/Handler.d.ts +372 -0
  167. package/types/webgl/Multisample.d.ts +89 -0
  168. package/types/webgl/Program.d.ts +155 -0
  169. package/types/webgl/ProgramController.d.ts +84 -0
  170. package/types/webgl/callbacks.d.ts +1 -0
  171. package/types/webgl/index.d.ts +6 -0
  172. package/types/webgl/types.d.ts +2 -0
package/css/og.css CHANGED
@@ -27,7 +27,7 @@
27
27
  }
28
28
 
29
29
  .ogGrabbingPoiner {
30
- cursor: url(data:text/plain;base64,AAACAAEAICACAAcABQAwAQAAFgAAACgAAAAgAAAAQAAAAAEAAQAAAAAAAAEAAAAAAAAAAAAAAgAAAAAAAAAAAAAA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD8AAAA/AAAAfwAAAP+AAAH/gAAB/8AAAH/AAAB/wAAA/0AAANsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//////////////////////////////////////////////////////////////////////////////////////gH///4B///8Af//+AD///AA///wAH//+AB///wAf//4AH//+AD///yT/////////////////////////////8=), default !important;
30
+ cursor: grabbing !important;
31
31
  }
32
32
 
33
33
  .ogViewport {
package/package.json CHANGED
@@ -1,20 +1,22 @@
1
1
  {
2
2
  "name": "@openglobus/og",
3
- "version": "0.10.4",
3
+ "version": "0.11.1",
4
4
  "description": "[OpenGlobus](http://www.openglobus.org/) is a javascript library designed to display interactive 3d maps and planets with map tiles, imagery and vector data, markers and 3d objects. It uses the WebGL technology, open source and completely free.",
5
5
  "directories": {
6
6
  "example": "./sandbox"
7
7
  },
8
8
  "main": "./src/og/index.js",
9
9
  "style": "./css/og.css",
10
+ "types": "./types/index.d.ts",
10
11
  "scripts": {
11
- "api": ".jsdoc -t ./jsdoc -r ./src/ -c ./jsdoc/conf.json -d ./api",
12
+ "api": "jsdoc -t ./jsdoc -r ./src/ -c ./jsdoc/conf.json -d ./api",
12
13
  "serve": "ws",
13
14
  "build": "rollup -c",
14
15
  "webgl": "rollup -c --environment entry:webgl",
15
16
  "core": "rollup -c --environment entry:core",
16
- "test": "jest --coverage",
17
+ "test": "jest --env=jsdom",
17
18
  "lint": "eslint src/og",
19
+ "generate_types": "rm -rf types; tsc src/**/*.js --declaration --allowJs --emitDeclarationOnly --outDir types; exit 0",
18
20
  "prepare": "husky install"
19
21
  },
20
22
  "repository": {
@@ -42,27 +44,26 @@
42
44
  "devDependencies": {
43
45
  "@babel/preset-env": "^7.12.17",
44
46
  "@rollup/plugin-json": "^4.1.0",
45
- "enhanced-resolve": "^4.3.0",
46
47
  "eslint": "^6.8.0",
47
48
  "eslint-config-defaults": "^9.0.0",
48
49
  "eslint-config-standard": "^14.1.1",
49
50
  "eslint-plugin-import": "^2.22.1",
50
51
  "eslint-plugin-node": "^11.1.0",
51
52
  "eslint-plugin-promise": "^4.3.1",
52
- "eslint-plugin-react": "^7.21.5",
53
53
  "eslint-plugin-standard": "^4.1.0",
54
54
  "husky": "^6.0.0",
55
55
  "jaguarjs-jsdoc": "^1.1.0",
56
- "jest": "^26.6.3",
56
+ "jest": "^27.2.3",
57
57
  "jsdoc": "^3.6.7",
58
58
  "lint-staged": "^11.0.0",
59
- "local-web-server": "^3.0.7",
59
+ "local-web-server": "^5.1.1",
60
60
  "msdf-bmfont-xml": "^2.3.6",
61
61
  "postcss": "^8.3.0",
62
62
  "prettier": "^2.3.0",
63
63
  "rollup": "^1.32.1",
64
64
  "rollup-plugin-postcss": "^4.0.0",
65
- "rollup-plugin-terser": "^5.3.1"
65
+ "rollup-plugin-terser": "^5.3.1",
66
+ "typescript": "^4.4.3"
66
67
  },
67
68
  "lint-staged": {
68
69
  "*.{js,ts}": [
@@ -71,7 +72,8 @@
71
72
  },
72
73
  "files": [
73
74
  "src/**/*",
74
- "css/**/*"
75
+ "css/**/*",
76
+ "types/**/*"
75
77
  ],
76
78
  "keywords": [
77
79
  "map",
package/src/og/Extent.js CHANGED
@@ -14,305 +14,306 @@ import { LonLat } from './LonLat.js';
14
14
  * @param {og.LonLat} [sw] - South West extent corner coordiantes.
15
15
  * @param {og.LonLat} [ne] - North East extent corner coordiantes.
16
16
  */
17
- const Extent = function (sw, ne) {
17
+ export class Extent {
18
+
19
+ constructor(sw, ne) {
20
+ /**
21
+ * @public
22
+ */
23
+ this.southWest = sw || new LonLat();
24
+ /**
25
+ * @public
26
+ */
27
+ this.northEast = ne || new LonLat();
28
+ }
29
+
18
30
  /**
19
- * @public
31
+ * Whole mercator extent.
32
+ * @const
20
33
  */
21
- this.southWest = sw || new LonLat();
34
+ static get FULL_MERC() { return new Extent(LonLat.SW_MERC, LonLat.NE_MERC) };
22
35
 
23
36
  /**
24
- * @public
37
+ * Degrees extent from north mercator limit to north pole.
38
+ * @const
25
39
  */
26
- this.northEast = ne || new LonLat();
27
- };
28
-
29
- /**
30
- * Whole mercator extent.
31
- * @const
32
- */
33
- Extent.FULL_MERC = new Extent(LonLat.SW_MERC, LonLat.NE_MERC);
34
-
35
- /**
36
- * Degrees extent from north mercator limit to north pole.
37
- * @const
38
- */
39
- Extent.NORTH_POLE_DEG = new Extent(LonLat.NW_MERC_DEG, new LonLat(180.0, 90.0));
40
-
41
- /**
42
- * Degrees extent from south pole to south mercator limit.
43
- * @const
44
- */
45
- Extent.SOUTH_POLE_DEG = new Extent(new LonLat(-180.0, -90.0), LonLat.SE_MERC_DEG);
46
-
47
- /**
48
- * Creates extent instance from values in array.
49
- * @static
50
- * @param {Array.<number,number,number,number>} arr - South west and north east longitude and latidudes packed in array.
51
- * @return {og.Extent} Extent object.
52
- */
53
- Extent.createFromArray = function (arr) {
54
- return new Extent(new LonLat(arr[0], arr[1]), new LonLat(arr[2], arr[3]));
55
- };
40
+ static get NORTH_POLE_DEG() { return new Extent(LonLat.NW_MERC_DEG, new LonLat(180.0, 90.0)); }
56
41
 
57
- /**
58
- * Creates bound extent instance by coordinate array.
59
- * @static
60
- * @param {Array.<og.LonLat>} arr - Coordinate array.
61
- * @return {og.Extent} Extent object.
62
- */
63
- Extent.createByCoordinates = function (arr) {
64
- var lonmin = math.MAX, lonmax = math.MIN,
65
- latmin = math.MAX, latmax = math.MIN;
66
- for (var i = 0; i < arr.length; i++) {
67
- var vi = arr[i];
68
- if (vi.lon < lonmin) lonmin = vi.lon;
69
- if (vi.lon > lonmax) lonmax = vi.lon;
70
- if (vi.lat < latmin) latmin = vi.lat;
71
- if (vi.lat > latmax) latmax = vi.lat;
72
- }
73
- return new Extent(new LonLat(lonmin, latmin), new LonLat(lonmax, latmax));
74
- };
75
-
76
- /**
77
- * Creates bound extent instance by coordinate array.
78
- * @static
79
- * @param {Array.<Array<number,number>>} arr - Coordinate array.
80
- * @return {og.Extent} Extent object.
81
- */
82
- Extent.createByCoordinatesArr = function (arr) {
83
- var lonmin = math.MAX, lonmax = math.MIN,
84
- latmin = math.MAX, latmax = math.MIN;
85
- for (var i = 0; i < arr.length; i++) {
86
- var vi = arr[i];
87
- if (vi[0] < lonmin) lonmin = vi[0];
88
- if (vi[0] > lonmax) lonmax = vi[0];
89
- if (vi[1] < latmin) latmin = vi[1];
90
- if (vi[1] > latmax) latmax = vi[1];
91
- }
92
- return new Extent(new LonLat(lonmin, latmin), new LonLat(lonmax, latmax));
93
- };
42
+ /**
43
+ * Degrees extent from south pole to south mercator limit.
44
+ * @const
45
+ */
46
+ static get SOUTH_POLE_DEG() { return new Extent(new LonLat(-180.0, -90.0), LonLat.SE_MERC_DEG) };
94
47
 
95
- /**
96
- * Creates extent by meractor grid tile coordinates.
97
- * @static
98
- * @param {number} x -
99
- * @param {number} y -
100
- * @param {number} z -
101
- * @param {number} width -
102
- * @param {number} height -
103
- * @returns {og.Extent} -
104
- */
105
- Extent.fromTile = function (x, y, z, width, height) {
106
- width = width || mercator.POLE_DOUBLE;
107
- height = height || mercator.POLE_DOUBLE;
108
- var H = Math.pow(2, z),
109
- W = Math.pow(2, z),
110
- lnSize = width / W,
111
- ltSize = height / H;
112
-
113
- var left = -width * 0.5 + x * lnSize,
114
- top = height * 0.5 - y * ltSize,
115
- bottom = top - ltSize,
116
- right = left + lnSize;
117
-
118
- return new Extent(new LonLat(left, bottom), new LonLat(right, top));
119
- };
48
+ /**
49
+ * Creates extent instance from values in array.
50
+ * @static
51
+ * @param {Array.<number>} arr - South west and north east longitude and latidudes packed in array. (exactly 4 entries)
52
+ * @return {og.Extent} Extent object.
53
+ */
54
+ static createFromArray(arr) {
55
+ return new Extent(new LonLat(arr[0], arr[1]), new LonLat(arr[2], arr[3]));
56
+ };
120
57
 
121
- /**
122
- * Sets current bounding extent object by coordinate array.
123
- * @public
124
- * @param {Array.<og.LonLat>} arr - Coordinate array.
125
- * @return {og.Extent} Current extent.
126
- */
127
- Extent.prototype.setByCoordinates = function (arr) {
128
- var lonmin = math.MAX, lonmax = math.MIN,
129
- latmin = math.MAX, latmax = math.MIN;
130
- for (var i = 0; i < arr.length; i++) {
131
- var vi = arr[i];
132
- if (vi.lon < lonmin) lonmin = vi.lon;
133
- if (vi.lon > lonmax) lonmax = vi.lon;
134
- if (vi.lat < latmin) latmin = vi.lat;
135
- if (vi.lat > latmax) latmax = vi.lat;
136
- }
137
- this.southWest.lon = lonmin;
138
- this.southWest.lat = latmin;
139
- this.northEast.lon = lonmax;
140
- this.northEast.lat = latmax;
141
- return this;
142
- };
58
+ /**
59
+ * Creates bound extent instance by coordinate array.
60
+ * @static
61
+ * @param {Array.<og.LonLat>} arr - Coordinate array.
62
+ * @return {og.Extent} Extent object.
63
+ */
64
+ static createByCoordinates(arr) {
65
+ let lonmin = math.MAX, lonmax = math.MIN,
66
+ latmin = math.MAX, latmax = math.MIN;
67
+ for (let i = 0; i < arr.length; i++) {
68
+ const vi = arr[i];
69
+ if (vi.lon < lonmin) lonmin = vi.lon;
70
+ if (vi.lon > lonmax) lonmax = vi.lon;
71
+ if (vi.lat < latmin) latmin = vi.lat;
72
+ if (vi.lat > latmax) latmax = vi.lat;
73
+ }
74
+ return new Extent(new LonLat(lonmin, latmin), new LonLat(lonmax, latmax));
75
+ };
143
76
 
144
- /**
145
- * Determines if point inside extent.
146
- * @public
147
- * @param {LonLat} lonlat - Coordinate point.
148
- * @return {boolean} Returns true if point inside extent.
149
- */
150
- Extent.prototype.isInside = function (lonlat) {
151
- var sw = this.southWest,
152
- ne = this.northEast;
153
- return lonlat.lon >= sw.lon && lonlat.lon <= ne.lon &&
154
- lonlat.lat >= sw.lat && lonlat.lat <= ne.lat;
155
- };
77
+ /**
78
+ * Creates bound extent instance by coordinate array.
79
+ * @static
80
+ * @param {Array.<Array<number,number>>} arr - Coordinate array.
81
+ * @return {og.Extent} Extent object.
82
+ */
83
+ static createByCoordinatesArr(arr) {
84
+ let lonmin = math.MAX, lonmax = math.MIN,
85
+ latmin = math.MAX, latmax = math.MIN;
86
+ for (let i = 0; i < arr.length; i++) {
87
+ const vi = arr[i];
88
+ if (vi[0] < lonmin) lonmin = vi[0];
89
+ if (vi[0] > lonmax) lonmax = vi[0];
90
+ if (vi[1] < latmin) latmin = vi[1];
91
+ if (vi[1] > latmax) latmax = vi[1];
92
+ }
93
+ return new Extent(new LonLat(lonmin, latmin), new LonLat(lonmax, latmax));
94
+ };
156
95
 
157
- /**
158
- * Returns true if two extent overlap each other.
159
- * @public
160
- * @param {Extent} e - Another extent.
161
- * @return {boolean} -
162
- */
163
- Extent.prototype.overlaps = function (e) {
164
- var sw = this.southWest,
165
- ne = this.northEast;
166
- return sw.lon <= e.northEast.lon && ne.lon >= e.southWest.lon &&
167
- sw.lat <= e.northEast.lat && ne.lat >= e.southWest.lat;
168
- };
96
+ /**
97
+ * Creates extent by meractor grid tile coordinates.
98
+ * @static
99
+ * @param {number} x -
100
+ * @param {number} y -
101
+ * @param {number} z -
102
+ * @param {number} width -
103
+ * @param {number} height -
104
+ * @returns {og.Extent} -
105
+ */
106
+ static fromTile(x, y, z, width, height) {
107
+ width = width || mercator.POLE_DOUBLE;
108
+ height = height || mercator.POLE_DOUBLE;
109
+ const H = Math.pow(2, z),
110
+ W = Math.pow(2, z),
111
+ lnSize = width / W,
112
+ ltSize = height / H;
113
+
114
+ const left = -width * 0.5 + x * lnSize,
115
+ top = height * 0.5 - y * ltSize,
116
+ bottom = top - ltSize,
117
+ right = left + lnSize;
118
+
119
+ return new Extent(new LonLat(left, bottom), new LonLat(right, top));
120
+ };
169
121
 
170
- /**
171
- * Gets extent width.
172
- * @public
173
- * @return {number} Extent width.
174
- */
175
- Extent.prototype.getWidth = function () {
176
- return this.northEast.lon - this.southWest.lon;
177
- };
122
+ /**
123
+ * Sets current bounding extent object by coordinate array.
124
+ * @public
125
+ * @param {Array.<og.LonLat>} arr - Coordinate array.
126
+ * @return {og.Extent} Current extent.
127
+ */
128
+ setByCoordinates(arr) {
129
+ let lonmin = math.MAX, lonmax = math.MIN,
130
+ latmin = math.MAX, latmax = math.MIN;
131
+ for (let i = 0; i < arr.length; i++) {
132
+ const vi = arr[i];
133
+ if (vi.lon < lonmin) lonmin = vi.lon;
134
+ if (vi.lon > lonmax) lonmax = vi.lon;
135
+ if (vi.lat < latmin) latmin = vi.lat;
136
+ if (vi.lat > latmax) latmax = vi.lat;
137
+ }
138
+ this.southWest.lon = lonmin;
139
+ this.southWest.lat = latmin;
140
+ this.northEast.lon = lonmax;
141
+ this.northEast.lat = latmax;
142
+ return this;
143
+ };
178
144
 
179
- /**
180
- * Gets extent height.
181
- * @public
182
- * @return {number} Extent height.
183
- */
184
- Extent.prototype.getHeight = function () {
185
- return this.northEast.lat - this.southWest.lat;
186
- };
145
+ /**
146
+ * Determines if point inside extent.
147
+ * @public
148
+ * @param {LonLat} lonlat - Coordinate point.
149
+ * @return {boolean} Returns true if point inside extent.
150
+ */
151
+ isInside(lonlat) {
152
+ const sw = this.southWest,
153
+ ne = this.northEast;
154
+ return lonlat.lon >= sw.lon && lonlat.lon <= ne.lon &&
155
+ lonlat.lat >= sw.lat && lonlat.lat <= ne.lat;
156
+ };
187
157
 
188
- /**
189
- * Creates clone instance of the current extent.
190
- * @public
191
- * @return {og.Extent} Extent clone.
192
- */
193
- Extent.prototype.clone = function () {
194
- return new Extent(this.southWest.clone(), this.northEast.clone());
195
- };
158
+ /**
159
+ * Returns true if two extent overlap each other.
160
+ * @public
161
+ * @param {Extent} e - Another extent.
162
+ * @return {boolean} -
163
+ */
164
+ overlaps(e) {
165
+ const sw = this.southWest,
166
+ ne = this.northEast;
167
+ return sw.lon <= e.northEast.lon && ne.lon >= e.southWest.lon &&
168
+ sw.lat <= e.northEast.lat && ne.lat >= e.southWest.lat;
169
+ };
196
170
 
197
- /**
198
- * Gets the center coordinate of the extent.
199
- * @public
200
- * @return {number} Center coordinate.
201
- */
202
- Extent.prototype.getCenter = function () {
203
- var sw = this.southWest, ne = this.northEast;
204
- return new LonLat(sw.lon + (ne.lon - sw.lon) * 0.5, sw.lat + (ne.lat - sw.lat) * 0.5);
205
- };
171
+ /**
172
+ * Gets extent width.
173
+ * @public
174
+ * @return {number} Extent width.
175
+ */
176
+ getWidth() {
177
+ return this.northEast.lon - this.southWest.lon;
178
+ };
206
179
 
207
- /**
208
- * @public
209
- */
210
- Extent.prototype.getNorthWest = function () {
211
- return new LonLat(this.southWest.lon, this.northEast.lat);
212
- };
180
+ /**
181
+ * Gets extent height.
182
+ * @public
183
+ * @return {number} Extent height.
184
+ */
185
+ getHeight() {
186
+ return this.northEast.lat - this.southWest.lat;
187
+ };
213
188
 
214
- /**
215
- * @public
216
- */
217
- Extent.prototype.getNorthEast = function () {
218
- return new LonLat(this.northEast.lon, this.northEast.lat);
219
- };
189
+ /**
190
+ * Creates clone instance of the current extent.
191
+ * @public
192
+ * @return {og.Extent} Extent clone.
193
+ */
194
+ clone() {
195
+ return new Extent(this.southWest.clone(), this.northEast.clone());
196
+ };
220
197
 
221
- Extent.prototype.getSouthWest = function () {
222
- return new LonLat(this.southWest.lon, this.southWest.lat);
223
- };
198
+ /**
199
+ * Gets the center coordinate of the extent.
200
+ * @public
201
+ * @return {number} Center coordinate.
202
+ */
203
+ getCenter() {
204
+ const sw = this.southWest, ne = this.northEast;
205
+ return new LonLat(sw.lon + (ne.lon - sw.lon) * 0.5, sw.lat + (ne.lat - sw.lat) * 0.5);
206
+ };
224
207
 
225
- /**
226
- * @public
227
- */
228
- Extent.prototype.getSouthEast = function () {
229
- return new LonLat(this.northEast.lon, this.southWest.lat);
230
- };
208
+ /**
209
+ * @public
210
+ */
211
+ getNorthWest() {
212
+ return new LonLat(this.southWest.lon, this.northEast.lat);
213
+ };
231
214
 
232
- /**
233
- * @public
234
- */
235
- Extent.prototype.getNorth = function () {
236
- return this.northEast.lat;
237
- };
215
+ /**
216
+ * @public
217
+ */
218
+ getNorthEast() {
219
+ return new LonLat(this.northEast.lon, this.northEast.lat);
220
+ };
238
221
 
239
- Extent.prototype.getEast = function () {
240
- return this.northEast.lon;
241
- };
222
+ getSouthWest() {
223
+ return new LonLat(this.southWest.lon, this.southWest.lat);
224
+ };
242
225
 
243
- /**
244
- * @public
245
- */
246
- Extent.prototype.getWest = function () {
247
- return this.southWest.lon;
248
- };
226
+ /**
227
+ * @public
228
+ */
229
+ getSouthEast() {
230
+ return new LonLat(this.northEast.lon, this.southWest.lat);
231
+ };
249
232
 
250
- /**
251
- * @public
252
- */
253
- Extent.prototype.getSouth = function () {
254
- return this.southWest.lat;
255
- };
233
+ /**
234
+ * @public
235
+ */
236
+ getNorth() {
237
+ return this.northEast.lat;
238
+ };
256
239
 
257
- /**
258
- * Returns extents are equals.
259
- * @param {og.Extent} extent - Extent.
260
- * @returns {boolean} -
261
- */
262
- Extent.prototype.equals = function (extent) {
263
- return this.southWest.lon === extent.southWest.lon && this.southWest.lat === extent.southWest.lat &&
264
- this.northEast.lon === extent.northEast.lon && this.northEast.lat === extent.northEast.lat;
265
- };
240
+ getEast() {
241
+ return this.northEast.lon;
242
+ };
266
243
 
267
- /**
268
- * Converts extent coordinates to mercator projection coordinates.
269
- * @public
270
- * @return {og.Extent} New instance of the current extent.
271
- */
272
- Extent.prototype.forwardMercator = function () {
273
- return new Extent(this.southWest.forwardMercator(), this.northEast.forwardMercator());
274
- };
244
+ /**
245
+ * @public
246
+ */
247
+ getWest() {
248
+ return this.southWest.lon;
249
+ };
275
250
 
276
- /**
277
- * Converts extent coordinates from mercator projection to degrees.
278
- * @public
279
- * @return {og.Extent} New instance of the current extent.
280
- */
281
- Extent.prototype.inverseMercator = function () {
282
- return new Extent(this.southWest.inverseMercator(), this.northEast.inverseMercator());
283
- };
251
+ /**
252
+ * @public
253
+ */
254
+ getSouth() {
255
+ return this.southWest.lat;
256
+ };
284
257
 
285
- /**
286
- * Gets cartesian bounding bounds of the current ellipsoid.
287
- * @public
288
- * @param {og.Ellipsoid} ellipsoid - Ellipsoid.
289
- * @return {Array.<number,number,number,number,number,number>} Cartesian 3d coordinate array.
290
- */
291
- Extent.prototype.getCartesianBounds = function (ellipsoid) {
292
- var xmin = math.MAX, xmax = math.MIN, ymin = math.MAX,
293
- ymax = math.MIN, zmin = math.MAX, zmax = math.MIN;
294
-
295
- var v = [new LonLat(this.southWest.lon, this.southWest.lat),
296
- new LonLat(this.southWest.lon, this.northEast.lat),
297
- new LonLat(this.northEast.lon, this.northEast.lat),
298
- new LonLat(this.northEast.lon, this.southWest.lat)];
299
-
300
- for (var i = 0; i < v.length; i++) {
301
- var coord = ellipsoid.lonLatToCartesian(v[i]);
302
- var x = coord.x, y = coord.y, z = coord.z;
303
- if (x < xmin) xmin = x;
304
- if (x > xmax) xmax = x;
305
- if (y < ymin) ymin = y;
306
- if (y > ymax) ymax = y;
307
- if (z < zmin) zmin = z;
308
- if (z > zmax) zmax = z;
309
- }
258
+ /**
259
+ * Returns extents are equals.
260
+ * @param {og.Extent} extent - Extent.
261
+ * @returns {boolean} -
262
+ */
263
+ equals(extent) {
264
+ return this.southWest.lon === extent.southWest.lon && this.southWest.lat === extent.southWest.lat &&
265
+ this.northEast.lon === extent.northEast.lon && this.northEast.lat === extent.northEast.lat;
266
+ };
310
267
 
311
- return [xmin, ymin, zmin, xmax, ymax, zmax];
312
- };
268
+ /**
269
+ * Converts extent coordinates to mercator projection coordinates.
270
+ * @public
271
+ * @return {og.Extent} New instance of the current extent.
272
+ */
273
+ forwardMercator() {
274
+ return new Extent(this.southWest.forwardMercator(), this.northEast.forwardMercator());
275
+ };
313
276
 
314
- Extent.prototype.toString = function () {
315
- return "[" + this.southWest.lon + ", " + this.southWest.lat + ", " + this.northEast.lon + ", " + this.northEast.lat + "]";
316
- };
277
+ /**
278
+ * Converts extent coordinates from mercator projection to degrees.
279
+ * @public
280
+ * @return {og.Extent} New instance of the current extent.
281
+ */
282
+ inverseMercator() {
283
+ return new Extent(this.southWest.inverseMercator(), this.northEast.inverseMercator());
284
+ };
317
285
 
318
- export { Extent };
286
+ /**
287
+ * Gets cartesian bounding bounds of the current ellipsoid.
288
+ * @public
289
+ * @param {og.Ellipsoid} ellipsoid - Ellipsoid.
290
+ * @return {Array.<number,number,number,number,number,number>} Cartesian 3d coordinate array.
291
+ */
292
+ getCartesianBounds(ellipsoid) {
293
+ let xmin = math.MAX, xmax = math.MIN, ymin = math.MAX,
294
+ ymax = math.MIN, zmin = math.MAX, zmax = math.MIN;
295
+
296
+ const v = [new LonLat(this.southWest.lon, this.southWest.lat),
297
+ new LonLat(this.southWest.lon, this.northEast.lat),
298
+ new LonLat(this.northEast.lon, this.northEast.lat),
299
+ new LonLat(this.northEast.lon, this.southWest.lat)];
300
+
301
+ for (let i = 0; i < v.length; i++) {
302
+ const coord = ellipsoid.lonLatToCartesian(v[i]);
303
+ const x = coord.x, y = coord.y, z = coord.z;
304
+ if (x < xmin) xmin = x;
305
+ if (x > xmax) xmax = x;
306
+ if (y < ymin) ymin = y;
307
+ if (y > ymax) ymax = y;
308
+ if (z < zmin) zmin = z;
309
+ if (z > zmax) zmax = z;
310
+ }
311
+
312
+ return [xmin, ymin, zmin, xmax, ymax, zmax];
313
+ };
314
+
315
+ toString() {
316
+ return "[" + this.southWest.lon + ", " + this.southWest.lat + ", " + this.northEast.lon + ", " + this.northEast.lat + "]";
317
+ };
318
+
319
+ }