umap-project 3.1.2__py3-none-any.whl → 3.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of umap-project might be problematic. Click here for more details.

Files changed (199) hide show
  1. umap/__init__.py +1 -1
  2. umap/locale/en/LC_MESSAGES/django.mo +0 -0
  3. umap/locale/en/LC_MESSAGES/django.po +22 -18
  4. umap/locale/fr/LC_MESSAGES/django.mo +0 -0
  5. umap/locale/fr/LC_MESSAGES/django.po +21 -17
  6. umap/management/commands/export_pictogram.py +29 -0
  7. umap/management/commands/migrate_to_S3.py +5 -1
  8. umap/management/commands/purge_old_versions.py +8 -6
  9. umap/settings/__init__.py +21 -0
  10. umap/settings/base.py +3 -0
  11. umap/static/umap/content.css +7 -2
  12. umap/static/umap/css/contextmenu.css +58 -2
  13. umap/static/umap/css/form.css +175 -45
  14. umap/static/umap/css/icon.css +97 -3
  15. umap/static/umap/css/panel.css +31 -1
  16. umap/static/umap/img/16-white.svg +21 -40
  17. umap/static/umap/img/16.svg +1 -1
  18. umap/static/umap/img/24-white.svg +9 -9
  19. umap/static/umap/img/24.svg +23 -10
  20. umap/static/umap/img/source/16-white.svg +23 -41
  21. umap/static/umap/img/source/16.svg +1 -1
  22. umap/static/umap/img/source/24-white.svg +11 -11
  23. umap/static/umap/img/source/24.svg +25 -12
  24. umap/static/umap/js/modules/browser.js +1 -1
  25. umap/static/umap/js/modules/caption.js +8 -0
  26. umap/static/umap/js/modules/data/features.js +331 -202
  27. umap/static/umap/js/modules/data/layer.js +263 -152
  28. umap/static/umap/js/modules/facets.js +2 -2
  29. umap/static/umap/js/modules/form/builder.js +11 -7
  30. umap/static/umap/js/modules/form/fields.js +66 -26
  31. umap/static/umap/js/modules/formatter.js +78 -28
  32. umap/static/umap/js/modules/importer.js +6 -1
  33. umap/static/umap/js/modules/importers/opendata.js +138 -33
  34. umap/static/umap/js/modules/importers/openrouteservice.js +140 -0
  35. umap/static/umap/js/modules/managers.js +67 -0
  36. umap/static/umap/js/modules/printer.js +107 -0
  37. umap/static/umap/js/modules/rendering/controls.js +78 -2
  38. umap/static/umap/js/modules/rendering/icon.js +116 -87
  39. umap/static/umap/js/modules/rendering/layers/classified.js +8 -7
  40. umap/static/umap/js/modules/rendering/layers/cluster.js +199 -63
  41. umap/static/umap/js/modules/rendering/map.js +6 -2
  42. umap/static/umap/js/modules/rendering/template.js +71 -1
  43. umap/static/umap/js/modules/rendering/ui.js +111 -34
  44. umap/static/umap/js/modules/rules.js +76 -23
  45. umap/static/umap/js/modules/schema.js +27 -0
  46. umap/static/umap/js/modules/share.js +19 -12
  47. umap/static/umap/js/modules/slideshow.js +1 -1
  48. umap/static/umap/js/modules/sync/updaters.js +1 -6
  49. umap/static/umap/js/modules/tableeditor.js +13 -37
  50. umap/static/umap/js/modules/templates.js +7 -6
  51. umap/static/umap/js/modules/ui/bar.js +6 -1
  52. umap/static/umap/js/modules/ui/base.js +24 -9
  53. umap/static/umap/js/modules/ui/contextmenu.js +17 -7
  54. umap/static/umap/js/modules/ui/dialog.js +7 -4
  55. umap/static/umap/js/modules/ui/panel.js +7 -0
  56. umap/static/umap/js/modules/umap.js +84 -67
  57. umap/static/umap/js/modules/utils.js +8 -7
  58. umap/static/umap/js/umap.controls.js +22 -57
  59. umap/static/umap/locale/am_ET.js +81 -9
  60. umap/static/umap/locale/am_ET.json +81 -9
  61. umap/static/umap/locale/ar.js +81 -9
  62. umap/static/umap/locale/ar.json +81 -9
  63. umap/static/umap/locale/ast.js +81 -9
  64. umap/static/umap/locale/ast.json +81 -9
  65. umap/static/umap/locale/bg.js +81 -9
  66. umap/static/umap/locale/bg.json +81 -9
  67. umap/static/umap/locale/br.js +68 -29
  68. umap/static/umap/locale/br.json +68 -29
  69. umap/static/umap/locale/ca.js +88 -16
  70. umap/static/umap/locale/ca.json +88 -16
  71. umap/static/umap/locale/cs_CZ.js +81 -9
  72. umap/static/umap/locale/cs_CZ.json +81 -9
  73. umap/static/umap/locale/da.js +48 -9
  74. umap/static/umap/locale/da.json +48 -9
  75. umap/static/umap/locale/de.js +48 -9
  76. umap/static/umap/locale/de.json +48 -9
  77. umap/static/umap/locale/el.js +58 -13
  78. umap/static/umap/locale/el.json +58 -13
  79. umap/static/umap/locale/en.js +48 -9
  80. umap/static/umap/locale/en.json +48 -9
  81. umap/static/umap/locale/en_US.json +81 -9
  82. umap/static/umap/locale/es.js +48 -9
  83. umap/static/umap/locale/es.json +48 -9
  84. umap/static/umap/locale/et.js +81 -9
  85. umap/static/umap/locale/et.json +81 -9
  86. umap/static/umap/locale/eu.js +97 -25
  87. umap/static/umap/locale/eu.json +97 -25
  88. umap/static/umap/locale/fa_IR.js +81 -9
  89. umap/static/umap/locale/fa_IR.json +81 -9
  90. umap/static/umap/locale/fi.js +81 -9
  91. umap/static/umap/locale/fi.json +81 -9
  92. umap/static/umap/locale/fr.js +48 -9
  93. umap/static/umap/locale/fr.json +48 -9
  94. umap/static/umap/locale/gl.js +81 -9
  95. umap/static/umap/locale/gl.json +81 -9
  96. umap/static/umap/locale/he.js +81 -9
  97. umap/static/umap/locale/he.json +81 -9
  98. umap/static/umap/locale/hr.js +81 -9
  99. umap/static/umap/locale/hr.json +81 -9
  100. umap/static/umap/locale/hu.js +72 -27
  101. umap/static/umap/locale/hu.json +72 -27
  102. umap/static/umap/locale/id.js +81 -9
  103. umap/static/umap/locale/id.json +81 -9
  104. umap/static/umap/locale/is.js +81 -9
  105. umap/static/umap/locale/is.json +81 -9
  106. umap/static/umap/locale/it.js +48 -9
  107. umap/static/umap/locale/it.json +48 -9
  108. umap/static/umap/locale/ja.js +81 -9
  109. umap/static/umap/locale/ja.json +81 -9
  110. umap/static/umap/locale/ko.js +81 -9
  111. umap/static/umap/locale/ko.json +81 -9
  112. umap/static/umap/locale/lt.js +81 -9
  113. umap/static/umap/locale/lt.json +81 -9
  114. umap/static/umap/locale/ms.js +81 -9
  115. umap/static/umap/locale/ms.json +81 -9
  116. umap/static/umap/locale/nl.js +48 -9
  117. umap/static/umap/locale/nl.json +48 -9
  118. umap/static/umap/locale/no.js +81 -9
  119. umap/static/umap/locale/no.json +81 -9
  120. umap/static/umap/locale/pl.js +81 -9
  121. umap/static/umap/locale/pl.json +81 -9
  122. umap/static/umap/locale/pl_PL.json +81 -9
  123. umap/static/umap/locale/pt.js +81 -9
  124. umap/static/umap/locale/pt.json +81 -9
  125. umap/static/umap/locale/pt_BR.js +91 -19
  126. umap/static/umap/locale/pt_BR.json +91 -19
  127. umap/static/umap/locale/pt_PT.js +81 -9
  128. umap/static/umap/locale/pt_PT.json +81 -9
  129. umap/static/umap/locale/ro.js +81 -9
  130. umap/static/umap/locale/ro.json +81 -9
  131. umap/static/umap/locale/ru.js +81 -9
  132. umap/static/umap/locale/ru.json +81 -9
  133. umap/static/umap/locale/sk_SK.js +81 -9
  134. umap/static/umap/locale/sk_SK.json +81 -9
  135. umap/static/umap/locale/sl.js +81 -9
  136. umap/static/umap/locale/sl.json +81 -9
  137. umap/static/umap/locale/sr.js +81 -9
  138. umap/static/umap/locale/sr.json +81 -9
  139. umap/static/umap/locale/sv.js +81 -9
  140. umap/static/umap/locale/sv.json +81 -9
  141. umap/static/umap/locale/th_TH.js +81 -9
  142. umap/static/umap/locale/th_TH.json +81 -9
  143. umap/static/umap/locale/tr.js +81 -9
  144. umap/static/umap/locale/tr.json +81 -9
  145. umap/static/umap/locale/uk_UA.js +81 -9
  146. umap/static/umap/locale/uk_UA.json +81 -9
  147. umap/static/umap/locale/vi.js +81 -9
  148. umap/static/umap/locale/vi.json +81 -9
  149. umap/static/umap/locale/vi_VN.json +81 -9
  150. umap/static/umap/locale/zh.js +81 -9
  151. umap/static/umap/locale/zh.json +81 -9
  152. umap/static/umap/locale/zh_CN.json +81 -9
  153. umap/static/umap/locale/zh_TW.Big5.json +81 -9
  154. umap/static/umap/locale/zh_TW.js +98 -26
  155. umap/static/umap/locale/zh_TW.json +98 -26
  156. umap/static/umap/map.css +325 -102
  157. umap/static/umap/vars.css +1 -0
  158. umap/static/umap/vendors/betterknown/betterknown.mjs +287 -0
  159. umap/static/umap/vendors/editable/Leaflet.Editable.js +3 -1
  160. umap/static/umap/vendors/openrouteservice/ors-js-client.js +521 -0
  161. umap/static/umap/vendors/openrouteservice/ors-js-client.js.map +1 -0
  162. umap/static/umap/vendors/simple-elevation-chart/elevation.js +63 -0
  163. umap/static/umap/vendors/simple-elevation-chart/elevation.svg +8 -0
  164. umap/static/umap/vendors/snapdom/snapdom.min.mjs +3 -0
  165. umap/storage/fs.py +3 -2
  166. umap/storage/staticfiles.py +12 -0
  167. umap/templates/base.html +4 -1
  168. umap/templates/umap/css.html +0 -4
  169. umap/templates/umap/js.html +1 -3
  170. umap/tests/base.py +9 -1
  171. umap/tests/integration/test_basics.py +3 -1
  172. umap/tests/integration/test_conditional_rules.py +79 -37
  173. umap/tests/integration/test_datalayer.py +1 -1
  174. umap/tests/integration/test_draw_polygon.py +3 -5
  175. umap/tests/integration/test_draw_polyline.py +4 -6
  176. umap/tests/integration/test_draw_route.py +178 -0
  177. umap/tests/integration/test_edit_datalayer.py +1 -1
  178. umap/tests/integration/test_edit_map.py +1 -1
  179. umap/tests/integration/test_edit_marker.py +8 -8
  180. umap/tests/integration/test_edit_polygon.py +2 -2
  181. umap/tests/integration/test_export_map.py +84 -10
  182. umap/tests/integration/test_import.py +140 -0
  183. umap/tests/integration/test_map_preview.py +1 -1
  184. umap/tests/integration/test_optimistic_merge.py +72 -12
  185. umap/tests/integration/test_share.py +1 -1
  186. umap/tests/integration/test_tableeditor.py +10 -7
  187. umap/tests/integration/test_websocket_sync.py +4 -4
  188. umap/utils.py +37 -0
  189. umap/views.py +18 -2
  190. umap_project-3.3.0.dist-info/METADATA +76 -0
  191. {umap_project-3.1.2.dist-info → umap_project-3.3.0.dist-info}/RECORD +194 -188
  192. umap/static/umap/vendors/markercluster/MarkerCluster.Default.css +0 -60
  193. umap/static/umap/vendors/markercluster/MarkerCluster.css +0 -14
  194. umap/static/umap/vendors/markercluster/leaflet.markercluster.js +0 -2
  195. umap/static/umap/vendors/markercluster/leaflet.markercluster.js.map +0 -1
  196. umap_project-3.1.2.dist-info/METADATA +0 -68
  197. {umap_project-3.1.2.dist-info → umap_project-3.3.0.dist-info}/WHEEL +0 -0
  198. {umap_project-3.1.2.dist-info → umap_project-3.3.0.dist-info}/entry_points.txt +0 -0
  199. {umap_project-3.1.2.dist-info → umap_project-3.3.0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,521 @@
1
+ const constants = {
2
+ defaultAPIVersion: "v2",
3
+ defaultHost: "https://api.openrouteservice.org",
4
+ missingAPIKeyMsg: "Please add your openrouteservice api_key..",
5
+ baseUrlConstituents: ["host", "service", "api_version", "mime_type"],
6
+ propNames: {
7
+ apiKey: "api_key",
8
+ host: "host",
9
+ service: "service",
10
+ apiVersion: "api_version",
11
+ mimeType: "mime_type",
12
+ profile: "profile",
13
+ format: "format",
14
+ timeout: "timeout"
15
+ }
16
+ };
17
+ class OrsUtil {
18
+ fillArgs(defaultArgs, requestArgs) {
19
+ requestArgs = { ...defaultArgs, ...requestArgs };
20
+ return requestArgs;
21
+ }
22
+ saveArgsToCache(args) {
23
+ return {
24
+ host: args[constants.propNames.host],
25
+ api_version: args[constants.propNames.apiVersion],
26
+ profile: args[constants.propNames.profile],
27
+ format: args[constants.propNames.format],
28
+ service: args[constants.propNames.service],
29
+ api_key: args[constants.propNames.apiKey],
30
+ mime_type: args[constants.propNames.mimeType]
31
+ };
32
+ }
33
+ prepareRequest(args) {
34
+ delete args[constants.propNames.mimeType];
35
+ delete args[constants.propNames.host];
36
+ delete args[constants.propNames.apiVersion];
37
+ delete args[constants.propNames.service];
38
+ delete args[constants.propNames.apiKey];
39
+ delete args[constants.propNames.profile];
40
+ delete args[constants.propNames.format];
41
+ delete args[constants.propNames.timeout];
42
+ return { ...args };
43
+ }
44
+ /**
45
+ * Prepare the request url based on url constituents
46
+ * @param {Object} args
47
+ * @return {string} url
48
+ */
49
+ prepareUrl(args) {
50
+ let url = args[constants.propNames.host];
51
+ let urlPathParts = [
52
+ args[constants.propNames.apiVersion],
53
+ args[constants.propNames.service],
54
+ args[constants.propNames.profile],
55
+ args[constants.propNames.format]
56
+ ];
57
+ urlPathParts = urlPathParts.join("/");
58
+ urlPathParts = urlPathParts.replace(/\/(\/)+/g, "/");
59
+ if (urlPathParts[0] === "/") {
60
+ urlPathParts = urlPathParts.slice(1);
61
+ }
62
+ let end = urlPathParts.slice(-1);
63
+ if (end[0] === "/") {
64
+ urlPathParts = urlPathParts.slice(0, -1);
65
+ }
66
+ url = url + "/" + urlPathParts;
67
+ return url;
68
+ }
69
+ }
70
+ const orsUtil$4 = new OrsUtil();
71
+ class OrsBase {
72
+ constructor(args) {
73
+ this.defaultArgs = {};
74
+ this.requestArgs = {};
75
+ this.argsCache = null;
76
+ this.customHeaders = {};
77
+ this._setRequestDefaults(args);
78
+ }
79
+ /**
80
+ * Set defaults for a request comparing with and overwriting default class arguments
81
+ * @param {Object} args - constructor input
82
+ */
83
+ _setRequestDefaults(args) {
84
+ this.defaultArgs[constants.propNames.host] = constants.defaultHost;
85
+ if (args[constants.propNames.host]) {
86
+ this.defaultArgs[constants.propNames.host] = args[constants.propNames.host];
87
+ }
88
+ if (args[constants.propNames.service]) {
89
+ this.defaultArgs[constants.propNames.service] = args[constants.propNames.service];
90
+ }
91
+ if (args[constants.propNames.timeout]) {
92
+ this.defaultArgs[constants.propNames.timeout] = args[constants.propNames.timeout];
93
+ }
94
+ if (constants.propNames.apiKey in args) {
95
+ this.defaultArgs[constants.propNames.apiKey] = args[constants.propNames.apiKey];
96
+ } else if (!args[constants.propNames.host]) {
97
+ console.error(constants.missingAPIKeyMsg);
98
+ throw new Error(constants.missingAPIKeyMsg);
99
+ }
100
+ }
101
+ checkHeaders() {
102
+ if (this.requestArgs.customHeaders) {
103
+ this.customHeaders = this.requestArgs.customHeaders;
104
+ delete this.requestArgs.customHeaders;
105
+ }
106
+ if (!("Content-type" in this.customHeaders)) {
107
+ this.customHeaders = { ...this.customHeaders, "Content-type": "application/json" };
108
+ }
109
+ }
110
+ async fetchRequest(body, controller) {
111
+ let url = orsUtil$4.prepareUrl(this.argsCache);
112
+ if (this.argsCache[constants.propNames.service] === "pois") {
113
+ url += url.indexOf("?") > -1 ? "&" : "?";
114
+ }
115
+ const authorization = { "Authorization": this.argsCache[constants.propNames.apiKey] };
116
+ return await fetch(url, {
117
+ method: "POST",
118
+ body: JSON.stringify(body),
119
+ headers: { ...authorization, ...this.customHeaders },
120
+ signal: controller.signal
121
+ });
122
+ }
123
+ async createRequest(body) {
124
+ var _a;
125
+ const controller = new AbortController();
126
+ const timeout = setTimeout(() => controller.abort(), this.defaultArgs[constants.propNames.timeout] || 5e3);
127
+ try {
128
+ const orsResponse = await this.fetchRequest(body, controller);
129
+ if (!orsResponse.ok) {
130
+ const error = new Error(orsResponse.statusText);
131
+ error.status = orsResponse.status;
132
+ error.response = orsResponse;
133
+ throw error;
134
+ }
135
+ return ((_a = this.argsCache) == null ? void 0 : _a.format) === "gpx" ? await orsResponse.text() : await orsResponse.json();
136
+ } finally {
137
+ clearTimeout(timeout);
138
+ }
139
+ }
140
+ // is overridden in Directions and Isochrones class
141
+ getBody() {
142
+ return this.httpArgs;
143
+ }
144
+ async calculate(reqArgs) {
145
+ this.requestArgs = reqArgs;
146
+ this.checkHeaders();
147
+ this.requestArgs = orsUtil$4.fillArgs(this.defaultArgs, this.requestArgs);
148
+ this.argsCache = orsUtil$4.saveArgsToCache(this.requestArgs);
149
+ this.httpArgs = orsUtil$4.prepareRequest(this.requestArgs);
150
+ const postBody = this.getBody(this.httpArgs);
151
+ return await this.createRequest(postBody);
152
+ }
153
+ }
154
+ const orsUtil$3 = new OrsUtil();
155
+ class OrsGeocode extends OrsBase {
156
+ constructor(args) {
157
+ super(args);
158
+ this.lookupParameter = {
159
+ api_key: function(key, val) {
160
+ return key + "=" + val;
161
+ },
162
+ text: function(key, val) {
163
+ return "&" + key + "=" + encodeURIComponent(val);
164
+ },
165
+ focus_point: function(key, val) {
166
+ let urlParams = "";
167
+ urlParams += "&focus.point.lon=" + val[1];
168
+ urlParams += "&focus.point.lat=" + val[0];
169
+ return urlParams;
170
+ },
171
+ boundary_bbox: function(key, val) {
172
+ let urlParams = "";
173
+ urlParams += "&boundary.rect.min_lon=" + val[0][1];
174
+ urlParams += "&boundary.rect.min_lat=" + val[0][0];
175
+ urlParams += "&boundary.rect.max_lon=" + val[1][1];
176
+ urlParams += "&boundary.rect.max_lat=" + val[1][0];
177
+ return urlParams;
178
+ },
179
+ point: function(key, val) {
180
+ if (val && Array.isArray(val.lat_lng)) {
181
+ let urlParams = "";
182
+ urlParams += "&point.lon=" + val.lat_lng[1];
183
+ urlParams += "&point.lat=" + val.lat_lng[0];
184
+ return urlParams;
185
+ }
186
+ },
187
+ boundary_circle: function(key, val) {
188
+ let urlParams = "";
189
+ urlParams += "&boundary.circle.lon=" + val.lat_lng[1];
190
+ urlParams += "&boundary.circle.lat=" + val.lat_lng[0];
191
+ urlParams += "&boundary.circle.radius=" + val.radius;
192
+ return urlParams;
193
+ },
194
+ sources: function(key, val) {
195
+ let urlParams = "&sources=";
196
+ if (val) {
197
+ for (const key2 in val) {
198
+ if (Number(key2) > 0) {
199
+ urlParams += ",";
200
+ }
201
+ urlParams += val[key2];
202
+ }
203
+ return urlParams;
204
+ }
205
+ },
206
+ layers: function(key, val) {
207
+ let urlParams = "&layers=";
208
+ let counter = 0;
209
+ for (key in val) {
210
+ if (counter > 0) {
211
+ urlParams += ",";
212
+ }
213
+ urlParams += val[key];
214
+ counter++;
215
+ }
216
+ return urlParams;
217
+ },
218
+ boundary_country: function(key, val) {
219
+ return "&boundary.country=" + val;
220
+ },
221
+ size: function(key, val) {
222
+ return "&" + key + "=" + val;
223
+ },
224
+ address: function(key, val) {
225
+ return "&" + key + "=" + val;
226
+ },
227
+ neighbourhood: function(key, val) {
228
+ return "&" + key + "=" + val;
229
+ },
230
+ borough: function(key, val) {
231
+ return "&" + key + "=" + val;
232
+ },
233
+ locality: function(key, val) {
234
+ return "&" + key + "=" + val;
235
+ },
236
+ county: function(key, val) {
237
+ return "&" + key + "=" + val;
238
+ },
239
+ region: function(key, val) {
240
+ return "&" + key + "=" + val;
241
+ },
242
+ postalcode: function(key, val) {
243
+ return "&" + key + "=" + val;
244
+ },
245
+ country: function(key, val) {
246
+ return "&" + key + "=" + val;
247
+ }
248
+ };
249
+ }
250
+ getParametersAsQueryString(args) {
251
+ let queryString = "";
252
+ for (const key in args) {
253
+ const val = args[key];
254
+ if (constants.baseUrlConstituents.indexOf(key) <= -1) {
255
+ queryString += this.lookupParameter[key](key, val);
256
+ }
257
+ }
258
+ return queryString;
259
+ }
260
+ async fetchGetRequest(controller) {
261
+ let url = orsUtil$3.prepareUrl(this.requestArgs);
262
+ url += "?" + this.getParametersAsQueryString(this.requestArgs);
263
+ return await fetch(url, {
264
+ method: "GET",
265
+ headers: this.customHeaders,
266
+ signal: controller.signal
267
+ });
268
+ }
269
+ async geocodePromise() {
270
+ const controller = new AbortController();
271
+ const timeout = setTimeout(() => controller.abort(), this.defaultArgs[constants.propNames.timeout] || 5e3);
272
+ try {
273
+ const orsResponse = await this.fetchGetRequest(controller);
274
+ if (!orsResponse.ok) {
275
+ const error = new Error(orsResponse.statusText);
276
+ error.status = orsResponse.status;
277
+ error.response = orsResponse;
278
+ throw error;
279
+ }
280
+ return await orsResponse.json() || orsResponse.text();
281
+ } finally {
282
+ clearTimeout(timeout);
283
+ }
284
+ }
285
+ async geocode(reqArgs) {
286
+ this.requestArgs = reqArgs;
287
+ this.checkHeaders();
288
+ if (!this.defaultArgs[constants.propNames.service] && !this.requestArgs[constants.propNames.service]) {
289
+ this.requestArgs.service = "geocode/search";
290
+ }
291
+ this.requestArgs = orsUtil$3.fillArgs(this.defaultArgs, this.requestArgs);
292
+ return await this.geocodePromise();
293
+ }
294
+ async reverseGeocode(reqArgs) {
295
+ this.requestArgs = reqArgs;
296
+ this.checkHeaders();
297
+ if (!this.defaultArgs[constants.propNames.service] && !this.requestArgs[constants.propNames.service]) {
298
+ this.requestArgs.service = "geocode/reverse";
299
+ }
300
+ this.requestArgs = orsUtil$3.fillArgs(this.defaultArgs, this.requestArgs);
301
+ return await this.geocodePromise();
302
+ }
303
+ async structuredGeocode(reqArgs) {
304
+ this.requestArgs = reqArgs;
305
+ this.checkHeaders();
306
+ if (!this.defaultArgs[constants.propNames.service] && !this.requestArgs[constants.propNames.service]) {
307
+ this.requestArgs.service = "geocode/search/structured";
308
+ }
309
+ this.requestArgs = orsUtil$3.fillArgs(this.defaultArgs, this.requestArgs);
310
+ return await this.geocodePromise();
311
+ }
312
+ }
313
+ class OrsIsochrones extends OrsBase {
314
+ constructor(args) {
315
+ super(args);
316
+ if (!this.defaultArgs[constants.propNames.service] && !this.requestArgs[constants.propNames.service]) {
317
+ this.defaultArgs.service = "isochrones";
318
+ }
319
+ if (!args[constants.propNames.apiVersion]) {
320
+ this.defaultArgs.api_version = constants.defaultAPIVersion;
321
+ }
322
+ }
323
+ getBody(args) {
324
+ const options = {};
325
+ if (args.restrictions) {
326
+ options.profile_params = {
327
+ restrictions: {
328
+ ...args.restrictions
329
+ }
330
+ };
331
+ delete args.restrictions;
332
+ }
333
+ if (args.avoidables) {
334
+ options.avoid_features = [...args.avoidables];
335
+ delete args.avoidables;
336
+ }
337
+ if (args.avoid_polygons) {
338
+ options.avoid_polygons = {
339
+ ...args.avoid_polygons
340
+ };
341
+ delete args.avoid_polygons;
342
+ }
343
+ if (Object.keys(options).length > 0) {
344
+ return {
345
+ ...args,
346
+ options
347
+ };
348
+ } else {
349
+ return {
350
+ ...args
351
+ };
352
+ }
353
+ }
354
+ }
355
+ class OrsMatrix extends OrsBase {
356
+ constructor(args) {
357
+ super(args);
358
+ if (!this.defaultArgs[constants.propNames.service] && !this.requestArgs[constants.propNames.service]) {
359
+ this.defaultArgs[constants.propNames.service] = "matrix";
360
+ }
361
+ if (!args[constants.propNames.apiVersion]) {
362
+ this.defaultArgs.api_version = constants.defaultAPIVersion;
363
+ }
364
+ }
365
+ }
366
+ class OrsDirections extends OrsBase {
367
+ constructor(args) {
368
+ super(args);
369
+ if (!this.defaultArgs[constants.propNames.service]) {
370
+ this.defaultArgs[constants.propNames.service] = "directions";
371
+ }
372
+ if (!args[constants.propNames.apiVersion]) {
373
+ this.defaultArgs.api_version = constants.defaultAPIVersion;
374
+ }
375
+ }
376
+ getBody(args) {
377
+ if (args.options && typeof args.options !== "object") {
378
+ args.options = JSON.parse(args.options);
379
+ }
380
+ if (args.restrictions) {
381
+ args.options = args.options || {};
382
+ args.options.profile_params = {
383
+ restrictions: { ...args.restrictions }
384
+ };
385
+ delete args.restrictions;
386
+ }
387
+ if (args.avoidables) {
388
+ args.options = args.options || {};
389
+ args.options.avoid_features = [...args.avoidables];
390
+ delete args.avoidables;
391
+ }
392
+ return args;
393
+ }
394
+ }
395
+ const orsUtil$2 = new OrsUtil();
396
+ class OrsPois extends OrsBase {
397
+ constructor(args) {
398
+ super(args);
399
+ if (!this.defaultArgs[constants.propNames.service]) {
400
+ this.defaultArgs[constants.propNames.service] = "pois";
401
+ }
402
+ }
403
+ generatePayload(args) {
404
+ const payload = {};
405
+ for (const key in args) {
406
+ if (!(constants.baseUrlConstituents.indexOf(key) > -1 || key === constants.propNames.apiKey || key === constants.propNames.timeout)) {
407
+ payload[key] = args[key];
408
+ }
409
+ }
410
+ return payload;
411
+ }
412
+ async poisPromise() {
413
+ this.requestArgs.request = this.requestArgs.request || "pois";
414
+ this.argsCache = orsUtil$2.saveArgsToCache(this.requestArgs);
415
+ if (this.requestArgs[constants.propNames.service]) {
416
+ delete this.requestArgs[constants.propNames.service];
417
+ }
418
+ const payload = this.generatePayload(this.requestArgs);
419
+ return await this.createRequest(payload);
420
+ }
421
+ async pois(reqArgs) {
422
+ this.requestArgs = reqArgs;
423
+ this.checkHeaders();
424
+ this.requestArgs = orsUtil$2.fillArgs(this.defaultArgs, this.requestArgs);
425
+ return await this.poisPromise();
426
+ }
427
+ }
428
+ const orsUtil$1 = new OrsUtil();
429
+ class OrsElevation extends OrsBase {
430
+ generatePayload(args) {
431
+ const payload = {};
432
+ for (const key in args) {
433
+ if (constants.baseUrlConstituents.indexOf(key) <= -1) {
434
+ payload[key] = args[key];
435
+ }
436
+ }
437
+ return payload;
438
+ }
439
+ async elevationPromise() {
440
+ this.argsCache = orsUtil$1.saveArgsToCache(this.requestArgs);
441
+ const payload = this.generatePayload(this.requestArgs);
442
+ return await this.createRequest(payload);
443
+ }
444
+ async lineElevation(reqArgs) {
445
+ this.requestArgs = reqArgs;
446
+ this.checkHeaders();
447
+ if (!this.defaultArgs[constants.propNames.service] && !this.requestArgs[constants.propNames.service]) {
448
+ this.requestArgs[constants.propNames.service] = "elevation/line";
449
+ }
450
+ this.requestArgs = orsUtil$1.fillArgs(this.defaultArgs, this.requestArgs);
451
+ return await this.elevationPromise();
452
+ }
453
+ async pointElevation(reqArgs) {
454
+ this.requestArgs = reqArgs;
455
+ this.checkHeaders();
456
+ if (!this.defaultArgs[constants.propNames.service] && !this.requestArgs[constants.propNames.service]) {
457
+ this.requestArgs[constants.propNames.service] = "elevation/point";
458
+ }
459
+ this.requestArgs = orsUtil$1.fillArgs(this.defaultArgs, this.requestArgs);
460
+ return await this.elevationPromise();
461
+ }
462
+ }
463
+ const orsUtil = new OrsUtil();
464
+ class OrsOptimization extends OrsBase {
465
+ generatePayload(args) {
466
+ let payload = {};
467
+ for (const key in args) {
468
+ if (constants.baseUrlConstituents.indexOf(key) <= -1) {
469
+ payload[key] = args[key];
470
+ }
471
+ }
472
+ return payload;
473
+ }
474
+ async optimizationPromise() {
475
+ this.argsCache = orsUtil.saveArgsToCache(this.requestArgs);
476
+ const payload = this.generatePayload(this.requestArgs);
477
+ return await this.createRequest(payload);
478
+ }
479
+ async optimize(reqArgs) {
480
+ this.requestArgs = reqArgs;
481
+ this.checkHeaders();
482
+ if (!this.defaultArgs[constants.propNames.service] && !reqArgs[constants.propNames.service]) {
483
+ reqArgs[constants.propNames.service] = "optimization";
484
+ }
485
+ this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs);
486
+ return await this.optimizationPromise();
487
+ }
488
+ }
489
+ class OrsSnap extends OrsBase {
490
+ constructor(args) {
491
+ super(args);
492
+ if (!this.defaultArgs[constants.propNames.service] && !this.requestArgs[constants.propNames.service]) {
493
+ this.defaultArgs[constants.propNames.service] = "snap";
494
+ }
495
+ if (!args[constants.propNames.apiVersion]) {
496
+ this.defaultArgs.api_version = constants.defaultAPIVersion;
497
+ }
498
+ }
499
+ }
500
+ const Openrouteservice = {
501
+ Geocode: OrsGeocode,
502
+ Isochrones: OrsIsochrones,
503
+ Directions: OrsDirections,
504
+ Matrix: OrsMatrix,
505
+ Pois: OrsPois,
506
+ Elevation: OrsElevation,
507
+ Optimization: OrsOptimization,
508
+ Snap: OrsSnap
509
+ };
510
+ if (typeof module === "object" && typeof module.exports === "object") {
511
+ module.exports = Openrouteservice;
512
+ } else if (typeof define === "function" && define.amd) {
513
+ define(Openrouteservice);
514
+ }
515
+ if (typeof window !== "undefined") {
516
+ window.Openrouteservice = Openrouteservice;
517
+ }
518
+ export {
519
+ Openrouteservice as default
520
+ };
521
+ //# sourceMappingURL=ors-js-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ors-js-client.js","sources":["../src/constants.js","../src/OrsUtil.js","../src/OrsBase.js","../src/OrsGeocode.js","../src/OrsIsochrones.js","../src/OrsMatrix.js","../src/OrsDirections.js","../src/OrsPois.js","../src/OrsElevation.js","../src/OrsOptimization.js","../src/OrsSnap.js","../src/index.js"],"sourcesContent":["const constants = {\n defaultAPIVersion: 'v2',\n defaultHost: 'https://api.openrouteservice.org',\n missingAPIKeyMsg: 'Please add your openrouteservice api_key..',\n baseUrlConstituents: ['host', 'service', 'api_version', 'mime_type'],\n propNames: {\n apiKey: 'api_key',\n host: 'host',\n service: 'service',\n apiVersion: 'api_version',\n mimeType: 'mime_type',\n profile: 'profile',\n format: 'format',\n timeout: 'timeout'\n }\n}\n\nexport default constants\n","import Constants from './constants.js'\nclass OrsUtil {\n fillArgs(defaultArgs, requestArgs) {\n requestArgs = {...defaultArgs, ...requestArgs}\n return requestArgs\n }\n\n saveArgsToCache(args) {\n return {\n host: args[Constants.propNames.host],\n api_version: args[Constants.propNames.apiVersion],\n profile: args[Constants.propNames.profile],\n format: args[Constants.propNames.format],\n service: args[Constants.propNames.service],\n api_key: args[Constants.propNames.apiKey],\n mime_type: args[Constants.propNames.mimeType]\n }\n }\n\n prepareRequest(args) {\n delete args[Constants.propNames.mimeType]\n delete args[Constants.propNames.host]\n delete args[Constants.propNames.apiVersion]\n delete args[Constants.propNames.service]\n delete args[Constants.propNames.apiKey]\n delete args[Constants.propNames.profile]\n delete args[Constants.propNames.format]\n delete args[Constants.propNames.timeout]\n return { ...args }\n }\n\n /**\n * Prepare the request url based on url constituents\n * @param {Object} args\n * @return {string} url\n */\n prepareUrl(args) {\n let url = args[Constants.propNames.host]\n let urlPathParts = [\n args[Constants.propNames.apiVersion],\n args[Constants.propNames.service],\n args[Constants.propNames.profile],\n args[Constants.propNames.format]\n ]\n\n urlPathParts = urlPathParts.join('/')\n urlPathParts = urlPathParts.replace(/\\/(\\/)+/g, '/')\n\n // The beginning and end of urlPathParts can not be a slash\n if (urlPathParts[0] === '/') {\n urlPathParts = urlPathParts.slice(1)\n }\n let end = urlPathParts.slice(-1)\n if (end[0] === '/') {\n urlPathParts = urlPathParts.slice(0, -1)\n }\n\n url = url + '/' + urlPathParts\n\n return url\n }\n}\n\nexport default OrsUtil\n","import OrsUtil from './OrsUtil.js'\nimport Constants from './constants.js'\n\nconst orsUtil = new OrsUtil()\n\nclass OrsBase {\n constructor(args) {\n this.defaultArgs = {}\n this.requestArgs = {}\n this.argsCache = null\n this.customHeaders = {}\n\n this._setRequestDefaults(args)\n }\n\n /**\n * Set defaults for a request comparing with and overwriting default class arguments\n * @param {Object} args - constructor input\n */\n _setRequestDefaults(args) {\n this.defaultArgs[Constants.propNames.host] = Constants.defaultHost\n if (args[Constants.propNames.host]) {\n this.defaultArgs[Constants.propNames.host] = args[Constants.propNames.host]\n }\n if (args[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = args[Constants.propNames.service]\n }\n if (args[Constants.propNames.timeout]) {\n this.defaultArgs[Constants.propNames.timeout] = args[Constants.propNames.timeout]\n }\n if (Constants.propNames.apiKey in args) {\n this.defaultArgs[Constants.propNames.apiKey] = args[Constants.propNames.apiKey]\n } else if (!args[Constants.propNames.host]) {\n // Do not error if a host is specified; useful for locally-run instances of ORS\n console.error(Constants.missingAPIKeyMsg)\n throw new Error(Constants.missingAPIKeyMsg)\n }\n }\n\n checkHeaders() {\n // Get custom header and remove from args\n if (this.requestArgs.customHeaders) {\n this.customHeaders = this.requestArgs.customHeaders\n delete this.requestArgs.customHeaders\n }\n // set default Content-type, since Postman sets Content-type to text/plain if not specified\n if (!('Content-type' in this.customHeaders)) {\n this.customHeaders = {...this.customHeaders, 'Content-type': 'application/json'}\n }\n }\n\n async fetchRequest(body, controller) {\n let url = orsUtil.prepareUrl(this.argsCache)\n if (this.argsCache[Constants.propNames.service] === 'pois') {\n url += url.indexOf('?') > -1 ? '&' : '?'\n }\n\n const authorization = {'Authorization': this.argsCache[Constants.propNames.apiKey]}\n\n return await fetch(url, {\n method: 'POST',\n body: JSON.stringify(body),\n headers: {...authorization, ...this.customHeaders},\n signal: controller.signal\n })\n }\n\n async createRequest(body) {\n const controller = new AbortController()\n const timeout = setTimeout(() => controller.abort(), this.defaultArgs[Constants.propNames.timeout] || 5000)\n\n try {\n const orsResponse = await this.fetchRequest(body, controller)\n\n if (!orsResponse.ok) {\n const error = new Error(orsResponse.statusText)\n error.status = orsResponse.status\n error.response = orsResponse\n throw error\n }\n\n return this.argsCache?.format === 'gpx' ? await orsResponse.text() : await orsResponse.json()\n } finally {\n clearTimeout(timeout)\n }\n }\n\n // is overridden in Directions and Isochrones class\n getBody() {\n return this.httpArgs;\n }\n\n async calculate(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n this.argsCache = orsUtil.saveArgsToCache(this.requestArgs)\n\n this.httpArgs = orsUtil.prepareRequest(this.requestArgs)\n const postBody = this.getBody(this.httpArgs)\n\n return await this.createRequest(postBody)\n }\n}\n\nexport default OrsBase\n","import OrsUtil from './OrsUtil.js'\nimport Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nconst orsUtil = new OrsUtil()\n\nclass OrsGeocode extends OrsBase {\n constructor(args) {\n super(args)\n\n this.lookupParameter = {\n api_key: function(key, val) {\n return key + '=' + val\n },\n text: function(key, val) {\n return '&' + key + '=' + encodeURIComponent(val)\n },\n focus_point: function(key, val) {\n let urlParams = ''\n urlParams += '&' + 'focus.point.lon' + '=' + val[1]\n urlParams += '&' + 'focus.point.lat' + '=' + val[0]\n return urlParams\n },\n boundary_bbox: function(key, val) {\n let urlParams = ''\n urlParams += '&' + 'boundary.rect.min_lon' + '=' + val[0][1]\n urlParams += '&' + 'boundary.rect.min_lat' + '=' + val[0][0]\n urlParams += '&' + 'boundary.rect.max_lon' + '=' + val[1][1]\n urlParams += '&' + 'boundary.rect.max_lat' + '=' + val[1][0]\n\n return urlParams\n },\n point: function(key, val) {\n if (val && Array.isArray(val.lat_lng)) {\n let urlParams = ''\n urlParams += '&' + 'point.lon' + '=' + val.lat_lng[1]\n urlParams += '&' + 'point.lat' + '=' + val.lat_lng[0]\n return urlParams\n }\n },\n boundary_circle: function(key, val) {\n let urlParams = ''\n urlParams += '&' + 'boundary.circle.lon' + '=' + val.lat_lng[1]\n urlParams += '&' + 'boundary.circle.lat' + '=' + val.lat_lng[0]\n urlParams += '&' + 'boundary.circle.radius' + '=' + val.radius\n\n return urlParams\n },\n sources: function(key, val) {\n let urlParams = '&sources='\n if (val) {\n for (const key in val) {\n if (Number(key) > 0) {\n urlParams += ','\n }\n urlParams += val[key]\n }\n return urlParams\n }\n },\n layers: function(key, val) {\n let urlParams = '&layers='\n let counter = 0\n for (key in val) {\n if (counter > 0) {\n urlParams += ','\n }\n urlParams += val[key]\n counter++\n }\n return urlParams\n },\n boundary_country: function(key, val) {\n return '&' + 'boundary.country' + '=' + val\n },\n size: function(key, val) {\n return '&' + key + '=' + val\n },\n address: function(key, val) {\n return '&' + key + '=' + val\n },\n neighbourhood: function(key, val) {\n return '&' + key + '=' + val\n },\n borough: function(key, val) {\n return '&' + key + '=' + val\n },\n locality: function(key, val) {\n return '&' + key + '=' + val\n },\n county: function(key, val) {\n return '&' + key + '=' + val\n },\n region: function(key, val) {\n return '&' + key + '=' + val\n },\n postalcode: function(key, val) {\n return '&' + key + '=' + val\n },\n country: function(key, val) {\n return '&' + key + '=' + val\n }\n }\n }\n\n getParametersAsQueryString(args) {\n let queryString = ''\n for (const key in args) {\n const val = args[key]\n if (Constants.baseUrlConstituents.indexOf(key) <= -1) {\n queryString += this.lookupParameter[key](key, val)\n }\n }\n return queryString\n }\n\n async fetchGetRequest(controller) {\n let url = orsUtil.prepareUrl(this.requestArgs)\n // Add url query string from args\n url += '?' + this.getParametersAsQueryString(this.requestArgs)\n\n // createRequest function from base class is not applicable: GET instead of POST request\n return await fetch(url, {\n method: 'GET',\n headers: this.customHeaders,\n signal: controller.signal\n })\n }\n\n async geocodePromise() {\n const controller = new AbortController()\n const timeout = setTimeout(() => controller.abort(), this.defaultArgs[Constants.propNames.timeout] || 5000)\n\n try {\n const orsResponse = await this.fetchGetRequest(controller)\n\n if (!orsResponse.ok) {\n const error = new Error(orsResponse.statusText)\n error.status = orsResponse.status\n error.response = orsResponse\n throw error\n }\n\n return await orsResponse.json() || orsResponse.text()\n } finally {\n clearTimeout(timeout)\n }\n }\n\n async geocode(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs.service = 'geocode/search'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.geocodePromise()\n }\n\n async reverseGeocode(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs.service = 'geocode/reverse'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.geocodePromise()\n }\n\n async structuredGeocode(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs.service = 'geocode/search/structured'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.geocodePromise()\n }\n}\n\nexport default OrsGeocode\n","import Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nclass OrsIsochrones extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.defaultArgs.service = 'isochrones'\n }\n if (!args[Constants.propNames.apiVersion]) {\n this.defaultArgs.api_version = Constants.defaultAPIVersion\n }\n }\n\n getBody(args) {\n const options = {}\n\n if (args.restrictions) {\n options.profile_params = {\n restrictions: {\n ...args.restrictions\n }\n }\n delete args.restrictions\n }\n if (args.avoidables) {\n options.avoid_features = [...args.avoidables]\n delete args.avoidables\n }\n\n if (args.avoid_polygons) {\n options.avoid_polygons = {\n ...args.avoid_polygons\n }\n delete args.avoid_polygons\n }\n\n if (Object.keys(options).length > 0) {\n return {\n ...args,\n options: options\n }\n } else {\n return {\n ...args\n }\n }\n }\n}\n\nexport default OrsIsochrones\n","import Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nclass OrsMatrix extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = 'matrix'\n }\n if (!args[Constants.propNames.apiVersion]) {\n this.defaultArgs.api_version = Constants.defaultAPIVersion\n }\n }\n}\n\nexport default OrsMatrix\n","import Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nclass OrsDirections extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = 'directions'\n }\n if (!args[Constants.propNames.apiVersion]) {\n this.defaultArgs.api_version = Constants.defaultAPIVersion\n }\n }\n\n getBody(args) {\n if (args.options && typeof args.options !== 'object') {\n args.options = JSON.parse(args.options)\n }\n\n if (args.restrictions) {\n args.options = args.options || {}\n args.options.profile_params = {\n restrictions: { ...args.restrictions }\n }\n delete args.restrictions\n }\n\n if (args.avoidables) {\n args.options = args.options || {}\n args.options.avoid_features = [...args.avoidables]\n delete args.avoidables\n }\n return args\n }\n}\n\nexport default OrsDirections\n","import OrsUtil from './OrsUtil.js'\nimport Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nconst orsUtil = new OrsUtil()\n\nclass OrsPois extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = 'pois'\n }\n }\n\n generatePayload(args) {\n const payload = {}\n\n for (const key in args) {\n if (\n !(\n Constants.baseUrlConstituents.indexOf(key) > -1 ||\n key === Constants.propNames.apiKey ||\n key === Constants.propNames.timeout\n )\n ) {\n payload[key] = args[key]\n }\n }\n return payload\n }\n\n async poisPromise() {\n // the request arg is required by the API as part of the body\n this.requestArgs.request = this.requestArgs.request || 'pois'\n\n this.argsCache = orsUtil.saveArgsToCache(this.requestArgs)\n\n if (this.requestArgs[Constants.propNames.service]) {\n delete this.requestArgs[Constants.propNames.service]\n }\n\n const payload = this.generatePayload(this.requestArgs)\n\n return await this.createRequest(payload)\n }\n\n async pois(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.poisPromise()\n }\n}\n\nexport default OrsPois\n","import OrsUtil from './OrsUtil.js'\nimport Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nconst orsUtil = new OrsUtil()\nclass OrsElevation extends OrsBase {\n\n generatePayload(args) {\n const payload = {}\n\n for (const key in args) {\n if (Constants.baseUrlConstituents.indexOf(key) <= -1) {\n payload[key] = args[key]\n }\n }\n return payload\n }\n\n async elevationPromise() {\n this.argsCache = orsUtil.saveArgsToCache(this.requestArgs)\n\n const payload = this.generatePayload(this.requestArgs)\n\n return await this.createRequest(payload)\n }\n\n async lineElevation(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs[Constants.propNames.service] = 'elevation/line'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.elevationPromise()\n }\n\n async pointElevation(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs[Constants.propNames.service] = 'elevation/point'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.elevationPromise()\n }\n}\n\nexport default OrsElevation\n","import OrsUtil from \"./OrsUtil.js\"\nimport Constants from \"./constants.js\"\nimport OrsBase from \"./OrsBase.js\"\n\nconst orsUtil = new OrsUtil()\n\nclass OrsOptimization extends OrsBase {\n generatePayload(args) {\n let payload = {}\n\n for (const key in args) {\n if (Constants.baseUrlConstituents.indexOf(key) <= -1) {\n payload[key] = args[key]\n }\n }\n return payload\n }\n\n async optimizationPromise() {\n this.argsCache = orsUtil.saveArgsToCache(this.requestArgs)\n\n const payload = this.generatePayload(this.requestArgs)\n\n return await this.createRequest(payload)\n }\n\n async optimize(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !reqArgs[Constants.propNames.service]) {\n reqArgs[Constants.propNames.service] = 'optimization'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.optimizationPromise()\n }\n}\n\nexport default OrsOptimization\n","import Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nclass OrsSnap extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = 'snap'\n }\n if (!args[Constants.propNames.apiVersion]) {\n this.defaultArgs.api_version = Constants.defaultAPIVersion\n }\n }\n}\n\nexport default OrsSnap\n","import OrsGeocode from './OrsGeocode.js'\nimport OrsIsochrones from './OrsIsochrones.js'\nimport OrsMatrix from './OrsMatrix.js'\nimport OrsDirections from './OrsDirections.js'\nimport OrsPois from './OrsPois.js'\nimport OrsElevation from './OrsElevation.js'\nimport OrsOptimization from './OrsOptimization.js'\nimport OrsSnap from './OrsSnap.js';\n\nconst Openrouteservice = {\n Geocode: OrsGeocode,\n Isochrones: OrsIsochrones,\n Directions: OrsDirections,\n Matrix: OrsMatrix,\n Pois: OrsPois,\n Elevation: OrsElevation,\n Optimization: OrsOptimization,\n Snap: OrsSnap\n}\n\n// Define Openrouteservice for Node module pattern loaders, including Browserify\nif (typeof module === 'object' && typeof module.exports === 'object') {\n module.exports = Openrouteservice\n // define Openrouteservice as an AMD module\n // eslint-disable-next-line no-undef\n} else if (typeof define === 'function' && define.amd) {\n // eslint-disable-next-line no-undef\n define(Openrouteservice)\n}\n\nif (typeof window !== 'undefined') {\n window.Openrouteservice = Openrouteservice\n}\n\nexport default Openrouteservice\n"],"names":["Constants","orsUtil","key"],"mappings":"AAAA,MAAM,YAAY;AAAA,EAChB,mBAAmB;AAAA,EACnB,aAAa;AAAA,EACb,kBAAkB;AAAA,EAClB,qBAAqB,CAAC,QAAQ,WAA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AAA,EACZ,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,WAAW;AAAA,EACX,cAAc;AAAA,EACd,MAAM;AACR;AAGA,IAAI,OAAO,WAAW,YAAY,OAAO,OAAO,YAAY,UAAU;AACpE,SAAO,UAAU;AAGnB,WAAW,OAAO,WAAW,cAAc,OAAO,KAAK;AAErD,SAAO,gBAAgB;AACzB;AAEA,IAAI,OAAO,WAAW,aAAa;AACjC,SAAO,mBAAmB;AAC5B;"}
@@ -0,0 +1,63 @@
1
+ function scale(max, min, num) {
2
+ const breathe = 10
3
+ return (100 * (num - min + breathe)) / (max + breathe - min) || 0
4
+ }
5
+
6
+ function elevationColor(value) {
7
+ // Minimize the number of different color variation.
8
+ value = Math.round(Math.abs(value) / 20) * 20
9
+ const red = 255 - value * 5
10
+ const green = 125 - value * 10
11
+ const blue = value
12
+ return `rgb(${red} ${green} ${blue})`
13
+ }
14
+
15
+ function draw() {
16
+ const elem = document.getElementsByTagName('svg')[0]
17
+ let elevationData = JSON.parse(window.frameElement.dataset.elevation)
18
+ elevationData = elevationData.map(([ele, dist]) => {
19
+ return { ele, dist }
20
+ })
21
+
22
+ const dataEle = elevationData.map((n) => parseFloat(n.ele, 10) || 0)
23
+ const dataDist = elevationData.map((n) => parseFloat(n.dist, 10) || 0)
24
+ const distTotal = dataDist.reduce((acc, current) => current + acc, 0)
25
+ const max = Math.max(...dataEle)
26
+ const min = Math.min(...dataEle)
27
+ const scaledEle = dataEle.map((num) => scale(max, min, num))
28
+ const length = scaledEle.length
29
+ let width
30
+ let x
31
+ let y
32
+ let height
33
+ let accX = 0
34
+ const far = 8
35
+ for (let i = 0; i < length; i++) {
36
+ const farNext = dataEle[Math.min(i + far, length - far) % length]
37
+ const farPrev = dataEle[Math.max(i + length - far, length + far) % length]
38
+ const diffNextPrev = farNext - farPrev
39
+ const color = elevationColor(diffNextPrev)
40
+ const rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect')
41
+ x = accX
42
+ y = 100 - scaledEle[i]
43
+ height = scaledEle[i] + 1
44
+ width = (dataDist[i] / distTotal) * 100
45
+ accX += width
46
+ rect.setAttribute('x', `${x}%`)
47
+ rect.setAttribute('y', `${y}%`)
48
+ rect.setAttribute('width', `${width}%`)
49
+ rect.setAttribute('height', `${height}%`)
50
+ rect.setAttribute('fill', color)
51
+ rect.setAttribute('data-index', i)
52
+ rect.setAttribute('data-ele', Math.round(dataEle[i]))
53
+ elem.appendChild(rect)
54
+ }
55
+ elem.addEventListener('mouseover', (event) => {
56
+ const eleOver = new CustomEvent('chart:over', {
57
+ detail: { element: event.target },
58
+ })
59
+ window.frameElement.dispatchEvent(eleOver)
60
+ })
61
+ }
62
+
63
+ draw()
@@ -0,0 +1,8 @@
1
+ <svg version="1.1"
2
+ baseProfile="full"
3
+ xmlns="http://www.w3.org/2000/svg"
4
+ xmlns:xlink="http://www.w3.org/1999/xlink"
5
+ xmlns:ev="http://www.w3.org/2001/xml-events"
6
+ width="100%" height="100%">
7
+ <script type="text/ecmascript" xlink:href="./elevation.js" />
8
+ </svg>