Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
BIN
Binary file not shown.
Executable
+22
@@ -0,0 +1,22 @@
|
||||
Copyright (c) 2012, Vladimir Agafonkin
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are
|
||||
permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
of conditions and the following disclaimer in the documentation and/or other materials
|
||||
provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
Simplify.js is a high-performance JavaScript 2D/3D polyline simplification library by Vladimir Agafonkin, extracted from [Leaflet](http://leafletjs.com).
|
||||
|
||||
Docs and demo: http://mourner.github.io/simplify-js/
|
||||
|
||||
#### Ports
|
||||
|
||||
* Python: [omarestrella / simplify.py](https://github.com/omarestrella/simplify.py) (by Omar Estrella)
|
||||
* PHP: [AKeN / simplify-php](https://github.com/AKeN/simplify-php) (by Rotari Gheorghe)
|
||||
* Java: [ekeneijeoma / simplify-java](https://github.com/ekeneijeoma/simplify-java) (by Ekene Ijeoma)
|
||||
* Java: [hgoebl / simplify-java](https://github.com/hgoebl/simplify-java) (by Heinrich Göbl)
|
||||
* Processing: [ekeneijeoma / simplify-processing](https://github.com/ekeneijeoma/simplify-processing) (by Ekene Ijeoma)
|
||||
* AS3: [fnicollet / simplify-as3](https://github.com/fnicollet/simplify-as3) (by Fabien Nicollet)
|
||||
* Rust: [calvinmetcalf / simplify-rs](https://github.com/calvinmetcalf/simplify-rs) (by Calvin Metcalf)
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "simplify-js",
|
||||
"description": "A high-performance JavaScript 2D/3D polyline simplification library",
|
||||
"homepage": "http://mourner.github.com/simplify-js/",
|
||||
"author": "Vladimir Agafonkin",
|
||||
"keywords": [
|
||||
"math",
|
||||
"geometry",
|
||||
"polyline",
|
||||
"simplification"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/mourner/simplify-js.git"
|
||||
},
|
||||
"main": "simplify.js",
|
||||
"version": "1.1.0"
|
||||
}
|
||||
Executable
+153
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
(c) 2013, Vladimir Agafonkin
|
||||
Simplify.js, a high-performance JS polyline simplification library
|
||||
mourner.github.io/simplify-js
|
||||
*/
|
||||
|
||||
(function () { "use strict";
|
||||
|
||||
// to suit your point format, run search/replace for '.x', '.y' and '.z';
|
||||
// (configurability would draw significant performance overhead)
|
||||
|
||||
// square distance between 2 points
|
||||
function getSquareDistance(p1, p2) {
|
||||
|
||||
var dx = p1.x - p2.x,
|
||||
dy = p1.y - p2.y,
|
||||
dz = p1.z - p2.z;
|
||||
|
||||
return dx * dx + dy * dy + dz * dz;
|
||||
}
|
||||
|
||||
// square distance from a point to a segment
|
||||
function getSquareSegmentDistance(p, p1, p2) {
|
||||
|
||||
var x = p1.x,
|
||||
y = p1.y,
|
||||
z = p1.z,
|
||||
|
||||
dx = p2.x - x,
|
||||
dy = p2.y - y,
|
||||
dz = p2.z - z;
|
||||
|
||||
if (dx !== 0 || dy !== 0 || dz !== 0) {
|
||||
|
||||
var t = ((p.x - x) * dx + (p.y - y) * dy + (p.z - z) * dz) /
|
||||
(dx * dx + dy * dy + dz * dz);
|
||||
|
||||
if (t > 1) {
|
||||
x = p2.x;
|
||||
y = p2.y;
|
||||
z = p2.z;
|
||||
|
||||
} else if (t > 0) {
|
||||
x += dx * t;
|
||||
y += dy * t;
|
||||
z += dz * t;
|
||||
}
|
||||
}
|
||||
|
||||
dx = p.x - x;
|
||||
dy = p.y - y;
|
||||
dz = p.z - z;
|
||||
|
||||
return dx * dx + dy * dy + dz * dz;
|
||||
}
|
||||
// the rest of the code doesn't care for the point format
|
||||
|
||||
// basic distance-based simplification
|
||||
function simplifyRadialDistance(points, sqTolerance) {
|
||||
|
||||
var prevPoint = points[0],
|
||||
newPoints = [prevPoint],
|
||||
point;
|
||||
|
||||
for (var i = 1, len = points.length; i < len; i++) {
|
||||
point = points[i];
|
||||
|
||||
if (getSquareDistance(point, prevPoint) > sqTolerance) {
|
||||
newPoints.push(point);
|
||||
prevPoint = point;
|
||||
}
|
||||
}
|
||||
|
||||
if (prevPoint !== point) {
|
||||
newPoints.push(point);
|
||||
}
|
||||
|
||||
return newPoints;
|
||||
}
|
||||
|
||||
// simplification using optimized Douglas-Peucker algorithm with recursion elimination
|
||||
function simplifyDouglasPeucker(points, sqTolerance) {
|
||||
|
||||
var len = points.length,
|
||||
MarkerArray = typeof Uint8Array !== 'undefined' ? Uint8Array : Array,
|
||||
markers = new MarkerArray(len),
|
||||
|
||||
first = 0,
|
||||
last = len - 1,
|
||||
|
||||
stack = [],
|
||||
newPoints = [],
|
||||
|
||||
i, maxSqDist, sqDist, index;
|
||||
|
||||
markers[first] = markers[last] = 1;
|
||||
|
||||
while (last) {
|
||||
|
||||
maxSqDist = 0;
|
||||
|
||||
for (i = first + 1; i < last; i++) {
|
||||
sqDist = getSquareSegmentDistance(points[i], points[first], points[last]);
|
||||
|
||||
if (sqDist > maxSqDist) {
|
||||
index = i;
|
||||
maxSqDist = sqDist;
|
||||
}
|
||||
}
|
||||
|
||||
if (maxSqDist > sqTolerance) {
|
||||
markers[index] = 1;
|
||||
stack.push(first, index, index, last);
|
||||
}
|
||||
|
||||
last = stack.pop();
|
||||
first = stack.pop();
|
||||
}
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (markers[i]) {
|
||||
newPoints.push(points[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return newPoints;
|
||||
}
|
||||
|
||||
// both algorithms combined for awesome performance
|
||||
function simplify(points, tolerance, highestQuality) {
|
||||
|
||||
var sqTolerance = tolerance !== undefined ? tolerance * tolerance : 1;
|
||||
|
||||
points = highestQuality ? points : simplifyRadialDistance(points, sqTolerance);
|
||||
points = simplifyDouglasPeucker(points, sqTolerance);
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
// export as a Node module, an AMD module or a global browser variable
|
||||
if (typeof module !== 'undefined') {
|
||||
module.exports = simplify;
|
||||
|
||||
} else if (typeof define === 'function' && define.amd) {
|
||||
define(function() {
|
||||
return simplify;
|
||||
});
|
||||
|
||||
} else {
|
||||
window.simplify = simplify;
|
||||
}
|
||||
|
||||
})();
|
||||
Executable
+239
@@ -0,0 +1,239 @@
|
||||
// $Id$
|
||||
// $HeadURL$
|
||||
// $Author$
|
||||
// Created by Norbert Thoden, 2021-11
|
||||
|
||||
//const fs = require('fs');
|
||||
//const aa = require('./simplify.js')();
|
||||
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var pnts = [{x:100.11,y:100.15, z:1.23}, {x:500.11,y:100.14, z:1.23},{x:500.11,y:200.14, z:1.23},{x:100.1,y:200.15, z:1.23}]
|
||||
|
||||
var pointsArray = [];
|
||||
pointsArray.push(pnts);
|
||||
|
||||
|
||||
|
||||
//static const QVector<LtsUtils::QPoint3D> polyBldg1116_206_9({
|
||||
// {24.038, 11.995, 6.431},
|
||||
// {23.858, 11.995, 6.431}, // dependent / will be removed
|
||||
// {21.226, 11.995, 6.431},
|
||||
// {21.226, 11.995, 6.449}
|
||||
pointsArray.push([{x:24.038, y: 11.995, z: 6.431}, {x: 23.858, y: 11.995, z: 6.431}, {x: 21.226, y: 11.995, z: 6.431}, {x: 21.226, y: 11.995, z: 6.449}] );
|
||||
|
||||
|
||||
//static const QVector<LtsUtils::QPoint3D> polyBldg3101_306_149({
|
||||
// {10.905, 16.003, 5.480},
|
||||
// {12.277, 16.003, 5.480}, // dependent / will be removed
|
||||
// {17.839, 16.004, 5.480},
|
||||
// {17.839, 16.004, 8.040},
|
||||
// {10.905, 16.003, 8.040}
|
||||
pointsArray.push([{x: 10.905, y: 16.003, z: 5.480}, {x: 12.277, y: 16.003, z: 5.480}, {x: 17.839, y: 16.004, z: 5.480}, {x: 17.839, y: 16.004, z: 8.040}, {x: 10.905, y: 16.003, z: 8.040} ]);
|
||||
|
||||
|
||||
// static const QVector<LtsUtils::QPoint3D> polyBldg1108_103_X({
|
||||
// {-0.000, 15.979, 2.278}, // idx=0
|
||||
// {-0.000, 15.979, 0.975}, // idx=1 // problem 1: linear dependent
|
||||
// {-0.000, 15.979, 0.000}, // idx=2
|
||||
// { 0.180, 15.979, 0.000}, // idx=3
|
||||
// { 0.180, 15.979, 2.490}, // idx=4
|
||||
// {-0.000, 15.979, 2.490}, // idx=5
|
||||
// {-0.000, 15.979, 0.000} // idx=6 identical to idx=2 - problem???
|
||||
// });
|
||||
|
||||
pointsArray.push([{x: -0.000, y: 15.979,z: 2.278}, {x: -0.000, y: 15.979,z: 0.975}, {x: -0.000, y: 15.979,z: 0.000}, {x: 0.180, y: 15.979,z: 0.000}, {x: 0.180, y: 15.979,z: 2.490}, {x: -0.000, y: 15.979,z: 2.490}, {x: -0.000, y: 15.979,z: 0.000}]);
|
||||
|
||||
|
||||
|
||||
// static const QVector<LtsUtils::QPoint3D> polyBldg3101_608_387_Org({
|
||||
// {10.726, 8.619, 16.787}, // idx=0
|
||||
// {10.726, 8.716, 16.786}, // idx=1
|
||||
// { 7.291, 8.716, 16.786}, // idx=2
|
||||
// { 7.291, 8.619, 16.787}, // idx=3 // problem 1: linear dependent, wenn z gleich wäre...
|
||||
// { 7.291, 4.281, 16.717}, // idx=4
|
||||
// {10.726, 4.281, 16.717} // idx=5
|
||||
// });
|
||||
|
||||
pointsArray.push([{x: 10.726,y: 8.619,z: 16.787}, {x: 10.726,y: 8.716,z: 16.786}, {x: 7.291,y: 8.716,z: 16.786}, {x: 7.291,y: 8.619,z: 16.787}, {x: 7.291,y: 4.281,z: 16.717}, {x: 10.726,y: 4.281,z: 16.717}] );
|
||||
|
||||
// static const QVector<LtsUtils::QPoint3D> polyBldg1131_201_3({ // sollte eigentlich waagerechte Wand darstellen
|
||||
// {0.000, 5.987, 2.689}, // idx=0
|
||||
// {0.000, 5.791, 2.695}, // idx=1 // idx=1 "stört"
|
||||
// {0.000, 0.170, 2.859}, // idx=2
|
||||
// {3.098, 0.170, 2.859}, // idx=3
|
||||
// {3.098, 5.791, 2.695}, // idx=4
|
||||
// {2.928, 5.987, 2.689} // idx=5
|
||||
// });
|
||||
|
||||
pointsArray.push([{x: 0.000,y: 5.987,z: 2.689}, {x: 0.000,y: 5.791,z: 2.695}, {x: 0.000,y: 0.170,z: 2.859}, {x: 3.098,y: 0.170,z: 2.859}, {x: 3.098,y: 5.791,z: 2.695}, {x: 2.928,y: 5.987,z: 2.689}]);
|
||||
|
||||
|
||||
// 0910:
|
||||
pointsArray.push([{x:22.337, y:0.064, z:5.232}, {x:14.362, y:0.064, z:5.232}, {x:14.362, y:-12.764, z:6.797}, {x:22.337, y:-12.764, z:6.797}]);
|
||||
|
||||
// 1275
|
||||
pointsArray.push([{x:-0.105, y:1.606, z:2.240}, {x:-0.105, y:2.494, z:2.240}, {x:-0.105, y:2.494, z:2.311}, {x:-0.105, y:1.606, z:2.311}]);
|
||||
|
||||
|
||||
var myArgs = process.argv.slice(2);
|
||||
|
||||
console.log('myArgs: ', myArgs);
|
||||
|
||||
|
||||
const tolerance = myArgs[0];
|
||||
const highQuality = myArgs[1];
|
||||
console.log('tolerance: ', tolerance + " - highQuality: " + highQuality);
|
||||
|
||||
|
||||
pointsArray.forEach(points => {
|
||||
console.log("-------------------------------------------");
|
||||
console.log("input: size=" + points.length + " \n data=" + util.inspect(points, {showHidden: false, depth: 2}));
|
||||
var result = simplify(points, tolerance, highQuality);
|
||||
console.log(" result: size=" + result.length + " \n data=" + util.inspect(result, {showHidden: false, depth: 2}));
|
||||
});
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************************/
|
||||
|
||||
|
||||
|
||||
// square distance between 2 points
|
||||
function getSquareDistance(p1, p2) {
|
||||
|
||||
var dx = p1.x - p2.x,
|
||||
dy = p1.y - p2.y,
|
||||
dz = p1.z - p2.z;
|
||||
|
||||
return dx * dx + dy * dy + dz * dz;
|
||||
}
|
||||
|
||||
// square distance from a point to a segment
|
||||
function getSquareSegmentDistance(p, p1, p2) {
|
||||
|
||||
var x = p1.x,
|
||||
y = p1.y,
|
||||
z = p1.z,
|
||||
|
||||
dx = p2.x - x,
|
||||
dy = p2.y - y,
|
||||
dz = p2.z - z;
|
||||
|
||||
if (dx !== 0 || dy !== 0 || dz !== 0) {
|
||||
|
||||
var t = ((p.x - x) * dx + (p.y - y) * dy + (p.z - z) * dz) /
|
||||
(dx * dx + dy * dy + dz * dz);
|
||||
|
||||
if (t > 1) {
|
||||
x = p2.x;
|
||||
y = p2.y;
|
||||
z = p2.z;
|
||||
|
||||
} else if (t > 0) {
|
||||
x += dx * t;
|
||||
y += dy * t;
|
||||
z += dz * t;
|
||||
}
|
||||
}
|
||||
|
||||
dx = p.x - x;
|
||||
dy = p.y - y;
|
||||
dz = p.z - z;
|
||||
|
||||
return dx * dx + dy * dy + dz * dz;
|
||||
}
|
||||
// the rest of the code doesn't care for the point format
|
||||
|
||||
// basic distance-based simplification
|
||||
function simplifyRadialDistance(points, sqTolerance) {
|
||||
console.log("use simplifyRadialDis");
|
||||
|
||||
var prevPoint = points[0],
|
||||
newPoints = [prevPoint],
|
||||
point;
|
||||
|
||||
for (var i = 1, len = points.length; i < len; i++) {
|
||||
point = points[i];
|
||||
|
||||
if (getSquareDistance(point, prevPoint) > sqTolerance) {
|
||||
newPoints.push(point);
|
||||
prevPoint = point;
|
||||
}
|
||||
}
|
||||
|
||||
if (prevPoint !== point) {
|
||||
newPoints.push(point);
|
||||
}
|
||||
|
||||
console.log("simplifyRadialDis -> lenght= " + newPoints.length);
|
||||
|
||||
return newPoints;
|
||||
}
|
||||
|
||||
// simplification using optimized Douglas-Peucker algorithm with recursion elimination
|
||||
function simplifyDouglasPeucker(points, sqTolerance) {
|
||||
|
||||
var len = points.length,
|
||||
MarkerArray = typeof Uint8Array !== 'undefined' ? Uint8Array : Array,
|
||||
markers = new MarkerArray(len),
|
||||
|
||||
first = 0,
|
||||
last = len - 1,
|
||||
|
||||
stack = [],
|
||||
newPoints = [],
|
||||
|
||||
i, maxSqDist, sqDist, index;
|
||||
|
||||
markers[first] = markers[last] = 1;
|
||||
|
||||
while (last) {
|
||||
|
||||
maxSqDist = 0;
|
||||
|
||||
for (i = first + 1; i < last; i++) {
|
||||
sqDist = getSquareSegmentDistance(points[i], points[first], points[last]);
|
||||
|
||||
if (sqDist > maxSqDist) {
|
||||
index = i;
|
||||
maxSqDist = sqDist;
|
||||
}
|
||||
}
|
||||
|
||||
if (maxSqDist > sqTolerance) {
|
||||
markers[index] = 1;
|
||||
stack.push(first, index, index, last);
|
||||
}
|
||||
|
||||
last = stack.pop();
|
||||
first = stack.pop();
|
||||
}
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (markers[i]) {
|
||||
newPoints.push(points[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return newPoints;
|
||||
}
|
||||
|
||||
// both algorithms combined for awesome performance
|
||||
function simplify(points, tolerance, highestQuality) {
|
||||
|
||||
var sqTolerance = tolerance !== undefined ? tolerance * tolerance : 1;
|
||||
|
||||
points = highestQuality ? points : simplifyRadialDistance(points, sqTolerance);
|
||||
points = simplifyDouglasPeucker(points, sqTolerance);
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************************/
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user