Skip to content

Commit 30a1fa0

Browse files
committed
fix simplify error
1 parent f4c2ff6 commit 30a1fa0

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ The GeoPackage JavaScript library currently provides the ability to read GeoPack
3838

3939
### Changelog
4040

41+
##### 4.2.2
42+
43+
- fix simplify error
44+
4145
##### 4.2.1
4246

4347
- Fix for drawing geometries outside of the 3857 bounds

lib/tiles/features/index.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -754,24 +754,13 @@ export class FeatureTiles {
754754
* @since 2.0.0
755755
*/
756756
simplifyPoints(lineString: any, isPolygon = false): any | null {
757-
const coords = simplify(
757+
lineString.coordinates = simplify(
758758
lineString.coordinates.map(coordinate => {
759759
return { x: coordinate[0], y: coordinate[1] };
760760
}),
761761
this.simplifyToleranceInPixels,
762762
false,
763763
).map(point => [point.x, point.y]);
764-
if (isPolygon) {
765-
if (coords.length < 4) {
766-
return null;
767-
} else if (coords[0][0] !== coords[coords.length - 1][0] || coords[0][1] !== coords[coords.length - 1][1]) {
768-
// if first and last point do not match, add first point to end
769-
coords.push(coords[0].slice());
770-
}
771-
} else if (coords.length < 2) {
772-
return null;
773-
}
774-
lineString.coordinates = coords;
775764
return lineString;
776765
}
777766

@@ -792,7 +781,7 @@ export class FeatureTiles {
792781
];
793782
});
794783
const simplifiedLineString = this.simplifyGeometries ? this.simplifyPoints(lineString, isPolygon) : lineString;
795-
if (simplifiedLineString.coordinates.length > 0) {
784+
if (simplifiedLineString.coordinates.length > 1) {
796785
context.moveTo(simplifiedLineString.coordinates[0][0], simplifiedLineString.coordinates[0][1]);
797786
for (let i = 1; i < simplifiedLineString.coordinates.length; i++) {
798787
context.lineTo(simplifiedLineString.coordinates[i][0], simplifiedLineString.coordinates[i][1]);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ngageoint/geopackage",
3-
"version": "4.2.1",
3+
"version": "4.2.2",
44
"description": "GeoPackage JavaScript Library",
55
"keywords": [
66
"NGA",

0 commit comments

Comments
 (0)