@dereekb/util 9.2.0 → 9.3.0

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
@@ -2,6 +2,17 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ # [9.3.0](https://github.com/dereekb/dbx-components/compare/v9.2.0-dev...v9.3.0) (2022-08-20)
6
+
7
+
8
+ ### Features
9
+
10
+ * added DbxMapboxMapStore ([9397b9a](https://github.com/dereekb/dbx-components/commit/9397b9a5951abe909d4539176d266c2934189034))
11
+ * added IsWithinLatLngBoundFunction() ([c986e5b](https://github.com/dereekb/dbx-components/commit/c986e5bfe1742319526f0d1ec62e3c3a09c47d2d))
12
+ * added Mapbox functions to DbxMapboxStore ([9a9f5f4](https://github.com/dereekb/dbx-components/commit/9a9f5f4a22088be4a5c170dffe6cc2eb9f66731b))
13
+
14
+
15
+
5
16
  # [9.2.0](https://github.com/dereekb/dbx-components/compare/v9.1.2-dev...v9.2.0) (2022-08-18)
6
17
 
7
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/util",
3
- "version": "9.2.0",
3
+ "version": "9.3.0",
4
4
  "type": "commonjs",
5
5
  "exports": {
6
6
  ".": {
@@ -0,0 +1,87 @@
1
+ import { Rectangle } from './vector';
2
+ import { LatLngPoint, LatLngPointInput, LatLngPrecision, LatLngPointFunction } from './point';
3
+ export declare type LatLngBoundSouthWestPoint = LatLngPoint;
4
+ export declare type LatLngBoundNothEastPoint = LatLngPoint;
5
+ export interface LatLngBound {
6
+ sw: LatLngBoundSouthWestPoint;
7
+ ne: LatLngBoundNothEastPoint;
8
+ }
9
+ export declare function isLatLngBound(input: LatLngBound | unknown): input is LatLngBound;
10
+ export declare function isSameLatLngBound(a: LatLngBound, b: LatLngBound): boolean;
11
+ /**
12
+ * Returns true if the input LatLngBound wrap across the wrapped longitudinal edge of a map.
13
+ *
14
+ * @param bound
15
+ * @returns
16
+ */
17
+ export declare function latLngBoundWrapsMap(bound: LatLngBound): boolean;
18
+ export declare function latLngBoundNorthEastPoint(bound: LatLngBound): LatLngPoint;
19
+ export declare function latLngBoundNorthWestPoint(bound: LatLngBound): LatLngPoint;
20
+ export declare function latLngBoundSouthEastPoint(bound: LatLngBound): LatLngPoint;
21
+ export declare function latLngBoundSouthWestPoint(bound: LatLngBound): LatLngPoint;
22
+ export declare function latLngBoundCenterPoint(bound: LatLngBound): LatLngPoint;
23
+ export declare function latLngBoundNorthBound(bound: LatLngBound): number;
24
+ export declare function latLngBoundSouthBound(bound: LatLngBound): number;
25
+ export declare function latLngBoundEastBound(bound: LatLngBound): number;
26
+ export declare function latLngBoundWestBound(bound: LatLngBound): number;
27
+ /**
28
+ * Tuple of the sw corner and the north east point.
29
+ */
30
+ export declare type LatLngBoundTuple = [LatLngBoundSouthWestPoint | LatLngPointInput, LatLngBoundNothEastPoint | LatLngPointInput];
31
+ export declare type LatLngBoundTuplePoints = [LatLngPointInput, LatLngPointInput, LatLngPointInput, LatLngPointInput];
32
+ export declare type LatLngBoundInput = LatLngBound | LatLngBoundTuple | LatLngBoundTuplePoints;
33
+ export declare function latLngBoundTuple(input: LatLngBoundSouthWestPoint | LatLngBoundInput, inputNe?: LatLngBoundNothEastPoint): LatLngBoundTuple;
34
+ /**
35
+ * Converts the input to a LatLngString
36
+ */
37
+ export declare type LatLngBoundTupleFunction = ((input: LatLngBoundSouthWestPoint | LatLngBoundInput, inputNe?: LatLngBoundNothEastPoint) => LatLngBoundTuple) & ((sw: LatLngBoundSouthWestPoint, ne: LatLngBoundNothEastPoint) => LatLngBoundTuple) & ((bound: LatLngBoundInput) => LatLngBoundTuple);
38
+ export declare type LatLngBoundTupleFunctionConfig = LatLngBoundFunctionConfig;
39
+ /**
40
+ * Creates a LatLngBoundTupleFunction
41
+ *
42
+ * @param precision
43
+ * @returns
44
+ */
45
+ export declare function latLngBoundTupleFunction(config?: LatLngBoundTupleFunctionConfig): LatLngBoundTupleFunction;
46
+ export declare function latLngBound(input: LatLngBoundSouthWestPoint | LatLngBoundInput, inputNe?: LatLngBoundNothEastPoint): LatLngBound;
47
+ /**
48
+ * Converts the input to a LatLngBound
49
+ */
50
+ export declare type LatLngBoundFunction = ((input: LatLngBoundSouthWestPoint | LatLngBoundInput, inputNe?: LatLngBoundNothEastPoint) => LatLngBound) & ((sw: LatLngBoundSouthWestPoint, ne: LatLngBoundNothEastPoint) => LatLngBound) & ((bound: LatLngBoundInput) => LatLngBound);
51
+ export interface LatLngBoundFunctionConfig {
52
+ /**
53
+ * Point function to use for calculations.
54
+ */
55
+ pointFunction?: LatLngPointFunction;
56
+ /**
57
+ * LatLngPrecision to use if pointFunction is not provided.
58
+ */
59
+ precision?: LatLngPrecision;
60
+ }
61
+ export declare function latLngBoundFunction(config?: LatLngBoundFunctionConfig): LatLngBoundFunction;
62
+ /**
63
+ * Function that returns true if the input is entirely within the context's bound.
64
+ */
65
+ export declare type IsWithinLatLngBoundFunction = ((boundOrPoint: LatLngBound | LatLngPoint) => boolean) & {
66
+ readonly _bound: LatLngBound;
67
+ };
68
+ export declare function isWithinLatLngBoundFunction(bound: LatLngBound): IsWithinLatLngBoundFunction;
69
+ export declare function isLatLngBoundWithinLatLngBound(bound: LatLngBound, within: LatLngBound): boolean;
70
+ export declare function isLatLngPointWithinLatLngBound(point: LatLngPoint, within: LatLngBound): boolean;
71
+ /**
72
+ * Function that returns true if the input overlaps the context's bound.
73
+ */
74
+ export declare type OverlapsLatLngBoundFunction = ((boundOrPoint: LatLngBound | LatLngPoint) => boolean) & {
75
+ readonly _bound: LatLngBound;
76
+ };
77
+ export declare function latLngBoundOverlapsLatLngBound(a: LatLngBound, b: LatLngBound): boolean;
78
+ export declare function overlapsLatLngBoundFunction(bound: LatLngBound): OverlapsLatLngBoundFunction;
79
+ export declare const TOTAL_SPAN_OF_LONGITUDE = 360;
80
+ /**
81
+ * "normalizes" the space so that the left -180 longitudinal bound will begin at 360.
82
+ *
83
+ * This turns the latitude/longitude into two rectangles in an arbitrary space that can be safely compared without worrying about wrapping.
84
+ *
85
+ * @param bound
86
+ */
87
+ export declare function boundToRectangle(bound: LatLngBound): Rectangle;
@@ -0,0 +1,207 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.boundToRectangle = exports.TOTAL_SPAN_OF_LONGITUDE = exports.overlapsLatLngBoundFunction = exports.latLngBoundOverlapsLatLngBound = exports.isLatLngPointWithinLatLngBound = exports.isLatLngBoundWithinLatLngBound = exports.isWithinLatLngBoundFunction = exports.latLngBoundFunction = exports.latLngBound = exports.latLngBoundTupleFunction = exports.latLngBoundTuple = exports.latLngBoundWestBound = exports.latLngBoundEastBound = exports.latLngBoundSouthBound = exports.latLngBoundNorthBound = exports.latLngBoundCenterPoint = exports.latLngBoundSouthWestPoint = exports.latLngBoundSouthEastPoint = exports.latLngBoundNorthWestPoint = exports.latLngBoundNorthEastPoint = exports.latLngBoundWrapsMap = exports.isSameLatLngBound = exports.isLatLngBound = void 0;
4
+ const vector_1 = require("./vector");
5
+ const point_1 = require("./point");
6
+ function isLatLngBound(input) {
7
+ return typeof input === 'object' && input.sw !== null && input.ne !== null;
8
+ }
9
+ exports.isLatLngBound = isLatLngBound;
10
+ function isSameLatLngBound(a, b) {
11
+ return (0, point_1.isSameLatLngPoint)(a.sw, b.sw) && (0, point_1.isSameLatLngPoint)(a.ne, b.ne);
12
+ }
13
+ exports.isSameLatLngBound = isSameLatLngBound;
14
+ /**
15
+ * Returns true if the input LatLngBound wrap across the wrapped longitudinal edge of a map.
16
+ *
17
+ * @param bound
18
+ * @returns
19
+ */
20
+ function latLngBoundWrapsMap(bound) {
21
+ return bound.sw.lng > bound.ne.lng;
22
+ }
23
+ exports.latLngBoundWrapsMap = latLngBoundWrapsMap;
24
+ function latLngBoundNorthEastPoint(bound) {
25
+ return bound.ne;
26
+ }
27
+ exports.latLngBoundNorthEastPoint = latLngBoundNorthEastPoint;
28
+ function latLngBoundNorthWestPoint(bound) {
29
+ return { lat: bound.ne.lat, lng: bound.sw.lng };
30
+ }
31
+ exports.latLngBoundNorthWestPoint = latLngBoundNorthWestPoint;
32
+ function latLngBoundSouthEastPoint(bound) {
33
+ return { lat: bound.sw.lat, lng: bound.ne.lng };
34
+ }
35
+ exports.latLngBoundSouthEastPoint = latLngBoundSouthEastPoint;
36
+ function latLngBoundSouthWestPoint(bound) {
37
+ return bound.sw;
38
+ }
39
+ exports.latLngBoundSouthWestPoint = latLngBoundSouthWestPoint;
40
+ function latLngBoundCenterPoint(bound) {
41
+ const { sw, ne } = bound;
42
+ const lat = (sw.lng + ne.lng) / 2;
43
+ const lng = (sw.lat + ne.lat) / 2;
44
+ return { lat, lng };
45
+ }
46
+ exports.latLngBoundCenterPoint = latLngBoundCenterPoint;
47
+ function latLngBoundNorthBound(bound) {
48
+ return bound.ne.lat;
49
+ }
50
+ exports.latLngBoundNorthBound = latLngBoundNorthBound;
51
+ function latLngBoundSouthBound(bound) {
52
+ return bound.sw.lat;
53
+ }
54
+ exports.latLngBoundSouthBound = latLngBoundSouthBound;
55
+ function latLngBoundEastBound(bound) {
56
+ return bound.ne.lng;
57
+ }
58
+ exports.latLngBoundEastBound = latLngBoundEastBound;
59
+ function latLngBoundWestBound(bound) {
60
+ return bound.sw.lng;
61
+ }
62
+ exports.latLngBoundWestBound = latLngBoundWestBound;
63
+ // MARK: BoundTuple
64
+ function latLngBoundTuple(input, inputNe) {
65
+ return latLngBoundTupleFunction()(input, inputNe);
66
+ }
67
+ exports.latLngBoundTuple = latLngBoundTuple;
68
+ /**
69
+ * Creates a LatLngBoundTupleFunction
70
+ *
71
+ * @param precision
72
+ * @returns
73
+ */
74
+ function latLngBoundTupleFunction(config) {
75
+ const fn = latLngBoundFunction(config);
76
+ return (input, inputNe) => {
77
+ const latLngBound = fn(input, inputNe);
78
+ return [latLngBound.sw, latLngBound.ne];
79
+ };
80
+ }
81
+ exports.latLngBoundTupleFunction = latLngBoundTupleFunction;
82
+ // MARK: Bound
83
+ function latLngBound(input, inputNe) {
84
+ return latLngBoundFunction()(input, inputNe);
85
+ }
86
+ exports.latLngBound = latLngBound;
87
+ function latLngBoundFunction(config) {
88
+ const { pointFunction, precision } = config !== null && config !== void 0 ? config : {};
89
+ const latLngPoint = pointFunction !== null && pointFunction !== void 0 ? pointFunction : (0, point_1.latLngPointFunction)({ precision });
90
+ return (input, inputNe) => {
91
+ let bound;
92
+ if (Array.isArray(input)) {
93
+ if (input.length === 2) {
94
+ const [sw, ne] = input;
95
+ bound = {
96
+ sw: latLngPoint(sw),
97
+ ne: latLngPoint(ne)
98
+ };
99
+ }
100
+ else if (input.length === 4) {
101
+ const points = input.map(latLngPoint);
102
+ const lats = points.map((x) => x.lat);
103
+ const lngs = points.map((x) => x.lng);
104
+ const minLat = Math.min(...lats);
105
+ const maxLat = Math.max(...lats);
106
+ const minLng = Math.min(...lngs);
107
+ const maxLng = Math.max(...lngs);
108
+ bound = {
109
+ sw: latLngPoint([minLat, minLng]),
110
+ ne: latLngPoint([maxLat, maxLng])
111
+ };
112
+ }
113
+ }
114
+ else if (input && inputNe) {
115
+ bound = { sw: input, ne: inputNe };
116
+ }
117
+ else if (input.sw && input.ne) {
118
+ bound = input;
119
+ }
120
+ if (!bound) {
121
+ throw new Error(`Invalid latLngBound input "${input}" + "${inputNe}"`);
122
+ }
123
+ return bound;
124
+ };
125
+ }
126
+ exports.latLngBoundFunction = latLngBoundFunction;
127
+ function isWithinLatLngBoundFunction(bound) {
128
+ const fn = ((boundOrPoint) => {
129
+ if ((0, point_1.isLatLngPoint)(boundOrPoint)) {
130
+ return isLatLngPointWithinLatLngBound(boundOrPoint, bound);
131
+ }
132
+ else {
133
+ return isLatLngBoundWithinLatLngBound(boundOrPoint, bound);
134
+ }
135
+ });
136
+ fn._bound = bound;
137
+ return fn;
138
+ }
139
+ exports.isWithinLatLngBoundFunction = isWithinLatLngBoundFunction;
140
+ function isLatLngBoundWithinLatLngBound(bound, within) {
141
+ return isLatLngPointWithinLatLngBound(bound.sw, within) && isLatLngPointWithinLatLngBound(bound.ne, within);
142
+ }
143
+ exports.isLatLngBoundWithinLatLngBound = isLatLngBoundWithinLatLngBound;
144
+ function isLatLngPointWithinLatLngBound(point, within) {
145
+ const { sw, ne } = within;
146
+ const latIsBounded = sw.lat <= point.lat && ne.lat <= point.lat;
147
+ if (latIsBounded) {
148
+ if (latLngBoundWrapsMap(within)) {
149
+ // test for map wrapping
150
+ return sw.lng >= point.lng && ne.lat >= point.lng;
151
+ }
152
+ else {
153
+ return sw.lng <= point.lng && ne.lat <= point.lng;
154
+ }
155
+ }
156
+ return false;
157
+ }
158
+ exports.isLatLngPointWithinLatLngBound = isLatLngPointWithinLatLngBound;
159
+ function latLngBoundOverlapsLatLngBound(a, b) {
160
+ return overlapsLatLngBoundFunction(a)(b);
161
+ }
162
+ exports.latLngBoundOverlapsLatLngBound = latLngBoundOverlapsLatLngBound;
163
+ function overlapsLatLngBoundFunction(bound) {
164
+ const a = boundToRectangle(bound);
165
+ const fn = ((boundOrPoint) => {
166
+ if ((0, point_1.isLatLngPoint)(boundOrPoint)) {
167
+ console.log('x', boundOrPoint);
168
+ return isLatLngPointWithinLatLngBound(boundOrPoint, bound);
169
+ }
170
+ else {
171
+ return (0, vector_1.rectangleOverlapsRectangle)(a, boundToRectangle(boundOrPoint));
172
+ }
173
+ });
174
+ fn._bound = bound;
175
+ return fn;
176
+ }
177
+ exports.overlapsLatLngBoundFunction = overlapsLatLngBoundFunction;
178
+ exports.TOTAL_SPAN_OF_LONGITUDE = 360;
179
+ /**
180
+ * "normalizes" the space so that the left -180 longitudinal bound will begin at 360.
181
+ *
182
+ * This turns the latitude/longitude into two rectangles in an arbitrary space that can be safely compared without worrying about wrapping.
183
+ *
184
+ * @param bound
185
+ */
186
+ function boundToRectangle(bound) {
187
+ function pointToVector(point, lngOffset = 0) {
188
+ return { x: point.lng + exports.TOTAL_SPAN_OF_LONGITUDE + lngOffset, y: point.lat };
189
+ }
190
+ let tr;
191
+ let bl;
192
+ if (latLngBoundWrapsMap(bound)) {
193
+ // compute the NE/TR corner first
194
+ tr = pointToVector(bound.ne);
195
+ const swDistanceToBound = bound.sw.lng - 180;
196
+ const neDistanceToBound = bound.ne.lng + 180;
197
+ const totalOffset = neDistanceToBound - swDistanceToBound;
198
+ bl = { x: tr.x - totalOffset, y: bound.sw.lat };
199
+ }
200
+ else {
201
+ tr = pointToVector(bound.ne);
202
+ bl = pointToVector(bound.sw);
203
+ }
204
+ return { bl, tr };
205
+ }
206
+ exports.boundToRectangle = boundToRectangle;
207
+ //# sourceMappingURL=bound.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bound.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/value/bound.ts"],"names":[],"mappings":";;;AAAA,qCAAyE;AAEzE,mCAAqJ;AAUrJ,SAAgB,aAAa,CAAC,KAA4B;IACxD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAK,KAAqB,CAAC,EAAE,KAAK,IAAI,IAAK,KAAqB,CAAC,EAAE,KAAK,IAAI,CAAC;AAC/G,CAAC;AAFD,sCAEC;AAED,SAAgB,iBAAiB,CAAC,CAAc,EAAE,CAAc;IAC9D,OAAO,IAAA,yBAAiB,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,IAAA,yBAAiB,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;AACxE,CAAC;AAFD,8CAEC;AAED;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,KAAkB;IACpD,OAAO,KAAK,CAAC,EAAE,CAAC,GAAG,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC;AACrC,CAAC;AAFD,kDAEC;AAED,SAAgB,yBAAyB,CAAC,KAAkB;IAC1D,OAAO,KAAK,CAAC,EAAE,CAAC;AAClB,CAAC;AAFD,8DAEC;AAED,SAAgB,yBAAyB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AAG,iBAAiB,GAAG,iBAAiB,CAAC;QAE1D,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,WAAW,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC;KACjD;SAAM;QACL,EAAE,GAAG,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC7B,EAAE,GAAG,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;KAC9B;IAED,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;AACpB,CAAC;AAvBD,4CAuBC"}
@@ -1,3 +1,4 @@
1
+ export * from './bound';
1
2
  export * from './build';
2
3
  export * from './decision';
3
4
  export * from './equal';
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./bound"), exports);
4
5
  tslib_1.__exportStar(require("./build"), exports);
5
6
  tslib_1.__exportStar(require("./decision"), exports);
6
7
  tslib_1.__exportStar(require("./equal"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/value/index.ts"],"names":[],"mappings":";;;AAAA,kDAAwB;AACxB,qDAA2B;AAC3B,kDAAwB;AACxB,oDAA0B;AAC1B,gDAAsB;AACtB,uDAA6B;AAC7B,kDAAwB;AACxB,qDAA2B;AAC3B,gDAAsB;AACtB,gDAAsB;AACtB,kDAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/value/index.ts"],"names":[],"mappings":";;;AAAA,kDAAwB;AACxB,kDAAwB;AACxB,qDAA2B;AAC3B,kDAAwB;AACxB,oDAA0B;AAC1B,gDAAsB;AACtB,uDAA6B;AAC7B,kDAAwB;AACxB,qDAA2B;AAC3B,gDAAsB;AACtB,gDAAsB;AACtB,kDAAwB"}
@@ -16,6 +16,8 @@ export interface LatLngPoint {
16
16
  lat: Latitude;
17
17
  lng: Longitude;
18
18
  }
19
+ export declare function isLatLngPoint(input: LatLngPoint | unknown): input is LatLngPoint;
20
+ export declare function isSameLatLngPoint(a: LatLngPoint, b: LatLngPoint): boolean;
19
21
  export declare function isValidLatitude(lat: Latitude): boolean;
20
22
  export declare function isValidLongitude(lat: Longitude): boolean;
21
23
  export declare function defaultLatLngPoint(): LatLngPoint;
@@ -27,11 +29,11 @@ export declare function defaultLatLngPoint(): LatLngPoint;
27
29
  */
28
30
  export declare function isValidLatLngPoint(input: LatLngPoint): boolean;
29
31
  export declare type LatLngTuple = [Latitude, Longitude];
30
- export declare function latLngTuple(lat: Latitude | LatLngPoint | LatLngString, lng?: Longitude): LatLngTuple;
32
+ export declare function latLngTuple(lat: LatLngPointInput, lng?: Longitude): LatLngTuple;
31
33
  /**
32
34
  * Converts the input to a LatLngString
33
35
  */
34
- export declare type LatLngTupleFunction = ((lat: LatLngInput, lng?: Longitude) => LatLngTuple) & ((latLng: string | LatLngTuple) => LatLngTuple) & ((latLng: LatLngPoint) => LatLngTuple) & ((lat: Latitude, lng?: Longitude) => LatLngTuple);
36
+ export declare type LatLngTupleFunction = ((lat: LatLngPointInput, lng?: Longitude) => LatLngTuple) & ((latLng: string | LatLngTuple) => LatLngTuple) & ((latLng: LatLngPoint) => LatLngTuple) & ((lat: Latitude, lng?: Longitude) => LatLngTuple);
35
37
  export declare type LatLngTupleFunctionConfig = LatLngPointFunctionConfig;
36
38
  /**
37
39
  * Creates a LatLngTupleFunction
@@ -44,7 +46,7 @@ export declare function latLngTupleFunction(config?: LatLngTupleFunctionConfig):
44
46
  * A lat,lng encoded value.
45
47
  */
46
48
  export declare type LatLngString = `${Latitude},${Longitude}`;
47
- export declare type LatLngInput = Latitude | LatLngPoint | LatLngString | LatLngTuple | string;
49
+ export declare type LatLngPointInput = Latitude | LatLngPoint | LatLngString | LatLngTuple | string;
48
50
  export declare type LatLngPrecision = NumberPrecision;
49
51
  /**
50
52
  * Creates a LatLngString from the input.
@@ -122,7 +124,7 @@ export declare function latLngPointPrecisionFunction(precision: LatLngPrecision)
122
124
  /**
123
125
  * Converts the input to a LatLngString
124
126
  */
125
- export declare type LatLngStringFunction = ((lat: LatLngInput, lng?: Longitude) => LatLngString) & ((latLng: string | LatLngString) => LatLngString) & ((latLng: LatLngPoint) => LatLngString) & ((lat: Latitude, lng?: Longitude) => LatLngString);
127
+ export declare type LatLngStringFunction = ((lat: LatLngPointInput, lng?: Longitude) => LatLngString) & ((latLng: string | LatLngString) => LatLngString) & ((latLng: LatLngPoint) => LatLngString) & ((lat: Latitude, lng?: Longitude) => LatLngString);
126
128
  export declare type LatLngStringFunctionConfig = LatLngPointFunctionConfig;
127
129
  /**
128
130
  * Creates a LatLngStringFunction
@@ -134,7 +136,7 @@ export declare function latLngStringFunction(config?: LatLngStringFunctionConfig
134
136
  /**
135
137
  * Converts the input to a LatLngPoint
136
138
  */
137
- export declare type LatLngPointFunction = ((lat: LatLngInput, lng?: Longitude) => LatLngPoint) & ((latLng: string | LatLngString) => LatLngPoint) & ((latLng: LatLngPoint) => LatLngPoint) & ((lat: Latitude, lng?: Longitude) => LatLngPoint);
139
+ export declare type LatLngPointFunction = ((lat: LatLngPointInput, lng?: Longitude) => LatLngPoint) & ((latLng: string | LatLngString) => LatLngPoint) & ((latLng: LatLngPoint) => LatLngPoint) & ((lat: Latitude, lng: Longitude) => LatLngPoint);
138
140
  export interface LatLngPointFunctionConfig {
139
141
  /**
140
142
  * LatLngPrecision to use
@@ -158,7 +160,7 @@ export interface LatLngPointFunctionConfig {
158
160
  * @param lng
159
161
  * @returns
160
162
  */
161
- export declare function latLngPoint(lat: LatLngInput, lng?: Longitude): LatLngPoint;
163
+ export declare function latLngPoint(lat: LatLngPointInput, lng?: Longitude): LatLngPoint;
162
164
  /**
163
165
  * Creates a LatLngPointFunction
164
166
  *
@@ -213,3 +215,7 @@ export declare type LatLngDataPointFunction<T extends LatLngRef> = (data: T) =>
213
215
  * @returns
214
216
  */
215
217
  export declare function latLngDataPointFunction<T extends LatLngRef>(config?: LatLngPointFunctionConfig): LatLngDataPointFunction<T>;
218
+ /**
219
+ * @deprecated use LatLngPointInput
220
+ */
221
+ export declare type LatLngInput = LatLngPointInput;
@@ -1,11 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.latLngDataPointFunction = exports.validLatLngPointFunction = exports.validLatLngPoint = exports.latLngPointFromString = exports.latLngPointFunction = exports.latLngPoint = exports.latLngStringFunction = exports.latLngPointPrecisionFunction = exports.LAT_LONG_GRAINS_OF_SAND_PRECISION = exports.LAT_LONG_1MM_PRECISION = exports.LAT_LONG_1CM_PRECISION = exports.LAT_LONG_10CM_PRECISION = exports.LAT_LONG_1M_PRECISION = exports.LAT_LONG_10M_PRECISION = exports.LAT_LONG_100M_PRECISION = exports.LAT_LONG_1KM_PRECISION = exports.LAT_LONG_10KM_PRECISION = exports.LAT_LONG_100KM_PRECISION = exports.isLatLngString = exports.LAT_LNG_PATTERN = exports.LAT_LNG_PATTERN_MAX_PRECISION = exports.latLngString = exports.latLngTupleFunction = exports.latLngTuple = exports.isValidLatLngPoint = exports.defaultLatLngPoint = exports.isValidLongitude = exports.isValidLatitude = exports.MAX_LONGITUDE_VALUE = exports.MIN_LONGITUDE_VALUE = exports.MAX_LATITUDE_VALUE = exports.MIN_LATITUDE_VALUE = void 0;
3
+ exports.latLngDataPointFunction = exports.validLatLngPointFunction = exports.validLatLngPoint = exports.latLngPointFromString = exports.latLngPointFunction = exports.latLngPoint = exports.latLngStringFunction = exports.latLngPointPrecisionFunction = exports.LAT_LONG_GRAINS_OF_SAND_PRECISION = exports.LAT_LONG_1MM_PRECISION = exports.LAT_LONG_1CM_PRECISION = exports.LAT_LONG_10CM_PRECISION = exports.LAT_LONG_1M_PRECISION = exports.LAT_LONG_10M_PRECISION = exports.LAT_LONG_100M_PRECISION = exports.LAT_LONG_1KM_PRECISION = exports.LAT_LONG_10KM_PRECISION = exports.LAT_LONG_100KM_PRECISION = exports.isLatLngString = exports.LAT_LNG_PATTERN = exports.LAT_LNG_PATTERN_MAX_PRECISION = exports.latLngString = exports.latLngTupleFunction = exports.latLngTuple = exports.isValidLatLngPoint = exports.defaultLatLngPoint = exports.isValidLongitude = exports.isValidLatitude = exports.isSameLatLngPoint = exports.isLatLngPoint = exports.MAX_LONGITUDE_VALUE = exports.MIN_LONGITUDE_VALUE = exports.MAX_LATITUDE_VALUE = exports.MIN_LATITUDE_VALUE = void 0;
4
4
  const round_1 = require("../number/round");
5
5
  exports.MIN_LATITUDE_VALUE = -90.0;
6
6
  exports.MAX_LATITUDE_VALUE = 90.0;
7
7
  exports.MIN_LONGITUDE_VALUE = -180.0;
8
8
  exports.MAX_LONGITUDE_VALUE = 180.0;
9
+ function isLatLngPoint(input) {
10
+ return typeof input === 'object' && input.lat != null && input.lng != null;
11
+ }
12
+ exports.isLatLngPoint = isLatLngPoint;
13
+ function isSameLatLngPoint(a, b) {
14
+ return a.lat === b.lat && a.lng === b.lng;
15
+ }
16
+ exports.isSameLatLngPoint = isSameLatLngPoint;
9
17
  function isValidLatitude(lat) {
10
18
  return lat >= exports.MIN_LATITUDE_VALUE && lat <= exports.MAX_LATITUDE_VALUE;
11
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"point.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/value/point.ts"],"names":[],"mappings":";;;AACA,2CAA+E;AAalE,QAAA,kBAAkB,GAAG,CAAC,IAAI,CAAC;AAC3B,QAAA,kBAAkB,GAAG,IAAI,CAAC;AAC1B,QAAA,mBAAmB,GAAG,CAAC,KAAK,CAAC;AAC7B,QAAA,mBAAmB,GAAG,KAAK,CAAC;AAOzC,SAAgB,eAAe,CAAC,GAAa;IAC3C,OAAO,GAAG,IAAI,0BAAkB,IAAI,GAAG,IAAI,0BAAkB,CAAC;AAChE,CAAC;AAFD,0CAEC;AAED,SAAgB,gBAAgB,CAAC,GAAc;IAC7C,OAA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M,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACnC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AACtB,CAAC;AALD,sDAKC;AAED,SAAgB,gBAAgB,CAAC,WAAwB,EAAE,YAAmC;IAC5F,OAAO,wBAAwB,CAAC,YAAY,CAAC,CAAC,WAAW,CAAC,CAAC;AAC7D,CAAC;AAFD,4CAEC;AASD,SAAgB,wBAAwB,CAAC,eAAqC,kBAAkB;IAC9F,OAAO,CAAC,WAAwB,EAAE,EAAE,CAAC,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC;AACxG,CAAC;AAFD,4DAEC;AAkCD;;;;;GAKG;AACH,SAAgB,uBAAuB,CAAsB,MAAkC;IAC7F,MAAM,EAAE,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;IACvC,OAAO,CAAC,IAAO,EAAE,EAAE;QACjB,MAAM,MAAM,GAAgB,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC5C,OAAO;YACL,MAAM;YACN,IAAI;SACL,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AATD,0DASC"}
@@ -0,0 +1,26 @@
1
+ import { Maybe } from './maybe.type';
2
+ export interface Vector {
3
+ x: number;
4
+ y: number;
5
+ }
6
+ export declare type RectangleOrigin = Vector;
7
+ export declare type TopRightCorner = Vector;
8
+ export declare type BottomLeftCorner = Vector;
9
+ export interface Rectangle {
10
+ /**
11
+ * Upper-Right/North-East corner.
12
+ */
13
+ tr: TopRightCorner;
14
+ /**
15
+ * Bottom-Left/South-West corner.
16
+ */
17
+ bl: BottomLeftCorner;
18
+ }
19
+ /**
20
+ * Returns true if the input vector overlaps another.
21
+ *
22
+ * @param a
23
+ * @param b
24
+ */
25
+ export declare function rectangleOverlapsRectangle(a: Rectangle, b: Rectangle): boolean;
26
+ export declare function getOverlappingRectangle(a: Rectangle, b: Rectangle): Maybe<Rectangle>;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getOverlappingRectangle = exports.rectangleOverlapsRectangle = void 0;
4
+ /**
5
+ * Returns true if the input vector overlaps another.
6
+ *
7
+ * @param a
8
+ * @param b
9
+ */
10
+ function rectangleOverlapsRectangle(a, b) {
11
+ const { tr: r1, bl: l1 } = a;
12
+ const { tr: r2, bl: l2 } = b;
13
+ let doesNotOverlap = true;
14
+ // corners only touch
15
+ if (l1.x == r1.x || l1.y == r1.y || r2.x == l2.x || l2.y == r2.y) {
16
+ doesNotOverlap = false;
17
+ }
18
+ else if (l1.x > r2.x || l2.x > r1.x) {
19
+ doesNotOverlap = false;
20
+ }
21
+ else if (r1.y < l2.y || r2.y < l1.y) {
22
+ doesNotOverlap = false;
23
+ }
24
+ return doesNotOverlap;
25
+ }
26
+ exports.rectangleOverlapsRectangle = rectangleOverlapsRectangle;
27
+ function getOverlappingRectangle(a, b) {
28
+ var xl = Math.max(a.bl.x, b.bl.x);
29
+ var yl = Math.max(a.bl.y, b.bl.y);
30
+ var xr = Math.min(a.tr.x, b.tr.x);
31
+ var yr = Math.min(a.tr.y, b.tr.y);
32
+ // does not intersect
33
+ if (xl > xr || yl > yr) {
34
+ return undefined;
35
+ }
36
+ let topRight = {
37
+ x: xr,
38
+ y: yr
39
+ };
40
+ let bottomLeft = {
41
+ x: xl,
42
+ y: yl
43
+ };
44
+ return { tr: topRight, bl: bottomLeft };
45
+ }
46
+ exports.getOverlappingRectangle = getOverlappingRectangle;
47
+ //# sourceMappingURL=vector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vector.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/value/vector.ts"],"names":[],"mappings":";;;AAsBA;;;;;GAKG;AACH,SAAgB,0BAA0B,CAAC,CAAY,EAAE,CAAY;IACnE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,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CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAElC,qBAAqB;IACrB,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QACtB,OAAO,SAAS,CAAC;KAClB;IAED,IAAI,QAAQ,GAAmB;QAC7B,CAAC,EAAE,EAAE;QACL,CAAC,EAAE,EAAE;KACN,CAAC;IAEF,IAAI,UAAU,GAAqB;QACjC,CAAC,EAAE,EAAE;QACL,CAAC,EAAE,EAAE;KACN,CAAC;IAEF,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC;AAC1C,CAAC;AAtBD,0DAsBC"}
package/test/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ # [9.3.0](https://github.com/dereekb/dbx-components/compare/v9.2.0-dev...v9.3.0) (2022-08-20)
6
+
7
+
8
+
5
9
  # [9.2.0](https://github.com/dereekb/dbx-components/compare/v9.1.2-dev...v9.2.0) (2022-08-18)
6
10
 
7
11
 
package/test/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@dereekb/util/test",
3
- "version": "9.2.0",
3
+ "version": "9.3.0",
4
4
  "type": "commonjs",
5
5
  "main": "./src/index.js",
6
6
  "typings": "./src/index.d.ts",
7
7
  "dependencies": {},
8
8
  "peerDependencies": {
9
- "@dereekb/util": "9.2.0",
9
+ "@dereekb/util": "9.3.0",
10
10
  "lodash.isequal": "^4.5.0",
11
11
  "make-error": "^1.3.0",
12
12
  "ts-essentials": "^9.1.2",