-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Geom compatibility check release 2.18 fixes #15741 #16927 #5223
Geom compatibility check release 2.18 fixes #15741 #16927 #5223
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one, make sure that there are no changes in terms of things that would have been committed before and are no longer committed because of early exit on failure, since we are in a stable release series.
* In case of convertion a message is notified in the log | ||
* @param geom pointer to the geometry that is adapted to provider | ||
* @return bool true if success | ||
* @note added in QGIS 2.18 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be QGIS 2.18.patch
@@ -148,4 +148,13 @@ class QgsVectorLayerEditBuffer : QObject | |||
void updateAttributeMapIndex( QgsAttributeMap& attrs, int index, int offset ) const; | |||
|
|||
void updateLayerFields(); | |||
|
|||
/** Apply geom modification basing on provider geometry type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/geom/geometry/
|
||
/** Apply geom modification basing on provider geometry type. | ||
* Geom is modified only if successful convertion is possibile. | ||
* In case of convertion a message is notified in the log |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
conversion
sent to the log
/** Apply geom modification basing on provider geometry type. | ||
* Geom is modified only if successful convertion is possibile. | ||
* In case of convertion a message is notified in the log | ||
* @param geom pointer to the geometry that is adapted to provider |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/geom/geometry
"is adapted" -> "should be adapted"
* Geom is modified only if successful convertion is possibile. | ||
* In case of convertion a message is notified in the log | ||
* @param geom pointer to the geometry that is adapted to provider | ||
* @return bool true if success |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can success be interpreted here? Only if the geometry has been changed or also if it already was ok before?
src/core/qgsofflineediting.cpp
Outdated
remoteLayer->addAttribute( field ); | ||
if ( !remoteLayer->addAttribute( field ) ) | ||
{ | ||
this->syncError = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to use this
.
src/core/qgsofflineediting.cpp
Outdated
remoteLayer->addFeature( f, false ); | ||
if ( !remoteLayer->addFeature( f, false ) ) | ||
{ | ||
this->syncError = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for this
src/core/qgsofflineediting.cpp
Outdated
remoteLayer->deleteFeature( fid ); | ||
if ( !remoteLayer->deleteFeature( fid ) ) | ||
{ | ||
this->syncError = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to use this
.
src/core/qgsofflineediting.cpp
Outdated
remoteLayer->changeAttributeValue( fid, attrLookup[ values.at( i ).attr ], values.at( i ).value ); | ||
if ( !remoteLayer->changeAttributeValue( fid, attrLookup[ values.at( i ).attr ], values.at( i ).value ) ) | ||
{ | ||
this->syncError = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No more repetitions ;)
QgsGeometry* newGeom = provider->convertToProviderType( geom ); | ||
if ( !newGeom ) | ||
{ | ||
QgsMessageLog::logMessage( tr( "ERROR: geometry type is not compatible with the layer.", "not compatible geometry" ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use level instead of an "ERROR" prefix
@m-kuhn about your comment: |
Ah, sorry, I wasn't aware of that. This changes everything a bit. In which scenario does this happen actually? I guess it's there for 2D->3D promotion and similar which should be easy to do, is it related to pasting multi-features on single-layers? |
in 2.14: you have a table that is not "multi" and you try to manually merge two features so to create a multi-geometry, a warning pop up saying that you can't and the operation is discarded. in 2.18: you do the same, no error/warning, you continue with (a ton of) other edits and then try to save > error because of the "multi" geometry you created and you can only discard all the changes you made. |
moreover at some point in 2.18 when discarding changes there was also data loss (now this seems fixed). |
Why could we do a warning pop up back then and now we need to send it to the message log? |
* @return bool true if success. | ||
* Success means that input geometry is changed because conversion is applied or | ||
* geometry is untouched if geometry conversion is not necessary. | ||
* Fail if conversion is not possible and geometry is untuched. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typos:
False if conversion is not possible and geometry is untouched.
Can you also change the "Geom" strings to "Geometry", while at it?
Thanks
good question. |
Bit +1 to go ahead with this fast |
@gioman @m-kuhn |
TestQgsServer now fail afte updated a doxygen comment? |
IIRC on the provider we have the infrastructure in place to |
I'll give a look |
@luipir I tested your branch and the patch seems to work fine to me! It certainly a much better user experience. I would suggest to merge asap for wider testing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all the improvements
@m-kuhn I'm doing some tests with pushMessages from QgsVectorDataProvider::convertToProviderType I'll give you more report tomorrows |
@m-kuhn simplified error message management usign pushMessage |
@m-kuhn now two test fails: |
still PyQgsServer failing as usual? I've to ask to merge? PyQgsServer seems fail in every 2.18 build |
@luipir can you identify since when the tests fail? |
76e9199
to
45f041d
Compare
rebased on the latest upstream fuixes that should fix failing trest on QgsServer |
now a new test fail that pass locally :/ |
again I'm lost :( |
If you could use git blame to see who created the test we could ping him here to see if he has a hint on what's going wrong. If it's unrelated to your changes (and only a flaky test) we can easily restart the tests, merge and leave the author of the legend tests to further investigate what could have gone wrong. |
I always think it's my responsability... and I loose a lot of time for this :/... I'll look for the test author |
@@ -148,4 +148,16 @@ class QgsVectorLayerEditBuffer : QObject | |||
void updateAttributeMapIndex( QgsAttributeMap& attrs, int index, int offset ) const; | |||
|
|||
void updateLayerFields(); | |||
|
|||
/** Apply geometry modification basing on provider geometry type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you could add here a hint on what kind of modification can be expected from this method this would help a lot for a reader of the API. (I.e. some reference to Z, M, Multi, others?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added more doc to the underling call that do the work: convertToProviderType
@nyalldawson any idea why: |
Sorry - no idea. I write a LOT of tests without necessarily understanding all the underlying code! ;) |
now success! :/ travis magics? |
Odd.. I don't recall seeing that test fail intermittently. Maybe another recent change has caused this... |
Probably more an unstable test... |
me too... is the first time I'm facing this fail! |
@m-kuhn merge? |
@@ -391,6 +391,13 @@ class QgsVectorDataProvider : QgsDataProvider | |||
void pushError( const QString& msg ); | |||
|
|||
/** Converts the geometry to the provider type if possible / necessary | |||
* this is the list of possibile modifications: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/possibile/possible/
* - convert to multitype if necessary | ||
* - convert to curved type if necessary | ||
* - convert to linear type from curved type | ||
* - Add or Remove z/m types |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this say "values" instead of "types"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh and either always capitalize the items or never
* - convert to multitype if necessary | ||
* - convert to curved type if necessary | ||
* - convert to linear type from curved type | ||
* - Add or Remove z/m types | ||
@return the converted geometry or nullptr if no conversion was necessary or possible*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better us \returns
, most code is now written this way
@m-kuhn is it safe to merge? do you need more reviewer to merge? |
It looks good for me. I can't tell if it is safe. |
Description
Added geometry compatibility check in addFeature and changeGeometry of QgsVectorLayerEditBuffer. In this way the user is prompted of incompatibility errors during editing.
Also added in QgsVectorLayerProvider::convertToProviderType flat geometry in case provider does not support 3d or M => they are removed.
This patch would fix #15741 #16927
This fix has effect also on the issue #16948 during paste in case of incompatibilities.
NOTE: because now editBuffer addFeature and changeGeometry can return boolean error => also vectorLayer changeGeometry and addFeature can return error. I updated (I hope) any place where this method were used without taking into account a possible fails. Most of these code parts were not covered by test to know if the patch can introduce more regressions.
Checklist
fixes #11111
in the commit message next to the description[FEATURE]
in the commit message[needs-docs]
in the commit message and containt sufficient information in the commit message to be documentedscripts/prepare-commit.sh
script before each commit