tg-map-vue3 3.9.8 → 3.9.9

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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,7 @@
4
4
 
5
5
  - ***BREAKING CHANGE***: 依赖[tg-commons](https://www.npmjs.com/package/tg-commons), 移除`typed`/`isDef`等和地图无关的导出
6
6
  - feat: [TgMarker]添加`label`属性, **它和已有的[TgLabel]不能同时设置**
7
+ - feat: 添加球体和线段工具: [SphericalUtil], [PolyUtil]
7
8
 
8
9
  ## 3.8.x
9
10
 
@@ -87,3 +88,5 @@
87
88
  [LatLng]: src/map/lat-lng.ts#L26
88
89
  [BaiduShape]: src/map/map/overlay/shape.ts#L32
89
90
  [MapStyle]: src/map/map/map-options.ts#72
91
+ [PolyUtil]: src/utils/maps-utils/poly-util.ts
92
+ [SphericalUtil]: src/utils/maps-utils/spherical-util.ts
@@ -38,6 +38,7 @@ export * from '../map/map/overlay/rectangle';
38
38
  export * from '../map/types';
39
39
  export * from '../utils/arrays';
40
40
  export * from '../utils/mapped-types';
41
+ export * from '../utils/maps-utils';
41
42
  export { Objects } from '../utils/objects';
42
43
  export * from '../utils/spherical-utils';
43
44
  export * from '../utils/strings';
@@ -0,0 +1,2 @@
1
+ export * as PolyUtil from './poly-util';
2
+ export * as SphericalUtil from './spherical-util';
@@ -0,0 +1,59 @@
1
+ /**
2
+ * The earth's radius, in meters.
3
+ * Mean radius as defined by IUGG.
4
+ */
5
+ export declare const EARTH_RADIUS = 6371009;
6
+ /**
7
+ * Restrict x to the range [low, high].
8
+ */
9
+ export declare function clamp(x: number, low: number, high: number): number;
10
+ /**
11
+ * Wraps the given value into the inclusive-exclusive interval between min and max.
12
+ *
13
+ * @param n The value to wrap.
14
+ * @param min The minimum.
15
+ * @param max The maximum.
16
+ */
17
+ export declare function wrap(n: number, min: number, max: number): number;
18
+ /**
19
+ * Returns the non-negative remainder of x / m.
20
+ *
21
+ * @param x The operand.
22
+ * @param m The modulus.
23
+ */
24
+ export declare function mod(x: number, m: number): number;
25
+ /**
26
+ * Returns mercator Y corresponding to latitude.
27
+ * See http://en.wikipedia.org/wiki/Mercator_projection .
28
+ */
29
+ export declare function mercator(lat: number): number;
30
+ /**
31
+ * Returns latitude from mercator Y.
32
+ */
33
+ export declare function inverseMercator(y: number): number;
34
+ /**
35
+ * Returns haversine(angle-in-radians).
36
+ * hav(x) == (1 - cos(x)) / 2 == sin(x / 2)^2.
37
+ */
38
+ export declare function hav(x: number): number;
39
+ /**
40
+ * Computes inverse haversine. Has good numerical stability around 0.
41
+ * arcHav(x) == acos(1 - 2 * x) == 2 * asin(sqrt(x)).
42
+ * The argument must be in [0, 1], and the result is positive.
43
+ */
44
+ export declare function arcHav(x: number): number;
45
+ export declare function sinFromHav(h: number): number;
46
+ export declare function havFromSin(x: number): number;
47
+ export declare function sinSumFromHav(x: number, y: number): number;
48
+ /**
49
+ * Returns hav() of distance from (lat1, lng1) to (lat2, lng2) on the unit sphere.
50
+ */
51
+ export declare function havDistance(lat1: number, lat2: number, dLng: number): number;
52
+ /**
53
+ * Converts degrees to radians.
54
+ */
55
+ export declare function toRadians(degrees: number): number;
56
+ /**
57
+ * Converts radians to degrees.
58
+ */
59
+ export declare function toDegrees(radians: number): number;
@@ -0,0 +1,103 @@
1
+ import type { LatLngLiteral } from '../../map/lat-lng';
2
+ export declare function containsLocation(point: LatLngLiteral, polygon: LatLngLiteral[], geodesic: boolean): boolean;
3
+ /**
4
+ * Computes whether the given point lies inside the specified polygon.
5
+ * The polygon is always considered closed, regardless of whether the last point equals
6
+ * the first or not.
7
+ * Inside is defined as not containing the South Pole -- the South Pole is always outside.
8
+ * The polygon is formed of great circle segments if geodesic is true, and of rhumb
9
+ * (loxodromic) segments otherwise.
10
+ */
11
+ export declare function containsLocationLatLng(latitude: number, longitude: number, polygon: LatLngLiteral[], geodesic: boolean): boolean;
12
+ /**
13
+ * Computes whether the given point lies on or near the edge of a polygon, within a specified
14
+ * tolerance in meters. The polygon edge is composed of great circle segments if geodesic
15
+ * is true, and of Rhumb segments otherwise. The polygon edge is implicitly closed -- the
16
+ * closing segment between the first point and the last point is included.
17
+ */
18
+ export declare function isLocationOnEdge(point: LatLngLiteral, polygon: LatLngLiteral[], geodesic?: boolean, tolerance?: number): boolean;
19
+ /**
20
+ * Computes whether the given point lies on or near a polyline, within a specified
21
+ * tolerance in meters. The polyline is composed of great circle segments if geodesic
22
+ * is true, and of Rhumb segments otherwise. The polyline is not closed -- the closing
23
+ * segment between the first point and the last point is not included.
24
+ */
25
+ export declare function isLocationOnPath(point: LatLngLiteral, polyline: LatLngLiteral[], geodesic?: boolean, tolerance?: number): boolean;
26
+ /**
27
+ * Computes whether (and where) a given point lies on or near a polyline, within a specified tolerance.
28
+ * The polyline is not closed -- the closing segment between the first point and the last point is not included.
29
+ *
30
+ * @param point our needle
31
+ * @param poly our haystack
32
+ * @param geodesic the polyline is composed of great circle segments if geodesic
33
+ * is true, and of Rhumb segments otherwise
34
+ * @param tolerance tolerance (in meters)
35
+ * @return -1 if point does not lie on or near the polyline.
36
+ * 0 if point is between poly[0] and poly[1] (inclusive),
37
+ * 1 if between poly[1] and poly[2],
38
+ * ...,
39
+ * poly.length-2 if between poly[poly.length - 2] and poly[poly.length - 1]
40
+ */
41
+ export declare function locationIndexOnPath(point: LatLngLiteral, poly: LatLngLiteral[], geodesic: boolean, tolerance?: number): number;
42
+ /**
43
+ * Computes whether (and where) a given point lies on or near a polyline, within a specified tolerance.
44
+ * If closed, the closing segment between the last and first points of the polyline is not considered.
45
+ *
46
+ * @param point our needle
47
+ * @param poly our haystack
48
+ * @param closed whether the polyline should be considered closed by a segment connecting the last point back to the first one
49
+ * @param geodesic the polyline is composed of great circle segments if geodesic
50
+ * is true, and of Rhumb segments otherwise
51
+ * @param toleranceEarth tolerance (in meters)
52
+ * @return -1 if point does not lie on or near the polyline.
53
+ * 0 if point is between poly[0] and poly[1] (inclusive),
54
+ * 1 if between poly[1] and poly[2],
55
+ * ...,
56
+ * poly.length-2 if between poly[poly.length - 2] and poly[poly.length - 1]
57
+ */
58
+ export declare function locationIndexOnEdgeOrPath(point: LatLngLiteral, poly: LatLngLiteral[], closed: boolean, geodesic: boolean, toleranceEarth: number): number;
59
+ /**
60
+ * Simplifies the given poly (polyline or polygon) using the Douglas-Peucker decimation
61
+ * algorithm. Increasing the tolerance will result in fewer points in the simplified polyline
62
+ * or polygon.
63
+ *
64
+ * When the providing a polygon as input, the first and last point of the list MUST have the
65
+ * same latitude and longitude (i.e., the polygon must be closed). If the input polygon is not
66
+ * closed, the resulting polygon may not be fully simplified.
67
+ *
68
+ * The time complexity of Douglas-Peucker is O(n^2), so take care that you do not call this
69
+ * algorithm too frequently in your code.
70
+ *
71
+ * @param poly polyline or polygon to be simplified. Polygon should be closed (i.e.,
72
+ * first and last points should have the same latitude and longitude).
73
+ * @param tolerance in meters. Increasing the tolerance will result in fewer points in the
74
+ * simplified poly.
75
+ * @return a simplified poly produced by the Douglas-Peucker algorithm
76
+ */
77
+ export declare function simplify(poly: LatLngLiteral[], tolerance: number): LatLngLiteral[];
78
+ /**
79
+ * Returns true if the provided list of points is a closed polygon (i.e., the first and last
80
+ * points are the same), and false if it is not
81
+ *
82
+ * @param poly polyline or polygon
83
+ * @return true if the provided list of points is a closed polygon (i.e., the first and last
84
+ * points are the same), and false if it is not
85
+ */
86
+ export declare function isClosedPolygon(poly: LatLngLiteral[]): boolean;
87
+ /**
88
+ * Computes the distance on the sphere between the point p and the line segment start to end.
89
+ *
90
+ * @param p the point to be measured
91
+ * @param start the beginning of the line segment
92
+ * @param end the end of the line segment
93
+ * @return the distance in meters (assuming spherical earth)
94
+ */
95
+ export declare function distanceToLine(p: LatLngLiteral, start: LatLngLiteral, end: LatLngLiteral): number;
96
+ /**
97
+ * Decodes an encoded path string into a sequence of LatLngs.
98
+ */
99
+ export declare function decode(encodedPath: string): LatLngLiteral[];
100
+ /**
101
+ * Encodes a sequence of LatLngs into an encoded path string.
102
+ */
103
+ export declare function encode(path: LatLngLiteral[]): string;
@@ -0,0 +1,67 @@
1
+ import type { LatLngLiteral } from '../../map/lat-lng';
2
+ /**
3
+ * Returns the heading from one LatLng to another LatLng. Headings are
4
+ * expressed in degrees clockwise from North within the range [-180,180).
5
+ *
6
+ * @return The heading in degrees clockwise from north.
7
+ */
8
+ export declare function computeHeading(from: LatLngLiteral, to: LatLngLiteral): number;
9
+ /**
10
+ * Returns the LatLng resulting from moving a distance from an origin
11
+ * in the specified heading (expressed in degrees clockwise from north).
12
+ *
13
+ * @param from The LatLng from which to start.
14
+ * @param distance The distance to travel.
15
+ * @param heading The heading in degrees clockwise from north.
16
+ */
17
+ export declare function computeOffset(from: LatLngLiteral, distance: number, heading: number): LatLngLiteral;
18
+ /**
19
+ * Returns the location of origin when provided with a LatLng destination,
20
+ * meters travelled and original heading. Headings are expressed in degrees
21
+ * clockwise from North. This function returns null when no solution is
22
+ * available.
23
+ *
24
+ * @param to The destination LatLng.
25
+ * @param distance The distance travelled, in meters.
26
+ * @param heading The heading in degrees clockwise from north.
27
+ */
28
+ export declare function computeOffsetOrigin(to: LatLngLiteral, distance: number, heading: number): LatLngLiteral | null;
29
+ /**
30
+ * Returns the LatLng which lies the given fraction of the way between the
31
+ * origin LatLng and the destination LatLng.
32
+ *
33
+ * @param from The LatLng from which to start.
34
+ * @param to The LatLng toward which to travel.
35
+ * @param fraction A fraction of the distance to travel.
36
+ * @return The interpolated LatLng.
37
+ */
38
+ export declare function interpolate(from: LatLngLiteral, to: LatLngLiteral, fraction: number): LatLngLiteral;
39
+ /**
40
+ * Returns the angle between two LatLngs, in radians. This is the same as the distance
41
+ * on the unit sphere.
42
+ */
43
+ export declare function computeAngleBetween(from: LatLngLiteral, to: LatLngLiteral): number;
44
+ /**
45
+ * Returns the distance between two LatLngs, in meters.
46
+ */
47
+ export declare function computeDistanceBetween(from: LatLngLiteral, to: LatLngLiteral): number;
48
+ /**
49
+ * Returns the length of the given path, in meters, on Earth.
50
+ */
51
+ export declare function computeLength(path: LatLngLiteral[]): number;
52
+ /**
53
+ * Returns the area of a closed path on Earth.
54
+ *
55
+ * @param path A closed path.
56
+ * @return The path's area in square meters.
57
+ */
58
+ export declare function computeArea(path: LatLngLiteral[]): number;
59
+ /**
60
+ * Returns the signed area of a closed path on Earth. The sign of the area may be used to
61
+ * determine the orientation of the path.
62
+ * "inside" is the surface that does not contain the South Pole.
63
+ *
64
+ * @param path A closed path.
65
+ * @return The loop's area in square meters.
66
+ */
67
+ export declare function computeSignedArea(path: LatLngLiteral[], radius?: number): number;
@@ -12,9 +12,16 @@ declare function getDistance(p1: LatLngLiteral, p2: LatLngLiteral): number;
12
12
  * @param dist 距离
13
13
  */
14
14
  export declare function getDestination(pt: LatLngLiteral, angle: number, dist: number): LatLngLiteral;
15
- /** 球面工具 */
15
+ /**
16
+ * 球面工具
17
+ *
18
+ * 代码copy自[CityBus-vue-admin](https://github.com/TranscodeGroup/CityBus-vue-admin/blob/8b8db7e23e94423747141084eb78ce3331965a4c/src/utils/index.js#L773), 实现似乎有些问题
19
+ * @deprecated 使用{@link SphericalUtil}替代
20
+ */
16
21
  export declare const SphericalUtils: {
22
+ /** @deprecated Use {@link SphericalUtil.computeDistanceBetween} instead */
17
23
  getDistance: typeof getDistance;
24
+ /** @deprecated Use {@link SphericalUtil.computeOffset} instead */
18
25
  getDestination: typeof getDestination;
19
26
  };
20
27
  export {};