Skip to content

Commit

Permalink
Merge pull request #12 from vojtatom/dev
Browse files Browse the repository at this point in the history
Release 1.0.9
  • Loading branch information
vojtatom authored Aug 30, 2024
2 parents f7423dd + 4e62e6d commit 376227e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "shpts",
"private": false,
"version": "1.0.8",
"version": "1.0.9",
"type": "module",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion shpts/reader/featureReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class FeatureReader {
}

private constructor(shapeFile: ShapeReader, dbfReader?: DbfReader) {
if (shapeFile.recordCount !== dbfReader?.recordCount) {
if (dbfReader && shapeFile.recordCount !== dbfReader?.recordCount) {
throw new Error(
`Record count mismatch: SHP-file has ${shapeFile.recordCount} records, DBF has ${dbfReader?.recordCount}`
);
Expand Down
16 changes: 16 additions & 0 deletions test/features.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,22 @@ test('Read feature collection', async () => {
});
});

test('Read feature collection only with geometry', async () => {
const shp = openFileAsArray('testdata/featureclass.shp');
const shx = openFileAsArray('testdata/featureclass.shx');
const reader = await FeatureReader.fromArrayBuffers(shp, shx);
const collection = reader.readFeatureCollection();
expect(collection.features.length).toEqual(7);
expect(reader.fields?.length).toEqual(undefined);

collection.features.forEach((feature) => {
expect(feature.geom).not.toBeNull();
expect(feature.properties).not.toBeNull();
expect(Object.keys(feature.properties).length).toEqual(0);
expect(feature.geom instanceof PolyLineRecord).toBeTruthy();
});
});

test('SHP and DBF count mismatch', async () => {
const shp = openFileAsArray('testdata/polyline.shp');
const shx = openFileAsArray('testdata/polyline.shx');
Expand Down

0 comments on commit 376227e

Please sign in to comment.