Opened 8 years ago

Closed 8 years ago

#6454 closed defect (invalid)

SetInternalInputUnitFromParam function doesn't parse the correct unit from the string

Reported by: lukesuimm Owned by: warmerdam
Priority: high Milestone:
Component: OGR_SF Version: 2.0.1
Severity: normal Keywords:
Cc:

Description

Problematic Function: SetInternalInputUnitFromParam in OGRStyleTool

Given the input string "PEN(w:1px,c:#000000,id:\"mapinfo-pen-2,ogr-pen-0\")", clearly the unit should be OGRSTUPixel. However, using this string will get OGRSTUGround. Checking the source code, and found that, if the letter "g" occurs in the string (even in a completely random position as the provided example string), the function will set the unit to ORSTUGround. The test mif file is also attached to this issue.

Attachments (1)

export-test.mif (661.2 KB ) - added by lukesuimm 8 years ago.
test mif file

Download all attachments as: .zip

Change History (3)

by lukesuimm, 8 years ago

Attachment: export-test.mif added

test mif file

comment:1 by Even Rouault, 8 years ago

You didn't really gave the API calls you use, so it is a bit difficult to know what really happens for you, but if you trace in SetInternalInputUnitFromParam(), you will see it is only provided "1px", so the issue is not that one.

As far as I can see, this is an intented, but not intuitive, behaviour of the API. The user has to set with SetUnit() the unit he wants, and that's the one he will get with GetUnit() (the default being OGRSTUMM. Then the parsing of tool parameter will convert from the unit in which they are expressed to the unit expressed by the user.

That's for example how MapServer uses the API to render :

          /* Setting up the size units according to msOGRLayerGetAutoStyle*/
          if (hStylePart && layer->map)
            OGR_ST_SetUnit(hStylePart, OGRSTUPixel, 
              layer->map->cellsize*layer->map->resolution/layer->map->defresolution*72.0*39.37);

I've added in r33962 a test that shows the API works as described above with your test stylestring

comment:2 by Even Rouault, 8 years ago

Resolution: invalid
Status: newclosed

Closing assuming that above comment answers the question.

Note: See TracTickets for help on using tickets.