[GRASS-dev] [GRASS GIS] #155: ps.map: the "M" highlight problem

#155: ps.map: the "M" highlight problem
------------------------------+---------------------------------------------
Reporter: perk | Owner: grass-dev@lists.osgeo.org
     Type: defect | Status: new
Priority: minor | Milestone: 6.4.0
Component: default | Version: svn-trunk
Keywords: ps.map highlight |
------------------------------+---------------------------------------------
Using any highlight on `text` and `labels` produces some very bad looking
results. I call this the "M" problem, because I first noticed it in
labels with a capital M, but other letters are affected too. I've
attached a sample that pretty clearly shows the problem.

I see two pretty easy ways to fix this: temporarily change (1) the miter
length or (2) the line join style when the highlight path gets stroked.
I've chosen the latter, because I think it looks better. I've attached a
patch for ps/ps.map/prolog.ps. It is marked as a binary file for some
reason, so I was not able to do "svn diff". I've also attached the same
ps.map output sample made after the fix.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/155&gt;
GRASS GIS <http://grass.osgeo.org>

#155: ps.map: the "M" highlight problem
----------------------+-----------------------------------------------------
  Reporter: perk | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: minor | Milestone: 6.4.0
Component: default | Version: svn-trunk
Resolution: | Keywords: ps.map highlight text labels
----------------------+-----------------------------------------------------
Changes (by perk):

  * keywords: ps.map highlight => ps.map highlight text labels

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/155#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#155: ps.map: the "M" highlight problem
----------------------+-----------------------------------------------------
  Reporter: perk | Owner: hamish
      Type: defect | Status: assigned
  Priority: minor | Milestone: 6.4.0
Component: default | Version: svn-trunk
Resolution: | Keywords: ps.map highlight text labels
----------------------+-----------------------------------------------------
Changes (by hamish):

  * status: new => assigned
  * owner: grass-dev@lists.osgeo.org => hamish
* cc: grass-dev@lists.osgeo.org (added)

Comment:

nice to finally see a solution for this, thanks.

before applying the patch I would like to ask about possible side effects
-- does the "currentlinejoin 1 setlinejoin stroke setlinejoin" part need
to be swiched off after drawing the labels, or will it be self contained?

could a similar technique be used to connect .eps pattern tiles?
eg broken lines: http://grass.osgeo.org/wiki/Psmap_flooding_example

you might also see that d.labels does not do very well with larger values
for the highlight width. In that case I guess the solution is to also
smear the color using the "knight's move" or similar, not just the 8
cardinal+ordinal directions.

> I've attached a patch for ps/ps.map/prolog.ps. It is marked as a binary
file
> for some reason, so I was not able to do "svn diff".

{{{
$ svn proplist prolog.ps
Properties on 'prolog.ps':
   svn:mime-type
$ svn propget svn:mime-type prolog.ps
application/postscript
$ svn diff prolog.ps
Index: prolog.ps

Cannot display: file marked as a binary type.
svn:mime-type = application/postscript
}}}

svn bug? (PostScript is ASCII)

fwiw, trac does nice markup when you click on the .diff file.

Hamish

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/155#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#155: ps.map: the "M" highlight problem
----------------------+-----------------------------------------------------
  Reporter: perk | Owner: hamish
      Type: defect | Status: assigned
  Priority: minor | Milestone: 6.4.0
Component: default | Version: svn-trunk
Resolution: | Keywords: ps.map highlight text labels
----------------------+-----------------------------------------------------
Comment (by hamish):

spearfish example:

{{{
v.label map=fields labels=lfields column=label fontsize=12 hcolor=aqua
hwidth=10

g.region n=4928430 s=4923300 w=602400 e=610740 res=30

ps.map out=test.ps << EOF
labels lfields
   end
end
EOF
}}}

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/155#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#155: ps.map: the "M" highlight problem
----------------------+-----------------------------------------------------
  Reporter: perk | Owner: hamish
      Type: defect | Status: assigned
  Priority: minor | Milestone: 6.4.0
Component: default | Version: svn-trunk
Resolution: | Keywords: ps.map highlight text labels
----------------------+-----------------------------------------------------
Comment (by perk):

Hamish,

Replying to [comment:2 hamish]:
> nice to finally see a solution for this, thanks.

Glad I could help.

> before applying the patch I would like to ask about possible side
effects -- does the "currentlinejoin 1 setlinejoin stroke setlinejoin"
part need to be swiched off after drawing the labels, or will it be self
contained?

This should be self-contained. "currentlinejoin" puts the current line
join style on the Postcript stack, "1 setlinejoin" sets the join style to
rounded, "stroke" draws the current path (does not affect the stack), and
the final "setlinejoin" uses the value put on the stack earlier to return
the join style to the previous value.

