Merge pull request #9190 from romanzoller/multi-polygon-area
Fix MultiPolygon area calculation
This commit is contained in:
@@ -16,7 +16,7 @@ import {deflateMultiCoordinatesArray} from './flat/deflate.js';
|
||||
import {inflateMultiCoordinatesArray} from './flat/inflate.js';
|
||||
import {getInteriorPointsOfMultiArray} from './flat/interiorpoint.js';
|
||||
import {intersectsLinearRingMultiArray} from './flat/intersectsextent.js';
|
||||
import {linearRingsAreOriented, orientLinearRingsArray} from './flat/orient.js';
|
||||
import {linearRingssAreOriented, orientLinearRingsArray} from './flat/orient.js';
|
||||
import {quantizeMultiArray} from './flat/simplify.js';
|
||||
|
||||
/**
|
||||
@@ -251,7 +251,7 @@ class MultiPolygon extends SimpleGeometry {
|
||||
getOrientedFlatCoordinates() {
|
||||
if (this.orientedRevision_ != this.getRevision()) {
|
||||
const flatCoordinates = this.flatCoordinates;
|
||||
if (linearRingsAreOriented(
|
||||
if (linearRingssAreOriented(
|
||||
flatCoordinates, 0, this.endss_, this.stride)) {
|
||||
this.orientedFlatCoordinates_ = flatCoordinates;
|
||||
} else {
|
||||
|
||||
@@ -16,7 +16,7 @@ import {deflateCoordinatesArray} from './flat/deflate.js';
|
||||
import {inflateCoordinatesArray} from './flat/inflate.js';
|
||||
import {getInteriorPointOfArray} from './flat/interiorpoint.js';
|
||||
import {intersectsLinearRingArray} from './flat/intersectsextent.js';
|
||||
import {linearRingIsOriented, orientLinearRings} from './flat/orient.js';
|
||||
import {linearRingsAreOriented, orientLinearRings} from './flat/orient.js';
|
||||
import {quantizeArray} from './flat/simplify.js';
|
||||
import {modulo} from '../math.js';
|
||||
|
||||
@@ -266,7 +266,7 @@ class Polygon extends SimpleGeometry {
|
||||
getOrientedFlatCoordinates() {
|
||||
if (this.orientedRevision_ != this.getRevision()) {
|
||||
const flatCoordinates = this.flatCoordinates;
|
||||
if (linearRingIsOriented(
|
||||
if (linearRingsAreOriented(
|
||||
flatCoordinates, 0, this.ends_, this.stride)) {
|
||||
this.orientedFlatCoordinates_ = flatCoordinates;
|
||||
} else {
|
||||
|
||||
@@ -41,7 +41,7 @@ export function linearRingIsClockwise(flatCoordinates, offset, end, stride) {
|
||||
* (counter-clockwise exterior ring and clockwise interior rings).
|
||||
* @return {boolean} Rings are correctly oriented.
|
||||
*/
|
||||
export function linearRingIsOriented(flatCoordinates, offset, ends, stride, opt_right) {
|
||||
export function linearRingsAreOriented(flatCoordinates, offset, ends, stride, opt_right) {
|
||||
const right = opt_right !== undefined ? opt_right : false;
|
||||
for (let i = 0, ii = ends.length; i < ii; ++i) {
|
||||
const end = ends[i];
|
||||
@@ -75,12 +75,16 @@ export function linearRingIsOriented(flatCoordinates, offset, ends, stride, opt_
|
||||
* (counter-clockwise exterior ring and clockwise interior rings).
|
||||
* @return {boolean} Rings are correctly oriented.
|
||||
*/
|
||||
export function linearRingsAreOriented(flatCoordinates, offset, endss, stride, opt_right) {
|
||||
export function linearRingssAreOriented(flatCoordinates, offset, endss, stride, opt_right) {
|
||||
for (let i = 0, ii = endss.length; i < ii; ++i) {
|
||||
if (!linearRingIsOriented(
|
||||
flatCoordinates, offset, endss[i], stride, opt_right)) {
|
||||
const ends = endss[i];
|
||||
if (!linearRingsAreOriented(
|
||||
flatCoordinates, offset, ends, stride, opt_right)) {
|
||||
return false;
|
||||
}
|
||||
if (ends.length) {
|
||||
offset = ends[ends.length - 1];
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user