diff --git a/README.md b/README.md index b12fa45a..df13adbf 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,10 @@ The GeoPackage JavaScript library currently provides the ability to read GeoPack ### Changelog +##### 4.2.2 + +- fix simplify error + ##### 4.2.1 - Fix for drawing geometries outside of the 3857 bounds diff --git a/lib/tiles/features/index.ts b/lib/tiles/features/index.ts index a8a34801..20150b4b 100644 --- a/lib/tiles/features/index.ts +++ b/lib/tiles/features/index.ts @@ -754,24 +754,13 @@ export class FeatureTiles { * @since 2.0.0 */ simplifyPoints(lineString: any, isPolygon = false): any | null { - const coords = simplify( + lineString.coordinates = simplify( lineString.coordinates.map(coordinate => { return { x: coordinate[0], y: coordinate[1] }; }), this.simplifyToleranceInPixels, false, ).map(point => [point.x, point.y]); - if (isPolygon) { - if (coords.length < 4) { - return null; - } else if (coords[0][0] !== coords[coords.length - 1][0] || coords[0][1] !== coords[coords.length - 1][1]) { - // if first and last point do not match, add first point to end - coords.push(coords[0].slice()); - } - } else if (coords.length < 2) { - return null; - } - lineString.coordinates = coords; return lineString; } @@ -792,7 +781,7 @@ export class FeatureTiles { ]; }); const simplifiedLineString = this.simplifyGeometries ? this.simplifyPoints(lineString, isPolygon) : lineString; - if (simplifiedLineString.coordinates.length > 0) { + if (simplifiedLineString.coordinates.length > 1) { context.moveTo(simplifiedLineString.coordinates[0][0], simplifiedLineString.coordinates[0][1]); for (let i = 1; i < simplifiedLineString.coordinates.length; i++) { context.lineTo(simplifiedLineString.coordinates[i][0], simplifiedLineString.coordinates[i][1]); diff --git a/package.json b/package.json index bb5a3a10..14593ad2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ngageoint/geopackage", - "version": "4.2.1", + "version": "4.2.2", "description": "GeoPackage JavaScript Library", "keywords": [ "NGA",