@tmlmobilidade/utils 20250822.1842.40 → 20250822.1906.1
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.
|
@@ -24,14 +24,14 @@ export declare function isValidCoordinatePair(lat: number, lng: number): boolean
|
|
|
24
24
|
*/
|
|
25
25
|
export declare function clampCoordinate(value: number): number;
|
|
26
26
|
/**
|
|
27
|
-
* Parses a coordinate string in the following formats:
|
|
27
|
+
* Parses a coordinate pair string in the following formats:
|
|
28
28
|
* - `lat, lng`
|
|
29
29
|
* - `lat lng` (with a space or a tab)
|
|
30
|
-
* @param input The coordinate string to parse.
|
|
30
|
+
* @param input The coordinate pair string to parse.
|
|
31
31
|
* @param clamp Whether to clamp the latitude and longitude values to 6 decimal places.
|
|
32
32
|
* @returns The parsed coordinates as an object, or null if the input is invalid.
|
|
33
33
|
*/
|
|
34
|
-
export declare const
|
|
34
|
+
export declare const parseCoordinatePairString: (input: string, clamp?: boolean) => null | {
|
|
35
35
|
lat: number;
|
|
36
36
|
lng: number;
|
|
37
37
|
};
|
|
@@ -33,14 +33,14 @@ export function clampCoordinate(value) {
|
|
|
33
33
|
return parseFloat(value.toFixed(6));
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
|
-
* Parses a coordinate string in the following formats:
|
|
36
|
+
* Parses a coordinate pair string in the following formats:
|
|
37
37
|
* - `lat, lng`
|
|
38
38
|
* - `lat lng` (with a space or a tab)
|
|
39
|
-
* @param input The coordinate string to parse.
|
|
39
|
+
* @param input The coordinate pair string to parse.
|
|
40
40
|
* @param clamp Whether to clamp the latitude and longitude values to 6 decimal places.
|
|
41
41
|
* @returns The parsed coordinates as an object, or null if the input is invalid.
|
|
42
42
|
*/
|
|
43
|
-
export const
|
|
43
|
+
export const parseCoordinatePairString = (input, clamp = true) => {
|
|
44
44
|
const regex = /^\s*([+-]?\d+(?:\.\d+)?)\s*(?:,|\s)\s*([+-]?\d+(?:\.\d+)?)\s*$/;
|
|
45
45
|
const match = input.match(regex);
|
|
46
46
|
if (!match)
|
package/package.json
CHANGED