@turf/center-mean 7.1.0 → 7.2.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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../index.ts"],"names":[],"mappings":";AACA,SAAS,UAAU,iBAAiB;AACpC,SAAS,UAAU,aAAiB;AA4BpC,SAAS,WACP,SACA,UAAqE,CAAC,GACnD;AACnB,MAAI,QAAQ;AACZ,MAAI,QAAQ;AACZ,MAAI,QAAQ;AACZ,WAAS,SAAS,SAAU,MAAM,cAAc,YAAY;AAC1D,QAAI,SAAS,QAAQ,SAAS,yCAAa,QAAQ,UAAU;AAC7D,aAAS,WAAW,UAAa,WAAW,OAAO,IAAI;AACvD,QAAI,CAAC,SAAS,MAAM;AAClB,YAAM,IAAI;AAAA,QACR,qDAAqD;AAAA,MACvD;AACF,aAAS,OAAO,MAAM;AACtB,QAAI,SAAS,GAAG;AACd,gBAAU,MAAM,SAAU,OAAO;AAC/B,iBAAS,MAAM,CAAC,IAAI;AACpB,iBAAS,MAAM,CAAC,IAAI;AACpB,iBAAS;AAAA,MACX,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACD,SAAO,MAAM,CAAC,QAAQ,OAAO,QAAQ,KAAK,GAAG,QAAQ,YAAY,OAAO;AAC1E;AAGA,IAAO,2BAAQ","sourcesContent":["import { BBox, Feature, Point, GeoJsonProperties } from \"geojson\";\nimport { geomEach, coordEach } from \"@turf/meta\";\nimport { isNumber, point, Id } from \"@turf/helpers\";\n\n/**\n * Takes a {@link Feature} or {@link FeatureCollection} and returns the mean center. Can be weighted.\n *\n * @name centerMean\n * @param {GeoJSON} geojson GeoJSON to be centered\n * @param {Object} [options={}] Optional parameters\n * @param {Object} [options.properties={}] Translate GeoJSON Properties to Point\n * @param {Object} [options.bbox={}] Translate GeoJSON BBox to Point\n * @param {Object} [options.id={}] Translate GeoJSON Id to Point\n * @param {string} [options.weight] the property name used to weight the center\n * @returns {Feature<Point>} a Point feature at the mean center point of all input features\n * @example\n * var features = turf.featureCollection([\n * turf.point([-97.522259, 35.4691], {value: 10}),\n * turf.point([-97.502754, 35.463455], {value: 3}),\n * turf.point([-97.508269, 35.463245], {value: 5})\n * ]);\n *\n * var options = {weight: \"value\"}\n * var mean = turf.centerMean(features, options);\n *\n * //addToMap\n * var addToMap = [features, mean]\n * mean.properties['marker-size'] = 'large';\n * mean.properties['marker-color'] = '#000';\n */\nfunction centerMean<P extends GeoJsonProperties = GeoJsonProperties>(\n geojson: any, // To-Do include Typescript AllGeoJSON\n options: { properties?: P; bbox?: BBox; id?: Id; weight?: string } = {}\n): Feature<Point, P> {\n let sumXs = 0;\n let sumYs = 0;\n let sumNs = 0;\n geomEach(geojson, function (geom, featureIndex, properties) {\n let weight = options.weight ? properties?.[options.weight] : undefined;\n weight = weight === undefined || weight === null ? 1 : weight;\n if (!isNumber(weight))\n throw new Error(\n \"weight value must be a number for feature index \" + featureIndex\n );\n weight = Number(weight);\n if (weight > 0) {\n coordEach(geom, function (coord) {\n sumXs += coord[0] * weight;\n sumYs += coord[1] * weight;\n sumNs += weight;\n });\n }\n });\n return point([sumXs / sumNs, sumYs / sumNs], options.properties, options);\n}\n\nexport { centerMean };\nexport default centerMean;\n"]}
1
+ {"version":3,"sources":["/home/runner/work/turf/turf/packages/turf-center-mean/dist/cjs/index.cjs","../../index.ts"],"names":[],"mappings":"AAAA;ACCA,kCAAoC;AACpC,wCAAoC;AA4BpC,SAAS,UAAA,CACP,OAAA,EACA,QAAA,EAAqE,CAAC,CAAA,EACnD;AACnB,EAAA,IAAI,MAAA,EAAQ,CAAA;AACZ,EAAA,IAAI,MAAA,EAAQ,CAAA;AACZ,EAAA,IAAI,MAAA,EAAQ,CAAA;AACZ,EAAA,4BAAA,OAAS,EAAS,QAAA,CAAU,IAAA,EAAM,YAAA,EAAc,UAAA,EAAY;AAC1D,IAAA,IAAI,OAAA,EAAS,OAAA,CAAQ,OAAA,EAAS,WAAA,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA,UAAA,CAAa,OAAA,CAAQ,MAAA,EAAA,EAAU,KAAA,CAAA;AAC7D,IAAA,OAAA,EAAS,OAAA,IAAW,KAAA,EAAA,GAAa,OAAA,IAAW,KAAA,EAAO,EAAA,EAAI,MAAA;AACvD,IAAA,GAAA,CAAI,CAAC,+BAAA,MAAe,CAAA;AAClB,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,mDAAA,EAAqD;AAAA,MACvD,CAAA;AACF,IAAA,OAAA,EAAS,MAAA,CAAO,MAAM,CAAA;AACtB,IAAA,GAAA,CAAI,OAAA,EAAS,CAAA,EAAG;AACd,MAAA,6BAAA,IAAU,EAAM,QAAA,CAAU,KAAA,EAAO;AAC/B,QAAA,MAAA,GAAS,KAAA,CAAM,CAAC,EAAA,EAAI,MAAA;AACpB,QAAA,MAAA,GAAS,KAAA,CAAM,CAAC,EAAA,EAAI,MAAA;AACpB,QAAA,MAAA,GAAS,MAAA;AAAA,MACX,CAAC,CAAA;AAAA,IACH;AAAA,EACF,CAAC,CAAA;AACD,EAAA,OAAO,4BAAA,CAAO,MAAA,EAAQ,KAAA,EAAO,MAAA,EAAQ,KAAK,CAAA,EAAG,OAAA,CAAQ,UAAA,EAAY,OAAO,CAAA;AAC1E;AAGA,IAAO,yBAAA,EAAQ,UAAA;AD/Bf;AACE;AACA;AACF,4EAAC","file":"/home/runner/work/turf/turf/packages/turf-center-mean/dist/cjs/index.cjs","sourcesContent":[null,"import { BBox, Feature, Point, GeoJsonProperties } from \"geojson\";\nimport { geomEach, coordEach } from \"@turf/meta\";\nimport { isNumber, point, Id } from \"@turf/helpers\";\n\n/**\n * Takes a {@link Feature} or {@link FeatureCollection} and returns the mean center. Can be weighted.\n *\n * @function\n * @param {GeoJSON} geojson GeoJSON to be centered\n * @param {Object} [options={}] Optional parameters\n * @param {Object} [options.properties={}] Translate GeoJSON Properties to Point\n * @param {Object} [options.bbox={}] Translate GeoJSON BBox to Point\n * @param {Object} [options.id={}] Translate GeoJSON Id to Point\n * @param {string} [options.weight] the property name used to weight the center\n * @returns {Feature<Point>} a Point feature at the mean center point of all input features\n * @example\n * var features = turf.featureCollection([\n * turf.point([-97.522259, 35.4691], {value: 10}),\n * turf.point([-97.502754, 35.463455], {value: 3}),\n * turf.point([-97.508269, 35.463245], {value: 5})\n * ]);\n *\n * var options = {weight: \"value\"}\n * var mean = turf.centerMean(features, options);\n *\n * //addToMap\n * var addToMap = [features, mean]\n * mean.properties['marker-size'] = 'large';\n * mean.properties['marker-color'] = '#000';\n */\nfunction centerMean<P extends GeoJsonProperties = GeoJsonProperties>(\n geojson: any, // To-Do include Typescript AllGeoJSON\n options: { properties?: P; bbox?: BBox; id?: Id; weight?: string } = {}\n): Feature<Point, P> {\n let sumXs = 0;\n let sumYs = 0;\n let sumNs = 0;\n geomEach(geojson, function (geom, featureIndex, properties) {\n let weight = options.weight ? properties?.[options.weight] : undefined;\n weight = weight === undefined || weight === null ? 1 : weight;\n if (!isNumber(weight))\n throw new Error(\n \"weight value must be a number for feature index \" + featureIndex\n );\n weight = Number(weight);\n if (weight > 0) {\n coordEach(geom, function (coord) {\n sumXs += coord[0] * weight;\n sumYs += coord[1] * weight;\n sumNs += weight;\n });\n }\n });\n return point([sumXs / sumNs, sumYs / sumNs], options.properties, options);\n}\n\nexport { centerMean };\nexport default centerMean;\n"]}
@@ -4,7 +4,7 @@ import { Id } from '@turf/helpers';
4
4
  /**
5
5
  * Takes a {@link Feature} or {@link FeatureCollection} and returns the mean center. Can be weighted.
6
6
  *
7
- * @name centerMean
7
+ * @function
8
8
  * @param {GeoJSON} geojson GeoJSON to be centered
9
9
  * @param {Object} [options={}] Optional parameters
10
10
  * @param {Object} [options.properties={}] Translate GeoJSON Properties to Point
@@ -4,7 +4,7 @@ import { Id } from '@turf/helpers';
4
4
  /**
5
5
  * Takes a {@link Feature} or {@link FeatureCollection} and returns the mean center. Can be weighted.
6
6
  *
7
- * @name centerMean
7
+ * @function
8
8
  * @param {GeoJSON} geojson GeoJSON to be centered
9
9
  * @param {Object} [options={}] Optional parameters
10
10
  * @param {Object} [options.properties={}] Translate GeoJSON Properties to Point
@@ -1 +1 @@
1
- {"version":3,"sources":["../../index.ts"],"sourcesContent":["import { BBox, Feature, Point, GeoJsonProperties } from \"geojson\";\nimport { geomEach, coordEach } from \"@turf/meta\";\nimport { isNumber, point, Id } from \"@turf/helpers\";\n\n/**\n * Takes a {@link Feature} or {@link FeatureCollection} and returns the mean center. Can be weighted.\n *\n * @name centerMean\n * @param {GeoJSON} geojson GeoJSON to be centered\n * @param {Object} [options={}] Optional parameters\n * @param {Object} [options.properties={}] Translate GeoJSON Properties to Point\n * @param {Object} [options.bbox={}] Translate GeoJSON BBox to Point\n * @param {Object} [options.id={}] Translate GeoJSON Id to Point\n * @param {string} [options.weight] the property name used to weight the center\n * @returns {Feature<Point>} a Point feature at the mean center point of all input features\n * @example\n * var features = turf.featureCollection([\n * turf.point([-97.522259, 35.4691], {value: 10}),\n * turf.point([-97.502754, 35.463455], {value: 3}),\n * turf.point([-97.508269, 35.463245], {value: 5})\n * ]);\n *\n * var options = {weight: \"value\"}\n * var mean = turf.centerMean(features, options);\n *\n * //addToMap\n * var addToMap = [features, mean]\n * mean.properties['marker-size'] = 'large';\n * mean.properties['marker-color'] = '#000';\n */\nfunction centerMean<P extends GeoJsonProperties = GeoJsonProperties>(\n geojson: any, // To-Do include Typescript AllGeoJSON\n options: { properties?: P; bbox?: BBox; id?: Id; weight?: string } = {}\n): Feature<Point, P> {\n let sumXs = 0;\n let sumYs = 0;\n let sumNs = 0;\n geomEach(geojson, function (geom, featureIndex, properties) {\n let weight = options.weight ? properties?.[options.weight] : undefined;\n weight = weight === undefined || weight === null ? 1 : weight;\n if (!isNumber(weight))\n throw new Error(\n \"weight value must be a number for feature index \" + featureIndex\n );\n weight = Number(weight);\n if (weight > 0) {\n coordEach(geom, function (coord) {\n sumXs += coord[0] * weight;\n sumYs += coord[1] * weight;\n sumNs += weight;\n });\n }\n });\n return point([sumXs / sumNs, sumYs / sumNs], options.properties, options);\n}\n\nexport { centerMean };\nexport default centerMean;\n"],"mappings":";AACA,SAAS,UAAU,iBAAiB;AACpC,SAAS,UAAU,aAAiB;AA4BpC,SAAS,WACP,SACA,UAAqE,CAAC,GACnD;AACnB,MAAI,QAAQ;AACZ,MAAI,QAAQ;AACZ,MAAI,QAAQ;AACZ,WAAS,SAAS,SAAU,MAAM,cAAc,YAAY;AAC1D,QAAI,SAAS,QAAQ,SAAS,yCAAa,QAAQ,UAAU;AAC7D,aAAS,WAAW,UAAa,WAAW,OAAO,IAAI;AACvD,QAAI,CAAC,SAAS,MAAM;AAClB,YAAM,IAAI;AAAA,QACR,qDAAqD;AAAA,MACvD;AACF,aAAS,OAAO,MAAM;AACtB,QAAI,SAAS,GAAG;AACd,gBAAU,MAAM,SAAU,OAAO;AAC/B,iBAAS,MAAM,CAAC,IAAI;AACpB,iBAAS,MAAM,CAAC,IAAI;AACpB,iBAAS;AAAA,MACX,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACD,SAAO,MAAM,CAAC,QAAQ,OAAO,QAAQ,KAAK,GAAG,QAAQ,YAAY,OAAO;AAC1E;AAGA,IAAO,2BAAQ;","names":[]}
1
+ {"version":3,"sources":["../../index.ts"],"sourcesContent":["import { BBox, Feature, Point, GeoJsonProperties } from \"geojson\";\nimport { geomEach, coordEach } from \"@turf/meta\";\nimport { isNumber, point, Id } from \"@turf/helpers\";\n\n/**\n * Takes a {@link Feature} or {@link FeatureCollection} and returns the mean center. Can be weighted.\n *\n * @function\n * @param {GeoJSON} geojson GeoJSON to be centered\n * @param {Object} [options={}] Optional parameters\n * @param {Object} [options.properties={}] Translate GeoJSON Properties to Point\n * @param {Object} [options.bbox={}] Translate GeoJSON BBox to Point\n * @param {Object} [options.id={}] Translate GeoJSON Id to Point\n * @param {string} [options.weight] the property name used to weight the center\n * @returns {Feature<Point>} a Point feature at the mean center point of all input features\n * @example\n * var features = turf.featureCollection([\n * turf.point([-97.522259, 35.4691], {value: 10}),\n * turf.point([-97.502754, 35.463455], {value: 3}),\n * turf.point([-97.508269, 35.463245], {value: 5})\n * ]);\n *\n * var options = {weight: \"value\"}\n * var mean = turf.centerMean(features, options);\n *\n * //addToMap\n * var addToMap = [features, mean]\n * mean.properties['marker-size'] = 'large';\n * mean.properties['marker-color'] = '#000';\n */\nfunction centerMean<P extends GeoJsonProperties = GeoJsonProperties>(\n geojson: any, // To-Do include Typescript AllGeoJSON\n options: { properties?: P; bbox?: BBox; id?: Id; weight?: string } = {}\n): Feature<Point, P> {\n let sumXs = 0;\n let sumYs = 0;\n let sumNs = 0;\n geomEach(geojson, function (geom, featureIndex, properties) {\n let weight = options.weight ? properties?.[options.weight] : undefined;\n weight = weight === undefined || weight === null ? 1 : weight;\n if (!isNumber(weight))\n throw new Error(\n \"weight value must be a number for feature index \" + featureIndex\n );\n weight = Number(weight);\n if (weight > 0) {\n coordEach(geom, function (coord) {\n sumXs += coord[0] * weight;\n sumYs += coord[1] * weight;\n sumNs += weight;\n });\n }\n });\n return point([sumXs / sumNs, sumYs / sumNs], options.properties, options);\n}\n\nexport { centerMean };\nexport default centerMean;\n"],"mappings":";AACA,SAAS,UAAU,iBAAiB;AACpC,SAAS,UAAU,aAAiB;AA4BpC,SAAS,WACP,SACA,UAAqE,CAAC,GACnD;AACnB,MAAI,QAAQ;AACZ,MAAI,QAAQ;AACZ,MAAI,QAAQ;AACZ,WAAS,SAAS,SAAU,MAAM,cAAc,YAAY;AAC1D,QAAI,SAAS,QAAQ,SAAS,yCAAa,QAAQ,UAAU;AAC7D,aAAS,WAAW,UAAa,WAAW,OAAO,IAAI;AACvD,QAAI,CAAC,SAAS,MAAM;AAClB,YAAM,IAAI;AAAA,QACR,qDAAqD;AAAA,MACvD;AACF,aAAS,OAAO,MAAM;AACtB,QAAI,SAAS,GAAG;AACd,gBAAU,MAAM,SAAU,OAAO;AAC/B,iBAAS,MAAM,CAAC,IAAI;AACpB,iBAAS,MAAM,CAAC,IAAI;AACpB,iBAAS;AAAA,MACX,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACD,SAAO,MAAM,CAAC,QAAQ,OAAO,QAAQ,KAAK,GAAG,QAAQ,YAAY,OAAO;AAC1E;AAGA,IAAO,2BAAQ;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/center-mean",
3
- "version": "7.1.0",
3
+ "version": "7.2.0",
4
4
  "description": "turf center-mean module",
5
5
  "author": "Turf Authors",
6
6
  "contributors": [
@@ -58,26 +58,26 @@
58
58
  "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts"
59
59
  },
60
60
  "devDependencies": {
61
- "@turf/center": "^7.1.0",
62
- "@turf/truncate": "^7.1.0",
61
+ "@turf/center": "^7.2.0",
62
+ "@turf/truncate": "^7.2.0",
63
63
  "@types/benchmark": "^2.1.5",
64
- "@types/tape": "^4.2.32",
64
+ "@types/tape": "^4.13.4",
65
65
  "benchmark": "^2.1.4",
66
66
  "glob": "^10.3.10",
67
67
  "load-json-file": "^7.0.1",
68
68
  "npm-run-all": "^4.1.5",
69
- "tape": "^5.7.2",
70
- "tsup": "^8.0.1",
71
- "tsx": "^4.6.2",
72
- "typescript": "^5.2.2",
69
+ "tape": "^5.9.0",
70
+ "tsup": "^8.3.5",
71
+ "tsx": "^4.19.2",
72
+ "typescript": "^5.5.4",
73
73
  "write-json-file": "^5.0.0"
74
74
  },
75
75
  "dependencies": {
76
- "@turf/bbox": "^7.1.0",
77
- "@turf/helpers": "^7.1.0",
78
- "@turf/meta": "^7.1.0",
76
+ "@turf/bbox": "^7.2.0",
77
+ "@turf/helpers": "^7.2.0",
78
+ "@turf/meta": "^7.2.0",
79
79
  "@types/geojson": "^7946.0.10",
80
- "tslib": "^2.6.2"
80
+ "tslib": "^2.8.1"
81
81
  },
82
- "gitHead": "68915eeebc9278bb40dec3f1034499698a0561ef"
82
+ "gitHead": "7b0f0374c4668cd569f8904c71e2ae7d941be867"
83
83
  }