@mint-ui/map 0.1.1-beta

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 (41) hide show
  1. package/.eslintrc.js +110 -0
  2. package/LICENSE +21 -0
  3. package/README.md +15 -0
  4. package/dist/components/mint-map/MintMap.d.ts +81 -0
  5. package/dist/components/mint-map/MintMap.js +206 -0
  6. package/dist/components/mint-map/MintMap.module.scss.js +13 -0
  7. package/dist/components/mint-map/core/MintMapController.d.ts +32 -0
  8. package/dist/components/mint-map/core/MintMapController.js +56 -0
  9. package/dist/components/mint-map/core/MintMapCore.d.ts +3 -0
  10. package/dist/components/mint-map/core/MintMapCore.js +69 -0
  11. package/dist/components/mint-map/core/MintMapCore.module.scss.js +13 -0
  12. package/dist/components/mint-map/core/advanced/MapBuildingProjection.d.ts +15 -0
  13. package/dist/components/mint-map/core/advanced/MapBuildingProjection.js +173 -0
  14. package/dist/components/mint-map/core/hooks/MarkerMovingHook.d.ts +6 -0
  15. package/dist/components/mint-map/core/hooks/MarkerMovingHook.js +145 -0
  16. package/dist/components/mint-map/core/index.d.ts +7 -0
  17. package/dist/components/mint-map/core/provider/MintMapProvider.d.ts +8 -0
  18. package/dist/components/mint-map/core/provider/MintMapProvider.js +30 -0
  19. package/dist/components/mint-map/core/util/animation.d.ts +16 -0
  20. package/dist/components/mint-map/core/util/animation.js +70 -0
  21. package/dist/components/mint-map/core/util/calculate.d.ts +29 -0
  22. package/dist/components/mint-map/core/util/calculate.js +167 -0
  23. package/dist/components/mint-map/core/util/waiting.d.ts +1 -0
  24. package/dist/components/mint-map/core/wrapper/MapControlWrapper.d.ts +11 -0
  25. package/dist/components/mint-map/core/wrapper/MapControlWrapper.js +77 -0
  26. package/dist/components/mint-map/core/wrapper/MapMarkerWrapper.d.ts +23 -0
  27. package/dist/components/mint-map/core/wrapper/MapMarkerWrapper.js +163 -0
  28. package/dist/components/mint-map/core/wrapper/MapPolygonWrapper.d.ts +5 -0
  29. package/dist/components/mint-map/core/wrapper/MapPolygonWrapper.js +39 -0
  30. package/dist/components/mint-map/core/wrapper/MapPolylineWrapper.d.ts +5 -0
  31. package/dist/components/mint-map/core/wrapper/MapPolylineWrapper.js +39 -0
  32. package/dist/components/mint-map/core/wrapper/MintMapWrapper.module.scss.js +13 -0
  33. package/dist/components/mint-map/google/GoogleMintMapController.d.ts +34 -0
  34. package/dist/components/mint-map/index.d.ts +2 -0
  35. package/dist/components/mint-map/naver/NaverMintMapController.d.ts +33 -0
  36. package/dist/index.d.ts +1 -0
  37. package/dist/index.es.js +1096 -0
  38. package/dist/index.js +23 -0
  39. package/dist/index.umd.js +1113 -0
  40. package/package.json +74 -0
  41. package/test.ts +7 -0
@@ -0,0 +1,173 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tslib = require('tslib');
6
+ var React = require('react');
7
+ var MintMap = require('../../MintMap.js');
8
+ var calculate = require('../util/calculate.js');
9
+ var MapMarkerWrapper = require('../wrapper/MapMarkerWrapper.js');
10
+ var MapPolygonWrapper = require('../wrapper/MapPolygonWrapper.js');
11
+
12
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
+
14
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
15
+
16
+ function getMaxLat(items) {
17
+ var max;
18
+
19
+ for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
20
+ var item = items_1[_i];
21
+
22
+ if (!max || max.lat < item.lat) {
23
+ max = item;
24
+ }
25
+ }
26
+
27
+ return max;
28
+ }
29
+
30
+ function getLngMinMaxPos(items, maxFlag) {
31
+ var data = tslib.__spreadArray([], items, true);
32
+
33
+ data.sort(function (a, b) {
34
+ var maxA = getLngMinMax(a.position, maxFlag);
35
+ var maxB = getLngMinMax(b.position, maxFlag);
36
+ return maxA.lat < maxB.lat ? maxFlag ? 1 : -1 : maxFlag ? -1 : 1;
37
+ });
38
+ return data[0];
39
+ }
40
+
41
+ function getLngMinMax(items, maxFlag) {
42
+ var val;
43
+
44
+ for (var _i = 0, items_2 = items; _i < items_2.length; _i++) {
45
+ var item = items_2[_i];
46
+
47
+ if (!val || maxFlag && val.lat < item.lat || !maxFlag && val.lat > item.lat) {
48
+ val = item;
49
+ }
50
+ }
51
+
52
+ return val;
53
+ }
54
+
55
+ function MapBuildingProjection(props) {
56
+ var basePolygonPath = props.basePolygonPath,
57
+ numberOfFloor = props.numberOfFloor,
58
+ _a = props.heightOfFloor,
59
+ heightOfFloor = _a === void 0 ? 4 : _a,
60
+ _b = props.lineColor,
61
+ lineColor = _b === void 0 ? 'blue' : _b,
62
+ _c = props.lineOpacity,
63
+ lineOpacity = _c === void 0 ? 1 : _c,
64
+ _d = props.fillColor,
65
+ fillColor = _d === void 0 ? 'lightblue' : _d,
66
+ _e = props.fillOpacity,
67
+ fillOpacity = _e === void 0 ? 1 : _e,
68
+ _f = props.title,
69
+ title = _f === void 0 ? '빌딩11' : _f,
70
+ titleElement = props.titleElement;
71
+
72
+ var _g = React.useState(),
73
+ basePolygon = _g[0],
74
+ setBasePolygon = _g[1];
75
+
76
+ var roofPolygon = React.useRef();
77
+ var wallPolygons = React.useRef();
78
+ var titlePosition = React.useRef();
79
+ React.useEffect(function () {
80
+ var base = {
81
+ position: basePolygonPath
82
+ };
83
+ var height = numberOfFloor * heightOfFloor;
84
+ var projectionHeight = calculate.GeoCalulator.convertMeterToLatitudeValue(height);
85
+ var roofPaths = [];
86
+
87
+ for (var _i = 0, basePolygonPath_1 = basePolygonPath; _i < basePolygonPath_1.length; _i++) {
88
+ var pos = basePolygonPath_1[_i];
89
+ roofPaths.push(new MintMap.Position(pos.lat + projectionHeight, pos.lng));
90
+ }
91
+
92
+ roofPolygon.current = {
93
+ position: roofPaths
94
+ };
95
+ wallPolygons.current = [];
96
+
97
+ for (var i = 0; i < basePolygonPath.length; i++) {
98
+ var start = basePolygonPath[i];
99
+ var startNext = basePolygonPath[i + 1] || basePolygonPath[0];
100
+ var end = roofPaths[i];
101
+ var endNext = roofPaths[i + 1] || roofPaths[0];
102
+ wallPolygons.current.push({
103
+ position: [start, startNext, endNext, end]
104
+ });
105
+ }
106
+
107
+ wallPolygons.current.sort(function (a, b) {
108
+ var maxA = getMaxLat(a.position);
109
+ var maxB = getMaxLat(b.position);
110
+ return maxA.lat < maxB.lat ? 1 : -1;
111
+ });
112
+
113
+ if (title || titleElement) {
114
+ var maxPos = getMaxLat(wallPolygons.current[0].position);
115
+ var maxLngPos = getLngMinMaxPos(wallPolygons.current, true);
116
+ var minLngPos = getLngMinMaxPos(wallPolygons.current, false);
117
+ var maxLng = getLngMinMax(maxLngPos.position, true);
118
+ var minLng = getLngMinMax(minLngPos.position, false);
119
+ var mid = minLng.lng + (maxLng.lng - minLng.lng) / 2;
120
+ titlePosition.current = {
121
+ position: new MintMap.Position(maxPos.lat, mid)
122
+ };
123
+ } else {
124
+ titlePosition.current = undefined;
125
+ }
126
+
127
+ setBasePolygon(base);
128
+ }, [props]);
129
+ return React__default["default"].createElement(React__default["default"].Fragment, null, basePolygon && React__default["default"].createElement(MapPolygonWrapper, tslib.__assign({}, basePolygon, {
130
+ lineColor: lineColor,
131
+ lineOpacity: lineOpacity,
132
+ fillColor: fillColor,
133
+ fillOpacity: fillOpacity
134
+ })), wallPolygons.current && wallPolygons.current.map(function (poly, idx) {
135
+ return React__default["default"].createElement(MapPolygonWrapper, tslib.__assign({
136
+ key: "walls-".concat(idx)
137
+ }, poly, {
138
+ lineColor: lineColor,
139
+ lineOpacity: lineOpacity,
140
+ fillColor: fillColor,
141
+ fillOpacity: fillOpacity
142
+ }));
143
+ }), roofPolygon.current && React__default["default"].createElement(MapPolygonWrapper, tslib.__assign({}, roofPolygon.current, {
144
+ lineColor: lineColor,
145
+ lineOpacity: lineOpacity,
146
+ fillColor: fillColor,
147
+ fillOpacity: fillOpacity
148
+ })), titlePosition.current && React__default["default"].createElement(MapMarkerWrapper, tslib.__assign({}, titlePosition.current), titleElement ? titleElement : React__default["default"].createElement("div", {
149
+ style: {
150
+ width: '150px',
151
+ height: '30px',
152
+ display: 'flex',
153
+ alignItems: 'center',
154
+ justifyContent: 'center',
155
+ position: 'absolute',
156
+ left: 'calc(50% - 75px)',
157
+ top: '-35px'
158
+ }
159
+ }, React__default["default"].createElement("div", {
160
+ style: {
161
+ maxWidth: '150px',
162
+ border: '1px solid gray',
163
+ borderRadius: '5px',
164
+ padding: '2px 5px',
165
+ background: 'white',
166
+ fontSize: '12px',
167
+ fontWeight: 600,
168
+ color: '#006fd1'
169
+ }
170
+ }, "".concat(title, " (").concat(numberOfFloor, "\uCE35)")))));
171
+ }
172
+
173
+ exports.MapBuildingProjection = MapBuildingProjection;
@@ -0,0 +1,6 @@
1
+ import { Marker } from "../../MintMap";
2
+ import { MapMarkerMoving } from "../wrapper/MapMarkerWrapper";
3
+ export interface MapMarkerMovingHookProps extends MapMarkerMoving {
4
+ marker?: Marker;
5
+ }
6
+ export declare function useMarkerMoving({ marker, positions, positionClosed, loop, fps, startPositionIndex, velocity, onMovingStart, onMovingEnd }: MapMarkerMovingHookProps): (() => void)[];
@@ -0,0 +1,145 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var MintMapProvider = require('../provider/MintMapProvider.js');
7
+ var animation = require('../util/animation.js');
8
+ var calculate = require('../util/calculate.js');
9
+
10
+ function nextIndex(array, currIdx) {
11
+ var next = currIdx + 1;
12
+
13
+ if (next > array.length - 1) {
14
+ next = 0;
15
+ }
16
+
17
+ return next;
18
+ }
19
+
20
+ function useMarkerMoving(_a) {
21
+ var _b = _a.marker,
22
+ marker = _b === void 0 ? undefined : _b,
23
+ _c = _a.positions,
24
+ positions = _c === void 0 ? [] : _c,
25
+ _d = _a.positionClosed,
26
+ positionClosed = _d === void 0 ? false : _d,
27
+ _e = _a.loop,
28
+ loop = _e === void 0 ? false : _e,
29
+ _f = _a.fps,
30
+ fps = _f === void 0 ? 1 : _f,
31
+ _g = _a.startPositionIndex,
32
+ startPositionIndex = _g === void 0 ? 0 : _g,
33
+ _h = _a.velocity,
34
+ velocity = _h === void 0 ? 10 : _h,
35
+ onMovingStart = _a.onMovingStart,
36
+ onMovingEnd = _a.onMovingEnd;
37
+ var controller = MintMapProvider.useMintMapController();
38
+ React.useEffect(function () {
39
+ contextRef.current && (contextRef.current.velocityKmh = velocity);
40
+ }, [velocity]);
41
+ var contextRef = React.useRef();
42
+ React.useEffect(function () {
43
+ if (marker) {
44
+ var currTargetIndex_1 = nextIndex(positions, startPositionIndex);
45
+ var stopNext_1 = false;
46
+ var loopCount_1 = 0;
47
+ var context_1 = contextRef.current = {
48
+ pos1: positions[startPositionIndex],
49
+ pos2: positions[currTargetIndex_1],
50
+ velocityKmh: velocity
51
+ };
52
+ var nextOption_1 = {
53
+ position: context_1.nextPos,
54
+ anchor: marker.options.anchor
55
+ };
56
+
57
+ var draw = function (frameGapTime, _elapsedTime) {
58
+ if (!marker) {
59
+ console.log('myMarker is not exist!!!');
60
+ return true;
61
+ }
62
+
63
+ context_1.elapsedTimeMs = frameGapTime;
64
+
65
+ while (true) {
66
+ calculate.GeoCalulator.computeNextPositionAndDistances(context_1);
67
+
68
+ if (context_1.nextPos === context_1.pos2) {
69
+ if (currTargetIndex_1 === startPositionIndex) {
70
+ loopCount_1 += 1;
71
+ }
72
+
73
+ if (!loop && loopCount_1 > 0) {
74
+ stopNext_1 = true;
75
+ break;
76
+ }
77
+
78
+ context_1.pos1 = positions[currTargetIndex_1];
79
+ currTargetIndex_1 = nextIndex(positions, currTargetIndex_1);
80
+
81
+ if (currTargetIndex_1 === 0 && !positionClosed) {
82
+ context_1.pos1 = positions[currTargetIndex_1];
83
+ currTargetIndex_1 = nextIndex(positions, currTargetIndex_1);
84
+ }
85
+
86
+ context_1.pos2 = positions[currTargetIndex_1];
87
+ } else {
88
+ break;
89
+ }
90
+ }
91
+
92
+ nextOption_1.position = context_1.nextPos;
93
+ marker.options.position = nextOption_1.position;
94
+ controller.updateMarker(marker, nextOption_1);
95
+
96
+ if (stopNext_1) {
97
+ onMovingEnd && onMovingEnd();
98
+ return true;
99
+ }
100
+
101
+ return false;
102
+ };
103
+
104
+ player.current = new animation.AnimationPlayer(draw, fps);
105
+ }
106
+
107
+ return function () {
108
+ player.current && player.current.stop();
109
+ };
110
+ }, [marker]);
111
+ var player = React.useRef();
112
+
113
+ var _j = React.useState('stop'),
114
+ playbackStatus = _j[0],
115
+ setPlaybackStatus = _j[1];
116
+
117
+ React.useEffect(function () {
118
+ var _a, _b, _c;
119
+
120
+ if (playbackStatus === 'start') {
121
+ (_a = player === null || player === void 0 ? void 0 : player.current) === null || _a === void 0 ? void 0 : _a.start();
122
+ onMovingStart && onMovingStart();
123
+ } else if (playbackStatus === 'resume') {
124
+ (_b = player === null || player === void 0 ? void 0 : player.current) === null || _b === void 0 ? void 0 : _b.resume();
125
+ } else if (playbackStatus === 'stop') {
126
+ (_c = player === null || player === void 0 ? void 0 : player.current) === null || _c === void 0 ? void 0 : _c.stop();
127
+ }
128
+ }, [playbackStatus]);
129
+
130
+ var start = function () {
131
+ setPlaybackStatus('start');
132
+ };
133
+
134
+ var stop = function () {
135
+ setPlaybackStatus('stop');
136
+ };
137
+
138
+ var resume = function () {
139
+ setPlaybackStatus('resume');
140
+ };
141
+
142
+ return [start, stop, resume];
143
+ }
144
+
145
+ exports.useMarkerMoving = useMarkerMoving;
@@ -0,0 +1,7 @@
1
+ export { default as MintMapController } from "./MintMapController";
2
+ export { default as MapControlWrapper } from './wrapper/MapControlWrapper';
3
+ export { default as MapMarkerWrapper } from './wrapper/MapMarkerWrapper';
4
+ export { default as MapPolygonWrapper } from './wrapper/MapPolygonWrapper';
5
+ export { default as MapPolylineWrapper } from './wrapper/MapPolylineWrapper';
6
+ export { default as MintMapProvider } from "./provider/MintMapProvider";
7
+ export { MapBuildingProjection } from "./advanced/MapBuildingProjection";
@@ -0,0 +1,8 @@
1
+ import { PropsWithChildren } from "react";
2
+ import MintMapController from "../MintMapController";
3
+ interface MintMapProviderProps {
4
+ controller: MintMapController;
5
+ }
6
+ export default function MintMapProvider({ controller, children }: PropsWithChildren<MintMapProviderProps>): JSX.Element;
7
+ export declare function useMintMapController(): MintMapController;
8
+ export {};
@@ -0,0 +1,30 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+
7
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
+
9
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
10
+
11
+ var MintMapControllerContext = React.createContext(null);
12
+ function MintMapProvider(_a) {
13
+ var controller = _a.controller,
14
+ children = _a.children;
15
+ return React__default["default"].createElement(MintMapControllerContext.Provider, {
16
+ value: controller
17
+ }, children);
18
+ }
19
+ function useMintMapController() {
20
+ var controller = React.useContext(MintMapControllerContext);
21
+
22
+ if (controller === null) {
23
+ throw new Error('controller is not initialized');
24
+ }
25
+
26
+ return controller;
27
+ }
28
+
29
+ exports["default"] = MintMapProvider;
30
+ exports.useMintMapController = useMintMapController;
@@ -0,0 +1,16 @@
1
+ export declare type DrawFunction = (frameGapTime: number, elapsedTime: number) => boolean | undefined;
2
+ export declare class AnimationPlayer {
3
+ prevtime: number;
4
+ elapsedTime: number;
5
+ fps: number | null;
6
+ baseDrawGapTime: number | null;
7
+ private deltaTime;
8
+ private playing;
9
+ draw: DrawFunction;
10
+ constructor(drawFunction: DrawFunction, fps?: number);
11
+ init(): void;
12
+ start(): void;
13
+ stop(): void;
14
+ resume(): void;
15
+ makeFrame(timestamp: number): void;
16
+ }
@@ -0,0 +1,70 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var AnimationPlayer = function () {
6
+ function AnimationPlayer(drawFunction, fps) {
7
+ this.prevtime = 0;
8
+ this.elapsedTime = 0;
9
+ this.fps = null;
10
+ this.baseDrawGapTime = null;
11
+ this.deltaTime = 0;
12
+ this.playing = false;
13
+ this.draw = drawFunction;
14
+ this.fps = fps || null;
15
+
16
+ if (fps !== undefined) {
17
+ this.baseDrawGapTime = 1000 / fps;
18
+ }
19
+
20
+ this.init();
21
+ }
22
+
23
+ AnimationPlayer.prototype.init = function () {
24
+ this.deltaTime = 0;
25
+ this.prevtime = 0;
26
+ this.elapsedTime = 0;
27
+ this.playing = false;
28
+ };
29
+
30
+ AnimationPlayer.prototype.start = function () {
31
+ this.init();
32
+ this.resume();
33
+ };
34
+
35
+ AnimationPlayer.prototype.stop = function () {
36
+ this.playing = false;
37
+ };
38
+
39
+ AnimationPlayer.prototype.resume = function () {
40
+ this.playing = true;
41
+ window.requestAnimationFrame(this.makeFrame.bind(this));
42
+ };
43
+
44
+ AnimationPlayer.prototype.makeFrame = function (timestamp) {
45
+ if (this.prevtime === 0) {
46
+ this.prevtime = timestamp;
47
+ }
48
+
49
+ this.deltaTime += timestamp - this.prevtime;
50
+ this.prevtime = timestamp;
51
+
52
+ if (!this.baseDrawGapTime || this.baseDrawGapTime <= this.deltaTime) {
53
+ this.elapsedTime += this.deltaTime;
54
+ var stopFlag = this.draw(this.deltaTime, this.elapsedTime);
55
+ this.deltaTime = 0;
56
+
57
+ if (stopFlag) {
58
+ this.stop();
59
+ }
60
+ }
61
+
62
+ if (this.playing) {
63
+ window.requestAnimationFrame(this.makeFrame.bind(this));
64
+ }
65
+ };
66
+
67
+ return AnimationPlayer;
68
+ }();
69
+
70
+ exports.AnimationPlayer = AnimationPlayer;
@@ -0,0 +1,29 @@
1
+ import { Position } from "../../MintMap";
2
+ export declare class PolygonCalculator {
3
+ static getCenter(positions: Position[]): Position;
4
+ static intersects(positions1: Position[], positions2: Position[]): boolean;
5
+ private static convertPositionToPoints;
6
+ private static findCrossPoint;
7
+ }
8
+ export interface NextPositionContext {
9
+ pos1: Position;
10
+ pos2: Position;
11
+ velocityKmh: number;
12
+ elapsedTimeMs: number;
13
+ totalDistance: number;
14
+ currDistance: number;
15
+ distanceRemain: number;
16
+ prevPos2: Position;
17
+ prevVelocityKmh: number;
18
+ vPerMs: number;
19
+ nextPos: Position;
20
+ }
21
+ export declare class GeoCalulator {
22
+ private static readonly EARTH_RADIUS;
23
+ private static readonly LATITUDE_POSITION_VALUE_PER_METER;
24
+ static computeDistanceKiloMeter(pos1: Position, pos2: Position): number;
25
+ private static deg2rad;
26
+ static convertMeterToLatitudeValue(meter: number): number;
27
+ private static readonly MS_FROM_HOUR;
28
+ static computeNextPositionAndDistances(context: NextPositionContext): NextPositionContext;
29
+ }
@@ -0,0 +1,167 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var MintMap = require('../../MintMap.js');
6
+
7
+ var LinePoints = function () {
8
+ function LinePoints(x1, y1, x2, y2) {
9
+ this.x1 = x1;
10
+ this.y1 = y1;
11
+ this.x2 = x2;
12
+ this.y2 = y2;
13
+ }
14
+
15
+ return LinePoints;
16
+ }();
17
+
18
+ var PolygonCalculator = function () {
19
+ function PolygonCalculator() {}
20
+
21
+ PolygonCalculator.getCenter = function (positions) {
22
+ var maxX, minX, maxY, minY;
23
+
24
+ for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
25
+ var pos = positions_1[_i];
26
+
27
+ if (maxX === undefined || pos.lat > maxX) {
28
+ maxX = pos.lat;
29
+ }
30
+
31
+ if (minX === undefined || pos.lat < minX) {
32
+ minX = pos.lat;
33
+ }
34
+
35
+ if (maxY === undefined || pos.lng > maxY) {
36
+ maxY = pos.lng;
37
+ }
38
+
39
+ if (minY === undefined || pos.lng < minY) {
40
+ minY = pos.lng;
41
+ }
42
+ }
43
+
44
+ if (maxX && minX && maxY && minY) {
45
+ return new MintMap.Position(minX + (maxX - minX) / 2, minY + (maxY - minY) / 2);
46
+ }
47
+
48
+ throw new Error('Calculate Center Error!!!');
49
+ };
50
+
51
+ PolygonCalculator.intersects = function (positions1, positions2) {
52
+ var lines = [];
53
+
54
+ for (var i = 0; i < positions2.length - 1; i++) {
55
+ lines.push(this.convertPositionToPoints(positions2[i], positions2[i + 1]));
56
+ }
57
+
58
+ for (var i = 0; i < positions1.length - 1; i++) {
59
+ var targetLinePoints = this.convertPositionToPoints(positions1[i], positions1[i + 1]);
60
+
61
+ if (this.findCrossPoint(lines, targetLinePoints)) {
62
+ return true;
63
+ }
64
+ }
65
+
66
+ return false;
67
+ };
68
+
69
+ PolygonCalculator.convertPositionToPoints = function (pos1, pos2) {
70
+ return new LinePoints(pos1.lng, pos1.lat, pos2.lng, pos2.lat);
71
+ };
72
+
73
+ PolygonCalculator.findCrossPoint = function (sr, tr) {
74
+ for (var _i = 0, sr_1 = sr; _i < sr_1.length; _i++) {
75
+ var tmp = sr_1[_i];
76
+ var p1 = (tmp.x1 - tmp.x2) * (tr.y1 - tr.y2) - (tmp.y1 - tmp.y2) * (tr.x1 - tr.x2);
77
+
78
+ if (p1 != 0) {
79
+ var x = ((tmp.x1 * tmp.y2 - tmp.y1 * tmp.x2) * (tr.x1 - tr.x2) - (tmp.x1 - tmp.x2) * (tr.x1 * tr.y2 - tr.y1 * tr.x2)) / p1;
80
+ var y = ((tmp.x1 * tmp.y2 - tmp.y1 * tmp.x2) * (tr.y1 - tr.y2) - (tmp.y1 - tmp.y2) * (tr.x1 * tr.y2 - tr.y1 * tr.x2)) / p1;
81
+
82
+ if ((x - tmp.x1) * (x - tmp.x2) <= 0 && (y - tmp.y1) * (y - tmp.y2) <= 0 && (x - tr.x1) * (x - tr.x2) <= 0 && (y - tr.y1) * (y - tr.y2) <= 0) {
83
+ return true;
84
+ }
85
+ }
86
+ }
87
+
88
+ return false;
89
+ };
90
+
91
+ return PolygonCalculator;
92
+ }();
93
+
94
+ var GeoCalulator = function () {
95
+ function GeoCalulator() {}
96
+
97
+ GeoCalulator.computeDistanceKiloMeter = function (pos1, pos2) {
98
+ var dLat = this.deg2rad(pos2.lat - pos1.lat);
99
+ var dLon = this.deg2rad(pos2.lng - pos1.lng);
100
+ var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(this.deg2rad(pos1.lat)) * Math.cos(this.deg2rad(pos2.lat)) * Math.sin(dLon / 2) * Math.sin(dLon / 2);
101
+ var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
102
+ var d = this.EARTH_RADIUS * c;
103
+ return d;
104
+ };
105
+
106
+ GeoCalulator.deg2rad = function (deg) {
107
+ return deg * (Math.PI / 180);
108
+ };
109
+
110
+ GeoCalulator.convertMeterToLatitudeValue = function (meter) {
111
+ return meter * this.LATITUDE_POSITION_VALUE_PER_METER;
112
+ };
113
+
114
+ GeoCalulator.computeNextPositionAndDistances = function (context) {
115
+ var pos1 = context.pos1,
116
+ pos2 = context.pos2,
117
+ prevPos2 = context.prevPos2,
118
+ velocityKmh = context.velocityKmh,
119
+ prevVelocityKmh = context.prevVelocityKmh,
120
+ elapsedTimeMs = context.elapsedTimeMs;
121
+
122
+ if (pos2 !== prevPos2) {
123
+ context.totalDistance = this.computeDistanceKiloMeter(pos1, pos2);
124
+ context.currDistance = 0;
125
+ context.prevPos2 = pos2;
126
+ }
127
+
128
+ var totalDistance = context.totalDistance;
129
+
130
+ if (velocityKmh !== prevVelocityKmh) {
131
+ context.vPerMs = velocityKmh / this.MS_FROM_HOUR;
132
+ context.prevVelocityKmh = velocityKmh;
133
+ }
134
+
135
+ var vPerMs = context.vPerMs;
136
+ var nextDistance = context.distanceRemain ? context.distanceRemain : context.currDistance + elapsedTimeMs * vPerMs;
137
+ context.currDistance = nextDistance;
138
+
139
+ if (totalDistance < context.currDistance) {
140
+ context.distanceRemain = context.currDistance - totalDistance;
141
+ context.nextPos = pos2;
142
+ return context;
143
+ } else {
144
+ context.distanceRemain = 0;
145
+ }
146
+
147
+ var ratio = nextDistance / totalDistance;
148
+ var latCalib = pos2.lat > pos1.lat ? 1 : -1;
149
+ var lngCalib = pos2.lng > pos1.lng ? 1 : -1;
150
+ var newPos = new MintMap.Position(pos1.lat + (pos2.lat - pos1.lat) * ratio, pos1.lng + (pos2.lng - pos1.lng) * ratio);
151
+
152
+ if ((latCalib === 1 && pos2.lat <= newPos.lat || latCalib === -1 && pos2.lat >= newPos.lat) && (lngCalib === 1 && pos2.lng <= newPos.lng || lngCalib === -1 && pos2.lng >= newPos.lng)) {
153
+ newPos = pos2;
154
+ }
155
+
156
+ context.nextPos = newPos;
157
+ return context;
158
+ };
159
+
160
+ GeoCalulator.EARTH_RADIUS = 6371;
161
+ GeoCalulator.LATITUDE_POSITION_VALUE_PER_METER = 1 / (110 * 1000);
162
+ GeoCalulator.MS_FROM_HOUR = 60 * 60 * 1000;
163
+ return GeoCalulator;
164
+ }();
165
+
166
+ exports.GeoCalulator = GeoCalulator;
167
+ exports.PolygonCalculator = PolygonCalculator;
@@ -0,0 +1 @@
1
+ export default function waiting(evaluation: () => boolean, timeoutSeconds?: number): Promise<boolean>;
@@ -0,0 +1,11 @@
1
+ import { PropsWithChildren } from "react";
2
+ declare type AlignHorizontal = 'left' | 'right' | 'center';
3
+ declare type AlignVertical = 'top' | 'bottom' | 'center';
4
+ export interface MapControlWrapperProps {
5
+ width?: number | string;
6
+ height?: number | string;
7
+ positionHorizontal?: AlignHorizontal;
8
+ positionVertical?: AlignVertical;
9
+ }
10
+ export default function MapControlWrapper({ width, height, positionHorizontal, positionVertical, children }: PropsWithChildren<MapControlWrapperProps>): JSX.Element;
11
+ export {};