#3017 closed enhancement (fixed)
support for background option for grid labels in d.grid
Reported by: | veroandreo | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | 7.4.0 |
Component: | Display | Version: | unspecified |
Keywords: | d.grid, gsoc2016, cartography | Cc: | |
CPU: | Unspecified | Platform: | Unspecified |
Description
It would be nice to also have background color option (along with grid color, text color and border color) when adding grid labels with d.grid.
Attachments (7)
Change History (23)
comment:1 by , 9 years ago
Keywords: | gsoc2016 cartography added |
---|
by , 9 years ago
Attachment: | d.grid.diff added |
---|
follow-up: 3 comment:2 by , 9 years ago
Thanks for the patch, but I am getting weird results (see attachment). It's possible I might have done something wrong when applying the patch, because I needed to get rid of the whitespace changes. Could you please check this?
Also bg_color
should be probably changed to bgcolor
to be compatible with all other modules having this option.
Ideally please upload a new patch without the whitespace changes.
follow-up: 4 comment:3 by , 9 years ago
Replying to annakrat:
Thanks for the patch, but I am getting weird results (see attachment). It's possible I might have done something wrong when applying the patch, because I needed to get rid of the whitespace changes. Could you please check this?
Also
bg_color
should be probably changed tobgcolor
to be compatible with all other modules having this option.Ideally please upload a new patch without the whitespace changes.
OK, I will change it to bgcolor
. I think the problem is not in whitespaces. The size of label background depends on the font size. I tested it on several font sizes and I got good results but obviously it doesn't work in general.
follow-up: 5 comment:4 by , 9 years ago
Replying to lazaa:
Replying to annakrat:
Thanks for the patch, but I am getting weird results (see attachment). It's possible I might have done something wrong when applying the patch, because I needed to get rid of the whitespace changes. Could you please check this?
Also
bg_color
should be probably changed tobgcolor
to be compatible with all other modules having this option.Ideally please upload a new patch without the whitespace changes.
OK, I will change it to
bgcolor
. I think the problem is not in whitespaces. The size of label background depends on the font size. I tested it on several font sizes and I got good results but obviously it doesn't work in general.
It seems to change with zoom level, so I think you have to somehow convert between the pixel and geographic coordinates.
by , 9 years ago
Attachment: | d.grid2.diff added |
---|
Updated patch with original whitespaces/tabs. Text box margin is calculated as a percentage of text width/height.
follow-up: 7 comment:5 by , 9 years ago
Replying to annakrat:
Replying to lazaa:
Replying to annakrat:
Thanks for the patch, but I am getting weird results (see attachment). It's possible I might have done something wrong when applying the patch, because I needed to get rid of the whitespace changes. Could you please check this?
Also
bg_color
should be probably changed tobgcolor
to be compatible with all other modules having this option.Ideally please upload a new patch without the whitespace changes.
OK, I will change it to
bgcolor
. I think the problem is not in whitespaces. The size of label background depends on the font size. I tested it on several font sizes and I got good results but obviously it doesn't work in general.It seems to change with zoom level, so I think you have to somehow convert between the pixel and geographic coordinates.
I uploaded new patch with original whitespaces/tabs.
I looked how it is done in d.text module. Now is the margin of the text box calculated from width and height of the text inside text box.
Another problem is that if user uses flag -g or -w. The geographical grid isn't horizontal/vertical so the labels are a bit rotated. But I couldn't find any way how to rotate the text box for filling background. I attached an image.
comment:7 by , 9 years ago
Replying to lazaa:
I uploaded new patch with original whitespaces/tabs.
I looked how it is done in d.text module. Now is the margin of the text box calculated from width and height of the text inside text box.
Another problem is that if user uses flag -g or -w. The geographical grid isn't horizontal/vertical so the labels are a bit rotated. But I couldn't find any way how to rotate the text box for filling background. I attached an image.
Thank you, I committed it. I don't think the rotation is a huge problem here for most cases. You could look at d.labels, it can do the rotation of the background. But I don't think you should focus on this now.
More testing welcome.
follow-up: 9 comment:8 by , 9 years ago
Hi, I'm happy to have background option in d.grid :)
I did a quick test and I attach an example below. I noted that when choosing white background for grid labels, I loose part of the map in the east (See no-transparency in fig 1 vs transparency in fig 2). So, background of labels seems to be a continuous white strip for Y coordinate, while it's fine for X coordinate.
On the other hand, grid lines overlap the white background of labels, while IMHO, label should always be in front.
I personally don't like the border tickmarks of d.grid but when disabling them, labels remain aligned as if there were border tickmarks (last fig). Maybe they could be aligned more close to the border (if not against it) as in ps.map.
And, would that be possible to also change font of labels?? :)
by , 9 years ago
Attachment: | d_grid_examples.png added |
---|
d.grid testing transparency vs no-transparency and labels positioning
follow-up: 10 comment:9 by , 9 years ago
Replying to veroandreo:
Hi, I'm happy to have background option in d.grid :)
I did a quick test and I attach an example below. I noted that when choosing white background for grid labels, I loose part of the map in the east (See no-transparency in fig 1 vs transparency in fig 2). So, background of labels seems to be a continuous white strip for Y coordinate, while it's fine for X coordinate.
I can confirm this, the size of the background rectangle still needs fixing, the problem showed up only in latlon for me.
On the other hand, grid lines overlap the white background of labels, while IMHO, label should always be in front.
Yes, the horizontal labels are fine, just the vertical ones are below the grid lines.
I personally don't like the border tickmarks of d.grid but when disabling them, labels remain aligned as if there were border tickmarks (last fig). Maybe they could be aligned more close to the border (if not against it) as in ps.map.
And, would that be possible to also change font of labels?? :)
You can do that from GUI settings - you set display font for all d.* commands.
comment:10 by , 9 years ago
Replying to annakrat:
Replying to veroandreo:
Hi, I'm happy to have background option in d.grid :)
I did a quick test and I attach an example below. I noted that when choosing white background for grid labels, I loose part of the map in the east (See no-transparency in fig 1 vs transparency in fig 2). So, background of labels seems to be a continuous white strip for Y coordinate, while it's fine for X coordinate.
I can confirm this, the size of the background rectangle still needs fixing, the problem showed up only in latlon for me.
I tried to find the problem, but I didn't succeed :(
On the other hand, grid lines overlap the white background of labels, while IMHO, label should always be in front.
Yes, the horizontal labels are fine, just the vertical ones are below the grid lines.
I fixed this problem. Now the grid lines are drawn first (both vertical and horizontal) and after that are drawn labels so at final they are shown in front.
I personally don't like the border tickmarks of d.grid but when disabling them, labels remain aligned as if there were border tickmarks (last fig). Maybe they could be aligned more close to the border (if not against it) as in ps.map.
And, would that be possible to also change font of labels?? :)
You can do that from GUI settings - you set display font for all d.* commands.
follow-up: 13 comment:12 by , 9 years ago
I confirm that the rectangular size in Y coordinate now appears as expected, but I noticed that disabling grid drawing (-n) also makes text disappear (both in latlong and projected locations).
follow-up: 14 comment:13 by , 9 years ago
Replying to veroandreo:
I confirm that the rectangular size in Y coordinate now appears as expected, but I noticed that disabling grid drawing (-n) also makes text disappear (both in latlong and projected locations).
The behavior didn't change, it was there before. Please create a separate ticket for that.
comment:14 by , 9 years ago
Replying to annakrat:
Replying to veroandreo:
I confirm that the rectangular size in Y coordinate now appears as expected, but I noticed that disabling grid drawing (-n) also makes text disappear (both in latlong and projected locations).
The behavior didn't change, it was there before. Please create a separate ticket for that.
Done in #3053
Added option bg_color to choose background color of grid labels