@@ -105,11 +105,11 @@ int main( int argc, char **argv )
105105 exit ( EXIT_FAILURE );
106106
107107 QFile stdinFile;
108- stdinFile.open ( 0 , QIODevice::ReadOnly );
108+ stdinFile.open ( stdin , QIODevice::ReadOnly );
109109 QDataStream stdinStream ( &stdinFile );
110110
111111 QFile stdoutFile;
112- stdoutFile.open ( 0 , QIODevice::ReadOnly );
112+ stdoutFile.open ( stdout , QIODevice::WriteOnly );
113113 QDataStream stdoutStream ( &stdoutFile );
114114
115115 qint32 typeQint32;
@@ -178,6 +178,8 @@ int main( int argc, char **argv )
178178 {
179179 exitIfCanceled ( stdinStream, isPolygon, tmpName, &tmpMap, finalName, &finalMap );
180180 stdinStream >> feature;
181+ stdoutStream << ( bool )true ; // feature received
182+ stdoutFile.flush ();
181183 if ( !feature.isValid () )
182184 {
183185 break ;
@@ -278,6 +280,29 @@ int main( int argc, char **argv )
278280 break ;
279281 }
280282 }
283+ // TODO: review if necessary and if there is GRASS function
284+ // remove zero length
285+ int nlines = Vect_get_num_lines ( map );
286+ struct line_pnts *line = Vect_new_line_struct ();
287+ for ( int i = 1 ; i <= nlines; i++ )
288+ {
289+ if ( !Vect_line_alive ( map, i ) )
290+ {
291+ continue ;
292+ }
293+
294+ int type = Vect_read_line ( map, line, NULL , i );
295+ if ( !( type & GV_BOUNDARY ) )
296+ {
297+ continue ;
298+ }
299+
300+ if ( Vect_line_length ( line ) == 0 )
301+ {
302+ Vect_delete_line ( map, i );
303+ }
304+ }
305+
281306 Vect_merge_lines ( map, GV_BOUNDARY, NULL , NULL );
282307#if GRASS_VERSION_MAJOR < 7
283308 Vect_remove_bridges ( map, NULL );
@@ -310,6 +335,8 @@ int main( int argc, char **argv )
310335 {
311336 exitIfCanceled ( stdinStream, isPolygon, tmpName, &tmpMap, finalName, &finalMap );
312337 stdinStream >> feature;
338+ stdoutStream << ( bool )true ; // feature received
339+ stdoutFile.flush ();
313340 if ( !feature.isValid () )
314341 {
315342 break ;
@@ -357,6 +384,7 @@ int main( int argc, char **argv )
357384 Vect_close ( &finalMap );
358385
359386 stdoutStream << ( bool )true ; // to keep caller waiting until finished
387+ stdoutFile.flush ();
360388 // TODO history
361389
362390 exit ( EXIT_SUCCESS );
0 commit comments