@pirireis/webglobeplugins 0.16.4 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/Math/angle-calculation.js +1 -0
  2. package/Math/arc.js +92 -2
  3. package/Math/circle-cdf-points.js +2 -2
  4. package/Math/circle.js +2 -2
  5. package/Math/contour/quadtreecontours.js +300 -0
  6. package/Math/finite-line-2d.js +58 -0
  7. package/Math/juction/arc-plane.js +67 -12
  8. package/Math/juction/line-sphere.js +6 -6
  9. package/Math/juction/plane-plane.js +4 -6
  10. package/Math/methods.js +5 -5
  11. package/Math/templete-shapes/grid-visually-equal.js +0 -1
  12. package/Math/tessellation/earcut/adapters.js +37 -0
  13. package/Math/tessellation/hybrid-triangle-tessellation-meta.js +123 -0
  14. package/Math/tessellation/methods.js +46 -0
  15. package/Math/tessellation/shred-input.js +18 -0
  16. package/Math/tessellation/tile-merger.js +56 -0
  17. package/Math/tessellation/tiler.js +50 -0
  18. package/Math/tessellation/triangle-tessellation-meta.js +516 -0
  19. package/Math/tessellation/triangle-tessellation.js +14 -0
  20. package/Math/tessellation/zoom-catch.js +1 -0
  21. package/Math/vec3.js +26 -1
  22. package/compass-rose/compass-text-writer.js +39 -33
  23. package/constants.js +3 -0
  24. package/{util/heatwavedatamanager → heatwave}/datamanager.js +1 -1
  25. package/heatwave/{plugins/heatwaveglobeshell.js → heatwave.js} +8 -6
  26. package/heatwave/index.js +5 -3
  27. package/heatwave/{isobar/plugin.js → isobar.js} +6 -5
  28. package/{util/heatwavedatamanager → heatwave}/texture-point-sampler.js +24 -3
  29. package/package.json +7 -3
  30. package/programs/arrowfield/{object.js → arrow-field.js} +1 -1
  31. package/programs/arrowfield/logic.js +1 -1
  32. package/programs/data2legend/density-to-legend.js +24 -29
  33. package/programs/data2legend/point-to-density-texture.js +14 -17
  34. package/programs/float2legendwithratio/logic.js +2 -2
  35. package/programs/float2legendwithratio/object.js +1 -1
  36. package/programs/helpers/{blender/program.js → blender.js} +1 -1
  37. package/programs/helpers/{fadeaway/logic.js → fadeaway.js} +11 -2
  38. package/programs/index.js +20 -9
  39. package/programs/line-on-globe/circle-accurate-3d.js +12 -14
  40. package/programs/line-on-globe/circle-accurate-flat.js +0 -1
  41. package/programs/line-on-globe/degree-padding-around-circle-3d.js +13 -15
  42. package/programs/line-on-globe/lines-color-instanced-flat.js +15 -18
  43. package/programs/line-on-globe/naive-accurate-flexible.js +0 -1
  44. package/programs/picking/pickable-polygon-renderer.js +1 -1
  45. package/programs/picking/pickable-renderer.js +2 -2
  46. package/programs/point-on-globe/element-globe-surface-glow.js +2 -2
  47. package/programs/point-on-globe/element-point-glow.js +1 -1
  48. package/programs/point-on-globe/square-pixel-point.js +1 -1
  49. package/programs/polygon-on-globe/texture-dem-triangle-test-plugin-triangle.js +204 -0
  50. package/programs/polygon-on-globe/texture-dem-triangle-test-plugin.js +31 -10
  51. package/programs/polygon-on-globe/texture-dem-triangles.js +81 -12
  52. package/programs/rings/partial-ring/piece-of-pie.js +26 -29
  53. package/programs/totems/camerauniformblock.js +34 -45
  54. package/programs/two-d/pixel-padding-for-compass.js +14 -24
  55. package/programs/vectorfields/logics/drawrectangleparticles.js +1 -2
  56. package/programs/vectorfields/logics/pixelbased.js +1 -2
  57. package/programs/vectorfields/pingpongbuffermanager.js +1 -1
  58. package/range-tools-on-terrain/bearing-line/adapters.js +1 -1
  59. package/range-tools-on-terrain/circle-line-chain/adapters.js +0 -5
  60. package/range-tools-on-terrain/circle-line-chain/plugin.js +1 -1
  61. package/range-tools-on-terrain/range-ring/plugin.js +4 -6
  62. package/semiplugins/lightweight/line-plugin.js +0 -1
  63. package/semiplugins/shape-on-terrain/arc-plugin.js +5 -7
  64. package/semiplugins/shape-on-terrain/circle-plugin.js +2 -2
  65. package/semiplugins/shape-on-terrain/padding-1-degree.js +1 -2
  66. package/semiplugins/shell/bbox-renderer/index.js +2 -0
  67. package/{programs/globeshell/wiggle → semiplugins/shell/bbox-renderer}/logic.js +101 -102
  68. package/{programs/globeshell/wiggle → semiplugins/shell/bbox-renderer}/object.js +6 -7
  69. package/semiplugins/utility/container-plugin.js +94 -0
  70. package/semiplugins/utility/object-pass-container-plugin.js +80 -0
  71. package/{point-heat-map → tracks/point-heat-map}/adaptors/timetracksplugin-format-to-this.js +1 -1
  72. package/{point-heat-map → tracks/point-heat-map}/plugin-webworker.js +3 -3
  73. package/{point-heat-map → tracks/point-heat-map}/point-to-heat-map-flow.js +11 -14
  74. package/{point-tracks → tracks/point-tracks}/plugin.js +5 -5
  75. package/{timetracks → tracks/timetracks}/adaptors-line-strip.js +1 -1
  76. package/{timetracks → tracks/timetracks}/program-line-strip.js +49 -49
  77. package/{timetracks → tracks/timetracks}/programpoint-line-strip.js +16 -13
  78. package/types.js +6 -0
  79. package/util/account/bufferoffsetmanager.js +1 -1
  80. package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +9 -95
  81. package/util/gl-util/uniform-block/manager.js +4 -5
  82. package/util/gl-util/uniform-block/types.js +0 -7
  83. package/util/index.js +10 -13
  84. package/util/picking/fence.js +16 -18
  85. package/util/picking/picker-displayer.js +4 -6
  86. package/util/programs/{shapesonglobe.js → draw-from-pixel-coords.js} +4 -7
  87. package/util/programs/draw-texture-on-canvas.js +1 -1
  88. package/util/programs/texturetoglobe.js +3 -3
  89. package/util/shaderfunctions/geometrytransformations.js +6 -0
  90. package/util/webglobe/rasteroverlay.js +1 -0
  91. package/vectorfield/arrowfield/index.js +3 -0
  92. package/{arrowfield → vectorfield/arrowfield}/plugin.js +2 -2
  93. package/{waveparticles → vectorfield/waveparticles}/plugin.js +12 -12
  94. package/{wind → vectorfield/wind}/index.js +1 -1
  95. package/{wind → vectorfield/wind}/plugin.js +32 -32
  96. package/write-text/attached-text-writer.js +9 -1
  97. package/write-text/context-text3.js +0 -1
  98. package/write-text/objectarraylabels/index.js +2 -0
  99. package/Math/mesh/mapbox-delaunay.js +0 -544
  100. package/arrowfield/index.js +0 -3
  101. package/bearing-line/index.js +0 -2
  102. package/bearing-line/plugin.js +0 -444
  103. package/circle-line-chain/chain-list-map.js +0 -201
  104. package/circle-line-chain/plugin.js +0 -411
  105. package/circle-line-chain/util.js +0 -1
  106. package/compassrose/compassrose.js +0 -293
  107. package/compassrose/index.js +0 -2
  108. package/index.js +0 -12
  109. package/partialrings/buffer-manager.js +0 -75
  110. package/partialrings/index.js +0 -2
  111. package/partialrings/plugin.js +0 -128
  112. package/partialrings/program.js +0 -279
  113. package/programs/arrowfield/index.js +0 -2
  114. package/programs/globe-util/is-globe-moved.js +0 -19
  115. package/programs/globeshell/index.js +0 -2
  116. package/programs/globeshell/wiggle/index.js +0 -2
  117. package/programs/helpers/blender/index.js +0 -1
  118. package/programs/helpers/fadeaway/index.js +0 -2
  119. package/programs/helpers/fadeaway/object.js +0 -14
  120. package/programs/helpers/index.js +0 -2
  121. package/programs/rings/distancering/circleflatprogram.js +0 -116
  122. package/programs/rings/distancering/circlepaddingfreeangleprogram.js +0 -326
  123. package/programs/rings/distancering/circlepaddysharedbuffer.js +0 -368
  124. package/programs/rings/distancering/index.js +0 -6
  125. package/programs/rings/distancering/paddyflatprogram.js +0 -127
  126. package/programs/rings/distancering/paddyflatprogram2d.js +0 -129
  127. package/programs/rings/distancering/paddyflatprogram3d.js +0 -128
  128. package/programs/two-d/pixel-circle.js +0 -1
  129. package/programs/vectorfields/index.js +0 -3
  130. package/rangerings/enum.js +0 -2
  131. package/rangerings/index.js +0 -5
  132. package/rangerings/plugin.js +0 -543
  133. package/rangerings/rangeringangletext.js +0 -326
  134. package/rangerings/ring-account.js +0 -112
  135. package/timetracks/index.js +0 -1
  136. package/util/build-strategy/general-strategy.js +0 -62
  137. package/util/gl-util/uniform-block/shader.js +0 -1
  138. package/util/heatwavedatamanager/index.js +0 -2
  139. package/util/heatwavedatamanager/pointcoordsmeta.js +0 -22
  140. package/util/jshelpers/data-filler.js +0 -17
  141. package/util/jshelpers/equality.js +0 -18
  142. package/util/jshelpers/index.js +0 -2
  143. package/util/jshelpers/timefilters.js +0 -30
  144. package/util/programs/index.js +0 -1
  145. package/util/surface-line-data/arc-bboxes.js +0 -25
  146. package/util/surface-line-data/arcs-to-cuts.js +0 -50
  147. package/util/surface-line-data/cut-arc.js +0 -1
  148. package/util/surface-line-data/flow.js +0 -28
  149. package/util/surface-line-data/rbush-manager.js +0 -1
  150. package/util/surface-line-data/web-worker.js +0 -1
  151. package/write-text/context-text3old.js +0 -152
  152. package/write-text/index.js +0 -1
  153. package/write-text/writer-plugin.js +0 -8
  154. /package/{heatwave/isobar/quadtreecontours.js → Math/contour/quadtreecontours1.js} +0 -0
  155. /package/{util/surface-line-data → Math/tessellation}/types.js +0 -0
  156. /package/pin/{pin-object-array.js → pin-object-array1.js} +0 -0
  157. /package/pin/{pin-point-totem.js → pin-point-totem1.js} +0 -0
  158. /package/{circle-line-chain/init.js → programs/polygon-on-globe/partial-tesselation.js} +0 -0
  159. /package/{point-heat-map → tracks/point-heat-map}/index.js +0 -0
  160. /package/{point-tracks → tracks/point-tracks}/key-methods.js +0 -0
  161. /package/{timetracks → tracks/timetracks}/plugin-line-strip.js +0 -0
  162. /package/{arrowfield → vectorfield/arrowfield}/adaptor.js +0 -0
  163. /package/{waveparticles → vectorfield/waveparticles}/adaptor.js +0 -0
  164. /package/{waveparticles → vectorfield/waveparticles}/index.js +0 -0
  165. /package/{wind → vectorfield/wind}/imagetovectorfieldandmagnitude.js +0 -0
  166. /package/{wind → vectorfield/wind}/vectorfieldimage.js +0 -0
  167. /package/write-text/{context-text.js → context-textDELETE.js} +0 -0
  168. /package/{heatwave/isobar → write-text/objectarraylabels}/objectarraylabels.js +0 -0
