Mercurial > gemma
annotate client/src/application/lib/geo.js @ 666:4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
PrepareProfile assumes data given in geoJSON format.
It extracts heigth and width information for the diagram and
transposes every coordinate given relative to the first coordinate
in the first set.
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Tue, 18 Sep 2018 13:43:24 +0200 |
parents | |
children | 3605af94d1ee |
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 */ |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
47 const generatePoint = coords => { |
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 |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
57 * given coordinates |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
58 * |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
59 * a) extracting the minimum altitude |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
60 * b) extracting the maximum altitude |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
61 * c) calculating the total length of the given profile |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
62 * d) transposes the datapoints given to the first point of the first section |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
63 * |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
64 * @param {object} feature |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
65 */ |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
66 const transform = feature => { |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
67 const sections = feature.geometry.coordinates; |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
68 let firstPoint = generatePoint(sections[0][0]); |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
69 let coordinates = []; |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
70 let totalLength = 0; |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
71 let minAlt = firstPoint.alt; |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
72 let maxAlt = firstPoint.alt; |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
73 for (let section of sections) { |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
74 let sectionCoordinates = []; |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
75 let previousPoint = generatePoint(section[0]); |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
76 for (let coords of section) { |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
77 const currentPoint = generatePoint(coords); |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
78 let x = distanceBetween(firstPoint, currentPoint); |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
79 let y = coords[2]; |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
80 sectionCoordinates.push({ |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
81 x: x, |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
82 y: y |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
83 }); |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
84 totalLength += distanceBetween(currentPoint, previousPoint); |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
85 previousPoint = currentPoint; |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
86 if (y < minAlt) minAlt = y; |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
87 if (y > maxAlt) maxAlt = y; |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
88 } |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
89 coordinates.push(sectionCoordinates); |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
90 } |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
91 return { coordinates, totalLength, minAlt, maxAlt }; |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
92 }; |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
93 |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
94 /** |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
95 * 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
|
96 * a MultiLineString, e.g. |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
97 * |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
98 * { |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
99 * type: "Feature", |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
100 * geometry: { |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
101 * type: "MultiLineString", |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
102 * coordinates: [ |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
103 * [ |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
104 * [16.53593398, 48.14694085, -146.52392755] |
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 * |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
108 * 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
|
109 * 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
|
110 * |
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 * { points: |
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 * [ { x: 0.005798201616417183, y: -146.52419461 }, |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
115 * { x: 0, y: -146.52394016 } |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
116 * ... |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
117 * ] |
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 * totalLength: 160.06814078495722, |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
120 * minAlt: -146.73122231, |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
121 * maxAlt: -145.65155866 |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
122 * } |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
123 * |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
124 * @param {object} geoJSON |
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 const prepareProfile = geoJSON => { |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
127 const { coordinates, totalLength, minAlt, maxAlt } = transform(geoJSON); |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
128 return { |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
129 points: coordinates, |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
130 totalLength: totalLength, |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
131 minAlt: minAlt, |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
132 maxAlt: maxAlt |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
133 }; |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
134 }; |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
135 |
4c36b0e39d78
feat: prepareProfile converts geoJSON to diagram data.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
136 export { prepareProfile }; |