@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.
- package/Math/angle-calculation.js +1 -0
- package/Math/arc.js +92 -2
- package/Math/circle-cdf-points.js +2 -2
- package/Math/circle.js +2 -2
- package/Math/contour/quadtreecontours.js +300 -0
- package/Math/finite-line-2d.js +58 -0
- package/Math/juction/arc-plane.js +67 -12
- package/Math/juction/line-sphere.js +6 -6
- package/Math/juction/plane-plane.js +4 -6
- package/Math/methods.js +5 -5
- package/Math/templete-shapes/grid-visually-equal.js +0 -1
- package/Math/tessellation/earcut/adapters.js +37 -0
- package/Math/tessellation/hybrid-triangle-tessellation-meta.js +123 -0
- package/Math/tessellation/methods.js +46 -0
- package/Math/tessellation/shred-input.js +18 -0
- package/Math/tessellation/tile-merger.js +56 -0
- package/Math/tessellation/tiler.js +50 -0
- package/Math/tessellation/triangle-tessellation-meta.js +516 -0
- package/Math/tessellation/triangle-tessellation.js +14 -0
- package/Math/tessellation/zoom-catch.js +1 -0
- package/Math/vec3.js +26 -1
- package/compass-rose/compass-text-writer.js +39 -33
- package/constants.js +3 -0
- package/{util/heatwavedatamanager → heatwave}/datamanager.js +1 -1
- package/heatwave/{plugins/heatwaveglobeshell.js → heatwave.js} +8 -6
- package/heatwave/index.js +5 -3
- package/heatwave/{isobar/plugin.js → isobar.js} +6 -5
- package/{util/heatwavedatamanager → heatwave}/texture-point-sampler.js +24 -3
- package/package.json +7 -3
- package/programs/arrowfield/{object.js → arrow-field.js} +1 -1
- package/programs/arrowfield/logic.js +1 -1
- package/programs/data2legend/density-to-legend.js +24 -29
- package/programs/data2legend/point-to-density-texture.js +14 -17
- package/programs/float2legendwithratio/logic.js +2 -2
- package/programs/float2legendwithratio/object.js +1 -1
- package/programs/helpers/{blender/program.js → blender.js} +1 -1
- package/programs/helpers/{fadeaway/logic.js → fadeaway.js} +11 -2
- package/programs/index.js +20 -9
- package/programs/line-on-globe/circle-accurate-3d.js +12 -14
- package/programs/line-on-globe/circle-accurate-flat.js +0 -1
- package/programs/line-on-globe/degree-padding-around-circle-3d.js +13 -15
- package/programs/line-on-globe/lines-color-instanced-flat.js +15 -18
- package/programs/line-on-globe/naive-accurate-flexible.js +0 -1
- package/programs/picking/pickable-polygon-renderer.js +1 -1
- package/programs/picking/pickable-renderer.js +2 -2
- package/programs/point-on-globe/element-globe-surface-glow.js +2 -2
- package/programs/point-on-globe/element-point-glow.js +1 -1
- package/programs/point-on-globe/square-pixel-point.js +1 -1
- package/programs/polygon-on-globe/texture-dem-triangle-test-plugin-triangle.js +204 -0
- package/programs/polygon-on-globe/texture-dem-triangle-test-plugin.js +31 -10
- package/programs/polygon-on-globe/texture-dem-triangles.js +81 -12
- package/programs/rings/partial-ring/piece-of-pie.js +26 -29
- package/programs/totems/camerauniformblock.js +34 -45
- package/programs/two-d/pixel-padding-for-compass.js +14 -24
- package/programs/vectorfields/logics/drawrectangleparticles.js +1 -2
- package/programs/vectorfields/logics/pixelbased.js +1 -2
- package/programs/vectorfields/pingpongbuffermanager.js +1 -1
- package/range-tools-on-terrain/bearing-line/adapters.js +1 -1
- package/range-tools-on-terrain/circle-line-chain/adapters.js +0 -5
- package/range-tools-on-terrain/circle-line-chain/plugin.js +1 -1
- package/range-tools-on-terrain/range-ring/plugin.js +4 -6
- package/semiplugins/lightweight/line-plugin.js +0 -1
- package/semiplugins/shape-on-terrain/arc-plugin.js +5 -7
- package/semiplugins/shape-on-terrain/circle-plugin.js +2 -2
- package/semiplugins/shape-on-terrain/padding-1-degree.js +1 -2
- package/semiplugins/shell/bbox-renderer/index.js +2 -0
- package/{programs/globeshell/wiggle → semiplugins/shell/bbox-renderer}/logic.js +101 -102
- package/{programs/globeshell/wiggle → semiplugins/shell/bbox-renderer}/object.js +6 -7
- package/semiplugins/utility/container-plugin.js +94 -0
- package/semiplugins/utility/object-pass-container-plugin.js +80 -0
- package/{point-heat-map → tracks/point-heat-map}/adaptors/timetracksplugin-format-to-this.js +1 -1
- package/{point-heat-map → tracks/point-heat-map}/plugin-webworker.js +3 -3
- package/{point-heat-map → tracks/point-heat-map}/point-to-heat-map-flow.js +11 -14
- package/{point-tracks → tracks/point-tracks}/plugin.js +5 -5
- package/{timetracks → tracks/timetracks}/adaptors-line-strip.js +1 -1
- package/{timetracks → tracks/timetracks}/program-line-strip.js +49 -49
- package/{timetracks → tracks/timetracks}/programpoint-line-strip.js +16 -13
- package/types.js +6 -0
- package/util/account/bufferoffsetmanager.js +1 -1
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +9 -95
- package/util/gl-util/uniform-block/manager.js +4 -5
- package/util/gl-util/uniform-block/types.js +0 -7
- package/util/index.js +10 -13
- package/util/picking/fence.js +16 -18
- package/util/picking/picker-displayer.js +4 -6
- package/util/programs/{shapesonglobe.js → draw-from-pixel-coords.js} +4 -7
- package/util/programs/draw-texture-on-canvas.js +1 -1
- package/util/programs/texturetoglobe.js +3 -3
- package/util/shaderfunctions/geometrytransformations.js +6 -0
- package/util/webglobe/rasteroverlay.js +1 -0
- package/vectorfield/arrowfield/index.js +3 -0
- package/{arrowfield → vectorfield/arrowfield}/plugin.js +2 -2
- package/{waveparticles → vectorfield/waveparticles}/plugin.js +12 -12
- package/{wind → vectorfield/wind}/index.js +1 -1
- package/{wind → vectorfield/wind}/plugin.js +32 -32
- package/write-text/attached-text-writer.js +9 -1
- package/write-text/context-text3.js +0 -1
- package/write-text/objectarraylabels/index.js +2 -0
- package/Math/mesh/mapbox-delaunay.js +0 -544
- package/arrowfield/index.js +0 -3
- package/bearing-line/index.js +0 -2
- package/bearing-line/plugin.js +0 -444
- package/circle-line-chain/chain-list-map.js +0 -201
- package/circle-line-chain/plugin.js +0 -411
- package/circle-line-chain/util.js +0 -1
- package/compassrose/compassrose.js +0 -293
- package/compassrose/index.js +0 -2
- package/index.js +0 -12
- package/partialrings/buffer-manager.js +0 -75
- package/partialrings/index.js +0 -2
- package/partialrings/plugin.js +0 -128
- package/partialrings/program.js +0 -279
- package/programs/arrowfield/index.js +0 -2
- package/programs/globe-util/is-globe-moved.js +0 -19
- package/programs/globeshell/index.js +0 -2
- package/programs/globeshell/wiggle/index.js +0 -2
- package/programs/helpers/blender/index.js +0 -1
- package/programs/helpers/fadeaway/index.js +0 -2
- package/programs/helpers/fadeaway/object.js +0 -14
- package/programs/helpers/index.js +0 -2
- package/programs/rings/distancering/circleflatprogram.js +0 -116
- package/programs/rings/distancering/circlepaddingfreeangleprogram.js +0 -326
- package/programs/rings/distancering/circlepaddysharedbuffer.js +0 -368
- package/programs/rings/distancering/index.js +0 -6
- package/programs/rings/distancering/paddyflatprogram.js +0 -127
- package/programs/rings/distancering/paddyflatprogram2d.js +0 -129
- package/programs/rings/distancering/paddyflatprogram3d.js +0 -128
- package/programs/two-d/pixel-circle.js +0 -1
- package/programs/vectorfields/index.js +0 -3
- package/rangerings/enum.js +0 -2
- package/rangerings/index.js +0 -5
- package/rangerings/plugin.js +0 -543
- package/rangerings/rangeringangletext.js +0 -326
- package/rangerings/ring-account.js +0 -112
- package/timetracks/index.js +0 -1
- package/util/build-strategy/general-strategy.js +0 -62
- package/util/gl-util/uniform-block/shader.js +0 -1
- package/util/heatwavedatamanager/index.js +0 -2
- package/util/heatwavedatamanager/pointcoordsmeta.js +0 -22
- package/util/jshelpers/data-filler.js +0 -17
- package/util/jshelpers/equality.js +0 -18
- package/util/jshelpers/index.js +0 -2
- package/util/jshelpers/timefilters.js +0 -30
- package/util/programs/index.js +0 -1
- package/util/surface-line-data/arc-bboxes.js +0 -25
- package/util/surface-line-data/arcs-to-cuts.js +0 -50
- package/util/surface-line-data/cut-arc.js +0 -1
- package/util/surface-line-data/flow.js +0 -28
- package/util/surface-line-data/rbush-manager.js +0 -1
- package/util/surface-line-data/web-worker.js +0 -1
- package/write-text/context-text3old.js +0 -152
- package/write-text/index.js +0 -1
- package/write-text/writer-plugin.js +0 -8
- /package/{heatwave/isobar/quadtreecontours.js → Math/contour/quadtreecontours1.js} +0 -0
- /package/{util/surface-line-data → Math/tessellation}/types.js +0 -0
- /package/pin/{pin-object-array.js → pin-object-array1.js} +0 -0
- /package/pin/{pin-point-totem.js → pin-point-totem1.js} +0 -0
- /package/{circle-line-chain/init.js → programs/polygon-on-globe/partial-tesselation.js} +0 -0
- /package/{point-heat-map → tracks/point-heat-map}/index.js +0 -0
- /package/{point-tracks → tracks/point-tracks}/key-methods.js +0 -0
- /package/{timetracks → tracks/timetracks}/plugin-line-strip.js +0 -0
- /package/{arrowfield → vectorfield/arrowfield}/adaptor.js +0 -0
- /package/{waveparticles → vectorfield/waveparticles}/adaptor.js +0 -0
- /package/{waveparticles → vectorfield/waveparticles}/index.js +0 -0
- /package/{wind → vectorfield/wind}/imagetovectorfieldandmagnitude.js +0 -0
- /package/{wind → vectorfield/wind}/vectorfieldimage.js +0 -0
- /package/write-text/{context-text.js → context-textDELETE.js} +0 -0
- /package/{heatwave/isobar → write-text/objectarraylabels}/objectarraylabels.js +0 -0
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { EPSILON } from "../constants";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
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
|
|
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 *
|
|
51
|
-
const latRad = lat *
|
|
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 *
|
|
63
|
-
WORLD_RADIUS_MERCATOR * Math.log(Math.tan(Math.PI / 4 + lat *
|
|
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
|
+
// // }
|