Mercurial > gemma
comparison client/tests/unit/geo/geo.spec.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 |
---|---|
328 return e.y; | 328 return e.y; |
329 }); | 329 }); |
330 o = o.concat(y); | 330 o = o.concat(y); |
331 return o; | 331 return o; |
332 }, []); | 332 }, []); |
333 const growing = values => { | |
334 let first = values[0].x; | |
335 for (let v of values) { | |
336 if (first > v.x) return false; | |
337 } | |
338 return true; | |
339 }; | |
333 const minAlt = Math.min(...alts); | 340 const minAlt = Math.min(...alts); |
334 const maxAlt = Math.max(...alts); | 341 const maxAlt = Math.max(...alts); |
335 expect(result.points.length).toBe(3); | 342 expect(result.points.length).toBe(3); |
343 expect(growing(result.points[0])).toBe(true); | |
344 expect(growing(result.points[1])).toBe(true); | |
345 expect(growing([...result.points[0], ...result.points[1]])).toBe(true); | |
346 expect(growing([...result.points[1], ...result.points[2]])).toBe(false); // because of corrupt testdata | |
336 expect(result.totalLength).toBe(160.06814078495722); | 347 expect(result.totalLength).toBe(160.06814078495722); |
337 expect(result.minAlt).toBe(minAlt); | 348 expect(result.minAlt).toBe(minAlt); |
338 expect(result.maxAlt).toBe(maxAlt); | 349 expect(result.maxAlt).toBe(maxAlt); |
339 }); | 350 }); |