@@ -58,7 +58,8 @@ struct Column<'a> {
58
58
replace : Option < & ' a str > ,
59
59
consol : Option < & ' a str > ,
60
60
subtable : Option < Table < ' a > > ,
61
- bbox : Option < BBox >
61
+ bbox : Option < BBox > ,
62
+ multitype : bool
62
63
}
63
64
impl std:: fmt:: Debug for Column < ' _ > {
64
65
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
@@ -99,10 +100,10 @@ impl BBox {
99
100
}
100
101
}
101
102
102
- fn gml_to_ewkb ( cell : & RefCell < String > , coll : & [ Geometry ] , bbox : Option < & BBox > ) -> bool {
103
+ fn gml_to_ewkb ( cell : & RefCell < String > , coll : & [ Geometry ] , bbox : Option < & BBox > , multitype : bool ) -> bool {
103
104
let mut ewkb: Vec < u8 > = vec ! [ ] ;
104
105
105
- if coll. len ( ) > 1 {
106
+ if multitype || coll. len ( ) > 1 {
106
107
let multitype = coll. first ( ) . unwrap ( ) . gtype +3 ;
107
108
ewkb. extend_from_slice ( & [ 1 , multitype, 0 , 0 , 0 ] ) ;
108
109
ewkb. extend_from_slice ( & ( coll. len ( ) as u32 ) . to_le_bytes ( ) ) ;
@@ -126,7 +127,7 @@ fn gml_to_ewkb(cell: &RefCell<String>, coll: &[Geometry], bbox: Option<&BBox>) -
126
127
for ring in geom. rings . iter ( ) {
127
128
if geom. gtype != 1 { ewkb. extend_from_slice ( & ( ( ring. len ( ) as u32 ) /geom. dims as u32 ) . to_le_bytes ( ) ) ; } // Points don't have multiple vertices
128
129
for ( i, pos) in ring. iter ( ) . enumerate ( ) {
129
- if overlap == true { }
130
+ if overlap { }
130
131
else if geom. dims == 2 {
131
132
if i%2 == 0 {
132
133
overlapx = false ;
@@ -144,7 +145,7 @@ fn gml_to_ewkb(cell: &RefCell<String>, coll: &[Geometry], bbox: Option<&BBox>) -
144
145
ewkb. extend_from_slice ( & pos. to_le_bytes ( ) ) ;
145
146
}
146
147
}
147
- if overlap == false { return false ; }
148
+ if ! overlap { return false ; }
148
149
}
149
150
else {
150
151
for ring in geom. rings . iter ( ) {
@@ -185,7 +186,8 @@ fn add_table<'a>(rowpath: &str, outfile: Option<&str>, filemode: &str, skip: Opt
185
186
let find = col[ "find" ] . as_str ( ) ;
186
187
let replace = col[ "repl" ] . as_str ( ) ;
187
188
let consol = col[ "cons" ] . as_str ( ) ;
188
- let bbox = col[ "bbox" ] . as_str ( ) . and_then ( |str| BBox :: from ( str) ) ;
189
+ let bbox = col[ "bbox" ] . as_str ( ) . and_then ( BBox :: from) ;
190
+ let multitype = col[ "mult" ] . as_bool ( ) . unwrap_or ( false ) ;
189
191
190
192
if convert. is_some ( ) && !vec ! ( "xml-to-text" , "gml-to-ewkb" ) . contains ( & convert. unwrap ( ) ) {
191
193
panic ! ( "Option 'convert' contains invalid value {}" , convert. unwrap( ) ) ;
@@ -205,7 +207,7 @@ fn add_table<'a>(rowpath: &str, outfile: Option<&str>, filemode: &str, skip: Opt
205
207
eprintln ! ( "Warning: the bbox option has no function without conversion type 'gml-to-ekwb'" ) ;
206
208
}
207
209
208
- let column = Column { name : name. to_string ( ) , path, value : RefCell :: new ( String :: new ( ) ) , attr, hide, include, exclude, convert, find, replace, consol, subtable, bbox } ;
210
+ let column = Column { name : name. to_string ( ) , path, value : RefCell :: new ( String :: new ( ) ) , attr, hide, include, exclude, convert, find, replace, consol, subtable, bbox, multitype } ;
209
211
table. columns . push ( column) ;
210
212
}
211
213
table
@@ -499,7 +501,7 @@ fn main() -> std::io::Result<()> {
499
501
for i in 0 ..table. columns . len ( ) {
500
502
if path == table. columns [ i] . path {
501
503
gmltoewkb = false ;
502
- if !gml_to_ewkb ( & table. columns [ i] . value , & gmlcoll, table. columns [ i] . bbox . as_ref ( ) ) {
504
+ if !gml_to_ewkb ( & table. columns [ i] . value , & gmlcoll, table. columns [ i] . bbox . as_ref ( ) , table . columns [ i ] . multitype ) {
503
505
filtered = true ;
504
506
table. clear_columns ( ) ;
505
507
}
0 commit comments