Factor out ol.geom.flat.simplify
This commit is contained in:
@@ -24,7 +24,7 @@
|
|||||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
// POSSIBILITY OF SUCH DAMAGE.
|
// POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
goog.provide('ol.geom.simplify');
|
goog.provide('ol.geom.flat.simplify');
|
||||||
|
|
||||||
goog.require('ol.geom.flat');
|
goog.require('ol.geom.flat');
|
||||||
|
|
||||||
@@ -40,19 +40,19 @@ goog.require('ol.geom.flat');
|
|||||||
* coordinates.
|
* coordinates.
|
||||||
* @return {Array.<number>} Simplified line string.
|
* @return {Array.<number>} Simplified line string.
|
||||||
*/
|
*/
|
||||||
ol.geom.simplify.lineString = function(flatCoordinates, offset, end, stride,
|
ol.geom.flat.simplify.lineString = function(flatCoordinates, offset, end,
|
||||||
squaredTolerance, highQuality, opt_simplifiedFlatCoordinates) {
|
stride, squaredTolerance, highQuality, opt_simplifiedFlatCoordinates) {
|
||||||
var simplifiedFlatCoordinates = goog.isDef(opt_simplifiedFlatCoordinates) ?
|
var simplifiedFlatCoordinates = goog.isDef(opt_simplifiedFlatCoordinates) ?
|
||||||
opt_simplifiedFlatCoordinates : [];
|
opt_simplifiedFlatCoordinates : [];
|
||||||
if (!highQuality) {
|
if (!highQuality) {
|
||||||
end = ol.geom.simplify.radialDistance(flatCoordinates, offset, end,
|
end = ol.geom.flat.simplify.radialDistance(flatCoordinates, offset, end,
|
||||||
stride, squaredTolerance,
|
stride, squaredTolerance,
|
||||||
simplifiedFlatCoordinates, 0);
|
simplifiedFlatCoordinates, 0);
|
||||||
flatCoordinates = simplifiedFlatCoordinates;
|
flatCoordinates = simplifiedFlatCoordinates;
|
||||||
offset = 0;
|
offset = 0;
|
||||||
stride = 2;
|
stride = 2;
|
||||||
}
|
}
|
||||||
simplifiedFlatCoordinates.length = ol.geom.simplify.douglasPeucker(
|
simplifiedFlatCoordinates.length = ol.geom.flat.simplify.douglasPeucker(
|
||||||
flatCoordinates, offset, end, stride, squaredTolerance,
|
flatCoordinates, offset, end, stride, squaredTolerance,
|
||||||
simplifiedFlatCoordinates, 0);
|
simplifiedFlatCoordinates, 0);
|
||||||
return simplifiedFlatCoordinates;
|
return simplifiedFlatCoordinates;
|
||||||
@@ -70,7 +70,7 @@ ol.geom.simplify.lineString = function(flatCoordinates, offset, end, stride,
|
|||||||
* @param {number} simplifiedOffset Simplified offset.
|
* @param {number} simplifiedOffset Simplified offset.
|
||||||
* @return {number} Simplified offset.
|
* @return {number} Simplified offset.
|
||||||
*/
|
*/
|
||||||
ol.geom.simplify.douglasPeucker = function(flatCoordinates, offset, end,
|
ol.geom.flat.simplify.douglasPeucker = function(flatCoordinates, offset, end,
|
||||||
stride, squaredTolerance, simplifiedFlatCoordinates, simplifiedOffset) {
|
stride, squaredTolerance, simplifiedFlatCoordinates, simplifiedOffset) {
|
||||||
var n = (end - offset) / stride;
|
var n = (end - offset) / stride;
|
||||||
if (n < 3) {
|
if (n < 3) {
|
||||||
@@ -142,13 +142,13 @@ ol.geom.simplify.douglasPeucker = function(flatCoordinates, offset, end,
|
|||||||
* @param {Array.<number>} simplifiedEnds Simplified ends.
|
* @param {Array.<number>} simplifiedEnds Simplified ends.
|
||||||
* @return {number} Simplified offset.
|
* @return {number} Simplified offset.
|
||||||
*/
|
*/
|
||||||
ol.geom.simplify.douglasPeuckers = function(flatCoordinates, offset,
|
ol.geom.flat.simplify.douglasPeuckers = function(flatCoordinates, offset,
|
||||||
ends, stride, squaredTolerance, simplifiedFlatCoordinates,
|
ends, stride, squaredTolerance, simplifiedFlatCoordinates,
|
||||||
simplifiedOffset, simplifiedEnds) {
|
simplifiedOffset, simplifiedEnds) {
|
||||||
var i, ii;
|
var i, ii;
|
||||||
for (i = 0, ii = ends.length; i < ii; ++i) {
|
for (i = 0, ii = ends.length; i < ii; ++i) {
|
||||||
var end = ends[i];
|
var end = ends[i];
|
||||||
simplifiedOffset = ol.geom.simplify.douglasPeucker(
|
simplifiedOffset = ol.geom.flat.simplify.douglasPeucker(
|
||||||
flatCoordinates, offset, end, stride, squaredTolerance,
|
flatCoordinates, offset, end, stride, squaredTolerance,
|
||||||
simplifiedFlatCoordinates, simplifiedOffset);
|
simplifiedFlatCoordinates, simplifiedOffset);
|
||||||
simplifiedEnds.push(simplifiedOffset);
|
simplifiedEnds.push(simplifiedOffset);
|
||||||
@@ -170,14 +170,14 @@ ol.geom.simplify.douglasPeuckers = function(flatCoordinates, offset,
|
|||||||
* @param {Array.<Array.<number>>} simplifiedEndss Simplified endss.
|
* @param {Array.<Array.<number>>} simplifiedEndss Simplified endss.
|
||||||
* @return {number} Simplified offset.
|
* @return {number} Simplified offset.
|
||||||
*/
|
*/
|
||||||
ol.geom.simplify.douglasPeuckerss = function(
|
ol.geom.flat.simplify.douglasPeuckerss = function(
|
||||||
flatCoordinates, offset, endss, stride, squaredTolerance,
|
flatCoordinates, offset, endss, stride, squaredTolerance,
|
||||||
simplifiedFlatCoordinates, simplifiedOffset, simplifiedEndss) {
|
simplifiedFlatCoordinates, simplifiedOffset, simplifiedEndss) {
|
||||||
var i, ii;
|
var i, ii;
|
||||||
for (i = 0, ii = endss.length; i < ii; ++i) {
|
for (i = 0, ii = endss.length; i < ii; ++i) {
|
||||||
var ends = endss[i];
|
var ends = endss[i];
|
||||||
var simplifiedEnds = [];
|
var simplifiedEnds = [];
|
||||||
simplifiedOffset = ol.geom.simplify.douglasPeuckers(
|
simplifiedOffset = ol.geom.flat.simplify.douglasPeuckers(
|
||||||
flatCoordinates, offset, ends, stride, squaredTolerance,
|
flatCoordinates, offset, ends, stride, squaredTolerance,
|
||||||
simplifiedFlatCoordinates, simplifiedOffset, simplifiedEnds);
|
simplifiedFlatCoordinates, simplifiedOffset, simplifiedEnds);
|
||||||
simplifiedEndss.push(simplifiedEnds);
|
simplifiedEndss.push(simplifiedEnds);
|
||||||
@@ -198,7 +198,7 @@ ol.geom.simplify.douglasPeuckerss = function(
|
|||||||
* @param {number} simplifiedOffset Simplified offset.
|
* @param {number} simplifiedOffset Simplified offset.
|
||||||
* @return {number} Simplified offset.
|
* @return {number} Simplified offset.
|
||||||
*/
|
*/
|
||||||
ol.geom.simplify.radialDistance = function(flatCoordinates, offset, end,
|
ol.geom.flat.simplify.radialDistance = function(flatCoordinates, offset, end,
|
||||||
stride, squaredTolerance, simplifiedFlatCoordinates, simplifiedOffset) {
|
stride, squaredTolerance, simplifiedFlatCoordinates, simplifiedOffset) {
|
||||||
if (end <= offset + stride) {
|
if (end <= offset + stride) {
|
||||||
// zero or one point, no simplification possible, so copy and return
|
// zero or one point, no simplification possible, so copy and return
|
||||||
@@ -241,7 +241,7 @@ ol.geom.simplify.radialDistance = function(flatCoordinates, offset, end,
|
|||||||
* @param {number} tolerance Squared tolerance.
|
* @param {number} tolerance Squared tolerance.
|
||||||
* @return {number} Rounded value.
|
* @return {number} Rounded value.
|
||||||
*/
|
*/
|
||||||
ol.geom.simplify.snap = function(value, tolerance) {
|
ol.geom.flat.simplify.snap = function(value, tolerance) {
|
||||||
return tolerance * Math.round(value / tolerance);
|
return tolerance * Math.round(value / tolerance);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -265,15 +265,15 @@ ol.geom.simplify.snap = function(value, tolerance) {
|
|||||||
* @param {number} simplifiedOffset Simplified offset.
|
* @param {number} simplifiedOffset Simplified offset.
|
||||||
* @return {number} Simplified offset.
|
* @return {number} Simplified offset.
|
||||||
*/
|
*/
|
||||||
ol.geom.simplify.quantize = function(flatCoordinates, offset, end, stride,
|
ol.geom.flat.simplify.quantize = function(flatCoordinates, offset, end, stride,
|
||||||
tolerance, simplifiedFlatCoordinates, simplifiedOffset) {
|
tolerance, simplifiedFlatCoordinates, simplifiedOffset) {
|
||||||
// do nothing if the line is empty
|
// do nothing if the line is empty
|
||||||
if (offset == end) {
|
if (offset == end) {
|
||||||
return simplifiedOffset;
|
return simplifiedOffset;
|
||||||
}
|
}
|
||||||
// snap the first coordinate (P1)
|
// snap the first coordinate (P1)
|
||||||
var x1 = ol.geom.simplify.snap(flatCoordinates[offset], tolerance);
|
var x1 = ol.geom.flat.simplify.snap(flatCoordinates[offset], tolerance);
|
||||||
var y1 = ol.geom.simplify.snap(flatCoordinates[offset + 1], tolerance);
|
var y1 = ol.geom.flat.simplify.snap(flatCoordinates[offset + 1], tolerance);
|
||||||
offset += stride;
|
offset += stride;
|
||||||
// add the first coordinate to the output
|
// add the first coordinate to the output
|
||||||
simplifiedFlatCoordinates[simplifiedOffset++] = x1;
|
simplifiedFlatCoordinates[simplifiedOffset++] = x1;
|
||||||
@@ -282,8 +282,8 @@ ol.geom.simplify.quantize = function(flatCoordinates, offset, end, stride,
|
|||||||
// coordinate (P2)
|
// coordinate (P2)
|
||||||
var x2, y2;
|
var x2, y2;
|
||||||
do {
|
do {
|
||||||
x2 = ol.geom.simplify.snap(flatCoordinates[offset], tolerance);
|
x2 = ol.geom.flat.simplify.snap(flatCoordinates[offset], tolerance);
|
||||||
y2 = ol.geom.simplify.snap(flatCoordinates[offset + 1], tolerance);
|
y2 = ol.geom.flat.simplify.snap(flatCoordinates[offset + 1], tolerance);
|
||||||
offset += stride;
|
offset += stride;
|
||||||
if (offset == end) {
|
if (offset == end) {
|
||||||
// all coordinates snap to the same value, the line collapses to a point
|
// all coordinates snap to the same value, the line collapses to a point
|
||||||
@@ -298,8 +298,8 @@ ol.geom.simplify.quantize = function(flatCoordinates, offset, end, stride,
|
|||||||
while (offset < end) {
|
while (offset < end) {
|
||||||
var x3, y3;
|
var x3, y3;
|
||||||
// snap the next coordinate (P3)
|
// snap the next coordinate (P3)
|
||||||
x3 = ol.geom.simplify.snap(flatCoordinates[offset], tolerance);
|
x3 = ol.geom.flat.simplify.snap(flatCoordinates[offset], tolerance);
|
||||||
y3 = ol.geom.simplify.snap(flatCoordinates[offset + 1], tolerance);
|
y3 = ol.geom.flat.simplify.snap(flatCoordinates[offset + 1], tolerance);
|
||||||
offset += stride;
|
offset += stride;
|
||||||
// skip P3 if it is equal to P2
|
// skip P3 if it is equal to P2
|
||||||
if (x3 == x2 && y3 == y2) {
|
if (x3 == x2 && y3 == y2) {
|
||||||
@@ -351,14 +351,14 @@ ol.geom.simplify.quantize = function(flatCoordinates, offset, end, stride,
|
|||||||
* @param {Array.<number>} simplifiedEnds Simplified ends.
|
* @param {Array.<number>} simplifiedEnds Simplified ends.
|
||||||
* @return {number} Simplified offset.
|
* @return {number} Simplified offset.
|
||||||
*/
|
*/
|
||||||
ol.geom.simplify.quantizes = function(
|
ol.geom.flat.simplify.quantizes = function(
|
||||||
flatCoordinates, offset, ends, stride,
|
flatCoordinates, offset, ends, stride,
|
||||||
tolerance,
|
tolerance,
|
||||||
simplifiedFlatCoordinates, simplifiedOffset, simplifiedEnds) {
|
simplifiedFlatCoordinates, simplifiedOffset, simplifiedEnds) {
|
||||||
var i, ii;
|
var i, ii;
|
||||||
for (i = 0, ii = ends.length; i < ii; ++i) {
|
for (i = 0, ii = ends.length; i < ii; ++i) {
|
||||||
var end = ends[i];
|
var end = ends[i];
|
||||||
simplifiedOffset = ol.geom.simplify.quantize(
|
simplifiedOffset = ol.geom.flat.simplify.quantize(
|
||||||
flatCoordinates, offset, end, stride,
|
flatCoordinates, offset, end, stride,
|
||||||
tolerance,
|
tolerance,
|
||||||
simplifiedFlatCoordinates, simplifiedOffset);
|
simplifiedFlatCoordinates, simplifiedOffset);
|
||||||
@@ -381,7 +381,7 @@ ol.geom.simplify.quantizes = function(
|
|||||||
* @param {Array.<Array.<number>>} simplifiedEndss Simplified endss.
|
* @param {Array.<Array.<number>>} simplifiedEndss Simplified endss.
|
||||||
* @return {number} Simplified offset.
|
* @return {number} Simplified offset.
|
||||||
*/
|
*/
|
||||||
ol.geom.simplify.quantizess = function(
|
ol.geom.flat.simplify.quantizess = function(
|
||||||
flatCoordinates, offset, endss, stride,
|
flatCoordinates, offset, endss, stride,
|
||||||
tolerance,
|
tolerance,
|
||||||
simplifiedFlatCoordinates, simplifiedOffset, simplifiedEndss) {
|
simplifiedFlatCoordinates, simplifiedOffset, simplifiedEndss) {
|
||||||
@@ -389,7 +389,7 @@ ol.geom.simplify.quantizess = function(
|
|||||||
for (i = 0, ii = endss.length; i < ii; ++i) {
|
for (i = 0, ii = endss.length; i < ii; ++i) {
|
||||||
var ends = endss[i];
|
var ends = endss[i];
|
||||||
var simplifiedEnds = [];
|
var simplifiedEnds = [];
|
||||||
simplifiedOffset = ol.geom.simplify.quantizes(
|
simplifiedOffset = ol.geom.flat.simplify.quantizes(
|
||||||
flatCoordinates, offset, ends, stride,
|
flatCoordinates, offset, ends, stride,
|
||||||
tolerance,
|
tolerance,
|
||||||
simplifiedFlatCoordinates, simplifiedOffset, simplifiedEnds);
|
simplifiedFlatCoordinates, simplifiedOffset, simplifiedEnds);
|
||||||
@@ -5,7 +5,7 @@ goog.require('ol.geom.GeometryType');
|
|||||||
goog.require('ol.geom.SimpleGeometry');
|
goog.require('ol.geom.SimpleGeometry');
|
||||||
goog.require('ol.geom.flat');
|
goog.require('ol.geom.flat');
|
||||||
goog.require('ol.geom.flat.closest');
|
goog.require('ol.geom.flat.closest');
|
||||||
goog.require('ol.geom.simplify');
|
goog.require('ol.geom.flat.simplify');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ ol.geom.LinearRing.prototype.getCoordinates = function() {
|
|||||||
ol.geom.LinearRing.prototype.getSimplifiedGeometryInternal =
|
ol.geom.LinearRing.prototype.getSimplifiedGeometryInternal =
|
||||||
function(squaredTolerance) {
|
function(squaredTolerance) {
|
||||||
var simplifiedFlatCoordinates = [];
|
var simplifiedFlatCoordinates = [];
|
||||||
simplifiedFlatCoordinates.length = ol.geom.simplify.douglasPeucker(
|
simplifiedFlatCoordinates.length = ol.geom.flat.simplify.douglasPeucker(
|
||||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride,
|
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride,
|
||||||
squaredTolerance, simplifiedFlatCoordinates, 0);
|
squaredTolerance, simplifiedFlatCoordinates, 0);
|
||||||
var simplifiedLinearRing = new ol.geom.LinearRing(null);
|
var simplifiedLinearRing = new ol.geom.LinearRing(null);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ goog.require('ol.geom.GeometryType');
|
|||||||
goog.require('ol.geom.SimpleGeometry');
|
goog.require('ol.geom.SimpleGeometry');
|
||||||
goog.require('ol.geom.flat');
|
goog.require('ol.geom.flat');
|
||||||
goog.require('ol.geom.flat.closest');
|
goog.require('ol.geom.flat.closest');
|
||||||
goog.require('ol.geom.simplify');
|
goog.require('ol.geom.flat.simplify');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -160,7 +160,7 @@ ol.geom.LineString.prototype.getFlatMidpoint = function() {
|
|||||||
ol.geom.LineString.prototype.getSimplifiedGeometryInternal =
|
ol.geom.LineString.prototype.getSimplifiedGeometryInternal =
|
||||||
function(squaredTolerance) {
|
function(squaredTolerance) {
|
||||||
var simplifiedFlatCoordinates = [];
|
var simplifiedFlatCoordinates = [];
|
||||||
simplifiedFlatCoordinates.length = ol.geom.simplify.douglasPeucker(
|
simplifiedFlatCoordinates.length = ol.geom.flat.simplify.douglasPeucker(
|
||||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride,
|
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride,
|
||||||
squaredTolerance, simplifiedFlatCoordinates, 0);
|
squaredTolerance, simplifiedFlatCoordinates, 0);
|
||||||
var simplifiedLineString = new ol.geom.LineString(null);
|
var simplifiedLineString = new ol.geom.LineString(null);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ goog.require('ol.geom.LineString');
|
|||||||
goog.require('ol.geom.SimpleGeometry');
|
goog.require('ol.geom.SimpleGeometry');
|
||||||
goog.require('ol.geom.flat');
|
goog.require('ol.geom.flat');
|
||||||
goog.require('ol.geom.flat.closest');
|
goog.require('ol.geom.flat.closest');
|
||||||
goog.require('ol.geom.simplify');
|
goog.require('ol.geom.flat.simplify');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -214,7 +214,7 @@ ol.geom.MultiLineString.prototype.getSimplifiedGeometryInternal =
|
|||||||
function(squaredTolerance) {
|
function(squaredTolerance) {
|
||||||
var simplifiedFlatCoordinates = [];
|
var simplifiedFlatCoordinates = [];
|
||||||
var simplifiedEnds = [];
|
var simplifiedEnds = [];
|
||||||
simplifiedFlatCoordinates.length = ol.geom.simplify.douglasPeuckers(
|
simplifiedFlatCoordinates.length = ol.geom.flat.simplify.douglasPeuckers(
|
||||||
this.flatCoordinates, 0, this.ends_, this.stride, squaredTolerance,
|
this.flatCoordinates, 0, this.ends_, this.stride, squaredTolerance,
|
||||||
simplifiedFlatCoordinates, 0, simplifiedEnds);
|
simplifiedFlatCoordinates, 0, simplifiedEnds);
|
||||||
var simplifiedMultiLineString = new ol.geom.MultiLineString(null);
|
var simplifiedMultiLineString = new ol.geom.MultiLineString(null);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ goog.require('ol.geom.Polygon');
|
|||||||
goog.require('ol.geom.SimpleGeometry');
|
goog.require('ol.geom.SimpleGeometry');
|
||||||
goog.require('ol.geom.flat');
|
goog.require('ol.geom.flat');
|
||||||
goog.require('ol.geom.flat.closest');
|
goog.require('ol.geom.flat.closest');
|
||||||
goog.require('ol.geom.simplify');
|
goog.require('ol.geom.flat.simplify');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -219,7 +219,7 @@ ol.geom.MultiPolygon.prototype.getSimplifiedGeometryInternal =
|
|||||||
function(squaredTolerance) {
|
function(squaredTolerance) {
|
||||||
var simplifiedFlatCoordinates = [];
|
var simplifiedFlatCoordinates = [];
|
||||||
var simplifiedEndss = [];
|
var simplifiedEndss = [];
|
||||||
simplifiedFlatCoordinates.length = ol.geom.simplify.quantizess(
|
simplifiedFlatCoordinates.length = ol.geom.flat.simplify.quantizess(
|
||||||
this.flatCoordinates, 0, this.endss_, this.stride,
|
this.flatCoordinates, 0, this.endss_, this.stride,
|
||||||
Math.sqrt(squaredTolerance),
|
Math.sqrt(squaredTolerance),
|
||||||
simplifiedFlatCoordinates, 0, simplifiedEndss);
|
simplifiedFlatCoordinates, 0, simplifiedEndss);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ goog.require('ol.geom.Point');
|
|||||||
goog.require('ol.geom.SimpleGeometry');
|
goog.require('ol.geom.SimpleGeometry');
|
||||||
goog.require('ol.geom.flat');
|
goog.require('ol.geom.flat');
|
||||||
goog.require('ol.geom.flat.closest');
|
goog.require('ol.geom.flat.closest');
|
||||||
goog.require('ol.geom.simplify');
|
goog.require('ol.geom.flat.simplify');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -243,7 +243,7 @@ ol.geom.Polygon.prototype.getSimplifiedGeometryInternal =
|
|||||||
function(squaredTolerance) {
|
function(squaredTolerance) {
|
||||||
var simplifiedFlatCoordinates = [];
|
var simplifiedFlatCoordinates = [];
|
||||||
var simplifiedEnds = [];
|
var simplifiedEnds = [];
|
||||||
simplifiedFlatCoordinates.length = ol.geom.simplify.quantizes(
|
simplifiedFlatCoordinates.length = ol.geom.flat.simplify.quantizes(
|
||||||
this.flatCoordinates, 0, this.ends_, this.stride,
|
this.flatCoordinates, 0, this.ends_, this.stride,
|
||||||
Math.sqrt(squaredTolerance),
|
Math.sqrt(squaredTolerance),
|
||||||
simplifiedFlatCoordinates, 0, simplifiedEnds);
|
simplifiedFlatCoordinates, 0, simplifiedEnds);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ goog.require('ol.color');
|
|||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
goog.require('ol.extent.Relationship');
|
goog.require('ol.extent.Relationship');
|
||||||
goog.require('ol.geom.flat');
|
goog.require('ol.geom.flat');
|
||||||
goog.require('ol.geom.simplify');
|
goog.require('ol.geom.flat.simplify');
|
||||||
goog.require('ol.render.IReplayGroup');
|
goog.require('ol.render.IReplayGroup');
|
||||||
goog.require('ol.render.IVectorContext');
|
goog.require('ol.render.IVectorContext');
|
||||||
goog.require('ol.render.canvas');
|
goog.require('ol.render.canvas');
|
||||||
@@ -1310,7 +1310,7 @@ ol.render.canvas.PolygonReplay.prototype.finish = function() {
|
|||||||
var coordinates = this.coordinates;
|
var coordinates = this.coordinates;
|
||||||
var i, ii;
|
var i, ii;
|
||||||
for (i = 0, ii = coordinates.length; i < ii; ++i) {
|
for (i = 0, ii = coordinates.length; i < ii; ++i) {
|
||||||
coordinates[i] = ol.geom.simplify.snap(coordinates[i], tolerance);
|
coordinates[i] = ol.geom.flat.simplify.snap(coordinates[i], tolerance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
goog.provide('ol.test.geom.simplify');
|
goog.provide('ol.test.geom.simplify');
|
||||||
|
|
||||||
|
|
||||||
describe('ol.geom.simplify', function() {
|
describe('ol.geom.flat.simplify', function() {
|
||||||
|
|
||||||
var flatCoordinates = [
|
var flatCoordinates = [
|
||||||
224.55, 250.15, 226.91, 244.19, 233.31, 241.45, 234.98, 236.06,
|
224.55, 250.15, 226.91, 244.19, 233.31, 241.45, 234.98, 236.06,
|
||||||
@@ -81,31 +81,31 @@ describe('ol.geom.simplify', function() {
|
|||||||
866.36, 480.77
|
866.36, 480.77
|
||||||
];
|
];
|
||||||
|
|
||||||
describe('ol.geom.simplify.lineString', function() {
|
describe('ol.geom.flat.simplify.lineString', function() {
|
||||||
|
|
||||||
it('works with empty line strings', function() {
|
it('works with empty line strings', function() {
|
||||||
expect(ol.geom.simplify.lineString([], 0, 0, 2, 1, true)).to.
|
expect(ol.geom.flat.simplify.lineString([], 0, 0, 2, 1, true)).to.
|
||||||
eql([]);
|
eql([]);
|
||||||
expect(ol.geom.simplify.lineString([], 0, 0, 2, 1, false)).to.
|
expect(ol.geom.flat.simplify.lineString([], 0, 0, 2, 1, false)).to.
|
||||||
eql([]);
|
eql([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works with a line string with a single point', function() {
|
it('works with a line string with a single point', function() {
|
||||||
expect(ol.geom.simplify.lineString([1, 2], 0, 2, 2, 1, true)).to.
|
expect(ol.geom.flat.simplify.lineString([1, 2], 0, 2, 2, 1, true)).to.
|
||||||
eql([1, 2]);
|
eql([1, 2]);
|
||||||
expect(ol.geom.simplify.lineString([1, 2], 0, 2, 2, 1, false)).to.
|
expect(ol.geom.flat.simplify.lineString([1, 2], 0, 2, 2, 1, false)).to.
|
||||||
eql([1, 2]);
|
eql([1, 2]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns the expected result with low quality', function() {
|
it('returns the expected result with low quality', function() {
|
||||||
var result = ol.geom.simplify.lineString(
|
var result = ol.geom.flat.simplify.lineString(
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2, 25, false);
|
flatCoordinates, 0, flatCoordinates.length, 2, 25, false);
|
||||||
expect(result.length).to.be(simplifiedFlatCoordinates.length);
|
expect(result.length).to.be(simplifiedFlatCoordinates.length);
|
||||||
expect(result).to.eql(simplifiedFlatCoordinates);
|
expect(result).to.eql(simplifiedFlatCoordinates);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns the expected result with high quality', function() {
|
it('returns the expected result with high quality', function() {
|
||||||
var result = ol.geom.simplify.lineString(
|
var result = ol.geom.flat.simplify.lineString(
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2, 25, true);
|
flatCoordinates, 0, flatCoordinates.length, 2, 25, true);
|
||||||
expect(result.length).to.be(simplifiedHighQualityFlatCoordinates.length);
|
expect(result.length).to.be(simplifiedHighQualityFlatCoordinates.length);
|
||||||
expect(result).to.eql(simplifiedHighQualityFlatCoordinates);
|
expect(result).to.eql(simplifiedHighQualityFlatCoordinates);
|
||||||
@@ -113,7 +113,7 @@ describe('ol.geom.simplify', function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('ol.geom.simplify.radialDistance', function() {
|
describe('ol.geom.flat.simplify.radialDistance', function() {
|
||||||
|
|
||||||
var dest;
|
var dest;
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
@@ -121,63 +121,63 @@ describe('ol.geom.simplify', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('works with empty line strings', function() {
|
it('works with empty line strings', function() {
|
||||||
expect(ol.geom.simplify.radialDistance(
|
expect(ol.geom.flat.simplify.radialDistance(
|
||||||
[], 0, 0, 2, 1, dest, 0)).to.be(0);
|
[], 0, 0, 2, 1, dest, 0)).to.be(0);
|
||||||
expect(dest).to.eql([]);
|
expect(dest).to.eql([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works with a line string with a single point', function() {
|
it('works with a line string with a single point', function() {
|
||||||
expect(ol.geom.simplify.radialDistance(
|
expect(ol.geom.flat.simplify.radialDistance(
|
||||||
[1, 2], 0, 2, 2, 1, dest, 0)).to.be(2);
|
[1, 2], 0, 2, 2, 1, dest, 0)).to.be(2);
|
||||||
expect(dest).to.eql([1, 2]);
|
expect(dest).to.eql([1, 2]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works with a line string with two points', function() {
|
it('works with a line string with two points', function() {
|
||||||
expect(ol.geom.simplify.radialDistance(
|
expect(ol.geom.flat.simplify.radialDistance(
|
||||||
[1, 2, 3, 4], 0, 4, 2, 1, dest, 0)).to.be(4);
|
[1, 2, 3, 4], 0, 4, 2, 1, dest, 0)).to.be(4);
|
||||||
expect(dest).to.eql([1, 2, 3, 4]);
|
expect(dest).to.eql([1, 2, 3, 4]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works when the points are widely spaced', function() {
|
it('works when the points are widely spaced', function() {
|
||||||
expect(ol.geom.simplify.radialDistance(
|
expect(ol.geom.flat.simplify.radialDistance(
|
||||||
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 0.5, dest, 0)).to.be(8);
|
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 0.5, dest, 0)).to.be(8);
|
||||||
expect(dest).to.eql([0, 0, 1, 0, 2, 0, 3, 0]);
|
expect(dest).to.eql([0, 0, 1, 0, 2, 0, 3, 0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works when the spacing matches the tolerance', function() {
|
it('works when the spacing matches the tolerance', function() {
|
||||||
expect(ol.geom.simplify.radialDistance(
|
expect(ol.geom.flat.simplify.radialDistance(
|
||||||
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 1, dest, 0)).to.be(6);
|
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 1, dest, 0)).to.be(6);
|
||||||
expect(dest).to.eql([0, 0, 2, 0, 3, 0]);
|
expect(dest).to.eql([0, 0, 2, 0, 3, 0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works when the points are closely spaced', function() {
|
it('works when the points are closely spaced', function() {
|
||||||
expect(ol.geom.simplify.radialDistance(
|
expect(ol.geom.flat.simplify.radialDistance(
|
||||||
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 1.5, dest, 0)).to.be(6);
|
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 1.5, dest, 0)).to.be(6);
|
||||||
expect(dest).to.eql([0, 0, 2, 0, 3, 0]);
|
expect(dest).to.eql([0, 0, 2, 0, 3, 0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works when the line oscillates with widely spaced points', function() {
|
it('works when the line oscillates with widely spaced points', function() {
|
||||||
expect(ol.geom.simplify.radialDistance(
|
expect(ol.geom.flat.simplify.radialDistance(
|
||||||
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], 0, 12, 2, 1, dest, 0)).
|
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], 0, 12, 2, 1, dest, 0)).
|
||||||
to.be(12);
|
to.be(12);
|
||||||
expect(dest).to.eql([0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]);
|
expect(dest).to.eql([0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works when the line oscillates with closely spaced points', function() {
|
it('works when the line oscillates with closely spaced points', function() {
|
||||||
expect(ol.geom.simplify.radialDistance(
|
expect(ol.geom.flat.simplify.radialDistance(
|
||||||
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], 0, 12, 2, 2, dest, 0)).to.be(4);
|
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], 0, 12, 2, 2, dest, 0)).to.be(4);
|
||||||
expect(dest).to.eql([0, 0, 1, 1]);
|
expect(dest).to.eql([0, 0, 1, 1]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works when the line oscillates within the tolerance', function() {
|
it('works when the line oscillates within the tolerance', function() {
|
||||||
expect(ol.geom.simplify.radialDistance(
|
expect(ol.geom.flat.simplify.radialDistance(
|
||||||
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0], 0, 14, 2, 2, dest, 0)).
|
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0], 0, 14, 2, 2, dest, 0)).
|
||||||
to.be(2);
|
to.be(2);
|
||||||
expect(dest).to.eql([0, 0]);
|
expect(dest).to.eql([0, 0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works with real data', function() {
|
it('works with real data', function() {
|
||||||
expect(ol.geom.simplify.radialDistance(
|
expect(ol.geom.flat.simplify.radialDistance(
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2, 25, dest, 0)).
|
flatCoordinates, 0, flatCoordinates.length, 2, 25, dest, 0)).
|
||||||
to.be(simplifiedRadiallyFlatCoordinates.length);
|
to.be(simplifiedRadiallyFlatCoordinates.length);
|
||||||
expect(dest).to.eql(simplifiedRadiallyFlatCoordinates);
|
expect(dest).to.eql(simplifiedRadiallyFlatCoordinates);
|
||||||
@@ -185,7 +185,7 @@ describe('ol.geom.simplify', function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('ol.geom.simplify.douglasPeucker', function() {
|
describe('ol.geom.flat.simplify.douglasPeucker', function() {
|
||||||
|
|
||||||
var dest;
|
var dest;
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
@@ -193,93 +193,93 @@ describe('ol.geom.simplify', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('works with empty line strings', function() {
|
it('works with empty line strings', function() {
|
||||||
expect(ol.geom.simplify.douglasPeucker(
|
expect(ol.geom.flat.simplify.douglasPeucker(
|
||||||
[], 0, 0, 2, 1, dest, 0)).to.be(0);
|
[], 0, 0, 2, 1, dest, 0)).to.be(0);
|
||||||
expect(dest).to.eql([]);
|
expect(dest).to.eql([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works with a line string with a single point', function() {
|
it('works with a line string with a single point', function() {
|
||||||
expect(ol.geom.simplify.douglasPeucker(
|
expect(ol.geom.flat.simplify.douglasPeucker(
|
||||||
[1, 2], 0, 2, 2, 1, dest, 0)).to.be(2);
|
[1, 2], 0, 2, 2, 1, dest, 0)).to.be(2);
|
||||||
expect(dest).to.eql([1, 2]);
|
expect(dest).to.eql([1, 2]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works with a line string with two points', function() {
|
it('works with a line string with two points', function() {
|
||||||
expect(ol.geom.simplify.douglasPeucker(
|
expect(ol.geom.flat.simplify.douglasPeucker(
|
||||||
[1, 2, 3, 4], 0, 4, 2, 1, dest, 0)).to.be(4);
|
[1, 2, 3, 4], 0, 4, 2, 1, dest, 0)).to.be(4);
|
||||||
expect(dest).to.eql([1, 2, 3, 4]);
|
expect(dest).to.eql([1, 2, 3, 4]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works when the points are widely spaced', function() {
|
it('works when the points are widely spaced', function() {
|
||||||
expect(ol.geom.simplify.douglasPeucker(
|
expect(ol.geom.flat.simplify.douglasPeucker(
|
||||||
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 0.5, dest, 0)).to.be(4);
|
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 0.5, dest, 0)).to.be(4);
|
||||||
expect(dest).to.eql([0, 0, 3, 0]);
|
expect(dest).to.eql([0, 0, 3, 0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works when the spacing matches the tolerance', function() {
|
it('works when the spacing matches the tolerance', function() {
|
||||||
expect(ol.geom.simplify.douglasPeucker(
|
expect(ol.geom.flat.simplify.douglasPeucker(
|
||||||
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 1, dest, 0)).to.be(4);
|
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 1, dest, 0)).to.be(4);
|
||||||
expect(dest).to.eql([0, 0, 3, 0]);
|
expect(dest).to.eql([0, 0, 3, 0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works when the points are closely spaced', function() {
|
it('works when the points are closely spaced', function() {
|
||||||
expect(ol.geom.simplify.douglasPeucker(
|
expect(ol.geom.flat.simplify.douglasPeucker(
|
||||||
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 1.5, dest, 0)).to.be(4);
|
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 1.5, dest, 0)).to.be(4);
|
||||||
expect(dest).to.eql([0, 0, 3, 0]);
|
expect(dest).to.eql([0, 0, 3, 0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not elimnate points outside the tolerance', function() {
|
it('does not elimnate points outside the tolerance', function() {
|
||||||
expect(ol.geom.simplify.douglasPeucker(
|
expect(ol.geom.flat.simplify.douglasPeucker(
|
||||||
[0, 0, 1, 1, 2, 0], 0, 6, 2, 0.5, dest, 0)).to.be(6);
|
[0, 0, 1, 1, 2, 0], 0, 6, 2, 0.5, dest, 0)).to.be(6);
|
||||||
expect(dest).to.eql([0, 0, 1, 1, 2, 0]);
|
expect(dest).to.eql([0, 0, 1, 1, 2, 0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does eliminate points within the tolerance', function() {
|
it('does eliminate points within the tolerance', function() {
|
||||||
expect(ol.geom.simplify.douglasPeucker(
|
expect(ol.geom.flat.simplify.douglasPeucker(
|
||||||
[0, 0, 1, 1, 2, 0], 0, 6, 2, 2, dest, 0)).to.be(4);
|
[0, 0, 1, 1, 2, 0], 0, 6, 2, 2, dest, 0)).to.be(4);
|
||||||
expect(dest).to.eql([0, 0, 2, 0]);
|
expect(dest).to.eql([0, 0, 2, 0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not eliminate multiple points outside the tolerance', function() {
|
it('does not eliminate multiple points outside the tolerance', function() {
|
||||||
expect(ol.geom.simplify.douglasPeucker(
|
expect(ol.geom.flat.simplify.douglasPeucker(
|
||||||
[0, 0, 1, 1, 1, -1, 2, 0], 0, 8, 2, 0.5, dest, 0)).to.be(8);
|
[0, 0, 1, 1, 1, -1, 2, 0], 0, 8, 2, 0.5, dest, 0)).to.be(8);
|
||||||
expect(dest).to.eql([0, 0, 1, 1, 1, -1, 2, 0]);
|
expect(dest).to.eql([0, 0, 1, 1, 1, -1, 2, 0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does eliminate multiple points within the tolerance', function() {
|
it('does eliminate multiple points within the tolerance', function() {
|
||||||
expect(ol.geom.simplify.douglasPeucker(
|
expect(ol.geom.flat.simplify.douglasPeucker(
|
||||||
[0, 0, 1, 1, 1, -1, 2, 0], 0, 8, 2, 2, dest, 0)).to.be(4);
|
[0, 0, 1, 1, 1, -1, 2, 0], 0, 8, 2, 2, dest, 0)).to.be(4);
|
||||||
expect(dest).to.eql([0, 0, 2, 0]);
|
expect(dest).to.eql([0, 0, 2, 0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works when the line oscillates with widely spaced points', function() {
|
it('works when the line oscillates with widely spaced points', function() {
|
||||||
expect(ol.geom.simplify.douglasPeucker(
|
expect(ol.geom.flat.simplify.douglasPeucker(
|
||||||
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], 0, 12, 2, 1, dest, 0)).to.be(4);
|
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], 0, 12, 2, 1, dest, 0)).to.be(4);
|
||||||
expect(dest).to.eql([0, 0, 1, 1]);
|
expect(dest).to.eql([0, 0, 1, 1]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works when the line oscillates with closely spaced points', function() {
|
it('works when the line oscillates with closely spaced points', function() {
|
||||||
expect(ol.geom.simplify.douglasPeucker(
|
expect(ol.geom.flat.simplify.douglasPeucker(
|
||||||
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], 0, 12, 2, 2, dest, 0)).
|
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], 0, 12, 2, 2, dest, 0)).
|
||||||
to.be(4);
|
to.be(4);
|
||||||
expect(dest).to.eql([0, 0, 1, 1]);
|
expect(dest).to.eql([0, 0, 1, 1]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works when the line oscillates within the tolerance', function() {
|
it('works when the line oscillates within the tolerance', function() {
|
||||||
expect(ol.geom.simplify.douglasPeucker(
|
expect(ol.geom.flat.simplify.douglasPeucker(
|
||||||
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0], 0, 14, 2, 2, dest, 0)).
|
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0], 0, 14, 2, 2, dest, 0)).
|
||||||
to.be(4);
|
to.be(4);
|
||||||
expect(dest).to.eql([0, 0, 0, 0]);
|
expect(dest).to.eql([0, 0, 0, 0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works on small triangles', function() {
|
it('works on small triangles', function() {
|
||||||
expect(ol.geom.simplify.douglasPeucker(
|
expect(ol.geom.flat.simplify.douglasPeucker(
|
||||||
[3, 0, 4, 1, 5, 2, 5, 0], 0, 8, 2, 1, dest, 0)).to.be(6);
|
[3, 0, 4, 1, 5, 2, 5, 0], 0, 8, 2, 1, dest, 0)).to.be(6);
|
||||||
expect(dest).to.eql([3, 0, 5, 2, 5, 0]);
|
expect(dest).to.eql([3, 0, 5, 2, 5, 0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('is the same as high quality simplification', function() {
|
it('is the same as high quality simplification', function() {
|
||||||
expect(ol.geom.simplify.douglasPeucker(
|
expect(ol.geom.flat.simplify.douglasPeucker(
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2, 25, dest, 0)).
|
flatCoordinates, 0, flatCoordinates.length, 2, 25, dest, 0)).
|
||||||
to.be(simplifiedHighQualityFlatCoordinates.length);
|
to.be(simplifiedHighQualityFlatCoordinates.length);
|
||||||
expect(dest).to.eql(simplifiedHighQualityFlatCoordinates);
|
expect(dest).to.eql(simplifiedHighQualityFlatCoordinates);
|
||||||
@@ -287,32 +287,32 @@ describe('ol.geom.simplify', function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('ol.geom.simplify.quantize', function() {
|
describe('ol.geom.flat.simplify.quantize', function() {
|
||||||
|
|
||||||
it('handles empty coordinates', function() {
|
it('handles empty coordinates', function() {
|
||||||
var simplifiedFlatCoordinates = [];
|
var simplifiedFlatCoordinates = [];
|
||||||
expect(ol.geom.simplify.quantize(
|
expect(ol.geom.flat.simplify.quantize(
|
||||||
[], 0, 0, 2, 2, simplifiedFlatCoordinates, 0)).to.be(0);
|
[], 0, 0, 2, 2, simplifiedFlatCoordinates, 0)).to.be(0);
|
||||||
expect(simplifiedFlatCoordinates).to.be.empty();
|
expect(simplifiedFlatCoordinates).to.be.empty();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('expands points to a zero-length line', function() {
|
it('expands points to a zero-length line', function() {
|
||||||
var simplifiedFlatCoordinates = [];
|
var simplifiedFlatCoordinates = [];
|
||||||
expect(ol.geom.simplify.quantize(
|
expect(ol.geom.flat.simplify.quantize(
|
||||||
[0, 0, 0, 0], 0, 4, 2, 2, simplifiedFlatCoordinates, 0)).to.be(4);
|
[0, 0, 0, 0], 0, 4, 2, 2, simplifiedFlatCoordinates, 0)).to.be(4);
|
||||||
expect(simplifiedFlatCoordinates).to.eql([0, 0, 0, 0]);
|
expect(simplifiedFlatCoordinates).to.eql([0, 0, 0, 0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('snaps near-by points to the same value', function() {
|
it('snaps near-by points to the same value', function() {
|
||||||
var simplifiedFlatCoordinates = [];
|
var simplifiedFlatCoordinates = [];
|
||||||
expect(ol.geom.simplify.quantize(
|
expect(ol.geom.flat.simplify.quantize(
|
||||||
[0.1, 0, 0, 0.1], 0, 4, 2, 2, simplifiedFlatCoordinates, 0)).to.be(4);
|
[0.1, 0, 0, 0.1], 0, 4, 2, 2, simplifiedFlatCoordinates, 0)).to.be(4);
|
||||||
expect(simplifiedFlatCoordinates).to.eql([0, 0, 0, 0]);
|
expect(simplifiedFlatCoordinates).to.eql([0, 0, 0, 0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('eliminates duplicate snapped points', function() {
|
it('eliminates duplicate snapped points', function() {
|
||||||
var simplifiedFlatCoordinates = [];
|
var simplifiedFlatCoordinates = [];
|
||||||
expect(ol.geom.simplify.quantize(
|
expect(ol.geom.flat.simplify.quantize(
|
||||||
[0.1, 0, 2, 0, 2.1, 0, 2, 0.1, 1.9, 0, 2, -0.1], 0, 12, 2, 2,
|
[0.1, 0, 2, 0, 2.1, 0, 2, 0.1, 1.9, 0, 2, -0.1], 0, 12, 2, 2,
|
||||||
simplifiedFlatCoordinates, 0)).to.be(4);
|
simplifiedFlatCoordinates, 0)).to.be(4);
|
||||||
expect(simplifiedFlatCoordinates).to.eql([0, 0, 2, 0]);
|
expect(simplifiedFlatCoordinates).to.eql([0, 0, 2, 0]);
|
||||||
@@ -320,7 +320,7 @@ describe('ol.geom.simplify', function() {
|
|||||||
|
|
||||||
it('eliminates horizontal colinear points', function() {
|
it('eliminates horizontal colinear points', function() {
|
||||||
var simplifiedFlatCoordinates = [];
|
var simplifiedFlatCoordinates = [];
|
||||||
expect(ol.geom.simplify.quantize(
|
expect(ol.geom.flat.simplify.quantize(
|
||||||
[0, 0, 2, 0, 4, 0, 6, 0], 0, 8, 2, 2,
|
[0, 0, 2, 0, 4, 0, 6, 0], 0, 8, 2, 2,
|
||||||
simplifiedFlatCoordinates, 0)).to.be(4);
|
simplifiedFlatCoordinates, 0)).to.be(4);
|
||||||
expect(simplifiedFlatCoordinates).to.eql([0, 0, 6, 0]);
|
expect(simplifiedFlatCoordinates).to.eql([0, 0, 6, 0]);
|
||||||
@@ -328,7 +328,7 @@ describe('ol.geom.simplify', function() {
|
|||||||
|
|
||||||
it('eliminates vertical colinear points', function() {
|
it('eliminates vertical colinear points', function() {
|
||||||
var simplifiedFlatCoordinates = [];
|
var simplifiedFlatCoordinates = [];
|
||||||
expect(ol.geom.simplify.quantize(
|
expect(ol.geom.flat.simplify.quantize(
|
||||||
[0, 0, 0, -2, 0, -4, 0, -6], 0, 8, 2, 2,
|
[0, 0, 0, -2, 0, -4, 0, -6], 0, 8, 2, 2,
|
||||||
simplifiedFlatCoordinates, 0)).to.be(4);
|
simplifiedFlatCoordinates, 0)).to.be(4);
|
||||||
expect(simplifiedFlatCoordinates).to.eql([0, 0, 0, -6]);
|
expect(simplifiedFlatCoordinates).to.eql([0, 0, 0, -6]);
|
||||||
@@ -336,7 +336,7 @@ describe('ol.geom.simplify', function() {
|
|||||||
|
|
||||||
it('eliminates diagonal colinear points', function() {
|
it('eliminates diagonal colinear points', function() {
|
||||||
var simplifiedFlatCoordinates = [];
|
var simplifiedFlatCoordinates = [];
|
||||||
expect(ol.geom.simplify.quantize(
|
expect(ol.geom.flat.simplify.quantize(
|
||||||
[0, 0, 2, -2, 4, -4, 6, -6], 0, 8, 2, 2,
|
[0, 0, 2, -2, 4, -4, 6, -6], 0, 8, 2, 2,
|
||||||
simplifiedFlatCoordinates, 0)).to.be(4);
|
simplifiedFlatCoordinates, 0)).to.be(4);
|
||||||
expect(simplifiedFlatCoordinates).to.eql([0, 0, 6, -6]);
|
expect(simplifiedFlatCoordinates).to.eql([0, 0, 6, -6]);
|
||||||
@@ -344,7 +344,7 @@ describe('ol.geom.simplify', function() {
|
|||||||
|
|
||||||
it('handles switchbacks', function() {
|
it('handles switchbacks', function() {
|
||||||
var simplifiedFlatCoordinates = [];
|
var simplifiedFlatCoordinates = [];
|
||||||
expect(ol.geom.simplify.quantize(
|
expect(ol.geom.flat.simplify.quantize(
|
||||||
[0, 0, 2, 0, 0, 0, 4, 0], 0, 8, 2, 2,
|
[0, 0, 2, 0, 0, 0, 4, 0], 0, 8, 2, 2,
|
||||||
simplifiedFlatCoordinates, 0)).to.be(8);
|
simplifiedFlatCoordinates, 0)).to.be(8);
|
||||||
expect(simplifiedFlatCoordinates).to.eql([0, 0, 2, 0, 0, 0, 4, 0]);
|
expect(simplifiedFlatCoordinates).to.eql([0, 0, 2, 0, 0, 0, 4, 0]);
|
||||||
@@ -355,4 +355,5 @@ describe('ol.geom.simplify', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
goog.require('ol.geom.simplify');
|
goog.require('ol.geom.flat');
|
||||||
|
goog.require('ol.geom.flat.simplify');
|
||||||
Reference in New Issue
Block a user