@@ -242,82 +242,91 @@ QString QgsGrassModelItem::info()
242
242
243
243
QgsGrass::setLocation ( mGisbase , mLocation );
244
244
245
- struct Map_info Map;
246
- int level = Vect_open_old_head ( &Map, mMap .toLocal8Bit ().data (),
247
- mMapset .toLocal8Bit ().data () );
248
-
249
- if ( level >= 2 )
245
+ try
250
246
{
251
- int is3d = Vect_is_3d ( &Map );
252
-
253
- // Number of elements
254
- str += htmlTableRow ( QObject::tr ( " Points" ), QString::number ( Vect_get_num_primitives ( &Map, GV_POINT ) ) );
255
- str += htmlTableRow ( QObject::tr ( " Lines" ), QString::number ( Vect_get_num_primitives ( &Map, GV_LINE ) ) );
256
- str += htmlTableRow ( QObject::tr ( " Boundaries" ), QString::number ( Vect_get_num_primitives ( &Map, GV_BOUNDARY ) ) );
257
- str += htmlTableRow ( QObject::tr ( " Centroids" ), QString::number ( Vect_get_num_primitives ( &Map, GV_CENTROID ) ) );
258
- if ( is3d )
247
+ struct Map_info Map;
248
+ int level = Vect_open_old_head ( &Map, mMap .toLocal8Bit ().data (),
249
+ mMapset .toLocal8Bit ().data () );
250
+
251
+ if ( level >= 2 )
259
252
{
260
- str += htmlTableRow ( QObject::tr ( " Faces" ), QString::number ( Vect_get_num_primitives ( &Map, GV_FACE ) ) );
261
- str += htmlTableRow ( QObject::tr ( " Kernels" ), QString::number ( Vect_get_num_primitives ( &Map, GV_KERNEL ) ) );
262
- }
253
+ int is3d = Vect_is_3d ( &Map );
254
+
255
+ // Number of elements
256
+ str += htmlTableRow ( QObject::tr ( " Points" ), QString::number ( Vect_get_num_primitives ( &Map, GV_POINT ) ) );
257
+ str += htmlTableRow ( QObject::tr ( " Lines" ), QString::number ( Vect_get_num_primitives ( &Map, GV_LINE ) ) );
258
+ str += htmlTableRow ( QObject::tr ( " Boundaries" ), QString::number ( Vect_get_num_primitives ( &Map, GV_BOUNDARY ) ) );
259
+ str += htmlTableRow ( QObject::tr ( " Centroids" ), QString::number ( Vect_get_num_primitives ( &Map, GV_CENTROID ) ) );
260
+ if ( is3d )
261
+ {
262
+ str += htmlTableRow ( QObject::tr ( " Faces" ), QString::number ( Vect_get_num_primitives ( &Map, GV_FACE ) ) );
263
+ str += htmlTableRow ( QObject::tr ( " Kernels" ), QString::number ( Vect_get_num_primitives ( &Map, GV_KERNEL ) ) );
264
+ }
263
265
264
- str += htmlTableRow ( QObject::tr ( " Areas" ), QString::number ( Vect_get_num_areas ( &Map ) ) );
265
- str += htmlTableRow ( QObject::tr ( " Islands" ), QString::number ( Vect_get_num_islands ( &Map ) ) );
266
+ str += htmlTableRow ( QObject::tr ( " Areas" ), QString::number ( Vect_get_num_areas ( &Map ) ) );
267
+ str += htmlTableRow ( QObject::tr ( " Islands" ), QString::number ( Vect_get_num_islands ( &Map ) ) );
266
268
267
269
268
- // Box and dimension
269
- BOUND_BOX box;
270
- char buffer[100 ];
270
+ // Box and dimension
271
+ BOUND_BOX box;
272
+ char buffer[100 ];
271
273
272
- Vect_get_map_box ( &Map, &box );
274
+ Vect_get_map_box ( &Map, &box );
273
275
274
- QgsGrass::setMapset ( mGisbase , mLocation , mMapset );
275
- struct Cell_head window;
276
- G_get_window ( &window );
277
- int proj = window.proj ;
276
+ QgsGrass::setMapset ( mGisbase , mLocation , mMapset );
277
+ struct Cell_head window;
278
+ G_get_window ( &window );
279
+ int proj = window.proj ;
278
280
279
- G_format_northing ( box.N , buffer, proj );
280
- str += htmlTableRow ( QObject::tr ( " North" ), QString ( buffer ) );
281
- G_format_northing ( box.S , buffer, proj );
282
- str += htmlTableRow ( QObject::tr ( " South" ), QString ( buffer ) );
283
- G_format_easting ( box.E , buffer, proj );
284
- str += htmlTableRow ( QObject::tr ( " East" ), QString ( buffer ) );
285
- G_format_easting ( box.W , buffer, proj );
286
- str += htmlTableRow ( QObject::tr ( " West" ), QString ( buffer ) );
287
- if ( is3d )
288
- {
289
- str += htmlTableRow ( QObject::tr ( " Top" ), QString::number ( box.T ) );
290
- str += htmlTableRow ( QObject::tr ( " Bottom" ), QString::number ( box.B ) );
291
- }
281
+ G_format_northing ( box.N , buffer, proj );
282
+ str += htmlTableRow ( QObject::tr ( " North" ), QString ( buffer ) );
283
+ G_format_northing ( box.S , buffer, proj );
284
+ str += htmlTableRow ( QObject::tr ( " South" ), QString ( buffer ) );
285
+ G_format_easting ( box.E , buffer, proj );
286
+ str += htmlTableRow ( QObject::tr ( " East" ), QString ( buffer ) );
287
+ G_format_easting ( box.W , buffer, proj );
288
+ str += htmlTableRow ( QObject::tr ( " West" ), QString ( buffer ) );
289
+ if ( is3d )
290
+ {
291
+ str += htmlTableRow ( QObject::tr ( " Top" ), QString::number ( box.T ) );
292
+ str += htmlTableRow ( QObject::tr ( " Bottom" ), QString::number ( box.B ) );
293
+ }
292
294
293
- str += htmlTableRow ( " 3D" , is3d ? QObject::tr ( " yes" ) : QObject::tr ( " no" ) );
295
+ str += htmlTableRow ( " 3D" , is3d ? QObject::tr ( " yes" ) : QObject::tr ( " no" ) );
294
296
295
- str += " </table>" ;
297
+ str += " </table>" ;
296
298
297
- // History
298
- Vect_hist_rewind ( &Map );
299
- char hbuffer[1001 ];
300
- str += " <p>" + QObject::tr ( " History<br>" );
301
- QRegExp rx ( " ^-+$" );
302
- while ( Vect_hist_read ( hbuffer, 1000 , &Map ) != NULL )
303
- {
304
- QString row = QString ( hbuffer );
305
- if ( rx.indexIn ( row ) != -1 )
299
+ // History
300
+ Vect_hist_rewind ( &Map );
301
+ char hbuffer[1001 ];
302
+ str += " <p>" + QObject::tr ( " History<br>" );
303
+ QRegExp rx ( " ^-+$" );
304
+ while ( Vect_hist_read ( hbuffer, 1000 , &Map ) != NULL )
306
305
{
307
- str += " <hr>" ;
308
- }
309
- else
310
- {
311
- str += row + " <br>" ;
306
+ QString row = QString ( hbuffer );
307
+ if ( rx.indexIn ( row ) != -1 )
308
+ {
309
+ str += " <hr>" ;
310
+ }
311
+ else
312
+ {
313
+ str += row + " <br>" ;
314
+ }
312
315
}
313
316
}
314
- }
315
- else
317
+ else
318
+ {
319
+ str += " </table>" ;
320
+ }
321
+ Vect_close ( &Map );
322
+ }
323
+ catch ( QgsGrass::Exception &e )
316
324
{
325
+ QgsDebugMsg ( QString ( " Cannot open GRASS vector: %1" ).arg ( e.what () ) );
317
326
str += " </table>" ;
327
+ str += QString ( " %1 <br>" ).arg ( e.what () );
318
328
}
319
329
320
- Vect_close ( &Map );
321
330
return str;
322
331
}
323
332
break ;
@@ -330,40 +339,49 @@ QString QgsGrassModelItem::info()
330
339
331
340
QgsGrass::setLocation ( mGisbase , mLocation );
332
341
333
- struct Map_info Map;
334
- int level = Vect_open_old_head ( &Map, mMap .toLocal8Bit ().data (),
335
- mMapset .toLocal8Bit ().data () );
336
-
337
- if ( level >= 2 )
342
+ try
338
343
{
339
- struct field_info *fi;
344
+ struct Map_info Map;
345
+ int level = Vect_open_old_head ( &Map, mMap .toLocal8Bit ().data (),
346
+ mMapset .toLocal8Bit ().data () );
340
347
341
- int field = QgsGrassProvider::grassLayer ( mLayer );
342
- if ( field != -1 )
348
+ if ( level >= 2 )
343
349
{
344
- // Number of features
345
- int type = QgsGrassProvider::grassLayerType ( mLayer );
346
- if ( type != -1 )
350
+ struct field_info *fi;
351
+
352
+ int field = QgsGrassProvider::grassLayer ( mLayer );
353
+ if ( field != -1 )
347
354
{
348
- str += htmlTableRow ( QObject::tr ( " Features" ),
349
- QString::number ( Vect_cidx_get_type_count ( &Map, field, type ) ) );
350
- }
355
+ // Number of features
356
+ int type = QgsGrassProvider::grassLayerType ( mLayer );
357
+ if ( type != -1 )
358
+ {
359
+ str += htmlTableRow ( QObject::tr ( " Features" ),
360
+ QString::number ( Vect_cidx_get_type_count ( &Map, field, type ) ) );
361
+ }
351
362
352
- fi = Vect_get_field ( &Map, field );
363
+ fi = Vect_get_field ( &Map, field );
353
364
354
- // Database link
355
- if ( fi )
356
- {
357
- str += htmlTableRow ( QObject::tr ( " Driver" ), QString ( fi->driver ) );
358
- str += htmlTableRow ( QObject::tr ( " Database" ), QString ( fi->database ) );
359
- str += htmlTableRow ( QObject::tr ( " Table" ), QString ( fi->table ) );
360
- str += htmlTableRow ( QObject::tr ( " Key column" ), QString ( fi->key ) );
365
+ // Database link
366
+ if ( fi )
367
+ {
368
+ str += htmlTableRow ( QObject::tr ( " Driver" ), QString ( fi->driver ) );
369
+ str += htmlTableRow ( QObject::tr ( " Database" ), QString ( fi->database ) );
370
+ str += htmlTableRow ( QObject::tr ( " Table" ), QString ( fi->table ) );
371
+ str += htmlTableRow ( QObject::tr ( " Key column" ), QString ( fi->key ) );
372
+ }
361
373
}
362
374
}
363
- }
364
- str += " </table>" ;
375
+ str += " </table>" ;
365
376
366
- Vect_close ( &Map );
377
+ Vect_close ( &Map );
378
+ }
379
+ catch ( QgsGrass::Exception &e )
380
+ {
381
+ QgsDebugMsg ( QString ( " Cannot open GRASS vector: %1" ).arg ( e.what () ) );
382
+ str += " </table>" ;
383
+ str += QString ( " %1 <br>" ).arg ( e.what () );
384
+ }
367
385
return str;
368
386
}
369
387
break ;
0 commit comments