Bug report #12634

Proj4 Exception in Measure tool leaves qgis in wait state (OTF On)

Added by Sandro Santilli over 9 years ago. Updated over 9 years ago.

Status:Closed
Priority:Normal
Assignee:Sandro Santilli
Category:-
Affected QGIS version:2.8.1 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:fixed/implemented
Crashes QGIS or corrupts data:No Copied to github as #:20749

Description

I've OnTheFly reprojection active. Map projection is EPSG:3003.
Two layers visible, one also EPSG:3003, one EPSG:4326.
If I open the "Measure tool" while the EPSG:4326 layer is selected, the first click on the map results in an error:

forward transform of
(1.745309, -1.396266)
PROJ.4:  +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 +to  +proj=tmerc +lat_0=0 +lon_0=9 +k=0.9996 +x_0=1500000 +y_0=0 +ellps=intl +towgs84=-104.1,-49.1,-9.9,0.971,-2.917,0.714,-11.68 +units=m +no_defs
Error: latitude or longitude exceeded limits

Then, qgis remains with the "waiting circle" spinning.

Note that selecting the same point with no layers selected works fine (but I need to restart to verify, as the previous error makes qgis stuck).
This is with current 2.8 branch (2.8.1+).

I hadn't checked with master or 2.6.


Related issues

Related to QGIS Application - Bug report #11784: Measure Line behaviour when "On the fly" enabled Closed 2014-12-03

Associated revisions

Revision 0480cabf
Added by Sandro Santilli over 9 years ago

Make QgsPointLocator discard geometries that cannot be projected

Fix #12634 (crash snapping in measure tool)
To be backported to 2.8 branch

Revision c9ec219f
Added by Sandro Santilli over 9 years ago

Make QgsPointLocator discard geometries that cannot be projected

Fix #12634 (crash snapping in measure tool)

(cherry picked from commit 0480cabfc91353156c58285b5748ef1c83bbe5d7)

History

#1 Updated by Sandro Santilli over 9 years ago

See also #11784

#2 Updated by Sandro Santilli over 9 years ago

  • Tag set to measure

#3 Updated by Sandro Santilli over 9 years ago

2.6.1 is not affected

#4 Updated by Sandro Santilli over 9 years ago

  • Target version set to Version 2.8.2

master, as of 95a7fbc IS affected

#5 Updated by Sandro Santilli over 9 years ago

It doesn't take 2 layers to reproduce. Single layer: world countries borders in EPSG:4326. Map projection in EPSG:3003, OTF projection, Measure tool and BOOM. Note: it still takes selecting the layer to trigger.

#6 Updated by Sandro Santilli over 9 years ago

It is an unhandled exception taking down one thread:

src/app/qgsmeasuretool.cpp: 155: (canvasReleaseEvent) [4639ms] XXX release event got point 822, 188
src/providers/postgres/qgspostgresconn.cpp: 923: (openCursor) [2ms] Starting read-only transaction: 90306
src/core/qgscoordinatetransform.cpp: 716: (transformCoords) [18ms] Projection failed emitting invalid transform signal: forward transform of
(3.141572, -1.396270)                                      
PROJ.4:  +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 +to  +proj=tmerc +lat_0=0 +lon_0=9 +k=0.9996 +x_0=1500000 +y_0=0 +ellps=intl +towgs84=-104.1,-49.1,-9.9,0.971,-2.917,0.714,-11.68 +units=m +no_defs
Error: latitude or longitude exceeded limits
src/core/qgscoordinatetransform.cpp: 720: (transformCoords) [0ms] throwing exception
src/core/qgscoordinatetransform.cpp: 367: (transformInPlace) [1ms] rethrowing exception
src/providers/postgres/qgspostgresconn.cpp: 941: (closeCursor) [6ms] Committing read-only transaction
src/core/qgsapplication.cpp: 257: (notify) [2ms] Caught unhandled QgsException: forward transform of
(3.141572, -1.396270)
PROJ.4:  +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 +to  +proj=tmerc +lat_0=0 +lon_0=9 +k=0.9996 +x_0=1500000 +y_0=0 +ellps=intl +towgs84=-104.1,-49.1,-9.9,0.971,-2.917,0.714,-11.68 +units=m +no_defs
Error: latitude or longitude exceeded limits

#7 Updated by Sandro Santilli over 9 years ago

May be related to the refactoring conducted by Martin Dobias in 334d885b6d4757398d63771e1019fc4ed68c1a35

#8 Updated by Sandro Santilli over 9 years ago

Catching the exception in QgsMeasureTool::snapPoint makes the measure tool functional, but still leaves a spinning waiting circle behind. It sounds like SnappingUtils::snapToMap is not exception safe.

#9 Updated by Sandro Santilli over 9 years ago

I found the exception being thrown during creation of the snapping index. I don't think it is correct to index all geometries rather than only those that fall in the viewport, but that's another issue. For now I think it'll be ok just NOT TO SNAP against geometries that cannot be projected to map coordinate space (although I dunno if it makes sense at all to snap on map units rather than on pixel units...)

#10 Updated by Sandro Santilli over 9 years ago

  • Status changed from Open to Closed

#11 Updated by Sandro Santilli over 9 years ago

  • Assignee set to Sandro Santilli
  • Resolution set to fixed/implemented

#12 Updated by Sandro Santilli over 9 years ago

It would be useful to add tests in tests/src/core/testqgspointlocator.cpp, but I hadn't seen examples of changing settings in there. The case is presence of layers in which some geometries can not be projected to map projection, and snapping option requesting snap to "current layer" (being the offending one).

Also available in: Atom PDF