Feature request #13387
Print composer grid coordinate formater should provide variables for current DMS values
|Pull Request or Patch supplied:||No||Resolution:|
|Easy fix?:||No||Copied to github as #:||21439|
Even after implementing custom grid annotation formatting, adding a DMS with a correct text is more like a rocket science than a usable feature.
Use case: add a grid in WGS84 CRS with labels in format DMS + label «24°00'00.0"E».
Current option "DMS with Suffix" will provide «24°00'00.0"A» ("A" stands for "Austrumi" in Latvian) and the only way how to change "A" to "E" is to change the QGIS GUI language into English. Sucks, but somehow works.
e8c3afa3984cee32b98b52ba65bcf5ed630ae72d adds a "custom" grid annotation formatting option. The only issue - there is no shortcut to get DMS or to get current direction of coordinate axis. It provides two variables "@grid_number" - line coordinate in decimal degrees and "@grid_axis" - "X" or "Y" value where "X" means longitude and "Y" means latitude. Converting @grid_number from DD to DMS and providing correct label (N,E,S,W) is left as an exercise to reader.
"Exercise to reader" is a bit too complicated to be considered a suitable solution for average QGIS user. Here follows a non-working example that could be used to provide labels for Easting. Rinse and repeat for W, N and S (after spotting the mistake I have made in the code).
The solution could cover two aspects (implementing one of them does not invalidate the second one):
case when @grid_axis == 'x' and @grid_number > 0 then format("%1°%2'%3\\"E", floor( @grid_number ), floor(( @grid_number - floor( @grid_number )) * 60), ( @grid_number - floor(( @grid_number - floor( @grid_number )) * 60)) * 3600) end
- for existing DMS + Suffix labels provide a configuration option where user can type-in labels for E,S,W,N directions (dummy friendly version);
- for "custom" label formatter to provide variables with (Boeing pilot version):
- current D, M, S values (thus allowing format('%1deg %2min %3sec', @grid_deg, @grid_min, @grid_sec))
- current label quadrant as static value (N,E,S,W) (it would allow if(@grid_quad 'N', 'Ziemeļi'))
#1 Updated by Nyall Dawson over 5 years ago
- Assignee deleted (
for "custom" label formatter to provide variables with (Boeing pilot version):
current D, M, S values (thus allowing format('%1deg %2min %3sec', @grid_deg, @grid_min, @grid_sec))
current label quadrant as static value (N,E,S,W) (it would allow if(@grid_quad 'N', 'Ziemeļi'))
Sounds like a good approach. Just a note though, please don't assign people to Feature Request tickets unless you've discussed with them in advance. Assignee is used to indicate that someone is either actively working on something or (for a bug) that they broke something and they need to fix it ;)