@turf/center-mean 6.4.0 → 7.0.0-alpha.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/README.md CHANGED
@@ -6,16 +6,17 @@
6
6
 
7
7
  Takes a [Feature][1] or [FeatureCollection][2] and returns the mean center. Can be weighted.
8
8
 
9
- **Parameters**
9
+ ### Parameters
10
10
 
11
- - `geojson` **[GeoJSON][3]** GeoJSON to be centered
12
- - `options` **[Object][4]** Optional parameters (optional, default `{}`)
13
- - `options.properties` **[Object][4]** Translate GeoJSON Properties to Point (optional, default `{}`)
14
- - `options.bbox` **[Object][4]** Translate GeoJSON BBox to Point (optional, default `{}`)
15
- - `options.id` **[Object][4]** Translate GeoJSON Id to Point (optional, default `{}`)
16
- - `options.weight` **[string][5]?** the property name used to weight the center
11
+ * `geojson` **[GeoJSON][3]** GeoJSON to be centered
12
+ * `options` **[Object][4]** Optional parameters (optional, default `{}`)
17
13
 
18
- **Examples**
14
+ * `options.properties` **[Object][4]** Translate GeoJSON Properties to Point (optional, default `{}`)
15
+ * `options.bbox` **[Object][4]** Translate GeoJSON BBox to Point (optional, default `{}`)
16
+ * `options.id` **[Object][4]** Translate GeoJSON Id to Point (optional, default `{}`)
17
+ * `options.weight` **[string][5]?** the property name used to weight the center
18
+
19
+ ### Examples
19
20
 
20
21
  ```javascript
21
22
  var features = turf.featureCollection([
@@ -33,7 +34,7 @@ mean.properties['marker-size'] = 'large';
33
34
  mean.properties['marker-color'] = '#000';
34
35
  ```
35
36
 
36
- Returns **[Feature][6]<[Point][7]>** a Point feature at the mean center point of all input features
37
+ Returns **[Feature][6]<[Point][7]>** a Point feature at the mean center point of all input features
37
38
 
38
39
  [1]: https://tools.ietf.org/html/rfc7946#section-3.2
39
40
 
package/dist/es/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { geomEach, coordEach } from "@turf/meta";
2
- import { isNumber, point, } from "@turf/helpers";
2
+ import { isNumber, point } from "@turf/helpers";
3
3
  /**
4
4
  * Takes a {@link Feature} or {@link FeatureCollection} and returns the mean center. Can be weighted.
5
5
  *
@@ -27,13 +27,12 @@ import { isNumber, point, } from "@turf/helpers";
27
27
  * mean.properties['marker-color'] = '#000';
28
28
  */
