Skip to content

Commit

Permalink
Fix extname for shapefile (#72)
Browse files Browse the repository at this point in the history
This also adds an example for re-projection to the readme as well as organizes imports using prettier.
  • Loading branch information
wavded authored Jul 29, 2021
1 parent b7664db commit c361bc5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
8 changes: 4 additions & 4 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import {Stream, Readable} from 'stream'
import {extname} from 'path'
import archiver from 'archiver'
import {execFile} from 'child_process'
import {createReadStream} from 'fs'
import archiver from 'archiver'
import {tmpdir} from 'os'
import {join} from 'path'
import {extname, join} from 'path'
import {Readable, Stream} from 'stream'

type JSONLike = Record<string, unknown>
type RunOutput = {stdout: string; stderr: string}
Expand Down Expand Up @@ -121,6 +120,7 @@ class Ogr2ogr implements PromiseLike<Result> {
switch (f.toLowerCase()) {
case 'esri shapefile':
path += '.shz'
ext = '.shz'
break
case 'mapinfo file':
case 'flatgeobuf':
Expand Down
8 changes: 4 additions & 4 deletions index_test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import test from 'blue-tape'
import ogr2ogr from './'
import {
createWriteStream,
createReadStream,
writeFileSync,
statSync,
createWriteStream,
ReadStream,
statSync,
writeFileSync,
} from 'fs'
import ogr2ogr from './'

let dir = __dirname + '/testdata/'

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"eslint-config-prettier": "^8.3.0",
"nyc": "^15.1.0",
"prettier": "^2.0.5",
"prettier-plugin-organize-imports": "^2.3.3",
"ts-node": "^10.0.0",
"typescript": "^4.3.2"
},
Expand Down
8 changes: 8 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ ogr2ogr('/path/to/file.csv', {
})
```

Re-project geometry:

```javascript
ogr2ogr('/path/to/file.shp', {
options: ['-t_srs', 'EPSG:4326'],
})
```

[1]: https://gdal.org/download.html
[2]: https://geojson.org
[3]: https://gdal.org/drivers/vector/index.html
Expand Down

0 comments on commit c361bc5

Please sign in to comment.