Class: GeometryAnalysis

GeometryAnalysis

要素级几何分析类,提供缓冲区分析、凹凸面计算等常见的空间分析接口。

new GeometryAnalysis(Module)

Usage
// 浏览器
<script type="text/javascript" src="https://iclient.supermap.io/dist/maplibregl/iclient-maplibregl.js"></script>
<script type="text/javascript" src="https://iclient.supermap.io/web/libs/ugcwasm/1.0.0/UGCWasmAll.js"></script>
<script>
  new maplibregl.supermap.GeometryAnalysis();
  
</script>

// ES6 Import
import { GeometryAnalysis } from "@supermapgis/iclient-maplibregl";

new GeometryAnalysis();
common/util/GeometryAnalysis.js, line 8
Name Type Description
Module Object 可选

几何分析模块。

Events

loaded

common/util/GeometryAnalysis.js, line 41

监听到几何分析模块加载完成事件后触发。

Methods

buffer(feature, radius){GeoJSONFeature}

common/util/GeometryAnalysis.js, line 52

缓冲区分析。

Name Type Description
feature GeoJSONFeature

要素。

radius number

缓冲区距离,单位与数据单位一致。

Version:
  • 11.2.0
Returns:
Type Description
GeoJSONFeature 结果要素。

computeConcaveHullPoints(xArray, yArray, angle){GeoJSONFeature}

common/util/GeometryAnalysis.js, line 258

点数组凹闭包计算。

Name Type Description
xArray Array

x 坐标数组,

yArray Array

y 坐标数组。

angle number

凹包内最小角度。

Version:
  • 11.2.0
Returns:
Type Description
GeoJSONFeature 结果要素。

computeConcaveHullPoints(points, angle){GeoJSONFeature}

common/util/GeometryAnalysis.js, line 267

点数组凹闭包计算。

Name Type Description
points Array | FeatureCollection

点坐标数组,支持的形式为 [[x, y]],[{x, y}],点要素数组,也支持 FeatureCollection。

angle number

凹包内最小角度。

Version:
  • 11.2.0
Returns:
Type Description
GeoJSONFeature 结果要素。

computeConvexHull(points){GeoJSONFeature}

common/util/GeometryAnalysis.js, line 69

凸多边形计算。

Name Type Description
points Array

点坐标数组。

Version:
  • 11.2.0
Returns:
Type Description
GeoJSONFeature 最小外接多边形要素。

computeConvexHullPoints(xArray, yArray){GeoJSONFeature}

common/util/GeometryAnalysis.js, line 487

点数组的凸闭包计算,即最小外接多边形。

Name Type Description
xArray Array

x 坐标数组。

yArray Array

y 坐标数组。

Version:
  • 11.2.0
Returns:
Type Description
GeoJSONFeature 最小外接多边形要素。

computeConvexHullPoints(points){GeoJSONFeature}

common/util/GeometryAnalysis.js, line 495

点数组的凸闭包计算,即最小外接多边形。

Name Type Description
points Array | FeatureCollection

点坐标数组,支持的形式为 [[x, y]],[{x, y}],点要素数组,也支持 FeatureCollection。

Version:
  • 11.2.0
Returns:
Type Description
GeoJSONFeature 最小外接多边形要素。

computeGeodesicArea(feature, unit){number}

common/util/GeometryAnalysis.js, line 377

计算坐标为经纬度的面要素面积。

Name Type Default Description
feature GeoJSONFeature

