* @private * @function WebMapV2.prototype._handleMultyPolygon * @description 处理复杂面情况
(features)
| 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; |
no test coverage detected