File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ export class FeatureReader {
2020 }
2121
2222 private constructor ( shapeFile : ShapeReader , dbfReader ?: DbfReader ) {
23- if ( shapeFile . recordCount !== dbfReader ?. recordCount ) {
23+ if ( dbfReader && shapeFile . recordCount !== dbfReader ?. recordCount ) {
2424 throw new Error (
2525 `Record count mismatch: SHP-file has ${ shapeFile . recordCount } records, DBF has ${ dbfReader ?. recordCount } `
2626 ) ;
Original file line number Diff line number Diff line change @@ -53,6 +53,22 @@ test('Read feature collection', async () => {
5353 } ) ;
5454} ) ;
5555
56+ test ( 'Read feature collection only with geometry' , async ( ) => {
57+ const shp = openFileAsArray ( 'testdata/featureclass.shp' ) ;
58+ const shx = openFileAsArray ( 'testdata/featureclass.shx' ) ;
59+ const reader = await FeatureReader . fromArrayBuffers ( shp , shx ) ;
60+ const collection = reader . readFeatureCollection ( ) ;
61+ expect ( collection . features . length ) . toEqual ( 7 ) ;
62+ expect ( reader . fields ?. length ) . toEqual ( undefined ) ;
63+
64+ collection . features . forEach ( ( feature ) => {
65+ expect ( feature . geom ) . not . toBeNull ( ) ;
66+ expect ( feature . properties ) . not . toBeNull ( ) ;
67+ expect ( Object . keys ( feature . properties ) . length ) . toEqual ( 0 ) ;
68+ expect ( feature . geom instanceof PolyLineRecord ) . toBeTruthy ( ) ;
69+ } ) ;
70+ } ) ;
71+
5672test ( 'SHP and DBF count mismatch' , async ( ) => {
5773 const shp = openFileAsArray ( 'testdata/polyline.shp' ) ;
5874 const shx = openFileAsArray ( 'testdata/polyline.shx' ) ;
You can’t perform that action at this time.
0 commit comments