Skip to content

Commit 74aa750

Browse files
add 几何分析 hasInteraction 方法
1 parent 8089b8d commit 74aa750

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed

src/common/util/GeometryAnalysis.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,21 @@ export class GeometryAnalysis extends Events {
7171
const ugFeature2 = geojson2UGGeometry(compareFeature);
7272
const result = this.module._UGCWasm_Geometrist_IsIdentical(ugFeature1, ugFeature2, tolerance);
7373
return result === 1;
74+
}
75+
/**
76+
* @function GeometryAnalysis.prototype.hasIntersection
77+
* @version 11.2.0
78+
* @description 几何对象是否相交分析。
79+
* @param {GeoJSONFeature} feature - geojson 要素。
80+
* @param {GeoJSONFeature} compareFeature - geojson 对比要素。
81+
* @param {number} [tolerance=1e-6] - 容限。
82+
* @returns {boolean} 要素是否相交。
83+
*/
84+
hasIntersection(feature, compareFeature, tolerance = 1e-6) {
85+
const ugFeature1 = geojson2UGGeometry(feature);
86+
const ugFeature2 = geojson2UGGeometry(compareFeature);
87+
const result = this.module._UGCWasm_Geometrist_HasIntersection(ugFeature1, ugFeature2, tolerance);
88+
return result === 1;
7489
}
7590
/**
7691
* @function GeometryAnalysis.prototype.hasTouch

test/common/util/GeometryAnalysisSpec.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,74 @@ describe('GeometryAnalysis', () => {
5858
expect(result).toBeTruthy();
5959
});
6060

61+
it('hasIntersection', () => {
62+
const poly1 = {
63+
"type": "Feature",
64+
"properties": {},
65+
"geometry": {
66+
"coordinates": [
67+
[
68+
[
69+
69.05078125000003,
70+
64.94452997268957
71+
],
72+
[
73+
69.05078125000003,
74+
52.72637398699237
75+
],
76+
[
77+
90.14453124999983,
78+
52.72637398699237
79+
],
80+
[
81+
90.14453124999983,
82+
64.94452997268957
83+
],
84+
[
85+
69.05078125000003,
86+
64.94452997268957
87+
]
88+
]
89+
],
90+
"type": "Polygon"
91+
},
92+
"id": 0
93+
};
94+
const poly2 = {
95+
"type": "Feature",
96+
"properties": {},
97+
"geometry": {
98+
"coordinates": [
99+
[
100+
[
101+
80.87563161140378,
102+
57.45030784568206
103+
],
104+
[
105+
80.87563161140378,
106+
43.6194265865916
107+
],
108+
[
109+
110.40688161140469,
110+
43.6194265865916
111+
],
112+
[
113+
110.40688161140469,
114+
57.45030784568206
115+
],
116+
[
117+
80.87563161140378,
118+
57.45030784568206
119+
]
120+
]
121+
],
122+
"type": "Polygon"
123+
}
124+
};
125+
const result = instance.hasIntersection(poly1, poly2);
126+
expect(result).toBeTruthy();
127+
});
128+
61129

62130
it('isIdentical multilinestring', () => {
63131
const line1 = {

0 commit comments

Comments
 (0)