# collectionOf
Enforce expectations about types of FeatureCollection inputs for Turf. Internally this uses geojsonType to judge geometry types.
强制要求Turf库的输入必须是FeatureCollection
类型,且几何类型符合预期。在内部,其使用geojsonType来判断几何类型。
> npm install @turf/invariant
参数
参数 | 类型 | 描述 |
---|---|---|
featureCollection | FeatureCollection | 一个将对Features进行判断的FeatureCollection |
type | string | 预期的GeoJSON类型 |
name | string | 调用函数的名称 |
示例
var locationA = turf.point([-75.343, 39.984], {name: 'Location A'});
var locationB = turf.point([-75.833, 39.284], {name: 'Location B'});
var locationC = turf.point([-75.534, 39.123], {name: 'Location C'});
var pointCollection = turf.featureCollection([
locationA,
locationB,
locationC
]);
turf.collectionOf(pointCollection, 'Point', 'Location A');