Remove simplified geometry cache
This commit is contained in:
@@ -45,12 +45,6 @@ class Geometry extends BaseObject {
|
|||||||
*/
|
*/
|
||||||
this.extentRevision_ = -1;
|
this.extentRevision_ = -1;
|
||||||
|
|
||||||
/**
|
|
||||||
* @protected
|
|
||||||
* @type {Object<string, Geometry>}
|
|
||||||
*/
|
|
||||||
this.simplifiedGeometryCache = {};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
* @type {number}
|
* @type {number}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import EventType from '../events/EventType.js';
|
|||||||
import {createOrUpdateEmpty, closestSquaredDistanceXY, extend, getCenter} from '../extent.js';
|
import {createOrUpdateEmpty, closestSquaredDistanceXY, extend, getCenter} from '../extent.js';
|
||||||
import Geometry from './Geometry.js';
|
import Geometry from './Geometry.js';
|
||||||
import GeometryType from './GeometryType.js';
|
import GeometryType from './GeometryType.js';
|
||||||
import {clear} from '../obj.js';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @classdesc
|
* @classdesc
|
||||||
@@ -131,8 +130,7 @@ class GeometryCollection extends Geometry {
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
getSimplifiedGeometry(squaredTolerance) {
|
getSimplifiedGeometry(squaredTolerance) {
|
||||||
if (this.simplifiedGeometryRevision != this.getRevision()) {
|
if (this.simplifiedGeometryRevision !== this.getRevision()) {
|
||||||
clear(this.simplifiedGeometryCache);
|
|
||||||
this.simplifiedGeometryMaxMinSquaredTolerance = 0;
|
this.simplifiedGeometryMaxMinSquaredTolerance = 0;
|
||||||
this.simplifiedGeometryRevision = this.getRevision();
|
this.simplifiedGeometryRevision = this.getRevision();
|
||||||
}
|
}
|
||||||
@@ -141,10 +139,7 @@ class GeometryCollection extends Geometry {
|
|||||||
squaredTolerance < this.simplifiedGeometryMaxMinSquaredTolerance)) {
|
squaredTolerance < this.simplifiedGeometryMaxMinSquaredTolerance)) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
const key = squaredTolerance.toString();
|
|
||||||
if (this.simplifiedGeometryCache.hasOwnProperty(key)) {
|
|
||||||
return this.simplifiedGeometryCache[key];
|
|
||||||
} else {
|
|
||||||
const simplifiedGeometries = [];
|
const simplifiedGeometries = [];
|
||||||
const geometries = this.geometries_;
|
const geometries = this.geometries_;
|
||||||
let simplified = false;
|
let simplified = false;
|
||||||
@@ -159,14 +154,12 @@ class GeometryCollection extends Geometry {
|
|||||||
if (simplified) {
|
if (simplified) {
|
||||||
const simplifiedGeometryCollection = new GeometryCollection(null);
|
const simplifiedGeometryCollection = new GeometryCollection(null);
|
||||||
simplifiedGeometryCollection.setGeometriesArray(simplifiedGeometries);
|
simplifiedGeometryCollection.setGeometriesArray(simplifiedGeometries);
|
||||||
this.simplifiedGeometryCache[key] = simplifiedGeometryCollection;
|
|
||||||
return simplifiedGeometryCollection;
|
return simplifiedGeometryCollection;
|
||||||
} else {
|
} else {
|
||||||
this.simplifiedGeometryMaxMinSquaredTolerance = squaredTolerance;
|
this.simplifiedGeometryMaxMinSquaredTolerance = squaredTolerance;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import {createOrUpdateFromFlatCoordinates, getCenter} from '../extent.js';
|
|||||||
import Geometry from './Geometry.js';
|
import Geometry from './Geometry.js';
|
||||||
import GeometryLayout from './GeometryLayout.js';
|
import GeometryLayout from './GeometryLayout.js';
|
||||||
import {rotate, scale, translate, transform2D} from './flat/transform.js';
|
import {rotate, scale, translate, transform2D} from './flat/transform.js';
|
||||||
import {clear} from '../obj.js';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @classdesc
|
* @classdesc
|
||||||
@@ -95,8 +94,7 @@ class SimpleGeometry extends Geometry {
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
getSimplifiedGeometry(squaredTolerance) {
|
getSimplifiedGeometry(squaredTolerance) {
|
||||||
if (this.simplifiedGeometryRevision != this.getRevision()) {
|
if (this.simplifiedGeometryRevision !== this.getRevision()) {
|
||||||
clear(this.simplifiedGeometryCache);
|
|
||||||
this.simplifiedGeometryMaxMinSquaredTolerance = 0;
|
this.simplifiedGeometryMaxMinSquaredTolerance = 0;
|
||||||
this.simplifiedGeometryRevision = this.getRevision();
|
this.simplifiedGeometryRevision = this.getRevision();
|
||||||
}
|
}
|
||||||
@@ -107,15 +105,11 @@ class SimpleGeometry extends Geometry {
|
|||||||
squaredTolerance <= this.simplifiedGeometryMaxMinSquaredTolerance)) {
|
squaredTolerance <= this.simplifiedGeometryMaxMinSquaredTolerance)) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
const key = squaredTolerance.toString();
|
|
||||||
if (this.simplifiedGeometryCache.hasOwnProperty(key)) {
|
|
||||||
return this.simplifiedGeometryCache[key];
|
|
||||||
} else {
|
|
||||||
const simplifiedGeometry =
|
const simplifiedGeometry =
|
||||||
this.getSimplifiedGeometryInternal(squaredTolerance);
|
this.getSimplifiedGeometryInternal(squaredTolerance);
|
||||||
const simplifiedFlatCoordinates = simplifiedGeometry.getFlatCoordinates();
|
const simplifiedFlatCoordinates = simplifiedGeometry.getFlatCoordinates();
|
||||||
if (simplifiedFlatCoordinates.length < this.flatCoordinates.length) {
|
if (simplifiedFlatCoordinates.length < this.flatCoordinates.length) {
|
||||||
this.simplifiedGeometryCache[key] = simplifiedGeometry;
|
|
||||||
return simplifiedGeometry;
|
return simplifiedGeometry;
|
||||||
} else {
|
} else {
|
||||||
// Simplification did not actually remove any coordinates. We now know
|
// Simplification did not actually remove any coordinates. We now know
|
||||||
@@ -128,7 +122,6 @@ class SimpleGeometry extends Geometry {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {number} squaredTolerance Squared tolerance.
|
* @param {number} squaredTolerance Squared tolerance.
|
||||||
|
|||||||
Reference in New Issue
Block a user