Installations
npm install @spatial/meta
Developer Guide
Typescript
Yes
Module System
CommonJS
Node Version
12.18.2
NPM Version
lerna/3.22.1/node@v12.18.2+x64 (linux)
Score
75.6
Supply Chain
98.9
Quality
77.8
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Languages
TypeScript (86.87%)
JavaScript (13.12%)
Shell (0.01%)
Developer
Download Statistics
Total Downloads
32,719
Last Day
13
Last Week
142
Last Month
1,832
Last Year
14,468
GitHub Statistics
9,519 Stars
3,736 Commits
953 Forks
182 Watching
48 Branches
168 Contributors
Bundle Size
5.57 kB
Minified
1.70 kB
Minified + Gzipped
Package Meta Information
Latest Version
2.0.0
Package Id
@spatial/meta@2.0.0
Unpacked Size
141.04 kB
Size
15.26 kB
File Count
7
NPM Version
lerna/3.22.1/node@v12.18.2+x64 (linux)
Node Version
12.18.2
Total Downloads
Cumulative downloads
Total Downloads
32,719
Last day
-72.3%
13
Compared to previous day
Last week
-50.2%
142
Compared to previous week
Last month
-54.5%
1,832
Compared to previous month
Last year
372%
14,468
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Dev Dependencies
5
@spatial/meta
coordEachCallback
Callback for coordEach
Type: Function
Parameters
currentCoord
Array<number> The current coordinate being processed.coordIndex
number The current index of the coordinate being processed.featureIndex
number The current index of the Feature being processed.multiFeatureIndex
number The current index of the Multi-Feature being processed.geometryIndex
number The current index of the Geometry being processed.
coordEach
Iterate over coordinates in any GeoJSON object, similar to Array.forEach()
Parameters
geojson
(FeatureCollection | Feature | Geometry) any GeoJSON objectcallback
Function a method that takes (currentCoord, coordIndex, featureIndex, multiFeatureIndex)excludeWrapCoord
boolean whether or not to include the final coordinate of LinearRings that wraps the ring in its iteration. (optional, defaultfalse
)
Examples
1var features = turf.featureCollection([ 2 turf.point([26, 37], {"foo": "bar"}), 3 turf.point([36, 53], {"hello": "world"}) 4]); 5 6turf.coordEach(features, function (currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) { 7 //=currentCoord 8 //=coordIndex 9 //=featureIndex 10 //=multiFeatureIndex 11 //=geometryIndex 12});
coordReduceCallback
Callback for coordReduce
The first time the callback function is called, the values provided as arguments depend on whether the reduce method has an initialValue argument.
If an initialValue is provided to the reduce method:
- The previousValue argument is initialValue.
- The currentValue argument is the value of the first element present in the array.
If an initialValue is not provided:
- The previousValue argument is the value of the first element present in the array.
- The currentValue argument is the value of the second element present in the array.
Type: Function
Parameters
previousValue
any The accumulated value previously returned in the last invocation of the callback, or initialValue, if supplied.currentCoord
Array<number> The current coordinate being processed.coordIndex
number The current index of the coordinate being processed. Starts at index 0, if an initialValue is provided, and at index 1 otherwise.featureIndex
number The current index of the Feature being processed.multiFeatureIndex
number The current index of the Multi-Feature being processed.geometryIndex
number The current index of the Geometry being processed.
coordReduce
Reduce coordinates in any GeoJSON object, similar to Array.reduce()
Parameters
geojson
(FeatureCollection | Geometry | Feature) any GeoJSON objectcallback
Function a method that takes (previousValue, currentCoord, coordIndex)initialValue
any? Value to use as the first argument to the first call of the callback.excludeWrapCoord
boolean whether or not to include the final coordinate of LinearRings that wraps the ring in its iteration. (optional, defaultfalse
)
Examples
1var features = turf.featureCollection([ 2 turf.point([26, 37], {"foo": "bar"}), 3 turf.point([36, 53], {"hello": "world"}) 4]); 5 6turf.coordReduce(features, function (previousValue, currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) { 7 //=previousValue 8 //=currentCoord 9 //=coordIndex 10 //=featureIndex 11 //=multiFeatureIndex 12 //=geometryIndex 13 return currentCoord; 14});
Returns any The value that results from the reduction.
propEachCallback
Callback for propEach
Type: Function
Parameters
currentProperties
Object The current Properties being processed.featureIndex
number The current index of the Feature being processed.
propEach
Iterate over properties in any GeoJSON object, similar to Array.forEach()
Parameters
geojson
(FeatureCollection | Feature) any GeoJSON objectcallback
Function a method that takes (currentProperties, featureIndex)
Examples
1var features = turf.featureCollection([ 2 turf.point([26, 37], {foo: 'bar'}), 3 turf.point([36, 53], {hello: 'world'}) 4]); 5 6turf.propEach(features, function (currentProperties, featureIndex) { 7 //=currentProperties 8 //=featureIndex 9});
propReduceCallback
Callback for propReduce
The first time the callback function is called, the values provided as arguments depend on whether the reduce method has an initialValue argument.
If an initialValue is provided to the reduce method:
- The previousValue argument is initialValue.
- The currentValue argument is the value of the first element present in the array.
If an initialValue is not provided:
- The previousValue argument is the value of the first element present in the array.
- The currentValue argument is the value of the second element present in the array.
Type: Function
Parameters
previousValue
any The accumulated value previously returned in the last invocation of the callback, or initialValue, if supplied.currentProperties
any The current Properties being processed.featureIndex
number The current index of the Feature being processed.
propReduce
Reduce properties in any GeoJSON object into a single value, similar to how Array.reduce works. However, in this case we lazily run the reduction, so an array of all properties is unnecessary.
Parameters
geojson
(FeatureCollection | Feature) any GeoJSON objectcallback
Function a method that takes (previousValue, currentProperties, featureIndex)initialValue
any? Value to use as the first argument to the first call of the callback.
Examples
1var features = turf.featureCollection([ 2 turf.point([26, 37], {foo: 'bar'}), 3 turf.point([36, 53], {hello: 'world'}) 4]); 5 6turf.propReduce(features, function (previousValue, currentProperties, featureIndex) { 7 //=previousValue 8 //=currentProperties 9 //=featureIndex 10 return currentProperties 11});
Returns any The value that results from the reduction.
featureEachCallback
Callback for featureEach
Type: Function
Parameters
currentFeature
Feature<any> The current Feature being processed.featureIndex
number The current index of the Feature being processed.
featureEach
Iterate over features in any GeoJSON object, similar to Array.forEach.
Parameters
geojson
(FeatureCollection | Feature | Geometry) any GeoJSON objectcallback
Function a method that takes (currentFeature, featureIndex)
Examples
1var features = turf.featureCollection([ 2 turf.point([26, 37], {foo: 'bar'}), 3 turf.point([36, 53], {hello: 'world'}) 4]); 5 6turf.featureEach(features, function (currentFeature, featureIndex) { 7 //=currentFeature 8 //=featureIndex 9});
featureReduceCallback
Callback for featureReduce
The first time the callback function is called, the values provided as arguments depend on whether the reduce method has an initialValue argument.
If an initialValue is provided to the reduce method:
- The previousValue argument is initialValue.
- The currentValue argument is the value of the first element present in the array.
If an initialValue is not provided:
- The previousValue argument is the value of the first element present in the array.
- The currentValue argument is the value of the second element present in the array.
Type: Function
Parameters
previousValue
any The accumulated value previously returned in the last invocation of the callback, or initialValue, if supplied.currentFeature
Feature The current Feature being processed.featureIndex
number The current index of the Feature being processed.
featureReduce
Reduce features in any GeoJSON object, similar to Array.reduce().
Parameters
geojson
(FeatureCollection | Feature | Geometry) any GeoJSON objectcallback
Function a method that takes (previousValue, currentFeature, featureIndex)initialValue
any? Value to use as the first argument to the first call of the callback.
Examples
1var features = turf.featureCollection([ 2 turf.point([26, 37], {"foo": "bar"}), 3 turf.point([36, 53], {"hello": "world"}) 4]); 5 6turf.featureReduce(features, function (previousValue, currentFeature, featureIndex) { 7 //=previousValue 8 //=currentFeature 9 //=featureIndex 10 return currentFeature 11});
Returns any The value that results from the reduction.
coordAll
Get all coordinates from any GeoJSON object.
Parameters
geojson
(FeatureCollection | Feature | Geometry) any GeoJSON object
Examples
1var features = turf.featureCollection([ 2 turf.point([26, 37], {foo: 'bar'}), 3 turf.point([36, 53], {hello: 'world'}) 4]); 5 6var coords = turf.coordAll(features); 7//= [[26, 37], [36, 53]]
Returns Array<Array<number>> coordinate position array
geomEachCallback
Callback for geomEach
Type: Function
Parameters
currentGeometry
Geometry The current Geometry being processed.featureIndex
number The current index of the Feature being processed.featureProperties
Object The current Feature Properties being processed.featureBBox
Array<number> The current Feature BBox being processed.featureId
(number | string) The current Feature Id being processed.
geomEach
Iterate over each geometry in any GeoJSON object, similar to Array.forEach()
Parameters
geojson
(FeatureCollection | Feature | Geometry) any GeoJSON objectcallback
Function a method that takes (currentGeometry, featureIndex, featureProperties, featureBBox, featureId)
Examples
1var features = turf.featureCollection([ 2 turf.point([26, 37], {foo: 'bar'}), 3 turf.point([36, 53], {hello: 'world'}) 4]); 5 6turf.geomEach(features, function (currentGeometry, featureIndex, featureProperties, featureBBox, featureId) { 7 //=currentGeometry 8 //=featureIndex 9 //=featureProperties 10 //=featureBBox 11 //=featureId 12});
geomReduceCallback
Callback for geomReduce
The first time the callback function is called, the values provided as arguments depend on whether the reduce method has an initialValue argument.
If an initialValue is provided to the reduce method:
- The previousValue argument is initialValue.
- The currentValue argument is the value of the first element present in the array.
If an initialValue is not provided:
- The previousValue argument is the value of the first element present in the array.
- The currentValue argument is the value of the second element present in the array.
Type: Function
Parameters
previousValue
any The accumulated value previously returned in the last invocation of the callback, or initialValue, if supplied.currentGeometry
Geometry The current Geometry being processed.featureIndex
number The current index of the Feature being processed.featureProperties
Object The current Feature Properties being processed.featureBBox
Array<number> The current Feature BBox being processed.featureId
(number | string) The current Feature Id being processed.
geomReduce
Reduce geometry in any GeoJSON object, similar to Array.reduce().
Parameters
geojson
(FeatureCollection | Feature | Geometry) any GeoJSON objectcallback
Function a method that takes (previousValue, currentGeometry, featureIndex, featureProperties, featureBBox, featureId)initialValue
any? Value to use as the first argument to the first call of the callback.
Examples
1var features = turf.featureCollection([ 2 turf.point([26, 37], {foo: 'bar'}), 3 turf.point([36, 53], {hello: 'world'}) 4]); 5 6turf.geomReduce(features, function (previousValue, currentGeometry, featureIndex, featureProperties, featureBBox, featureId) { 7 //=previousValue 8 //=currentGeometry 9 //=featureIndex 10 //=featureProperties 11 //=featureBBox 12 //=featureId 13 return currentGeometry 14});
Returns any The value that results from the reduction.
flattenEachCallback
Callback for flattenEach
Type: Function
Parameters
currentFeature
Feature The current flattened feature being processed.featureIndex
number The current index of the Feature being processed.multiFeatureIndex
number The current index of the Multi-Feature being processed.
flattenEach
Iterate over flattened features in any GeoJSON object, similar to Array.forEach.
Parameters
geojson
(FeatureCollection | Feature | Geometry) any GeoJSON objectcallback
Function a method that takes (currentFeature, featureIndex, multiFeatureIndex)
Examples
1var features = turf.featureCollection([ 2 turf.point([26, 37], {foo: 'bar'}), 3 turf.multiPoint([[40, 30], [36, 53]], {hello: 'world'}) 4]); 5 6turf.flattenEach(features, function (currentFeature, featureIndex, multiFeatureIndex) { 7 //=currentFeature 8 //=featureIndex 9 //=multiFeatureIndex 10});
flattenReduceCallback
Callback for flattenReduce
The first time the callback function is called, the values provided as arguments depend on whether the reduce method has an initialValue argument.
If an initialValue is provided to the reduce method:
- The previousValue argument is initialValue.
- The currentValue argument is the value of the first element present in the array.
If an initialValue is not provided:
- The previousValue argument is the value of the first element present in the array.
- The currentValue argument is the value of the second element present in the array.
Type: Function
Parameters
previousValue
any The accumulated value previously returned in the last invocation of the callback, or initialValue, if supplied.currentFeature
Feature The current Feature being processed.featureIndex
number The current index of the Feature being processed.multiFeatureIndex
number The current index of the Multi-Feature being processed.
flattenReduce
Reduce flattened features in any GeoJSON object, similar to Array.reduce().
Parameters
geojson
(FeatureCollection | Feature | Geometry) any GeoJSON objectcallback
Function a method that takes (previousValue, currentFeature, featureIndex, multiFeatureIndex)initialValue
any? Value to use as the first argument to the first call of the callback.
Examples
1var features = turf.featureCollection([ 2 turf.point([26, 37], {foo: 'bar'}), 3 turf.multiPoint([[40, 30], [36, 53]], {hello: 'world'}) 4]); 5 6turf.flattenReduce(features, function (previousValue, currentFeature, featureIndex, multiFeatureIndex) { 7 //=previousValue 8 //=currentFeature 9 //=featureIndex 10 //=multiFeatureIndex 11 return currentFeature 12});
Returns any The value that results from the reduction.
segmentEachCallback
Callback for segmentEach
Type: Function
Parameters
currentSegment
Feature<LineString> The current Segment being processed.featureIndex
number The current index of the Feature being processed.multiFeatureIndex
number The current index of the Multi-Feature being processed.geometryIndex
number The current index of the Geometry being processed.segmentIndex
number The current index of the Segment being processed.
Returns void
segmentEach
Iterate over 2-vertex line segment in any GeoJSON object, similar to Array.forEach() (Multi)Point geometries do not contain segments therefore they are ignored during this operation.
Parameters
geojson
(FeatureCollection | Feature | Geometry) any GeoJSONcallback
Function a method that takes (currentSegment, featureIndex, multiFeatureIndex, geometryIndex, segmentIndex)
Examples
1var polygon = turf.polygon([[[-50, 5], [-40, -10], [-50, -10], [-40, 5], [-50, 5]]]); 2 3// Iterate over GeoJSON by 2-vertex segments 4turf.segmentEach(polygon, function (currentSegment, featureIndex, multiFeatureIndex, geometryIndex, segmentIndex) { 5 //=currentSegment 6 //=featureIndex 7 //=multiFeatureIndex 8 //=geometryIndex 9 //=segmentIndex 10}); 11 12// Calculate the total number of segments 13var total = 0; 14turf.segmentEach(polygon, function () { 15 total++; 16});
Returns void
segmentReduceCallback
Callback for segmentReduce
The first time the callback function is called, the values provided as arguments depend on whether the reduce method has an initialValue argument.
If an initialValue is provided to the reduce method:
- The previousValue argument is initialValue.
- The currentValue argument is the value of the first element present in the array.
If an initialValue is not provided:
- The previousValue argument is the value of the first element present in the array.
- The currentValue argument is the value of the second element present in the array.
Type: Function
Parameters
previousValue
any The accumulated value previously returned in the last invocation of the callback, or initialValue, if supplied.currentSegment
Feature<LineString> The current Segment being processed.featureIndex
number The current index of the Feature being processed.multiFeatureIndex
number The current index of the Multi-Feature being processed.geometryIndex
number The current index of the Geometry being processed.segmentIndex
number The current index of the Segment being processed.
segmentReduce
Reduce 2-vertex line segment in any GeoJSON object, similar to Array.reduce() (Multi)Point geometries do not contain segments therefore they are ignored during this operation.
Parameters
geojson
(FeatureCollection | Feature | Geometry) any GeoJSONcallback
Function a method that takes (previousValue, currentSegment, currentIndex)initialValue
any? Value to use as the first argument to the first call of the callback.
Examples
1var polygon = turf.polygon([[[-50, 5], [-40, -10], [-50, -10], [-40, 5], [-50, 5]]]); 2 3// Iterate over GeoJSON by 2-vertex segments 4turf.segmentReduce(polygon, function (previousSegment, currentSegment, featureIndex, multiFeatureIndex, geometryIndex, segmentIndex) { 5 //= previousSegment 6 //= currentSegment 7 //= featureIndex 8 //= multiFeatureIndex 9 //= geometryIndex 10 //= segmentInex 11 return currentSegment 12}); 13 14// Calculate the total number of segments 15var initialValue = 0 16var total = turf.segmentReduce(polygon, function (previousValue) { 17 previousValue++; 18 return previousValue; 19}, initialValue);
Returns void
lineEachCallback
Callback for lineEach
Type: Function
Parameters
currentLine
Feature<LineString> The current LineString|LinearRing being processedfeatureIndex
number The current index of the Feature being processedmultiFeatureIndex
number The current index of the Multi-Feature being processedgeometryIndex
number The current index of the Geometry being processed
lineEach
Iterate over line or ring coordinates in LineString, Polygon, MultiLineString, MultiPolygon Features or Geometries, similar to Array.forEach.
Parameters
geojson
(Geometry | Feature<(LineString | Polygon | MultiLineString | MultiPolygon)>) objectcallback
Function a method that takes (currentLine, featureIndex, multiFeatureIndex, geometryIndex)
Examples
1var multiLine = turf.multiLineString([ 2 [[26, 37], [35, 45]], 3 [[36, 53], [38, 50], [41, 55]] 4]); 5 6turf.lineEach(multiLine, function (currentLine, featureIndex, multiFeatureIndex, geometryIndex) { 7 //=currentLine 8 //=featureIndex 9 //=multiFeatureIndex 10 //=geometryIndex 11});
lineReduceCallback
Callback for lineReduce
The first time the callback function is called, the values provided as arguments depend on whether the reduce method has an initialValue argument.
If an initialValue is provided to the reduce method:
- The previousValue argument is initialValue.
- The currentValue argument is the value of the first element present in the array.
If an initialValue is not provided:
- The previousValue argument is the value of the first element present in the array.
- The currentValue argument is the value of the second element present in the array.
Type: Function
Parameters
previousValue
any The accumulated value previously returned in the last invocation of the callback, or initialValue, if supplied.currentLine
Feature<LineString> The current LineString|LinearRing being processed.featureIndex
number The current index of the Feature being processedmultiFeatureIndex
number The current index of the Multi-Feature being processedgeometryIndex
number The current index of the Geometry being processed
lineReduce
Reduce features in any GeoJSON object, similar to Array.reduce().
Parameters
geojson
(Geometry | Feature<(LineString | Polygon | MultiLineString | MultiPolygon)>) objectcallback
Function a method that takes (previousValue, currentLine, featureIndex, multiFeatureIndex, geometryIndex)initialValue
any? Value to use as the first argument to the first call of the callback.
Examples
1var multiPoly = turf.multiPolygon([ 2 turf.polygon([[[12,48],[2,41],[24,38],[12,48]], [[9,44],[13,41],[13,45],[9,44]]]), 3 turf.polygon([[[5, 5], [0, 0], [2, 2], [4, 4], [5, 5]]]) 4]); 5 6turf.lineReduce(multiPoly, function (previousValue, currentLine, featureIndex, multiFeatureIndex, geometryIndex) { 7 //=previousValue 8 //=currentLine 9 //=featureIndex 10 //=multiFeatureIndex 11 //=geometryIndex 12 return currentLine 13});
Returns any The value that results from the reduction.
This module is part of the Turfjs project, an open source module collection dedicated to geographic algorithms. It is maintained in the Turfjs/turf repository, where you can create PRs and issues.
Installation
Install this module individually:
1$ npm install @spatial/meta
Or install the Turf module that includes it as a function:
1$ npm install @turf/turf
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
security policy file detected
Details
- Info: security policy file detected: docs/SECURITY.md:1
- Info: Found linked content: docs/SECURITY.md:1
- Info: Found disclosure, vulnerability, and/or timelines in security policy: docs/SECURITY.md:1
- Info: Found text in security policy: docs/SECURITY.md:1
Reason
30 commit(s) and 16 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
no binaries found in the repo
Reason
project is fuzzed
Details
- Info: OSSFuzz integration found
Reason
Found 9/10 approved changesets -- score normalized to 9
Reason
4 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-8hc4-vh64-cxmj
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-g3ch-rx76-35fx
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/prerelease.yml:1
- Warn: topLevel 'contents' permission set to 'write': .github/workflows/release.yml:9
- Info: topLevel 'contents' permission set to 'read': .github/workflows/turf.yml:14
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/prerelease.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/Turfjs/turf/prerelease.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/prerelease.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/Turfjs/turf/prerelease.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/prerelease.yml:30: update your workflow using https://app.stepsecurity.io/secureworkflow/Turfjs/turf/prerelease.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/Turfjs/turf/release.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:29: update your workflow using https://app.stepsecurity.io/secureworkflow/Turfjs/turf/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:34: update your workflow using https://app.stepsecurity.io/secureworkflow/Turfjs/turf/release.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:54: update your workflow using https://app.stepsecurity.io/secureworkflow/Turfjs/turf/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/turf.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/Turfjs/turf/turf.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/turf.yml:29: update your workflow using https://app.stepsecurity.io/secureworkflow/Turfjs/turf/turf.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/turf.yml:34: update your workflow using https://app.stepsecurity.io/secureworkflow/Turfjs/turf/turf.yml/master?enable=pin
- Info: 0 out of 6 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 4 third-party GitHubAction dependencies pinned
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 30 are checked with a SAST tool
Score
6.7
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More