comparison client/src/application/lib/geo.js @ 677:3605af94d1ee

fix: prepare profile calculation algorithm fixed The x-value of a point is determined according to its reference point * in case of the first segment, it is the first element of the line string * in case of consecutive segments it is the last point of the previous segment
author Thomas Junk <thomas.junk@intevation.de>
date Wed, 19 Sep 2018 16:37:03 +0200
parents 4c36b0e39d78
children 87ea9d267c2b
comparison
equal deleted inserted replaced
676:bd215c4325ce 677:3605af94d1ee
59 * a) extracting the minimum altitude 59 * a) extracting the minimum altitude
60 * b) extracting the maximum altitude 60 * b) extracting the maximum altitude
61 * c) calculating the total length of the given profile 61 * c) calculating the total length of the given profile
62 * d) transposes the datapoints given to the first point of the first section 62 * d) transposes the datapoints given to the first point of the first section
63 * 63 *
64 * The calculation of total equals the sum of partial distances between points
65 * The x-value of a point is determined according to its reference point
66 * in case of the first segment, it is the first element of the line string
67 * in case of consecutive segments it is the last point of the previous segment
68 *
64 * @param {object} feature 69 * @param {object} feature
65 */ 70 */
66 const transform = feature => { 71 const transform = feature => {
67 const sections = feature.geometry.coordinates; 72 const sections = feature.geometry.coordinates;
68 let firstPoint = generatePoint(sections[0][0]); 73 let firstPoint = generatePoint(sections[0][0]);
71 let minAlt = firstPoint.alt; 76 let minAlt = firstPoint.alt;
72 let maxAlt = firstPoint.alt; 77 let maxAlt = firstPoint.alt;
73 for (let section of sections) { 78 for (let section of sections) {
74 let sectionCoordinates = []; 79 let sectionCoordinates = [];
75 let previousPoint = generatePoint(section[0]); 80 let previousPoint = generatePoint(section[0]);
81 let currentPoint = null;
76 for (let coords of section) { 82 for (let coords of section) {
77 const currentPoint = generatePoint(coords); 83 currentPoint = generatePoint(coords);
78 let x = distanceBetween(firstPoint, currentPoint); 84 let x = distanceBetween(firstPoint, currentPoint);
79 let y = coords[2]; 85 let y = coords[2];
80 sectionCoordinates.push({ 86 sectionCoordinates.push({
81 x: x, 87 x: x,
82 y: y 88 y: y
85 previousPoint = currentPoint; 91 previousPoint = currentPoint;
86 if (y < minAlt) minAlt = y; 92 if (y < minAlt) minAlt = y;
87 if (y > maxAlt) maxAlt = y; 93 if (y > maxAlt) maxAlt = y;
88 } 94 }
89 coordinates.push(sectionCoordinates); 95 coordinates.push(sectionCoordinates);
96 firstPoint = currentPoint;
90 } 97 }
91 return { coordinates, totalLength, minAlt, maxAlt }; 98 return { coordinates, totalLength, minAlt, maxAlt };
92 }; 99 };
93 100
94 /** 101 /**