Summary
Methods:
clone |
复制拓展几何对象。 |
distanceTo |
计算圆几何和一个地理几何体之间的距离(X-Y平面内)。 |
getBBox |
获取圆的三维包围盒 |
getCenter |
获取圆的中心点。 |
getCoordSeqs |
获取圆的坐标序列数组,其长度为1。 |
getRadius |
获取圆的半径。 |
getType |
获取当前几何体的类型 |
intersectsGeometry |
检测圆与入参几何体是否相交。 |
setCtrlPoints |
重新设置圆的控制点。 |
toPolygon |
将圆转化为面几何体 |
Constructor
new Circle(point1, point2, pointNum)
使用点几何体作为控制点构造圆,控制点数量为2,且不可以重复。
Parameters:
Name | Type | Default | Description |
---|---|---|---|
point1 |
module:geom~Point | 控制点1,即圆心。 |
|
point2 |
module:geom~Point | 控制点2,即圆边线上一个点。 |
|
pointNum |
Number | 100 | 构成圆的边的数量,默认是100,可选项。边数越多,需要渲染的数据量越大,渲染时需要消耗的计算机资源就越多,耗时因此会增加。 |
Throws:
Example
let pnt1 = new hmap.geom.Point(new hmap.basetype.Coordinate(120,30,0));
let pnt2 = new hmap.geom.Point(new hmap.basetype.Coordinate(120,31,0));
let circleGeom = new hmap.geomext.Circle(pnt1,pnt2,20);
Methods
-
clone() → {module:geomext~GeometryExt}
-
复制拓展几何对象。
-
distanceTo(geometry, options) → {Number|Object}
-
计算圆几何和一个地理几何体之间的距离(X-Y平面内)。
Parameters:
Name Type Description geometry
module:geom~Geometry 地理几何体,继承Geomerty的任意几何体实例。
options
Object 距离计算时的可选配置项。
Name Type Description details
Boolean 指定返回结果的格式,默认为false
若为true,则返回一个对象:{"distance":xxx,"x0":xxx,"y0":xxx,"x1":xxx,"y1":xxx}。其中 distance 表示几何对象到目标几何对象的距离;x0 和 y0 属性表示当前几何体上最靠近目标几何对象的坐标;x1 和 y1 表示目标几何上最靠近当前几何体的坐标。
但当edge为false且两个几何体相交,则计算距离的详细交点信息的:x0,y0,x1,y1 无参考意义!
若为false,则返回几何对象到目标几何对象的距离值,距离的单位与几何体的坐标相同。edge
Boolean 是否计算一个几何图形到目标几何图形边缘的最近距离,默认为true。 如果为true, 一个几何图形完全包含在目标几何图形中时,计算距离为负数;如果为false,两个几何图形相交情况下 计算距离为0。
Returns:
Number | Object -两个几何之间的距离。details为true 返回Object 否则返回 Number
Example
let options = {details:true,edge:false}; let geom = new hmap.geom.Point(new hmap.basetype.Coordinate(112.0,26.0)); circle.distanceTo(geom,options);
-
getBBox() → {module:basetype~BBox}
-
获取圆的三维包围盒
-
getCenter() → {module:geom~Point}
-
获取圆的中心点。
Example
let coord = new hmap.basetype.Coordinate(120,30,0); let center = new hmap.geom.Point(coord); let circle = new hmap.geom.Circle(center,20); let result = circle.getCenter();
-
getCoordSeqs() → {Array.<module:basetype~CoordSeq>}
-
获取圆的坐标序列数组,其长度为1。
Returns:
Array.<module:basetype~CoordSeq>Example
let coordSeqs = circleGeom.getCoordSeqs();
-
getRadius() → {Number}
-
获取圆的半径。
Returns:
Number -圆的半径。
Example
let result = circle.getRadius();
-
getType() → {String}
-
获取当前几何体的类型
Example
let type = circleGeom.getType();
-
intersectsGeometry(geom) → {Boolean}
-
检测圆与入参几何体是否相交。
Parameters:
Name Type Description geom
module:geom~Geometry 几何体。
Returns:
Boolean -返回true表示相交;返回false表示不相交。
Example
const pt1 = new hmap.geom.Point(new hmap.basetype.Coordinate(119.0,30.0)); const pt2 = new hmap.geom.Point(new hmap.basetype.Cooridinate(120.0,30.2)); let geom = new hmap.geom.Line([pt1,pt2]); circle.intersectsGeometry(geom);
-
setCtrlPoints(points)
-
重新设置圆的控制点。
Parameters:
Name Type Description points
Array.<module:geom~Point> 点几何体数组,数组长度为2,否则抛出构造异常。
Throws:
RangeError | TypeError -数组长度不等于2或非数组类型,则抛出构造异常。
Example
let point1 = new hmap.geom.Point(new hmap.basetype.Coordinate(120,30,0)); let point2 = new hmap.geom.Point(new hmap.basetype.Coordinate(121,31,0)); circleGeom.setCtrlPoints([point1,point2])
-
toPolygon() → {module:geom~Polygon}
-
将圆转化为面几何体
Example
let polygon = circleGeom.toPolygon();