Bug report #5577

"Densify geomteries" crashes QGIS

Added by Giovanni Manghi over 12 years ago. Updated over 7 years ago.

Status:Closed
Priority:Severe/Regression
Assignee:Alexander Bruy
Category:Processing/QGIS
Affected QGIS version:master Regression?:
Operating System: Easy fix?:
Pull Request or Patch supplied:No Resolution:fixed
Crashes QGIS or corrupts data:Yes Copied to github as #:15157

Description

On Ubuntu 64bit

gio@sibirica:~$ qgis
Warning: loading of qgis translation failed [/usr/share/qgis/i18n//qgis_en_US]
Warning: loading of qt translation failed [/usr/share/qt4/translations/qt_en_US]
Debug: OpenlayersLayer draw
Debug: page file: file:////home/gio/.qgis/python/plugins/openlayers/html/google_satellite.html
Debug: undefined0: TypeError: 'null' is not an object
Debug: extent: -798709.4330660001141950,4709909.2752386806532741 : -797664.5537049998529255,4710634.0523063195869327
Debug: center: -798186.993386, 4710271.663773
Debug: size: 1149, 797
Debug: logicalDpiX: 96
Debug: outputDpi: 96.000000
Debug: mapUnitsPerPixel: 0
Debug: olSize: 1149, 797
Debug: adjust viewport: 0.909382 -> 0.597164: 1749.735190 x 1213.697952
Debug: updating OpenLayers extent
Debug: undefined0: TypeError: 'null' is not an object
Debug: scale image: 1749 x 1213 -> 1149 x 797
Debug: OpenlayersLayer draw
Debug: extent: -798709.4330656065139920,4709909.2752385335043073 : -797664.5537053393200040,4710634.0523056639358401
Debug: center: -798186.993385, 4710271.663772
Debug: size: 1149, 797
Debug: logicalDpiX: 96
Debug: outputDpi: 96.000000
Debug: mapUnitsPerPixel: 0
Debug: olSize: 1149, 797
Debug: adjust viewport: 0.909382 -> 0.597164: 1749.735189 x 1213.697951
Debug: updating OpenLayers extent
Debug: scale image: 1749 x 1213 -> 1149 x 797
Warning: QObject::setParent: Cannot set parent, new parent is in a different thread
Warning: QPixmap: It is not safe to use pixmaps outside the GUI thread
Warning: QPixmap: It is not safe to use pixmaps outside the GUI thread
Warning: X Error: BadIDChoice (invalid resource ID chosen for this connection) 14
Major opcode: 1 (X_CreateWindow)
Resource id: 0x260028d
Warning: X Error: BadIDChoice (invalid resource ID chosen for this connection) 14
Extension: 150 (RENDER)
Minor opcode: 4 (RenderCreatePicture)
Resource id: 0x260028e
qgis.bin: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.0.

on windows it just gives a python error (see attached image and sample)

55.png (21.9 KB) Giovanni Manghi, 2012-05-11 11:01 AM

caminhos_shp.zip (3.07 KB) Giovanni Manghi, 2012-05-11 11:01 AM

LinestringQGIS.png (131 KB) Salvatore Larosa, 2012-05-12 03:32 AM

History

#1 Updated by Alexander Bruy over 12 years ago

This is because attached layer contains MultiLineString geometry. It is odd that wkbType() for this layer returns 2 (WKBLineString) instead of 5 (WKBMultiLineString). So IMHO here we have two problems:
  1. wkbType() reports wrong layer geometry type
  2. densify geometries don't work with multi-geometries

I'll try to fix second ASAP

#2 Updated by Salvatore Larosa over 12 years ago

I don't think that the problem is the MultiGeometries:

$ ogrinfo /home/sam/Scaricati/caminhos_shp/caminhos.shp
INFO: Open of `/home/sam/Scaricati/caminhos_shp/caminhos.shp'
      using driver `ESRI Shapefile' successful.
1: caminhos (Line String)

indeed it is not a MultiLinestring!

#3 Updated by Giovanni Manghi over 12 years ago

Alexander Bruy wrote:

This is because attached layer contains MultiLineString geometry. It is odd that wkbType() for this layer returns 2 (WKBLineString) instead of 5 (WKBMultiLineString). So IMHO here we have two problems:
  1. wkbType() reports wrong layer geometry type
  2. densify geometries don't work with multi-geometries

I'll try to fix second ASAP

Hi Alex,
this line shape was obtain in QGIS by digitizing a few features and doing a couple of "merge selected features" operations, so really nothing uncommon.

#4 Updated by Alexander Bruy over 12 years ago

Salvatore Larosa wrote:

I don't think that the problem is the MultiGeometries:

[...]

indeed it is not a MultiLinestring!

Well, take a look at geometry with FID = 1. This one is MultiGeometry and you can easy check this in Python console

>>> layer = qgis.utils.iface.mapCanvas().currentLayer()
>>> ft = QgsFeature()
>>> layer.featureAtId(1, ft)
True
>>> ft.geometry().wkbType()
5

Giovanni Manghi wrote:

this line shape was obtain in QGIS by digitizing a few features and doing a couple of "merge selected features" operations, so really nothing uncommon.

Ah, so root of the problem is that "merge selected features" sometimes creates MultiGeometries (e.g. when there is a small distance between two features. Maybe when snapping is not used during digitizing, or something like this)

#5 Updated by Alexander Bruy over 12 years ago

Anyway I add MultiLineString support in 033d58d454, and now attached file processed correctly. Now working on MultiPolygon support

#6 Updated by Salvatore Larosa over 12 years ago

Alexander Bruy wrote:

Well, take a look at geometry with FID = 1. This one is MultiGeometry and you can easy check this in Python console
[...]

Right, thanks!
Anyway I noticed that imports shp in PostGIS, densify tool works succesfully this because the geometries are MultiLinestring!

I don't know why in QGIS (see image) and ogrinfo, it is consider like a LineString geometry type!!!

#7 Updated by Salvatore Larosa over 12 years ago

Well,

FID 0,2,3 wkbType() returns 2 and isMultipart() returns False;
FID 1 wkbType() returns 5 and isMultipart() returns True.

Is it conceptually correct?

Now I begin to understand the issues #5547, #5328!
Could help Jürgen's fix(#5109)?

#8 Updated by Alexander Bruy over 12 years ago

  • Status changed from Open to Closed
  • Resolution set to fixed

As I understand, shapefile can contain in LineString layer also MultiLineString geometries, and in MultiLineString layer simple LineString geometries (same for points and polygons). "Merge selected features" tool sometimes (when input features have some distance between them) produces multi-geometry. Modifying shapefile didn't change it type, so it continues to report old LineString type.

Multipolygon support added in 2607535b3f, so I close this ticket. Please reopen if necessary

#9 Updated by Giovanni Manghi over 12 years ago

Alexander Bruy wrote:

As I understand, shapefile can contain in LineString layer also MultiLineString geometries, and in MultiLineString layer simple LineString geometries (same for points and polygons). "Merge selected features" tool sometimes (when input features have some distance between them) produces multi-geometry. Modifying shapefile didn't change it type, so it continues to report old LineString type.

Multipolygon support added in 2607535b3f, so I close this ticket. Please reopen if necessary

Hi Alex, thanks for this! I will give it a try asap!

#10 Updated by Giovanni Manghi over 7 years ago

The "ftools" category is being removed from the tracker, changing the category of this ticket to "Processing/QGIS" to not leave the category orphaned.

Also available in: Atom PDF