Skip to content

Commit

Permalink
fix for cached geometry error
Browse files Browse the repository at this point in the history
  • Loading branch information
caldwellc committed Oct 10, 2022
1 parent 0d7a905 commit c1ab4aa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ The GeoPackage JavaScript library currently provides the ability to read GeoPack

### Changelog

##### 4.2.3

- fix cached geometry error

##### 4.2.2

- fix simplify error
Expand Down
23 changes: 11 additions & 12 deletions lib/tiles/features/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -748,20 +748,19 @@ export class FeatureTiles {

/**
* Simplify x,y tile coordinates by 1 pixel
* @param lineString GeoJSON with coordinates in pixels
* @param coordinatesArray GeoJSON with coordinates in pixels
* @param isPolygon determines if the first and last point need to stay connected
* @return simplified GeoJSON
* @since 2.0.0
*/
simplifyPoints(lineString: any, isPolygon = false): any | null {
lineString.coordinates = simplify(
lineString.coordinates.map(coordinate => {
simplifyPoints(coordinatesArray: any, isPolygon = false): any | null {
return simplify(
coordinatesArray.map(coordinate => {
return { x: coordinate[0], y: coordinate[1] };
}),
this.simplifyToleranceInPixels,
false,
).map(point => [point.x, point.y]);
return lineString;
}

/**
Expand All @@ -773,18 +772,18 @@ export class FeatureTiles {
* @param transform
*/
getPath(lineString: any, context: any, boundingBox: BoundingBox, isPolygon = false, transform: Function): void {
lineString.coordinates = lineString.coordinates.map(coordinate => {
const transformedCoordinate = transform(coordinate);
const line = lineString.coordinates.map(coordinate => {
const transformedCoordinate = transform(coordinate.slice());
return [
TileBoundingBoxUtils.getXPixel(this.tileWidth, boundingBox, transformedCoordinate[0]),
TileBoundingBoxUtils.getYPixel(this.tileHeight, boundingBox, transformedCoordinate[1]),
];
});
const simplifiedLineString = this.simplifyGeometries ? this.simplifyPoints(lineString, isPolygon) : lineString;
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]);
const simplifiedLineString = this.simplifyGeometries ? this.simplifyPoints(line, isPolygon) : line;
if (simplifiedLineString.length > 1) {
context.moveTo(simplifiedLineString[0][0], simplifiedLineString[0][1]);
for (let i = 1; i < simplifiedLineString.length; i++) {
context.lineTo(simplifiedLineString[i][0], simplifiedLineString[i][1]);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ngageoint/geopackage",
"version": "4.2.2",
"version": "4.2.3",
"description": "GeoPackage JavaScript Library",
"keywords": [
"NGA",
Expand Down

0 comments on commit c1ab4aa

Please sign in to comment.