geomext~Rectangle(points)

矩形

Summary

Methods:
getBBox

获取拓展几何的三维包围盒

getCoordSeqs

获取矩形的坐标序列数组,其长度为1。

getType

获取几何体类型

intersectsGeometry

检测与另一个几何体是否相交。

setCtrlPoints

重新设置矩形的控制点。

toLine

将矩形转化为线几何

toPolygon

将矩形转化为面几何

Constructor

new Rectangle(points)

使用点几何体作为控制点构造矩形,控制点数量至少为2,且不可以重复。

Parameters:
Name Type Description
points Array.<module:geom~Point>

点几何体数组,数组大于2时,构造控制点的外接矩形;数组长度小于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));
let rectangleGeom = new hmap.geomext.Rectangle([point1,point2]);

Methods

getBBox() → {module:basetype~BBox}

获取拓展几何的三维包围盒

Returns:
module:basetype~BBox -

返回三维包围盒

getCoordSeqs() → {Array.<module:basetype~CoordSeq>}

获取矩形的坐标序列数组,其长度为1。

Returns:
Array.<module:basetype~CoordSeq> -

坐标序列数组

Example
let coordSeqs = rectangleGeom.getCoordSeqs();

getType() → {String}

获取几何体类型

Returns:
String -

hmap拓展的几何类型,参见GeometryExtType

Example
let type = rectangleGeom.getType();

intersectsGeometry(geom) → {Boolean}

检测与另一个几何体是否相交。

Parameters:
Name Type Description
geom module:geom~Geometry

另一个几何体。

Returns:
Boolean -

返回true表示相交;返回false表示不相交。

setCtrlPoints(points)

重新设置矩形的控制点。

Parameters:
Name Type Description
points Array.<module:geom~Point>

点几何体数组,数组大于2时,构造控制点的外接矩形;数组长度小于2或非数组类型时,则抛出构造异常。

Throws:
RangeError | TypeError -

数组长度小于2或非数组类型,则抛出构造异常。

Example
let point1 = new hmap.geom.Point(new hmap.basetype.Coordinate(121,30,0));
 let point2 = new hmap.geom.Point(new hmap.basetype.Coordinate(122,31,0));
 rectangleGeom.setCtrlPoints([point1,point2]);

toLine() → {module:geom~Line}

将矩形转化为线几何

Returns:
module:geom~Line -

线几何

Example
let line = rectangleGeom.toLine();

toPolygon() → {module:geom~Polygon}

将矩形转化为面几何

Returns:
module:geom~Polygon -

面几何

Example
let polygon = rectangleGeom.toPolygon();