29
29
  function centerMean(geojson, // To-Do include Typescript AllGeoJSON
30
- options) {
31
- if (options === void 0) { options = {}; }
32
- var sumXs = 0;
33
- var sumYs = 0;
34
- var sumNs = 0;
30
+ options = {}) {
31
+ let sumXs = 0;
32
+ let sumYs = 0;
33
+ let sumNs = 0;
35
34
  geomEach(geojson, function (geom, featureIndex, properties) {
36
- var weight = options.weight ? properties === null || properties === void 0 ? void 0 : properties[options.weight] : undefined;
35
+ let weight = options.weight ? properties === null || properties === void 0 ? void 0 : properties[options.weight] : undefined;
37
36
  weight = weight === undefined || weight === null ? 1 : weight;
38
37
  if (!isNumber(weight))
39
38
  throw new Error("weight value must be a number for feature index " + featureIndex);
@@ -1,4 +1,5 @@
1
- import { Feature, Point, Properties, BBox, Id } from "@turf/helpers";
1
+ import { BBox, Feature, Point, GeoJsonProperties } from "geojson";
2
+ import { Id } from "@turf/helpers";
2
3
  /**
3
4
  * Takes a {@link Feature} or {@link FeatureCollection} and returns the mean center. Can be weighted.
4
5
  *
@@ -25,7 +26,7 @@ import { Feature, Point, Properties, BBox, Id } from "@turf/helpers";
25
26
  * mean.properties['marker-size'] = 'large';
26
27
  * mean.properties['marker-color'] = '#000';
27
28
  */
28
- declare function centerMean<P = Properties>(geojson: any, // To-Do include Typescript AllGeoJSON
29
+ declare function centerMean<P = GeoJsonProperties>(geojson: any, // To-Do include Typescript AllGeoJSON
29
30
  options?: {
30
31
  properties?: P;
31
32
  bbox?: BBox;
package/dist/js/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var meta_1 = require("@turf/meta");
4
- var helpers_1 = require("@turf/helpers");
3
+ const meta_1 = require("@turf/meta");
4
+ const helpers_1 = require("@turf/helpers");
5
5
  /**
6
6
  * Takes a {@link Feature} or {@link FeatureCollection} and returns the mean center. Can be weighted.
7
7
  *
@@ -29,13 +29,12 @@ var helpers_1 = require("@turf/helpers");
29
29
  * mean.properties['marker-color'] = '#000';
30
30
  */
31
31
  function centerMean(geojson, // To-Do include Typescript AllGeoJSON
32
- options) {
33
- if (options === void 0) { options = {}; }
34
- var sumXs = 0;
35
- var sumYs = 0;
36
- var sumNs = 0;
32
+ options = {}) {
33
+ let sumXs = 0;
34
+ let sumYs = 0;
35
+ let sumNs = 0;
37
36
  meta_1.geomEach(geojson, function (geom, featureIndex, properties) {
38
- var weight = options.weight ? properties === null || properties === void 0 ? void 0 : properties[options.weight] : undefined;
37
+ let weight = options.weight ? properties === null || properties === void 0 ? void 0 : properties[options.weight] : undefined;
39
38
  weight = weight === undefined || weight === null ? 1 : weight;
40
39
  if (!helpers_1.isNumber(weight))
41
40
  throw new Error("weight value must be a number for feature index " + featureIndex);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/center-mean",
3
- "version": "6.4.0",
3
+ "version": "7.0.0-alpha.0",
4
4
  "description": "turf center-mean module",
5
5
  "author": "Turf Authors",
6
6
  "contributors": [
@@ -15,6 +15,7 @@
15
15
  "type": "git",
16
16
  "url": "git://github.com/Turfjs/turf.git"
17
17
  },
18
+ "funding": "https://opencollective.com/turf",
18
19
  "publishConfig": {
19
20
  "access": "public"
20
21
  },
@@ -49,11 +50,11 @@
49
50
  "docs": "node ../../scripts/generate-readmes",
50
51
  "test": "npm-run-all test:*",
51
52
  "test:tape": "ts-node -r esm test.js",
52
- "test:types": "tsc --esModuleInterop --noEmit types.ts"
53
+ "test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
53
54
  },
54
55
  "devDependencies": {
55
- "@turf/center": "^6.4.0",
56
- "@turf/truncate": "^6.4.0",
56
+ "@turf/center": "^7.0.0-alpha.0",
57
+ "@turf/truncate": "^7.0.0-alpha.0",
57
58
  "@types/tape": "*",
58
59
  "benchmark": "*",
59
60
  "glob": "*",
@@ -66,9 +67,10 @@
66
67
  "write-json-file": "*"
67
68
  },
68
69
  "dependencies": {
69
- "@turf/bbox": "^6.4.0",
70
- "@turf/helpers": "^6.4.0",
71
- "@turf/meta": "^6.4.0"
70
+ "@turf/bbox": "^7.0.0-alpha.0",
71
+ "@turf/helpers": "^7.0.0-alpha.0",
72
+ "@turf/meta": "^7.0.0-alpha.0",
73
+ "tslib": "^2.3.0"
72
74
  },
73
- "gitHead": "1e62773cfc88c627cca8effcb5c14cfb65a905ac"
75
+ "gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
74
76
  }