Turf中的ellipse
函数可以根据指定的中心点、半径和选项参数绘制椭圆形。
import { ellipse } from '@turf/turf'
const center = [-73.9911, 40.7357];
const radiusX = 1000;
const radiusY = 500;
const options = { steps: 50, units: 'meters', properties: { foo: 'bar' } };
const ellipsePolygon = ellipse(center, radiusX, radiusY, options);
function ellipse(center: turf.Point, radiusX: number, radiusY: number, options?: turf.EllipseOptions): turf.Feature<turf.Polygon>
center
(Array<number>
): 椭圆中心点,用经度和纬度表示。必填项。radiusX
(number
): 椭圆长轴半径。单位由选项参数units
指定,默认单位是米。必填项。radiusY
(number
): 椭圆短轴半径。单位由选项参数units
指定,默认单位是米。必填项。options
(Object
,可选项): 包含以下属性:
steps
(number
): 绘制椭圆时用到的点数。默认值是64。units
(string
): 椭圆轴半径的单位。默认是'meters'。properties
(Object
): 新生成的Feature的属性信息。默认是空对象。一个新的Polygon
类型的Feature对象,表示生成的椭圆。如果输入的参数无效,ellipse
函数会返回null
。
const center = [-73.9911, 40.7357];
const radiusX = 1000;
const radiusY = 500;
const options = { steps: 50, units: 'meters', properties: { foo: 'bar' } };
const ellipsePolygon = ellipse(center, radiusX, radiusY, options);
console.log(ellipsePolygon);
输出:
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[-73.9911023239686,40.73311029898332],
...
[-73.9911023239686,40.73311029898332]
]
]
},
"properties": {
"foo": "bar"
}
}
无。