面要素,坐标参考系统为 WGS84 (http://www.opengis.net/def/crs/OGC/1.3/CRS84)。

unit string 'SquareMeter' 可选

结果面积单位,默认值为 SquareMeter,支持的值有:"SquareKiloMeter","SquareFoot","SquareYard","SquareMile","SquareMeter"。

Version:
  • 11.2.0
Returns:
Type Description
number 面积大小,单位与设置单位一致。

computeGeodesicDistance(xArray, yArray, majorAxis, flatten, unit){number}

common/util/GeometryAnalysis.js, line 422

计算测地线长度,坐标参考系统为 WGS84 (http://www.opengis.net/def/crs/OGC/1.3/CRS84)。

Name Type Default Description
xArray Array

x 坐标数组。

yArray Array

y 坐标数组。

majorAxis number

测地线所在椭球体的长轴,单位为米。

flatten number

测地线所在椭球体的扁率。

unit string 'METER' 可选

结果长度单位,默认值为 METER,支持的值有: "METER","KILOMETER","INCH","FOOT"。

Version:
  • 11.2.0
Returns:
Type Description
number 测地线的长度。

computeGeodesicDistance(points, majorAxis, flatten, unit){number}

common/util/GeometryAnalysis.js, line 433

计算测地线长度,坐标参考系统为 WGS84 (http://www.opengis.net/def/crs/OGC/1.3/CRS84)。

Name Type Default Description
points Array | FeatureCollection

点坐标数组,支持的形式为 [[x, y]],[{x, y}],点要素数组,也支持 FeatureCollection。

majorAxis number

测地线所在椭球体的长轴,单位为米。

flatten number

测地线所在椭球体的扁率。

unit string 'METER' 可选

结果长度单位,默认值为 METER,支持的值有: "METER","KILOMETER","INCH","FOOT"。

Version:
  • 11.2.0
Returns:
Type Description
number 测地线的长度。

computeParallel(feature, distance, featureUnit, unit){GeoJSONFeature}

common/util/GeometryAnalysis.js, line 463

根据距离获取线要素的平行线,线可为折线。

Name Type Default Description
feature GeoJSONFeature

线要素。

distance number

平行线距离。

featureUnit string 'DEGREE' 可选

线要素距离单位,默认值为 DEGREE,支持的值有: "METER","KILOMETER","INCH","FOOT","DEGREE"。

unit string 'DEGREE' 可选

平行线距离单位,默认值为 DEGREE,支持的值有: "METER","KILOMETER","INCH","FOOT","DEGREE"。

Version:
  • 11.2.0
Returns:
Type Description
GeoJSONFeature 结果为与线要素相隔传入距离长度的平行线要素。

computePerpendicularPosition(x1, y1, x2, y2, x3, y3){Array}

common/util/GeometryAnalysis.js, line 164

点到线的垂线分析。

Name Type Description
x1 number

点坐标 X。

y1 number

点坐标 Y。

x2 number

第一条线的起点X。

y2 number

第一条线的起点Y。

x3 number

第一条线的终点X。

y3 number

第一条线的终点Y。

Version:
  • 11.2.0
Returns:
Type Description
Array 垂线点坐标。

distanceToLineSegment(x, y, startX, startY, endX, endY, featureUnit, unit){number}

common/util/GeometryAnalysis.js, line 216

计算点到线段的距离。

Name Type Default Description
x number

点 X 坐标。

y number

点 Y 坐标。

startX number

线起点 X 坐标。

startY number

线起点 Y 坐标。

endX number

线终点 X 坐标。

endY number

线终点 Y 坐标。

featureUnit string 'DEGREE' 可选

线坐标的单位,默认值为 DEGREE, 支持的值有: "METER","KILOMETER","INCH","FOOT","DEGREE"。

unit string 'DEGREE' 可选

结果距离单位,默认值为 DEGREE,支持的值有: "METER","KILOMETER","INCH","FOOT","DEGREE"。

Version:
  • 11.2.0
Returns:
Type Description
number 点到线段的距离。如果点到线段的垂足不在线段上,则返回点到线段较近的端点的距离。

hasIntersection(feature, compareFeature, tolerance){boolean}

common/util/GeometryAnalysis.js, line 100

几何对象是否相交分析,传入要素坐标系需一致。

Name Type Default Description
feature GeoJSONFeature

要素。

compareFeature GeoJSONFeature

对比要素。

tolerance number 1e-6 可选

要素节点容限值。

Version:
  • 11.2.0
Returns:
Type Description
boolean 要素是否相交。

hasTouch(feature, compareFeature, tolerance){boolean}

common/util/GeometryAnalysis.js, line 115

几何对象边界是否接触分析,传入要素坐标系需一致。

Name Type Default Description
feature GeoJSONFeature

要素。

compareFeature GeoJSONFeature

对比要素。

tolerance number 1e-6 可选

要素节点容限值。

Version:
  • 11.2.0
Returns:
Type Description
boolean 几何对象边界是否接触。

isIdentical(feature, compareFeature, tolerance){boolean}

common/util/GeometryAnalysis.js, line 85

几何对象相等分析,传入要素坐标系需一致。

Name Type Default Description
feature GeoJSONFeature

要素。

compareFeature GeoJSONFeature

对比要素。

tolerance number 1e-6 可选

要素节点容限值。

Version:
  • 11.2.0
Returns:
Type Description
boolean 要素是否完全相等。

isIntersectRegionWithRect(feature, left, top, right, bottom, tolerance){boolean}

common/util/GeometryAnalysis.js, line 309

几何对象与矩形是否相交分析。

Name Type Default Description
feature GeoJSONFeature

要素。

left number

矩形左坐标。

top number

矩形上坐标。

right number

矩形右坐标。

bottom number

矩形下坐标。

tolerance number 1e-6 可选

要素节点容限值。

Version:
  • 11.2.0
Returns:
Type Description
boolean 要素是否与矩形相交。

isLeft(x, y, startX, startY, endX, endY){boolean}

common/util/GeometryAnalysis.js, line 361

判断点是否在线的左侧。

Name Type Description
x number

点 X 坐标。

y number

点 Y 坐标。

startX number

线起点 X 坐标。

startY number

线起点 Y 坐标。

endX number

线终点 X 坐标。

endY number

线终点 Y 坐标。

Version:
  • 11.2.0
Returns:
Type Description
boolean 点是否在线的左侧。

isOnSameSide(x1, y1, x2, y2, startX, startY, endX, endY){boolean}

common/util/GeometryAnalysis.js, line 326

判断两点是否在线的同一侧。

Name Type Description
x1 number

点1 X 坐标。

y1 number

点1 Y 坐标。

x2 number

点2 X 坐标。

y2 number

点2 Y 坐标。

startX number

线起点 X 坐标。

startY number

线起点 Y 坐标。

endX number

线终点 X 坐标。

endY number

线终点 Y 坐标。

Version:
  • 11.2.0
Returns:
Type Description
boolean 是否两点在线的同一侧。

isParallel(x1, y1, x2, y2, x3, y3, x4, y4){boolean}

common/util/GeometryAnalysis.js, line 146

线平行分析。

Name Type Description
x1 number

第一条线的起点X。

y1 number

第一条线的起点Y。

x2 number

第一条线的终点X。

y2 number

第一条线的终点Y。

x3 number

第二条线的起点X。

y3 number

第二条线的起点Y。

x4 number

第二条线的终点X。

y4 number

第二条线的终点Y。

Version:
  • 11.2.0
Returns:
Type Description
boolean 两条线是否平行。

isPointOnLine(x1, y1, x2, y2, x3, y3, extended){boolean}

common/util/GeometryAnalysis.js, line 183

点是否在已知线段上。

Name Type Default Description
x1 number

点坐标 X。

y1 number

点坐标 Y。

x2 number

第一条线的起点X。

y2 number

第一条线的起点Y。

x3 number

第一条线的终点X。

y3 number

第一条线的终点Y。

extended boolean false 可选

是否将线段进行延长计算,默认不延长。

Version:
  • 11.2.0
Returns:
Type Description
boolean 点是否在已知线段上。

isProjectOnLineSegment(x, y, startX, startY, endX, endY){boolean}

common/util/GeometryAnalysis.js, line 200

判断点到线段的垂足是否在该线段上。

Name Type Description
x number

点 X 坐标。

y number

点 Y 坐标。

startX number

线起点 X 坐标。

startY number

线起点 Y 坐标。

endX number

线终点 X 坐标。

endY number

线终点 Y 坐标。

Version:
  • 11.2.0
Returns:
Type Description
boolean 点到线段的垂足是否在该线段上。

isRight(x, y, startX, startY, endX, endY){boolean}

common/util/GeometryAnalysis.js, line 344

判断点是否在线的右侧。

Name Type Description
x number

点 X 坐标。

y number

点 Y 坐标。

startX number

线起点 X 坐标。

startY number

线起点 Y 坐标。

endX number

线终点 X 坐标。

endY number

线终点 Y 坐标。

Version:
  • 11.2.0
Returns:
Type Description
boolean 点是否在线的右侧。

isSegmentIntersect(x1, y1, x2, y2, x3, y3, x4, y4){boolean}

common/util/GeometryAnalysis.js, line 291

计算线段是否相交。

Name Type Description
x1 number

第一条线的起点X。

y1 number

第一条线的起点Y。

x2 number

第一条线的终点X。

y2 number

第一条线的终点Y。

x3 number

第二条线的起点X。

y3 number

第二条线的起点Y。

x4 number

第二条线的终点X。

y4 number

第二条线的终点Y。

Version:
  • 11.2.0
Returns:
Type Description
boolean 线是否相交。

nearestPointToVertex(x, y, feature){Array}

common/util/GeometryAnalysis.js, line 237

计算线到点的最近距离点,传入要素坐标系需一致。

Name Type Description
x number

点 X 坐标。

y number

点 Y 坐标。

feature GeoJSONFeature

线要素。

Version:
  • 11.2.0
Returns:
Type Description
Array 线到点最近点的坐标数组。

resample(feature, tolerance){GeoJSONFeature}

common/util/GeometryAnalysis.js, line 130

重采样分析。

Name Type Default Description
feature GeoJSONFeature

要素。

tolerance number 1e-6 可选

指定的重采样容限。

Version:
  • 11.2.0
Returns:
Type Description
GeoJSONFeature 结果要素。

smooth(feature, smoothness){GeoJSONFeature}

common/util/GeometryAnalysis.js, line 401

线要素光滑分析。

Name Type Default Description
feature GeoJSONFeature

线要素。

smoothness number 2 可选

有效范围为大于等于2,设置为小于2的值会抛出异常,光滑系数越大,线对象节点数越多,也就越光滑。 建议取值范围为[2,10]。

Version:
  • 11.2.0
Returns:
Type Description
GeoJSONFeature 光滑处理后的线要素。