File tree 2 files changed +18
-15
lines changed
2 files changed +18
-15
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ function justType(gjType, shpType) {
14
14
return function ( gj ) {
15
15
var oftype = gj . features . filter ( isType ( gjType ) ) ;
16
16
return {
17
- geometries : shpType === 'POLYLINE' ? oftype . map ( l => [ justCoords ( l ) ] ) : oftype . map ( justCoords ) ,
17
+ geometries : shpType === 'POLYLINE' ? [ oftype . map ( justCoords ) ] : oftype . map ( justCoords ) ,
18
18
properties : oftype . map ( justProps ) ,
19
19
type : shpType ,
20
20
} ;
Original file line number Diff line number Diff line change @@ -18,25 +18,28 @@ module.exports = function (
18
18
var prj = ( options && options . prj ) ? options . prj : defaultPrj ;
19
19
20
20
[
21
- geojson . point ( gj ) ,
22
- geojson . line ( gj ) ,
23
- geojson . polygon ( gj ) ,
24
- geojson . multipolygon ( gj ) ,
25
- geojson . multiline ( gj ) ,
26
- ] . forEach ( function ( l ) {
27
- if ( l . geometries . length && l . geometries [ 0 ] . length ) {
28
- write (
21
+ [ geojson . point ( gj ) ] ,
22
+ [ geojson . line ( gj ) , geojson . multiline ( gj ) ] ,
23
+ [ geojson . polygon ( gj ) , geojson . multipolygon ( gj ) ] ,
24
+ ] . forEach ( function ( l ) {
25
+ if ( ( l [ 0 ] . geometries . length && l [ 0 ] . geometries [ 0 ] . length ) || l [ 1 ] && l [ 1 ] . geometries . length && l [ 1 ] . geometries [ 0 ] . length ) {
26
+
27
+ const properties = l . flatMap ( l => l . properties ) ;
28
+ const geometries = l . flatMap ( l => l . geometries ) ;
29
+ const type = l [ 0 ] . type ;
30
+
31
+ write (
29
32
// field definitions
30
- l . properties ,
33
+ properties ,
31
34
// geometry type
32
- l . type ,
35
+ l [ 0 ] . type ,
33
36
// geometries
34
- l . geometries ,
37
+ geometries ,
35
38
function ( err , files ) {
36
39
var fileName =
37
- options && options . types && options . types [ l . type . toLowerCase ( ) ]
38
- ? options . types [ l . type . toLowerCase ( ) ]
39
- : l . type ;
40
+ options && options . types && options . types [ type . toLowerCase ( ) ]
41
+ ? options . types [ type . toLowerCase ( ) ]
42
+ : type ;
40
43
zipTarget . file ( fileName + ".shp" , files . shp . buffer , { binary : true } ) ;
41
44
zipTarget . file ( fileName + ".shx" , files . shx . buffer , { binary : true } ) ;
42
45
zipTarget . file ( fileName + ".dbf" , files . dbf . buffer , { binary : true } ) ;
You can’t perform that action at this time.
0 commit comments