Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the layer type when adding a part to a featureless entry. Fix #8459 #984

Merged
merged 1 commit into from Nov 5, 2013
Merged

Use the layer type when adding a part to a featureless entry. Fix #8459 #984

merged 1 commit into from Nov 5, 2013

Conversation

biolds
Copy link
Contributor

@biolds biolds commented Nov 4, 2013

@ghost ghost assigned mhugent Nov 4, 2013
@3nids
Copy link
Member

3nids commented Nov 4, 2013

@mhugent can you have a look to this?

@biolds
Copy link
Contributor Author

biolds commented Nov 4, 2013

I should explain a bit:
Adding a new part to a empty geometry fails because the type of geometry (created in QgsVectorLayerEditUtils::addPart) is UnknownGeometry. Adding a part to this type of geometry fails in QgsGeometry::addPart, because the code relies on it to check the added part.
This patch adds an argument to addPart to allow passing the type that we know from the layer.

@mhugent
Copy link
Contributor

mhugent commented Nov 4, 2013

Could you explain a bit more on the use case? I assume there is a specific reason why you add a part to an empty geometry (instead creating a new geometry).
Also, is it possible to test the geometry type ( and do fromGeos() if unknown) at the begin of the function instead of passing the geometry type as an argument?

@3nids
Copy link
Member

3nids commented Nov 5, 2013

Basically if you already have a feature without any geometry and want to edit it. If it's a multi part, I think the most obvious way is to use add part.

The question for single geometry would still be open.

@mhugent
Copy link
Contributor

mhugent commented Nov 5, 2013

Right, that sounds reasonable for single and multi types.
Is it possible to just alter the behaviour of addPart() function such that the part becomes the geometry if geometry is empty (so without the need to pass a type as an argument to the function)?

@biolds
Copy link
Contributor Author

biolds commented Nov 5, 2013

Both for multi part type and single part the "Add part" button can be used to set the geometry, I think they are handled the same way in Qgis. I checked it works correctly with single and multi geometries.
In my use case, the database lines are created using an other software (Tryton, an ERP), and afterward I set geometries on these entries.
It's not possible to retrieve the type from the Geometry because it uses the underlying GEOS object to retrieve the type, and since it is NULL the Geometry has a type UnknownGeometry at this point.

mhugent added a commit that referenced this pull request Nov 5, 2013
Use the layer type when adding a part to a featureless entry. Fix #8459
@mhugent mhugent merged commit e3e22be into qgis:master Nov 5, 2013
@mhugent
Copy link
Contributor

mhugent commented Nov 5, 2013

I see, we need the geometry type to create the part object. That's fine, patch is applied. Thank you !

@qgib qgib mentioned this pull request May 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants