Always add first segment when appending coordinates

When we have only a single point, we want to make sure it gets added (fixes #1821).

Because this code doesn't differentiate coordinates that are part of a linestring or linearring from those that are independent points, we always add the first segment (or pair of points).  In addition, coordinates for segments are appended whenever they represent a change in relationship with respect to the extent.  This keeps the code simpler for handling fills and properly capturing intersection points for linestrings.  This could be modified to save a few extra coordinates, but it provides for simpler code at a very minimal cost.
This commit is contained in:
Tim Schaub
2014-03-07 11:02:25 -07:00
parent 7da18bd144
commit 8317317127
2 changed files with 88 additions and 0 deletions

View File

@@ -2,6 +2,7 @@
// FIXME add option to apply snapToPixel to all coordinates?
// FIXME can eliminate empty set styles and strokes (when all geoms skipped)
goog.provide('ol.render.canvas.Replay');
goog.provide('ol.render.canvas.ReplayGroup');
goog.require('goog.array');
@@ -166,6 +167,12 @@ ol.render.canvas.Replay.prototype.appendFlatCoordinates =
lastRel = nextRel;
}
// handle case where there is only one point to append
if (i === offset + stride) {
this.coordinates[myEnd++] = lastCoord[0];
this.coordinates[myEnd++] = lastCoord[1];
}
if (close) {
this.coordinates[myEnd++] = flatCoordinates[offset];
this.coordinates[myEnd++] = flatCoordinates[offset + 1];