Skip to content

Commit d3773a5

Browse files
committed
Add custom projection
1 parent ebded5b commit d3773a5

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,15 @@ const zipData = shpwrite.zip(
117117
);
118118
```
119119

120+
## Custom .prj file
121+
To pass a custom [WKT string](http://www.opengeospatial.org/standards/wkt-crs) in the .prj file to define a different projection the prj option can be used:
122+
123+
```js
124+
var options = {
125+
prj: 'PROJCS["Amersfoort / RD New",GEOGCS["Amersfoort",DATUM["D_Amersfoort",SPHEROID["Bessel_1841",6377397.155,299.1528128]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Stereographic_North_Pole"],PARAMETER["standard_parallel_1",52.15616055555555],PARAMETER["central_meridian",5.38763888888889],PARAMETER["scale_factor",0.9999079],PARAMETER["false_easting",155000],PARAMETER["false_northing",463000],UNIT["Meter",1]]'
126+
}
127+
```
128+
120129
## API
121130
### `write(data, geometrytype, geometries, callback)`
122131

dist/index.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ declare module "@mapbox/shp-write" {
1818
export interface DownloadOptions {
1919
folder?: string;
2020
filename?: string;
21+
prj?: string;
2122
types?: {
2223
point?: string;
2324
polygon?: string;

indexTest.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ require('./src/download')({
7575
}
7676
]
7777
}, {
78-
file: 'shapefiles',
79-
folder: 'shapefiles',
78+
file: 'my_zip_filename', // if empty, filename will be download.zip
79+
folder: 'my_internal_shapes_folder', // leave empty to put in root
8080
outputType: 'blob',
8181
compression: 'DEFLATE',
8282
types: {

src/zip.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
var write = require("./write"),
2-
geojson = require("./geojson"),
3-
prj = require("./prj"),
4-
JSZip = require("jszip");
1+
var write = require("./write");
2+
var geojson = require("./geojson");
3+
var defaultPrj = require('./prj');
4+
var JSZip = require("jszip");
5+
56

67
module.exports = function (
78
gj,
@@ -14,6 +15,8 @@ module.exports = function (
1415
zipTarget = zip.folder(options.folder);
1516
}
1617

18+
var prj = (options && options.prj) ? options.prj : defaultPrj;
19+
1720
[
1821
geojson.point(gj),
1922
geojson.line(gj),

0 commit comments

Comments
 (0)