MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / _handleMultyPolygon

Method _handleMultyPolygon

src/common/mapping/WebMapV2.js:3194–3220  ·  view source on GitHub ↗

* @private * @function WebMapV2.prototype._handleMultyPolygon * @description 处理复杂面情况

(features)

Source from the content-addressed store, hash-verified

3192 * @description 处理复杂面情况
3193 */
3194 _handleMultyPolygon(features) {
3195 features.forEach((feature) => {
3196 if (feature.geometry.type !== 'Polygon') {
3197 return;
3198 }
3199 let coords = feature.geometry.coordinates;
3200 if (coords.length > 1) {
3201 let coordinates = [[coords[0]]];
3202 for (let index = 1; index < coords.length; index++) {
3203 const element = coords[index];
3204 const area = this.signedArea(element);
3205 if (area === 0) {
3206 continue;
3207 }
3208 if (area > 0) {
3209 coordinates[coordinates.length - 1].push(coords[index]);
3210 } else {
3211 coordinates.push([coords[index]]);
3212 }
3213 }
3214
3215 feature.geometry.coordinates = coordinates;
3216 feature.geometry.type = 'MultiPolygon';
3217 }
3218 });
3219 return features;
3220 }
3221
3222 signedArea(ring) {
3223 let sum = 0;

Callers 3

_initOverlayLayerMethod · 0.95
WebMapSpec.jsFile · 0.80
WebMapSpec.jsFile · 0.80

Calls 3

signedAreaMethod · 0.95
forEachMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected