Opened 20 years ago

Closed 20 years ago

#751 closed defect (fixed)

[OGR] STYLEITEM "AUTO" does not set symbol size.

Reported by: jlacroix Owned by: mapserverbugs
Priority: high Milestone:
Component: OGR Support Version: unspecified
Severity: normal Keywords:
Cc:

Description

In mapserver 4.3, the StyleItem "Auto" option in mapogr.cpp only set the color,
backgroundcolor and symbol for brush. The size is not setted. It cause problem
when trying to fill a polygon with a symbol. Since no symbol size is specified,
size 1 is use. Then the icon used to fill the polygon is not appear.

For example we want to use this symbol:

Symbol
Name 'mapinfo-brush-70'
  TYPE vector
FILLED true
POINTS
9 9
9 10
10 10
10 9
END

in this layer:
  LAYER
    TYPE POLYGON
    STATUS DEFAULT
    NAME "ICE 1"
    CONNECTIONTYPE OGR
    CONNECTION "ttt.mif"
    STYLEITEM "AUTO"
    CLASS
    END
  END

but to have the result we want, we need to set the SIZE to 5 in the STYLE. 

Since the STYLEITEM "AUTO" option override the class, we can't set the SIZE so
we use the styleitem auto option. One solution we can use, would be to force a
symbol to a certain size if not setted in the mapfile. Something like this would
solve the issue:

Symbol
Name 'mapinfo-brush-70'
TYPE vector
FILLED true
SIZE 5
POINTS
9 9
9 10
10 10
10 9
END

I can attach a test case if needed.

Change History (8)

comment:1 by dmorissette, 20 years ago

Steve, what do you think about the idea of adding a default SIZE value in a
symbol definition that would be used if the class/style doesn't have an explicit
size set?  That would solve our issue with MapInfo symbols, and could perhaps be
a nice feature to have to provide a default size when creating a mapfile.

comment:2 by sdlime, 20 years ago

I don't see any problem with it. There is a default size of 1 now, what value
were you thinking of?

Steve

comment:3 by dmorissette, 20 years ago

The global default of 1 would remain, but were thinking of a configurable value
that would be set inside the symbol definition, so for a given symbol you could
set its default size to 10, for another one 30, etc... 

comment:4 by sdlime, 20 years ago

Man, I gotta read messages closer, sorry about that. Been happening a lot lately.

I'm not sure this will work easily since it's not easy (possible?) to detect
that nothing was set in the mapfile. Size=1 is perfectly legal. Could your code
in mapogr.cpp make use of a function like msSymbolGetDefaultSize()? It would be
easy to write and would give you a reasonable value to start with. In many cases
it would just return 1, but with certain vector symbols you could compute a bbox
nab the height.

Steve

comment:5 by dmorissette, 20 years ago

Do you mean computing the BBOX of the points in the symbol definition and using
that as the symbol's size?  That would work for the OGR case, but I'm worried
that this could lead to confusion since the same symbol would be scaled
differently depending on whether you use it via OGR or via the regular
class/style mechanism in the mapfile. i.e. via OGR the symbol size would default
to the size of the bbox, but via the regular mapfile mechanism it would always
default to 1 pixel.

How about changing the default behavior in MapServer as well so that size is set
to 0 by default when the mapfile is read and the bbox of the symbol is used as
the default size by default.  That shouldn't break too many applications since a
size of 1 was useless in the past anyway except for the default 1-pixel symbol.
 Or am I missing something?

comment:6 by sdlime, 20 years ago

My vote would be to do:

 - set default style size to -1
 - write a msSymbolGetDefaultSize() function
 - modify the GD-based symbol drawing functions to call that function if size=-1

I don't know what effect this would have on the SWF and PDF output filters 
though so it should be run by Assefa and Zak.

Steve

comment:7 by jlacroix, 20 years ago

Status: newassigned
With bug 815, we added a Hatch sybol type. Is this one will always use the style
size for the thickness of the hatching? If the style size is set to -1, is it ok
to just set it to 1? Or do we plan to use a symbol to do the hatching?

BTW, I've started working on this, marking as ASSIGNED

comment:8 by jlacroix, 20 years ago

Resolution: fixed
Status: assignedclosed
Changes commited to CVS. I've done Steve's proposition. This add the
msSymbolGetDefaultSize function everywhere needed. I hope this will not have an
impact on the performance. The only place where we can notice it is in the
labelcache drawing I think. However the function is really simple, so don't worry.

Marking as FIXED.
Note: See TracTickets for help on using tickets.