getType函数返回给定要素的类型。
feature (Feature): 要素Point、LineString、Polygon、MultiPoint、MultiLineString、MultiPolygon、GeometryCollection和Feature。const feature = {
type: 'Feature',
properties: {},
geometry: {
type: 'Polygon',
coordinates: [[[0,0], [1,1], [0,1], [0,0]]]
}
};
const type = turf.getType(feature);
// type === 'Polygon'
无
getType函数首先检查给定要素是否是基本类型(Point、LineString、Polygon、MultiPoint、MultiLineString、MultiPolygon)。如果是,它将返回要素类型。如果要素不是基本类型,则它将查找geometry属性,如果该属性存在,则它将返回geometry.type。否则,将返回Feature类型。
本函数所涉及代码基于MIT许可证。