Skip to content

Commit

Permalink
add 几何分析 hasInteraction 方法
Browse files Browse the repository at this point in the history
  • Loading branch information
xilanhuaweidapao committed Jun 24, 2024
1 parent 8089b8d commit 74aa750
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/common/util/GeometryAnalysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,21 @@ export class GeometryAnalysis extends Events {
const ugFeature2 = geojson2UGGeometry(compareFeature);
const result = this.module._UGCWasm_Geometrist_IsIdentical(ugFeature1, ugFeature2, tolerance);
return result === 1;
}
/**
* @function GeometryAnalysis.prototype.hasIntersection
* @version 11.2.0
* @description 几何对象是否相交分析。
* @param {GeoJSONFeature} feature - geojson 要素。
* @param {GeoJSONFeature} compareFeature - geojson 对比要素。
* @param {number} [tolerance=1e-6] - 容限。
* @returns {boolean} 要素是否相交。
*/
hasIntersection(feature, compareFeature, tolerance = 1e-6) {
const ugFeature1 = geojson2UGGeometry(feature);
const ugFeature2 = geojson2UGGeometry(compareFeature);
const result = this.module._UGCWasm_Geometrist_HasIntersection(ugFeature1, ugFeature2, tolerance);
return result === 1;
}
/**
* @function GeometryAnalysis.prototype.hasTouch
Expand Down
68 changes: 68 additions & 0 deletions test/common/util/GeometryAnalysisSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,74 @@ describe('GeometryAnalysis', () => {
expect(result).toBeTruthy();
});

it('hasIntersection', () => {
const poly1 = {
"type": "Feature",
"properties": {},
"geometry": {
"coordinates": [
[
[
69.05078125000003,
64.94452997268957
],
[
69.05078125000003,
52.72637398699237
],
[
90.14453124999983,
52.72637398699237
],
[
90.14453124999983,
64.94452997268957
],
[
69.05078125000003,
64.94452997268957
]
]
],
"type": "Polygon"
},
"id": 0
};
const poly2 = {
"type": "Feature",
"properties": {},
"geometry": {
"coordinates": [
[
[
80.87563161140378,
57.45030784568206
],
[
80.87563161140378,
43.6194265865916
],
[
110.40688161140469,
43.6194265865916
],
[
110.40688161140469,
57.45030784568206
],
[
80.87563161140378,
57.45030784568206
]
]
],
"type": "Polygon"
}
};
const result = instance.hasIntersection(poly1, poly2);
expect(result).toBeTruthy();
});


it('isIdentical multilinestring', () => {
const line1 = {
Expand Down

0 comments on commit 74aa750

Please sign in to comment.