@map-colonies/mc-utils 1.7.0 → 1.7.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.
@@ -1,4 +1,4 @@
1
- import { Feature, MultiPolygon, Polygon } from '@turf/turf';
1
+ import { Feature, FeatureCollection, MultiPolygon, Polygon } from '@turf/turf';
2
2
  /**
3
3
  * tuft intersect supported footprint types
4
4
  */
@@ -9,5 +9,12 @@ declare type Footprint = Polygon | MultiPolygon | Feature<Polygon | MultiPolygon
9
9
  * @returns intersection footprint or null
10
10
  */
11
11
  declare const multiIntersect: (footprints: Footprint[]) => Footprint | null;
12
- export { multiIntersect, Footprint };
12
+ /**
13
+ * indicates if 2 object of type FeatureCollection are equal by validating properties and features array (order not important)
14
+ * @param fc1 first featureCollection to compare equal
15
+ * @param fc2 second featureCollection to compare equal
16
+ * @returns true if same featureCollection, false if not
17
+ */
18
+ declare const featureCollectionBooleanEqual: (fc1: FeatureCollection, fc2: FeatureCollection) => boolean;
19
+ export { multiIntersect, featureCollectionBooleanEqual, Footprint };
13
20
  //# sourceMappingURL=geoIntersection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"geoIntersection.d.ts","sourceRoot":"","sources":["../../src/geo/geoIntersection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAa,YAAY,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAEvE;;GAEG;AACH,OAAO,MAAM,SAAS,GAAG,OAAO,GAAG,YAAY,GAAG,OAAO,CAAC,OAAO,GAAG,YAAY,CAAC,CAAC;AAElF;;;;GAIG;AACH,QAAA,MAAM,cAAc,eAAgB,SAAS,EAAE,KAAG,SAAS,GAAG,IAe7D,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,CAAC"}
1
+ {"version":3,"file":"geoIntersection.d.ts","sourceRoot":"","sources":["../../src/geo/geoIntersection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAa,YAAY,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAG1F;;GAEG;AACH,OAAO,MAAM,SAAS,GAAG,OAAO,GAAG,YAAY,GAAG,OAAO,CAAC,OAAO,GAAG,YAAY,CAAC,CAAC;AAkClF;;;;GAIG;AACH,QAAA,MAAM,cAAc,eAAgB,SAAS,EAAE,KAAG,SAAS,GAAG,IAe7D,CAAC;AAEF;;;;;GAKG;AACH,QAAA,MAAM,6BAA6B,QAAS,iBAAiB,OAAO,iBAAiB,KAAG,OAEvF,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,6BAA6B,EAAE,SAAS,EAAE,CAAC"}
@@ -1,7 +1,40 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.multiIntersect = void 0;
6
+ exports.featureCollectionBooleanEqual = exports.multiIntersect = void 0;
4
7
  var turf_1 = require("@turf/turf");
8
+ var lodash_1 = __importDefault(require("lodash"));
9
+ var featuresCustomizer = function (objectValue, otherValue) {
10
+ // compare features
11
+ // https://lodash.com/docs/4.17.15#find
12
+ if (!lodash_1.default.isEqual(objectValue.length, otherValue.length)) {
13
+ return false;
14
+ }
15
+ for (var i = 0; i < objectValue.length; i++) {
16
+ var isFeatureContained = lodash_1.default.find(otherValue, objectValue[i]);
17
+ if (isFeatureContained === undefined) {
18
+ return false;
19
+ }
20
+ }
21
+ for (var i = 0; i < otherValue.length; i++) {
22
+ var isFeatureContained = lodash_1.default.find(objectValue, otherValue[i]);
23
+ if (isFeatureContained === undefined) {
24
+ return false;
25
+ }
26
+ }
27
+ return true;
28
+ };
29
+ var featureCollectionCustomized = function (objectValue, otherValue) {
30
+ // compare type
31
+ if (!lodash_1.default.isEqual(objectValue.type, otherValue.type)) {
32
+ return false;
33
+ }
34
+ // compare features
35
+ var isFeaturesEqual = lodash_1.default.isEqualWith(objectValue.features, otherValue.features, featuresCustomizer);
36
+ return isFeaturesEqual;
37
+ };
5
38
  /**
6
39
  * return the intersection footprint of all specified footprints or null when there is no intersection
7
40
  * @param footprints footprint list to intersect
@@ -25,4 +58,14 @@ var multiIntersect = function (footprints) {
25
58
  return intersection;
26
59
  };
27
60
  exports.multiIntersect = multiIntersect;
61
+ /**
62
+ * indicates if 2 object of type FeatureCollection are equal by validating properties and features array (order not important)
63
+ * @param fc1 first featureCollection to compare equal
64
+ * @param fc2 second featureCollection to compare equal
65
+ * @returns true if same featureCollection, false if not
66
+ */
67
+ var featureCollectionBooleanEqual = function (fc1, fc2) {
68
+ return lodash_1.default.isEqualWith(fc1, fc2, featureCollectionCustomized);
69
+ };
70
+ exports.featureCollectionBooleanEqual = featureCollectionBooleanEqual;
28
71
  //# sourceMappingURL=geoIntersection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"geoIntersection.js","sourceRoot":"","sources":["../../src/geo/geoIntersection.ts"],"names":[],"mappings":";;;AAAA,mCAAuE;AAOvE;;;;GAIG;AACH,IAAM,cAAc,GAAG,UAAC,UAAuB;IAC7C,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;QAC3B,OAAO,IAAI,CAAC;KACb;SAAM,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;QAClC,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC;KACtB;IACD,IAAI,YAAY,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;IACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC1C,IAAM,eAAe,GAAG,IAAA,gBAAS,EAAC,YAAY,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/D,IAAI,eAAe,KAAK,IAAI,EAAE;YAC5B,OAAO,IAAI,CAAC;SACb;QACD,YAAY,GAAG,eAAe,CAAC;KAChC;IACD,OAAO,YAAY,CAA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AQ,EAAE,kBAAkB,CAAC,CAAC;IACrG,OAAO,eAAe,CAAC;AACzB,CAAC,CAAC;AAEF;;;;GAIG;AACH,IAAM,cAAc,GAAG,UAAC,UAAuB;IAC7C,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;QAC3B,OAAO,IAAI,CAAC;KACb;SAAM,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;QAClC,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC;KACtB;IACD,IAAI,YAAY,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;IACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC1C,IAAM,eAAe,GAAG,IAAA,gBAAS,EAAC,YAAY,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/D,IAAI,eAAe,KAAK,IAAI,EAAE;YAC5B,OAAO,IAAI,CAAC;SACb;QACD,YAAY,GAAG,eAAe,CAAC;KAChC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAYO,wCAAc;AAVvB;;;;;GAKG;AACH,IAAM,6BAA6B,GAAG,UAAC,GAAsB,EAAE,GAAsB;IACnF,OAAO,gBAAC,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,2BAA2B,CAAC,CAAC;AAC9D,CAAC,CAAC;AAEuB,sEAA6B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@map-colonies/mc-utils",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "description": "This is template for map colonies typescript packages",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {