mahal_map 1.0.3 → 1.0.4

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.
Files changed (85) hide show
  1. package/dist/index.d.mts +101 -0
  2. package/dist/index.d.ts +100 -13
  3. package/dist/index.js +1 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/index.mjs +2 -0
  6. package/dist/index.mjs.map +1 -0
  7. package/dist/mahal_map.sdk.js +1 -0
  8. package/package.json +20 -10
  9. package/.vscode/settings.json +0 -3
  10. package/dist/app/config/constants.d.ts +0 -9
  11. package/dist/app/config/constants.d.ts.map +0 -1
  12. package/dist/app/config/geojson-polyline.d.ts +0 -3
  13. package/dist/app/config/geojson-polyline.d.ts.map +0 -1
  14. package/dist/app/config/geometry-polyline.d.ts +0 -3
  15. package/dist/app/config/geometry-polyline.d.ts.map +0 -1
  16. package/dist/app/config/index.d.ts +0 -4
  17. package/dist/app/config/index.d.ts.map +0 -1
  18. package/dist/app/lib/axios/api/axios.d.ts +0 -2
  19. package/dist/app/lib/axios/api/axios.d.ts.map +0 -1
  20. package/dist/app/lib/axios/api/index.d.ts +0 -2
  21. package/dist/app/lib/axios/api/index.d.ts.map +0 -1
  22. package/dist/app/lib/axios/index.d.ts +0 -2
  23. package/dist/app/lib/axios/index.d.ts.map +0 -1
  24. package/dist/app/lib/checking-coordinates/index.d.ts +0 -2
  25. package/dist/app/lib/checking-coordinates/index.d.ts.map +0 -1
  26. package/dist/app/lib/checking-coordinates/utils.d.ts +0 -5
  27. package/dist/app/lib/checking-coordinates/utils.d.ts.map +0 -1
  28. package/dist/app/lib/index.d.ts +0 -4
  29. package/dist/app/lib/index.d.ts.map +0 -1
  30. package/dist/app/lib/saveKey/index.d.ts +0 -2
  31. package/dist/app/lib/saveKey/index.d.ts.map +0 -1
  32. package/dist/app/lib/saveKey/utils.d.ts +0 -5
  33. package/dist/app/lib/saveKey/utils.d.ts.map +0 -1
  34. package/dist/app/types/additional-param/index.d.ts +0 -6
  35. package/dist/app/types/additional-param/index.d.ts.map +0 -1
  36. package/dist/app/types/index.d.ts +0 -5
  37. package/dist/app/types/index.d.ts.map +0 -1
  38. package/dist/app/types/map/index.d.ts +0 -10
  39. package/dist/app/types/map/index.d.ts.map +0 -1
  40. package/dist/app/types/router-param/index.d.ts +0 -33
  41. package/dist/app/types/router-param/index.d.ts.map +0 -1
  42. package/dist/app/types/search-param/index.d.ts +0 -13
  43. package/dist/app/types/search-param/index.d.ts.map +0 -1
  44. package/dist/index.d.ts.map +0 -1
  45. package/dist/lib/map/utils.d.ts +0 -5
  46. package/dist/lib/map/utils.d.ts.map +0 -1
  47. package/dist/lib/routing/api.d.ts +0 -3
  48. package/dist/lib/routing/api.d.ts.map +0 -1
  49. package/dist/lib/routing/utils.d.ts +0 -4
  50. package/dist/lib/routing/utils.d.ts.map +0 -1
  51. package/dist/lib/search/api.d.ts +0 -3
  52. package/dist/lib/search/api.d.ts.map +0 -1
  53. package/dist/lib/search/utils.d.ts +0 -4
  54. package/dist/lib/search/utils.d.ts.map +0 -1
  55. package/dist/mahal_map.esm.js +0 -2
  56. package/dist/mahal_map.esm.js.map +0 -1
  57. package/dist/mahal_map.umd.js +0 -2
  58. package/dist/mahal_map.umd.js.map +0 -1
  59. package/index.html +0 -465
  60. package/rollup.config.js +0 -38
  61. package/src/app/config/constants.ts +0 -15
  62. package/src/app/config/geojson-polyline.ts +0 -47
  63. package/src/app/config/geometry-polyline.ts +0 -58
  64. package/src/app/config/index.ts +0 -3
  65. package/src/app/lib/axios/api/axios.ts +0 -17
  66. package/src/app/lib/axios/api/index.ts +0 -1
  67. package/src/app/lib/axios/index.ts +0 -1
  68. package/src/app/lib/checking-coordinates/index.ts +0 -1
  69. package/src/app/lib/checking-coordinates/utils.ts +0 -20
  70. package/src/app/lib/index.ts +0 -3
  71. package/src/app/lib/saveKey/index.ts +0 -1
  72. package/src/app/lib/saveKey/utils.ts +0 -18
  73. package/src/app/types/additional-param/index.ts +0 -6
  74. package/src/app/types/index.ts +0 -4
  75. package/src/app/types/map/index.ts +0 -10
  76. package/src/app/types/router-param/index.ts +0 -33
  77. package/src/app/types/search-param/index.ts +0 -13
  78. package/src/index.d.ts +0 -21
  79. package/src/index.ts +0 -26
  80. package/src/lib/map/utils.ts +0 -35
  81. package/src/lib/routing/api.ts +0 -17
  82. package/src/lib/routing/utils.ts +0 -37
  83. package/src/lib/search/api.ts +0 -13
  84. package/src/lib/search/utils.ts +0 -40
  85. package/tsconfig.json +0 -23