> could a similar technique be used to connect .eps pattern tiles?
> eg broken lines: http://grass.osgeo.org/wiki/Psmap_flooding_example

I'll look into this.

> you might also see that d.labels does not do very well with larger
values for the highlight width. In that case I guess the solution is to
also smear the color using the "knight's move" or similar, not just the 8
cardinal+ordinal directions.
>
>
> > I've attached a patch for ps/ps.map/prolog.ps. It is marked as a
binary file
> > for some reason, so I was not able to do "svn diff".
>
> {{{
> $ svn proplist prolog.ps
> Properties on 'prolog.ps':
> svn:mime-type
> $ svn propget svn:mime-type prolog.ps
> application/postscript
> $ svn diff prolog.ps
> Index: prolog.ps
> ===================================================================
> Cannot display: file marked as a binary type.
> svn:mime-type = application/postscript
> }}}
>
> svn bug? (PostScript is ASCII)

Is SVN like CVS in that you have to mark a file as binary? In CVS, you
use the command "cvs admin -kb" to mark a file as binary, so that it won't
mess with the contents by changing line end characters or do keyword
substitution.

> fwiw, trac does nice markup when you click on the .diff file.

Yea, it's pretty cool.

Bill

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/155#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>

#155: ps.map: the "M" highlight problem
----------------------+-----------------------------------------------------
  Reporter: perk | Owner: hamish
      Type: defect | Status: assigned
  Priority: minor | Milestone: 6.4.0
Component: default | Version: svn-trunk
Resolution: | Keywords: ps.map highlight text labels
----------------------+-----------------------------------------------------
Comment (by glynn):

Replying to [comment:4 perk]:

> > before applying the patch I would like to ask about possible side
effects -- does the "currentlinejoin 1 setlinejoin stroke setlinejoin"
part need to be swiched off after drawing the labels, or will it be self
contained?
>
> This should be self-contained. "currentlinejoin" puts the current line
join style on the Postcript stack, "1 setlinejoin" sets the join style to
rounded, "stroke" draws the current path (does not affect the stack), and
the final "setlinejoin" uses the value put on the stack earlier to return
the join style to the previous value.

The normal way to make temporary changes to the rendering state is with
gsave/grestore, e.g.:

{{{
gsave 1 setlinejoin stroke grestore
}}}

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/155#comment:5&gt;
GRASS GIS <http://grass.osgeo.org>

#155: ps.map: the "M" highlight problem
----------------------+-----------------------------------------------------
  Reporter: perk | Owner: hamish
      Type: defect | Status: assigned
  Priority: minor | Milestone: 6.4.0
Component: default | Version: svn-trunk
Resolution: | Keywords: ps.map highlight text labels
----------------------+-----------------------------------------------------
Comment (by perk):

Replying to [comment:5 glynn]:
> Replying to [comment:4 perk]:
>
> > > before applying the patch I would like to ask about possible side
effects -- does the "currentlinejoin 1 setlinejoin stroke setlinejoin"
part need to be swiched off after drawing the labels, or will it be self
contained?
> >
> > This should be self-contained. "currentlinejoin" puts the current
line join style on the Postcript stack, "1 setlinejoin" sets the join
style to rounded, "stroke" draws the current path (does not affect the
stack), and the final "setlinejoin" uses the value put on the stack
earlier to return the join style to the previous value.
>
> The normal way to make temporary changes to the rendering state is with
gsave/grestore, e.g.:
>
> {{{
> gsave 1 setlinejoin stroke grestore
> }}}

Works for me. The patch is updated.

Bill

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/155#comment:6&gt;
GRASS GIS <http://grass.osgeo.org>

#155: ps.map: the "M" highlight problem
----------------------+-----------------------------------------------------
  Reporter: perk | Owner: hamish
      Type: defect | Status: closed
  Priority: minor | Milestone: 6.4.0
Component: default | Version: svn-trunk
Resolution: fixed | Keywords: ps.map highlight text labels
----------------------+-----------------------------------------------------
Changes (by hamish):

  * status: assigned => closed
  * resolution: => fixed

Comment:

Hi,

thanks, applied in SVN relbr6 + trunk.

In SVN you do not have to mark a binary file as binary to avoid unwanted
newline translation. But you do set file properties, be they an executable
bit or a mime-type. In this case the mime type is set for a postscript
file, but SVN is misconfigured to think that those are binary files when
they are not.

more on svn propset:
   http://trac.osgeo.org/grass/wiki/HowToSVN#Fileproperties

thanks again,
Hamish

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/155#comment:7&gt;
GRASS GIS <http://grass.osgeo.org>