Mercurial > gemma
annotate client/src/application/lib/geo.js @ 935:430d52c2f6ef
client: move layer isolines to be drawn at the top
* Move layer isolones to be drawn last (and thus being "on top")
so that the bottleneck (position) layer will not interfere that much
with the colours. It also allows to set a white background with high
opacity on the bottleneck polygon in order to get highly visible
isolines.
author | Bernhard Reiter <bernhard@intevation.de> |
---|---|
date | Mon, 08 Oct 2018 17:20:42 +0200 |
parents | dedf252b3e01 |
children | ca628dce90dd |
rev | line source |
---|---|
666
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
1 /** |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
2 * |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
3 * Distance calculations |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
4 * JS transposition of cross.go functions |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
5 * |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
6 */ |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
7 |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
8 const EARTHRADIUS = 6378137.0; |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
9 |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
10 /** |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
11 * Converts to radiant |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
12 * @param {degree} d |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
13 */ |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
14 const deg2rad = d => { |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
15 return (d * Math.PI) / 180.0; |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
16 }; |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
17 |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
18 /** |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
19 * Calculates the difference between two points in m |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
20 * |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
21 * Points are given with {lat: $lat, lon: $lon} |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
22 * |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
23 * @param {object} P1 |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
24 * @param {object} P2 |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
25 */ |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
26 const distanceBetween = (P1, P2) => { |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
27 const dLat = deg2rad(P2.lat - P1.lat); |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
28 let dLng = Math.abs(deg2rad(P2.lon - P1.lon)); |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
29 if (dLng > Math.PI) { |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
30 dLng = 2 * Math.PI - dLng; |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
31 } |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
32 const x = dLng * Math.cos(deg2rad((P1.lat + P2.lat) / 2.0)); |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
33 return Math.sqrt(dLat * dLat + x * x) * EARTHRADIUS; |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
34 }; |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
35 |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
36 /** |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
37 * Takes a triple of [lat, long, alt] and generates |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
38 * an object with according attributes |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
39 * { |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
40 * lat: $lat, |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
41 * lon: $lon, |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
42 * alt: $alt |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
43 * } |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
44 * |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
45 * @param {array} coords |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
46 */ |
692
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
47 const Point = coords => { |
666
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
48 return { |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
49 lon: coords[0], |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
50 lat: coords[1], |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
51 alt: coords[2] |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
52 }; |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
53 }; |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
54 |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
55 /** |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
56 * Has geoJSON as its input and transforms |
692
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
57 * given coordinates into points representing |
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
58 * distance from startpoint / altitude information |
666
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
59 * |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
60 * a) extracting the minimum altitude |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
61 * b) extracting the maximum altitude |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
62 * c) calculating the total length of the given profile |
692
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
63 * d) transposes the datapoints relative to a given start point |
666
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
64 * |
677
3605af94d1ee
fix: prepare profile calculation algorithm fixed
Thomas Junk <thomas.junk@intevation.de>
parents:
666
diff
changeset
|
65 * The calculation of total equals the sum of partial distances between points |
692
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
66 * |
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
67 * The x-value of a point is equal to the total distance up to this point |
677
3605af94d1ee
fix: prepare profile calculation algorithm fixed
Thomas Junk <thomas.junk@intevation.de>
parents:
666
diff
changeset
|
68 * |
692
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
69 * The distance between the last point of the last segment and the end point is added |
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
70 * to the total |
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
71 * |
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
72 * @param {object} geoJSON, startPoint, endPoint |
666
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
73 */ |
692
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
74 const transform = ({ geoJSON, startPoint, endPoint }) => { |
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
75 const lineSegments = geoJSON.geometry.coordinates; |
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
76 let segmentPoints = []; |
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
77 let lengthPolyLine = 0; |
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
78 let referencePoint = Point(startPoint); |
767
dedf252b3e01
feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents:
692
diff
changeset
|
79 let minAlt = Math.abs(lineSegments[0][0][2]); |
dedf252b3e01
feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents:
692
diff
changeset
|
80 let maxAlt = Math.abs(lineSegments[0][0][2]); |
692
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
81 let currentPoint = null; |
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
82 for (let segment of lineSegments) { |
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
83 let points = []; |
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
84 for (let coordinateTriplet of segment) { |
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
85 currentPoint = Point(coordinateTriplet); |
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
86 lengthPolyLine += distanceBetween(referencePoint, currentPoint); |
767
dedf252b3e01
feat: fairwayprofile partially with retrieved data from the server
Thomas Junk <thomas.junk@intevation.de>
parents:
692
diff
changeset
|
87 let y = Math.abs(currentPoint.alt); |
692
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
88 points.push({ |
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
89 x: lengthPolyLine, |
666
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
90 y: y |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
91 }); |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
92 if (y < minAlt) minAlt = y; |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
93 if (y > maxAlt) maxAlt = y; |
692
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
94 referencePoint = currentPoint; |
666
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
95 } |
692
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
96 segmentPoints.push(points); |
666
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
97 } |
692
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
98 lengthPolyLine += distanceBetween(currentPoint, Point(endPoint)); |
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
99 return { segmentPoints, lengthPolyLine, minAlt, maxAlt }; |
666
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
100 }; |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
101 |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
102 /** |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
103 * Prepare profile takes geoJSON data in form of |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
104 * a MultiLineString, e.g. |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
105 * |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
106 * { |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
107 * type: "Feature", |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
108 * geometry: { |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
109 * type: "MultiLineString", |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
110 * coordinates: [ |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
111 * [ |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
112 * [16.53593398, 48.14694085, -146.52392755] |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
113 * ... |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
114 * ]] |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
115 * |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
116 * and transforms it to a structure representing the number of sections |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
117 * where data is present with according lengths and the points |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
118 * |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
119 * { |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
120 * { points: |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
121 * [ |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
122 * [ { x: 0.005798201616417183, y: -146.52419461 }, |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
123 * { x: 0, y: -146.52394016 } |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
124 * ... |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
125 * ] |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
126 * ] |
692
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
127 * lengthPolyLine: 160.06814078495722, |
666
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
128 * minAlt: -146.73122231, |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
129 * maxAlt: -145.65155866 |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
130 * } |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
131 * |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
132 * @param {object} geoJSON |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
133 */ |
692
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
134 const prepareProfile = ({ geoJSON, startPoint, endPoint }) => { |
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
135 const { segmentPoints, lengthPolyLine, minAlt, maxAlt } = transform({ |
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
136 geoJSON, |
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
137 startPoint, |
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
138 endPoint |
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
139 }); |
666
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
140 return { |
692
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
141 points: segmentPoints, |
87ea9d267c2b
refac: transformation formula for diagram adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
677
diff
changeset
|
142 lengthPolyLine: lengthPolyLine, |
666
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
143 minAlt: minAlt, |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
144 maxAlt: maxAlt |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
145 }; |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
146 }; |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
147 |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
148 export { prepareProfile }; |