package/index.html DELETED
@@ -1,465 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <link
6
- rel="stylesheet"
7
- href="https://unpkg.com/maplibre-gl@5.3.0/dist/maplibre-gl.css"
8
- />
9
- <script src="https://unpkg.com/maplibre-gl@5.3.0/dist/maplibre-gl.js"></script>
10
- <script src="dist/mahal_map.umd.js?apikey=4|3wfLEwkl6d5PZWMKrUDbakyVCiylF0Iqs5iehPEk388cd6eb"></script>
11
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
12
- <title>Mahal Map</title>
13
- <style>
14
- body {
15
- margin: 0;
16
- padding: 0;
17
- height: 100%;
18
- display: flex;
19
- justify-content: center;
20
- align-items: center;
21
- }
22
- html,
23
- body,
24
- #map {
25
- height: 100%;
26
- width: 100%;
27
- }
28
- .loading {
29
- content: url("https://api.iconify.design/svg-spinners:180-ring.svg");
30
- }
31
- .search-container {
32
- position: absolute;
33
- top: 20px;
34
- left: 20px;
35
- z-index: 10;
36
- width: 300px;
37
- }
38
- .search-input {
39
- width: 250px;
40
- padding: 10px 40px 10px 15px;
41
- font-size: 16px;
42
- border: 2px solid #ccc;
43
- border-radius: 25px;
44
- outline: none;
45
- transition: 0.3s;
46
- }
47
- .search-input:focus {
48
- border-color: #007bff;
49
- box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
50
- }
51
- .search-icon {
52
- position: absolute;
53
- right: 10px;
54
- top: 50%;
55
- transform: translateY(-50%);
56
- width: 20px;
57
- height: 20px;
58
- opacity: 0.6;
59
- }
60
- .search-results {
61
- list-style: none;
62
- padding: 0;
63
- margin-top: 5px;
64
- background: white;
65
- border: 1px solid #ddd;
66
- max-height: 200px;
67
- overflow-y: auto;
68
- display: none;
69
- position: absolute;
70
- width: 100%;
71
- border-radius: 5px;
72
- box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
73
- }
74
- .search-results li {
75
- padding: 8px;
76
- cursor: pointer;
77
- }
78
- .search-results li:hover {
79
- background: #f0f0f0;
80
- }
81
- #routerPanel {
82
- position: absolute;
83
- top: 100px;
84
- right: 20px;
85
- background: white;
86
- padding: 12px;
87
- border-radius: 8px;
88
- box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
89
- z-index: 1000;
90
- display: none;
91
- }
92
-
93
- .route-button {
94
- position: absolute;
95
- top: 20px;
96
- right: 20px;
97
- z-index: 1001;
98
- padding: 10px 20px;
99
- font-size: 16px;
100
- background: linear-gradient(135deg, #1e90ff, #007bff);
101
- color: white;
102
- border: none;
103
- border-radius: 8px;
104
- box-shadow: 0 4px 10px rgba(0, 123, 255, 0.3);
105
- cursor: pointer;
106
- transition: all 0.2s ease-in-out;
107
- }
108
-
109
- .route-button:hover {
110
- background: linear-gradient(135deg, #007bff, #0056b3);
111
- box-shadow: 0 6px 14px rgba(0, 123, 255, 0.4);
112
- transform: translateY(-1px);
113
- }
114
-
115
- .route-button:active {
116
- transform: scale(0.98);
117
- box-shadow: 0 2px 6px rgba(0, 123, 255, 0.2);
118
- }
119
- #routerPanel {
120
- position: absolute;
121
- top: 100px;
122
- right: 20px;
123
- background: white;
124
- padding: 16px 20px;
125
- border-radius: 12px;
126
- box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
127
- z-index: 1000;
128
- display: none;
129
- min-width: 200px;
130
- font-family: "Segoe UI", sans-serif;
131
- }
132
-
133
- #routerPanel label {
134
- font-size: 14px;
135
- font-weight: 500;
136
- margin-bottom: 8px;
137
- display: block;
138
- color: #333;
139
- }
140
-
141
- #routerPanel select {
142
- width: 100%;
143
- padding: 8px 10px;
144
- font-size: 14px;
145
- border: 1px solid #ccc;
146
- border-radius: 6px;
147
- margin-bottom: 12px;
148
- background-color: #f9f9f9;
149
- transition: border-color 0.2s;
150
- }
151
-
152
- #routerPanel select:focus {
153
- outline: none;
154
- border-color: #007bff;
155
- box-shadow: 0 0 4px rgba(0, 123, 255, 0.3);
156
- }
157
-
158
- #clearRoute {
159
- width: 100%;
160
- padding: 10px 0;
161
- font-size: 14px;
162
- background-color: #f44336;
163
- color: white;
164
- border: none;
165
- border-radius: 6px;
166
- cursor: pointer;
167
- transition: background-color 0.2s ease-in-out, transform 0.1s ease;
168
- }
169
-
170
- #clearRoute:hover {
171
- background-color: #d32f2f;
172
- }
173
-
174
- #clearRoute:active {
175
- transform: scale(0.97);
176
- }
177
- </style>
178
- </head>
179
- <body>
180
- <div id="map"></div>
181
- <div class="search-container">
182
- <input
183
- type="text"
184
- id="search"
185
- class="search-input"
186
- placeholder="Поиск..."
187
- />
188
- <img
189
- id="search-icon"
190
- class="search-icon"
191
- src="https://cdn-icons-png.flaticon.com/512/622/622669.png"
192
- alt="🔍"
193
- />
194
- <ul id="search-results" class="search-results"></ul>
195
- </div>
196
-
197
- <div id="routerPanel">
198
- <label>Тип транспорта:</label>
199
- <select id="transportType"></select>
200
- <button id="clearRoute">Очистить</button>
201
- </div>
202
-
203
- <button id="startRouting" class="route-button">Маршрут</button>
204
-
205
- <script>
206
- const map = mmaps.Map.createMap({});
207
- const routePoints = [];
208
- const markerss = [];
209
- const routeLayerId = "route-line-layer";
210
- let isRouting = false;
211
- let selectedRouteType = "";
212
- let routeVariants = [];
213
- const positionClient = {
214
- lat: 0,
215
- lng: 0,
216
- };
217
-
218
- if (navigator.geolocation) {
219
- navigator.geolocation.watchPosition(
220
- (position) => {
221
- positionClient.lat = position.coords.latitude;
222
- positionClient.lng = position.coords.longitude;
223
- console.log("📍 Новая позиция:", positionClient);
224
- },
225
- (error) => {
226
- console.error("Ошибка геолокации:", error.message);
227
- },
228
- {
229
- enableHighAccuracy: true, // точность GPS
230
- maximumAge: 0, // не использовать кэш
231
- timeout: 5000, // время ожидания
232
- }
233
- );
234
- } else {
235
- console.log("Геолокация не поддерживается вашим браузером");
236
- }
237
-
238
- const routerPanel = document.getElementById("routerPanel");
239
- const transportSelect = document.getElementById("transportType");
240
- const startBtn = document.getElementById("startRouting");
241
- const clearBtn = document.getElementById("clearRoute");
242
-
243
- startBtn.onclick = async () => {
244
- isRouting = true;
245
- };
246
-
247
- transportSelect.onchange = async (e) => {
248
- selectedRouteType = e.target.value;
249
-
250
- const selectedRoute = routeVariants.find(
251
- (r) => r.type === selectedRouteType
252
- );
253
- if (!selectedRoute) return;
254
-
255
- const geometry = selectedRoute?.route?.routes[0]?.geometry;
256
- if (!geometry || !Array.isArray(geometry)) return;
257
-
258
- if (map.getLayer(routeLayerId)) map.removeLayer(routeLayerId);
259
- if (map.getSource(routeLayerId)) map.removeSource(routeLayerId);
260
-
261
- map.addSource(routeLayerId, {
262
- type: "geojson",
263
- data: {
264
- type: "Feature",
265
- geometry: {
266
- type: "LineString",
267
- coordinates: geometry,
268
- },
269
- },
270
- });
271
-
272
- map.addLayer({
273
- id: routeLayerId,
274
- type: "line",
275
- source: routeLayerId,
276
- layout: {
277
- "line-join": "round",
278
- "line-cap": "round",
279
- },
280
- paint: {
281
- "line-color": "#007bff",
282
- "line-width": 4,
283
- },
284
- });
285
- };
286
-
287
- map.on("click", async (e) => {
288
- if (!isRouting) return;
289
-
290
- const coord = [e.lngLat.lng, e.lngLat.lat];
291
- routePoints.push(coord);
292
-
293
- const marker = new maplibregl.Marker({ color: "#1E90FF" })
294
- .setLngLat(coord)
295
- .addTo(map);
296
- markerss.push(marker);
297
-
298
- if (routePoints.length >= 2) {
299
- try {
300
- const result = await mmaps.routerUtils.getrouter(
301
- routePoints,
302
- "geojson"
303
- );
304
- routeVariants = result;
305
- routerPanel.style.display = "block";
306
- transportSelect.innerHTML = "";
307
-
308
- result.forEach((route) => {
309
- const opt = document.createElement("option");
310
- opt.value = route.type;
311
- opt.textContent = route.name;
312
- transportSelect.appendChild(opt);
313
- });
314
- selectedRouteType = result[0].type;
315
- transportSelect.value = selectedRouteType;
316
-
317
- transportSelect.dispatchEvent(new Event("change"));
318
- } catch (err) {
319
- console.error(err);
320
- }
321
- }
322
- });
323
-
324
- clearBtn.onclick = () => {
325
- isRouting = false;
326
- routePoints.length = 0;
327
- markerss.forEach((m) => m.remove());
328
- markerss.length = 0;
329
- if (map.getLayer(routeLayerId)) map.removeLayer(routeLayerId);
330
- if (map.getSource(routeLayerId)) map.removeSource(routeLayerId);
331
- routerPanel.style.display = "none";
332
- transportSelect.innerHTML = "";
333
- selectedRouteType = "";
334
- routeVariants = [];
335
- };
336
-
337
- const searchInput = document.getElementById("search");
338
- const searchIcon = document.getElementById("search-icon");
339
- const searchResults = document.getElementById("search-results");
340
-
341
- let markers = [];
342
- function clearMarkers() {
343
- if (markers.length > 0) {
344
- markers.forEach((marker) => {
345
- marker.remove();
346
- });
347
- markers = [];
348
- }
349
- }
350
-
351
- document.addEventListener("DOMContentLoaded", function () {
352
- const searchInput = document.getElementById("search");
353
- const searchIcon = document.getElementById("search-icon");
354
- const searchResults = document.getElementById("search-results");
355
- let markers = [];
356
-
357
- function clearMarkers() {
358
- markers.forEach((marker) => marker.remove());
359
- markers = [];
360
- }
361
-
362
- function clearResults() {
363
- searchResults.innerHTML = "";
364
- searchResults.style.display = "none";
365
- }
366
-
367
- const getLatLng = (item) => {
368
- const lat = parseFloat(item.latitude);
369
- const lng = parseFloat(item.longitude);
370
- return isNaN(lat) || isNaN(lng) ? null : [lng, lat];
371
- };
372
-
373
- const buildDisplayName = (item) => {
374
- return (
375
- item.fullAddress ||
376
- [
377
- item.subject_name,
378
- item.region,
379
- item.city,
380
- item.settlement,
381
- item.village,
382
- item.street_name,
383
- item.name,
384
- ]
385
- .filter(Boolean)
386
- .join(", ")
387
- );
388
- };
389
-
390
- async function handleSearch(query) {
391
- if (!query) {
392
- clearMarkers();
393
- clearResults();
394
- return;
395
- }
396
-
397
- searchIcon.classList.add("loading");
398
-
399
- try {
400
- const res = await mmaps.searchUtils.search(
401
- query,
402
- positionClient.lat !== 0 ? positionClient : null
403
- );
404
- if (res.data.length == 0) {
405
- return;
406
- }
407
-
408
- const items = res.data || [];
409
- clearMarkers();
410
- clearResults();
411
-
412
- items.forEach((item) => {
413
- const coords = getLatLng(item);
414
- if (!coords) return;
415
-
416
- const marker = new maplibregl.Marker()
417
- .setLngLat(coords)
418
- .addTo(map);
419
- markers.push(marker);
420
-
421
- const li = document.createElement("li");
422
- li.textContent = buildDisplayName(item);
423
- li.addEventListener("click", () => {
424
- clearMarkers();
425
-
426
- const newMarker = new maplibregl.Marker()
427
- .setLngLat(coords)
428
- .addTo(map);
429
- markers.push(newMarker);
430
-
431
- searchInput.value = li.textContent;
432
- searchResults.style.display = "none";
433
-
434
- map.flyTo({ center: coords, zoom: 15 });
435
- });
436
- searchResults.appendChild(li);
437
- });
438
-
439
- if (items.length) searchResults.style.display = "block";
440
-
441
- // Центр карты на первый результат
442
- const firstCoords = getLatLng(items[0]);
443
- if (firstCoords) map.flyTo({ center: firstCoords, zoom: 10 });
444
- } catch (err) {
445
- console.error(err);
446
- } finally {
447
- searchIcon.classList.remove("loading");
448
- }
449
- }
450
-
451
- searchInput.addEventListener("input", (e) =>
452
- handleSearch(e.target.value.trim())
453
- );
454
-
455
- // Делегирование клика по li (на всякий случай)
456
- searchResults.addEventListener("click", (e) => {
457
- if (e.target.tagName === "LI") {
458
- searchInput.value = e.target.textContent;
459
- searchResults.style.display = "none";
460
- }
461
- });
462
- });
463
- </script>
464
- </body>
465
- </html>
package/rollup.config.js DELETED
@@ -1,38 +0,0 @@
1
- import resolve from "@rollup/plugin-node-resolve";
2
- import typescript from "@rollup/plugin-typescript";
3
- import commonjs from "@rollup/plugin-commonjs";
4
- import { terser } from "rollup-plugin-terser";
5
-
6
- export default {
7
- input: "src/index.ts",
8
- output: [
9
- {
10
- file: "dist/mahal_map.esm.js",
11
- format: "esm",
12
- sourcemap: true,
13
- },
14
- {
15
- file: "dist/mahal_map.umd.js",
16
- format: "umd",
17
- name: "mmaps",
18
- sourcemap: true,
19
- globals: {
20
- "maplibre-gl": "maplibregl",
21
- },
22
- },
23
- ],
24
- external: ["maplibre-gl"],
25
- context: "window",
26
- plugins: [
27
- resolve({ browser: true, preferBuiltins: false }),
28
- commonjs(),
29
- typescript({
30
- tsconfig: "./tsconfig.json",
31
- declaration: true,
32
- declarationDir: "dist",
33
- rootDir: "src",
34
- emitDeclarationOnly: true,
35
- }),
36
- terser(),
37
- ],
38
- };
@@ -1,15 +0,0 @@
1
- const BASE_URL = "https://platform.mahal.tj/api/";
2
- const LATLNGREGEX =
3
- /^([-+]?(?:[1-8]?\d(?:\.\d+)?|90(?:\.0+)?)),\s*([-+]?(?:180(?:\.0+)?|(?:(?:1[0-7]\d)|(?:[1-9]?\d))(?:\.\d+)?))$/;
4
- const LNGLATREGEX =
5
- /^([-+]?(?:180(?:\.0+)?|(?:(?:1[0-7]\d)|(?:[1-9]?\d))(?:\.\d+)?)),\s*([-+]?(?:[1-8]?\d(?:\.\d+)?|90(?:\.0+)?))$/;
6
-
7
- const REGEX =
8
- /^[-+]?([1-8]?\d(\.\d+)?|90(\.0+)?),\s*[-+]?(180(\.0+)?|((1[0-7]\d)|([1-9]?\d))(\.\d+)?)$/;
9
-
10
- const DARK = "https://mtile.gram.tj/custom-styles/dark-style.json";
11
- const LIGHT = "https://mtile.gram.tj/custom-styles/mapstyle.json";
12
- const VECTOR =
13
- "https://mtile.gram.tj/custom-styles/style_maptiler_basic_hn.json";
14
-
15
- export { BASE_URL, LATLNGREGEX, LNGLATREGEX, REGEX, DARK, LIGHT, VECTOR };
@@ -1,47 +0,0 @@
1
- function geojsonPolyline(encoded: string): number[][] {
2
- let points = [];
3
- let index = 0,
4
- len = encoded.length;
5
- let lat = 0,
6
- lng = 0;
7
-
8
- while (index < len) {
9
- let b,
10
- shift = 0,
11
- result = 0;
12
- do {
13
- b = encoded.charCodeAt(index++) - 63;
14
- result |= (b & 0x1f) << shift;
15
- shift += 5;
16
- } while (b >= 0x20);
17
- let dlat = result & 1 ? ~(result >> 1) : result >> 1;
18
- lat += dlat;
19
-
20
- shift = 0;
21
- result = 0;
22
- do {
23
- b = encoded.charCodeAt(index++) - 63;
24
- result |= (b & 0x1f) << shift;
25
- shift += 5;
26
- } while (b >= 0x20);
27
- let dlng = result & 1 ? ~(result >> 1) : result >> 1;
28
- lng += dlng;
29
-
30
- points.push([lng * 1e-5, lat * 1e-5]);
31
- }
32
-
33
- return points;
34
- }
35
-
36
- export { geojsonPolyline };
37
-
38
- // Пример использования:
39
-
40
- // geojsonPolyline("yzocFzynhVq}@n}@o}@nzD")
41
-
42
- // Вернёт массив вида [
43
- // [102.0, 0.5],
44
- // [103.0, 1.0],
45
- // [104.0, 0.5],
46
- // [105.0, 0.0]
47
- // ].
@@ -1,58 +0,0 @@
1
- function geometryPolyline(coordinates: number[][]): string {
2
- let encoded = '';
3
- let prevLat = 0;
4
- let prevLng = 0;
5
-
6
- for (let i = 0; i < coordinates.length; i++) {
7
- const [lng, lat] = coordinates[i];
8
-
9
- // Умножаем координаты на 1e5 и округляем
10
- const latE5 = Math.round(lat * 1e5);
11
- const lngE5 = Math.round(lng * 1e5);
12
-
13
- // Вычисляем разницу от предыдущих значений
14
- const dLat = latE5 - prevLat;
15
- const dLng = lngE5 - prevLng;
16
-
17
- // Обновляем предыдущие значения
18
- prevLat = latE5;
19
- prevLng = lngE5;
20
-
21
- // Добавляем к закодированной строке
22
- encoded += encodeSignedNumber(dLat) + encodeSignedNumber(dLng);
23
- }
24
-
25
- return encoded;
26
- }
27
-
28
- function encodeSignedNumber(num: number) {
29
- let sgnNum = num << 1;
30
- if (num < 0) {
31
- sgnNum = ~sgnNum;
32
- }
33
- return encodeNumber(sgnNum);
34
- }
35
-
36
- function encodeNumber(num :number) {
37
- let encoded = '';
38
- while (num >= 0x20) {
39
- encoded += String.fromCharCode((0x20 | (num & 0x1f)) + 63);
40
- num >>= 5;
41
- }
42
- encoded += String.fromCharCode(num + 63);
43
- return encoded;
44
- }
45
-
46
- export default geometryPolyline
47
-
48
-
49
- // Пример использования:
50
-
51
- // geometryPolyline([
52
- // [102.0, 0.5],
53
- // [103.0, 1.0],
54
- // [104.0, 0.5],
55
- // [105.0, 0.0]
56
- // ])
57
-
58
- // Вернёт строку вида "yzocFzynhVq}@n}@o}@nzD".
@@ -1,3 +0,0 @@
1
- export * from "./constants";
2
- export * from "./geojson-polyline";
3
- export * from "./geometry-polyline";
@@ -1,17 +0,0 @@
1
- import axios from "axios";
2
- import { BASE_URL } from "@app/config/index";
3
- import { clearKey } from "@app/lib";
4
-
5
- export const api = axios.create({
6
- baseURL: BASE_URL,
7
- });
8
-
9
- api.interceptors.request.use(
10
- (response) => response,
11
- (error) => {
12
- if (error.request?.status === 401) {
13
- clearKey();
14
- }
15
- return Promise.reject(error);
16
- }
17
- );
@@ -1 +0,0 @@
1
- export * from "./axios";
@@ -1 +0,0 @@
1
- export * from "./api";
@@ -1 +0,0 @@
1
- export * from "./utils";
@@ -1,20 +0,0 @@
1
- import { LATLNGREGEX, LNGLATREGEX } from "@app/config/index";
2
-
3
- export function checkCoordinates(coordinates: string) {
4
- let lat, lng;
5
- if (LATLNGREGEX.test(coordinates)) {
6
- const match = coordinates.match(LATLNGREGEX);
7
- if (match) {
8
- [, lat, lng] = match; // Первый элемент — полное совпадение, пропускаем его
9
- }
10
- } else if (LNGLATREGEX.test(coordinates)) {
11
- const match = coordinates.match(LNGLATREGEX);
12
- if (match) {
13
- [, lng, lat] = match; // Меняем местами
14
- }
15
- } else {
16
- console.log("Неверный формат координат");
17
- return null;
18
- }
19
- return { lat, lng };
20
- }
@@ -1,3 +0,0 @@
1
- export * from "./axios";
2
- export * from "./checking-coordinates";
3
- export * from "./saveKey";
@@ -1 +0,0 @@
1
- export * from "./utils";