@@ -1,10 +1,8 @@
1
1
  import { EPSILON } from "../constants";
2
- import { copy, create, dot, cross, lengthSquared } from "../vec3";
3
- const _normal1 = create();
4
- const _normal2 = create();
5
- export function planePlaneJuction(out, plane1, plane2) {
6
- copy(_normal1, plane1.normal);
7
- copy(_normal2, plane2.normal);
2
+ import { dot, cross, lengthSquared } from "../vec3";
3
+ export function planePlaneJunction(out, plane1, plane2) {
4
+ const _normal1 = plane1.normal;
5
+ const _normal2 = plane2.normal;
8
6
  const distance1 = plane1.distance;
9
7
  const distance2 = plane2.distance;
10
8
  const { origin, direction } = out;
package/Math/methods.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { WORLD_RADIUS_3D, WORLD_RADIUS_MERCATOR } from './constants';
2
2
  import { dot as dot3, copy as copy3 } from './vec3';
3
- export const RADIANS = Math.PI / 180;
3
+ export const RADIAN = Math.PI / 180;
4
4
  const _0vec3 = [0, 0, 0];
5
5
  const _0vec2 = [0, 0];
6
6
  export const cartesian3dToRadian = (output, cartesian) => {
@@ -47,8 +47,8 @@ export const sphericalLinearInterpolation_Cartesian3d = (output, a, b, ratio) =>
47
47
  output[2] = _0vec3[2] * height;
48
48
  };
49
49
  export const wgs84ToCartesian3d = (output, long, lat, height) => {
50
- const longRad = long * RADIANS;
51
- const latRad = lat * RADIANS;
50
+ const longRad = long * RADIAN;
51
+ const latRad = lat * RADIAN;
52
52
  const x = Math.cos(latRad) * Math.cos(longRad);
53
53
  const y = Math.cos(latRad) * Math.sin(longRad);
54
54
  const z = Math.sin(latRad);
@@ -59,8 +59,8 @@ export const wgs84ToCartesian3d = (output, long, lat, height) => {
59
59
  };
60
60
  export const wgs84ToMercator = (long, lat) => {
61
61
  return [
62
- WORLD_RADIUS_MERCATOR * long * RADIANS,
63
- WORLD_RADIUS_MERCATOR * Math.log(Math.tan(Math.PI / 4 + lat * RADIANS / 2))
62
+ WORLD_RADIUS_MERCATOR * long * RADIAN,
63
+ WORLD_RADIUS_MERCATOR * Math.log(Math.tan(Math.PI / 4 + lat * RADIAN / 2))
64
64
  ];
65
65
  };
66
66
  export const pixelXYToRadians = (pixelXY) => {
@@ -41,7 +41,6 @@ export function createfillGrid(globe, origin, startX, startY, rowSize, columnSiz
41
41
  grid[startY][i] = [long, lat];
42
42
  }
43
43
  // fill single horizontal from origin from startY to 0
44
- console.log("grid", grid);
45
44
  for (let i = startY - 1; i >= 0; i--) {
46
45
  for (let j = 0; j < rowSize; j++) {
47
46
  const [long, lat] = moveByAngle(grid[i + 1][j], angleRadians - Math.PI / 2, cellSizeY);
@@ -0,0 +1,37 @@
1
+ function geoJSONToEarcut(geojson) {
2
+ const vertices = [];
3
+ const holes = [];
4
+ const dimensions = 2; // Assuming 2D coordinates (longitude, latitude)
5
+ let holeIndex = 0;
6
+ if (geojson.type !== 'FeatureCollection') {
7
+ throw new Error('Invalid GeoJSON: Expected FeatureCollection');
8
+ }
9
+ const features = geojson.features;
10
+ function processPolygon(coordinates) {
11
+ for (let i = 0; i < coordinates.length; i++) {
12
+ if (i > 0) {
13
+ holeIndex += coordinates[i - 1].length;
14
+ holes.push(holeIndex);
15
+ }
16
+ for (const coord of coordinates[i]) {
17
+ vertices.push(coord[0], coord[1]);
18
+ }
19
+ }
20
+ }
21
+ function processMultiPolygon(coordinates) {
22
+ for (const polygon of coordinates) {
23
+ processPolygon(polygon);
24
+ }
25
+ }
26
+ for (const feature of features) {
27
+ const geometry = feature.geometry;
28
+ if (geometry.type === 'Polygon') {
29
+ processPolygon(geometry.coordinates);
30
+ }
31
+ else if (geometry.type === 'MultiPolygon') {
32
+ processMultiPolygon(geometry.coordinates);
33
+ }
34
+ }
35
+ return { vertices, holes, dimensions };
36
+ }
37
+ export { geoJSONToEarcut };
@@ -0,0 +1,123 @@
1
+ /**
2
+ * @author Toprak Ozturk
3
+ */
4
+ import { equals, fromLongLatToUnitVector, fromUnitVectorToLongLat } from "../vec3";
5
+ import { pointsOnArc } from "../juction/arc-plane";
6
+ import { junctionVerticalOrHorizontalLines } from "../finite-line-2d";
7
+ // TODO:get rid of embedded lists. always flat list
8
+ const TILE_DEM_VERTEX_COUNT = 5; // 5x5 grid for DEM
9
+ const TILE_DEM_STEPCOUNT = TILE_DEM_VERTEX_COUNT - 1; // 4 inner divisions in each dimension
10
+ var EdgeType;
11
+ (function (EdgeType) {
12
+ EdgeType[EdgeType["ARC"] = 0] = "ARC";
13
+ EdgeType[EdgeType["LINEAR"] = 1] = "LINEAR";
14
+ })(EdgeType || (EdgeType = {}));
15
+ const _tempVec2 = /*@__PURE__*/ [0, 0];
16
+ const _plane = /*@__PURE__*/ { normal: [0, 0, 0], distance: 0 };
17
+ const _resultPoints = /*@__PURE__*/ [[0, 0, 0], [0, 0, 0]];
18
+ /**
19
+ *
20
+ * @param triangleMeta
21
+ * @param zoom
22
+ * @param angle
23
+ * @param dimension false for longitude (meridian) true for latitude (parallel)
24
+ */
25
+ function getPoints(triangleMeta, angle, dimension) {
26
+ // console.log("getPoints called with angle:", angle * 180 / Math.PI, "dimension:", dimension ? 'latitude' : 'longitude');
27
+ // find which arcs are cut by plane
28
+ const radians = angle;
29
+ if (dimension) {
30
+ _plane.normal[0] = 0;
31
+ _plane.normal[1] = 0;
32
+ _plane.normal[2] = 1;
33
+ _plane.distance = Math.sin(radians);
34
+ }
35
+ else {
36
+ _plane.normal[0] = Math.sin(radians);
37
+ _plane.normal[1] = -Math.cos(radians);
38
+ _plane.normal[2] = 0;
39
+ _plane.distance = 0;
40
+ }
41
+ let result = [];
42
+ // Add debugging
43
+ let resultsFromDistinctEdges = 0;
44
+ for (let i = 0; i < 3; i++) {
45
+ const edgeType = triangleMeta.edgeTypes[i];
46
+ const edge = triangleMeta.edges[i];
47
+ const coordIndex = dimension ? 1 : 0;
48
+ const minCoord = edge.bbox.min[coordIndex];
49
+ const maxCoord = edge.bbox.max[coordIndex];
50
+ if (minCoord > angle || maxCoord < angle) {
51
+ continue; // edge is out of range
52
+ }
53
+ let count = 0;
54
+ if (edgeType === EdgeType.ARC) {
55
+ count = pointsOnArc(edge, _plane, _resultPoints);
56
+ if (count === 1) {
57
+ fromUnitVectorToLongLat(_tempVec2, _resultPoints[0]);
58
+ result.push([[..._resultPoints[0]], [..._tempVec2]]);
59
+ }
60
+ else if (count === 2) {
61
+ // throw new Error('Unexpected 2 cut points on arc, should be max 1'); // TODO DELETE this line later
62
+ fromUnitVectorToLongLat(_tempVec2, _resultPoints[0]);
63
+ result.push([[..._resultPoints[0]], [..._tempVec2]]);
64
+ fromUnitVectorToLongLat(_tempVec2, _resultPoints[1]);
65
+ result.push([[..._resultPoints[1]], [..._tempVec2]]); // TODO: this is a fix for a bug, need to investigate later
66
+ }
67
+ }
68
+ else {
69
+ // linear line
70
+ count = junctionVerticalOrHorizontalLines(_tempVec2, edge.line, angle, dimension);
71
+ if (count === 1) {
72
+ fromLongLatToUnitVector(_resultPoints[0], _tempVec2);
73
+ result.push([[..._resultPoints[0]], [..._tempVec2]]);
74
+ }
75
+ }
76
+ resultsFromDistinctEdges += 1;
77
+ }
78
+ if (resultsFromDistinctEdges === 3) {
79
+ result = filterDuplicate(result);
80
+ }
81
+ if (result.length !== 2 && result.length !== 4) {
82
+ // TODO: THERE is a case where 4 points are found.
83
+ // this happens when two arcs has limit and share space in Z dimension
84
+ console.log("ERROR");
85
+ const text = 'Angle:' + angle + ' dimension:' + (dimension ? 'latitude' : 'longitude') + "\n" +
86
+ 'Result points count:' + result.length + "\n" +
87
+ "bbox:" + triangleMeta.bbox.min[0] * 180 / Math.PI + ", " + triangleMeta.bbox.min[1] * 180 / Math.PI + ", " + triangleMeta.bbox.max[0] * 180 / Math.PI + ", " + triangleMeta.bbox.max[1] * 180 / Math.PI + "\n";
88
+ for (let res of result) {
89
+ const ll = res[1];
90
+ console.log("Point: " + ll[0] * 180 / Math.PI + ", " + ll[1] * 180 / Math.PI + "\n");
91
+ }
92
+ throw new Error(`Unexpected cut count for tile cut, got: ${result.length}, angle: ${angle * 180 / Math.PI}, dimension: ${dimension ? 'latitude' : 'longitude'} \n` + text);
93
+ }
94
+ // TODO: i want to see it delete later
95
+ if (result.length === 4) {
96
+ console.warn("Warning: 4 cut points found on triangle for angle:", angle * 180 / Math.PI, "dimension:", dimension ? 'latitude' : 'longitude', "points:", result);
97
+ }
98
+ result.sort((a, b) => {
99
+ if (dimension) {
100
+ return a[1][0] - b[1][0]; // sort by y for longitude cuts
101
+ }
102
+ else {
103
+ return a[1][1] - b[1][1]; // sort by x for latitude cuts
104
+ }
105
+ });
106
+ return result;
107
+ }
108
+ function filterDuplicate(points) {
109
+ const result = [points[0]];
110
+ let dublicate = false;
111
+ for (let i = 1; i < points.length; i++) {
112
+ for (let j = 0; j < result.length; j++) {
113
+ if (equals(points[i][0], result[j][0])) {
114
+ dublicate = true;
115
+ break;
116
+ }
117
+ }
118
+ if (!dublicate) {
119
+ result.push(points[i]);
120
+ }
121
+ }
122
+ return result;
123
+ }
@@ -0,0 +1,46 @@
1
+ import { TILE_COUNTS } from "./zoom-catch";
2
+ /**
3
+ * If the slope is not close the zero not very important but
4
+ * If a line goes along a parallel its latitude can tilt a lot
5
+ * For these cases:
6
+ * Meridian junctions should be first.
7
+ * So we have information about possible edge latitude
8
+ * Or the counting box should be calculated accourding to great circle
9
+ *
10
+ *
11
+ */
12
+ export function latToTileY(lat, zoom) {
13
+ return (1 - Math.log(Math.tan(lat) + 1 / Math.cos(lat)) / Math.PI) / 2 * TILE_COUNTS[zoom];
14
+ }
15
+ export function lonToTileX(lon, zoom) {
16
+ return (lon + Math.PI) / (2 * Math.PI) * TILE_COUNTS[zoom];
17
+ }
18
+ export function longLatToTileDecimal(lon, lat, zoom) {
19
+ return [lonToTileX(lon, zoom), latToTileY(lat, zoom)];
20
+ }
21
+ export function tileYtoLat(y, zoom) {
22
+ const n = Math.PI - 2 * Math.PI * y / TILE_COUNTS[zoom];
23
+ return (Math.PI / Math.PI * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n))));
24
+ }
25
+ export function tileXtoLon(x, zoom) {
26
+ return x / TILE_COUNTS[zoom] * (2 * Math.PI) - Math.PI;
27
+ }
28
+ export function tessellationLatDimention(zoom, lowLat, highLat) {
29
+ const lowY = latToTileY(lowLat, zoom);
30
+ const highY = latToTileY(highLat, zoom);
31
+ const latitudes = [];
32
+ if (lowY % 1 !== 0)
33
+ latitudes.push(lowLat);
34
+ for (let y = Math.ceil(lowY); y <= Math.floor(highY); y++) {
35
+ latitudes.push(tileYtoLat(y, zoom));
36
+ }
37
+ if (highY % 1 !== 0)
38
+ latitudes.push(highLat);
39
+ return latitudes;
40
+ }
41
+ export function isOnTileEdge(longLat, zoom) {
42
+ const tileX = lonToTileX(longLat[0], zoom);
43
+ const tileY = latToTileY(longLat[1], zoom);
44
+ const epsilon = 1 / TILE_COUNTS[zoom] / 200;
45
+ return (Math.abs(tileX % 1) < epsilon || Math.abs(tileY % 1) < epsilon || Math.abs(tileX % 1 - 1) < epsilon || Math.abs(tileY % 1 - 1) < epsilon);
46
+ }
@@ -0,0 +1,18 @@
1
+ import earcut from "earcut";
2
+ import { createTriangleTessellationMeta } from "./triangle-tessellation-meta";
3
+ function shredInput(vertices, holes, zoomLevel) {
4
+ const result = [];
5
+ const triangles = earcut(vertices, holes, 2);
6
+ for (let i = 0; i < triangles.length; i += 3) {
7
+ const idx1 = triangles[i] * 2;
8
+ const idx2 = triangles[i + 1] * 2;
9
+ const idx3 = triangles[i + 2] * 2;
10
+ const p1 = [vertices[idx1], vertices[idx1 + 1]];
11
+ const p2 = [vertices[idx2], vertices[idx2 + 1]];
12
+ const p3 = [vertices[idx3], vertices[idx3 + 1]];
13
+ const triangleMeta = createTriangleTessellationMeta(p1, p2, p3);
14
+ result.push(triangleMeta);
15
+ }
16
+ // cut triangles into smaller pieces based on zoom level...
17
+ return result;
18
+ }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ function _sortXY(a, b) {
3
+ if (a.y === b.y) {
4
+ return a.x - b.x;
5
+ }
6
+ return a.y - b.y;
7
+ }
8
+ function groupByZoomLevel(tiles) {
9
+ const map = new Map();
10
+ for (const tile of tiles) {
11
+ if (!map.has(tile.z)) {
12
+ map.set(tile.z, []);
13
+ }
14
+ map.get(tile.z).push(tile);
15
+ }
16
+ map.forEach((tileList, z) => {
17
+ tileList.sort(_sortXY);
18
+ });
19
+ return map;
20
+ }
21
+ function _insertDEM(sourceDEM, sourceWidth, sourceHeight, targetDEM, targetWidth, targetHeight, offsetX, offsetY) {
22
+ for (let row = 0; row < sourceHeight; row++) {
23
+ for (let col = 0; col < sourceWidth; col++) {
24
+ const sourceIndex = row * sourceWidth + col;
25
+ const targetIndex = (row + offsetY) * targetWidth + (col + offsetX);
26
+ targetDEM[targetIndex] = sourceDEM[sourceIndex];
27
+ }
28
+ }
29
+ }
30
+ function mergeTiles(tiles, demWidth, demHeight) {
31
+ let minX = Number.MAX_VALUE;
32
+ let maxX = Number.MIN_VALUE;
33
+ let minY = Number.MAX_VALUE;
34
+ let maxY = Number.MIN_VALUE;
35
+ for (let tile of tiles) {
36
+ if (tile.x < minX) {
37
+ minX = tile.x;
38
+ }
39
+ if (tile.x > maxX) {
40
+ maxX = tile.x;
41
+ }
42
+ if (tile.y < minY) {
43
+ minY = tile.y;
44
+ }
45
+ if (tile.y > maxY) {
46
+ maxY = tile.y;
47
+ }
48
+ }
49
+ const xCount = maxX - minX + 1;
50
+ const yCount = maxY - minY + 1;
51
+ const mergedDEM = new Float32Array(xCount * demWidth * yCount * demHeight).fill(0);
52
+ for (let tile of tiles) {
53
+ _insertDEM(tile.DEM, demWidth, demHeight, mergedDEM, xCount * demWidth, yCount * demHeight, (tile.x - minX) * demWidth, (tile.y - minY) * demHeight);
54
+ }
55
+ return mergedDEM;
56
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ // /**
3
+ // * Find length in x and y for a tile in given zoom level (in wgs84)
4
+ // * Find tile cuts for given line represented by two points
5
+ // * Find inner position of point in tile
6
+ // *
7
+ // */
8
+ // import { LongLat } from "../../types";
9
+ // export function tileLength(zoom: number): LongLat {
10
+ // const tileSize = 256; // in pixels
11
+ // const worldSize = tileSize * Math.pow(2, zoom);
12
+ // const latLength = 180 / worldSize;
13
+ // const lonLength = 360 / worldSize;
14
+ // return [lonLength, latLength];
15
+ // }
16
+ // // export function tileCuts(p1: LongLat, p2: LongLat, zoom: number): LongLat[] {
17
+ // // const cuts: LongLat[] = [];
18
+ // // const tileSize = 256;
19
+ // // const worldSize = tileSize * Math.pow(2, zoom);
20
+ // // const latLength = 180 / worldSize;
21
+ // // const lonLength = 360 / worldSize;
22
+ // // const x1 = (p1[0] + 180) / lonLength;
23
+ // // const y1 = (90 - p1[1]) / latLength;
24
+ // // const x2 = (p2[0] + 180) / lonLength;
25
+ // // const y2 = (90 - p2[1]) / latLength;
26
+ // // const dx = x2 - x1;
27
+ // // const dy = y2 - y1;
28
+ // // const steps = Math.max(Math.abs(dx), Math.abs(dy));
29
+ // // const xStep = dx / steps;
30
+ // // const yStep = dy / steps;
31
+ // // let x = x1;
32
+ // // let y = y1;
33
+ // // for (let i = 0; i <= steps; i++) {
34
+ // // const tileX = Math.floor(x);
35
+ // // const tileY = Math.floor(y);
36
+ // // const cutX = tileX * lonLength - 180;
37
+ // // const cutY = 90 - tileY * latLength;
38
+ // // const cut: LongLat = [cutX, cutY];
39
+ // // if (cuts.length === 0 || (cuts[cuts.length - 1][0] !== cut[0] || cuts[cuts.length - 1][1] !== cut[1])) {
40
+ // // cuts.push(cut);
41
+ // // }
42
+ // // x += xStep;
43
+ // // y += yStep;
44
+ // // }
45
+ // // return cuts;
46
+ // // }
47
+ // // function fillTriangle(p1: LongLat, p2: LongLat, p3: LongLat, zoom: number): {positions:LongLat[], indices:number[]} {
48
+ // // // this function fills the triangle triangle iteratively
49
+ // // //
50
+ // // }