Opened 13 years ago

Closed 12 years ago

#4042 closed defect (fixed)

Python Mapscript does not write COLOR to reference map

Reported by: jachym Owned by: aboudreault
Priority: normal Milestone: 6.0.2 release
Component: MapScript-Python Version: svn-trunk (development)
Severity: normal Keywords:
Cc: dmorissette, sdlime

Description

Hi,

when creating COLOR attribute to REFERENCE map using Python mapscript, the COLOR is not written to mapfile, when RGB set to "-1":

mapObj = mapscript.mapObj()
mapObj.extent  = mapscript.rectObj(-117.623198,23.208206,
                                           -82.322650,46.182910)

mapObj.reference.status = mapscript.MS_ON
mapObj.reference.image = "reference.png"
mapObj.reference.extent = mapscript.rectObj(-117.623198,23.208206,
                                           -82.322650,46.182910)
mapObj.reference.color = mapscript.colorObj(-1,-1,-1)
mapObj.reference.outlinecolor = mapscript.colorObj(255,0,0)

print "Saving generated mapfile to [mapfile.map]"
mapObj.save("mapfile.map")

Resulting mapfile.map (the REFERENCE block):

  REFERENCE
    EXTENT -117.623198 23.208206 -82.322650 46.182910
    IMAGE "reference.png"
    OUTLINECOLOR 255 0 0
    SIZE 180 90
    STATUS ON
    MARKERSIZE 0
    MAXBOXSIZE 0
    MINBOXSIZE 3
  END # REFERENCE

so the COLOR is missing

Change History (9)

comment:1 by jachym, 13 years ago

We tested it on MapServer 5.6.1, it seems to be working properly.

comment:2 by dmorissette, 13 years ago

Cc: aboudreault added
Milestone: 6.0.2 release
Owner: changed from hobu to dmorissette
Status: newassigned

There is indeed a bug in mapObj.save() that was introduced in MapServer 6.0 (that was not present in 5.6.x):

In 6.0, writeReferenceMap() was converted to use writeColor(), and writeColor() assumes default value of -1,-1,-1 for any color (and in this case does not write the color to the output map file since its already set to default value). This is not correct for the reference.color member which has a default value of 255,0,0 instead of -1,-1,-1.

However, the above behavior confirms that the value -1,-1,-1 is properly set and accepted by MapScript... so the bug is not the way the value is set but in the mapObj.save() method.

Will get back to this to fix the mapObj.save() method ASAP, and will also check that none of the other color values written suffer of similar problems.

comment:3 by dmorissette, 13 years ago

Correction, the default values for the referenceMapObj are:

  reference.color = 255,0,0
  reference.outlinecolor = 0,0,0

Both cases are not properly handled by the current writeColor() implementation.

comment:4 by dmorissette, 13 years ago

Cc: sdlime added

comment:5 by aboudreault, 13 years ago

Cc: dmorissette added; aboudreault removed
Owner: changed from dmorissette to aboudreault
Status: assignednew

comment:6 by aboudreault, 13 years ago

I've modified the function writeColor to accept a defaultColor object. That way, color object that do not use -1,-1,-1,255 as default color can be written properly.

Fixed and committed in r12638 and r12641.

jachym, may you give a try to trunk if everything if good in your application please? If so, I'm going to backport this in branch-6.0.

comment:7 by aboudreault, 13 years ago

modified the last commit to use pointers.... r12642.

comment:8 by jachym, 13 years ago

I can confirm that, fresh trunk *does* save COLOR attribute to generated mapfile:

import mapscript
mapobj = mapscript.mapObj()
mapobj.reference.status = mapscript.MS_ON
mapobj.reference.color = mapscript.colorObj(-1,-1,-1)
mapobj.reference.image="ref.png"
mapobj.save("mapfile.map")

result

...
  REFERENCE
    COLOR -1 -1 -1
    IMAGE "ref.png"
    SIZE 0 0
    STATUS ON
    MARKERSIZE 0
    MAXBOXSIZE 0
    MINBOXSIZE 3
  END # REFERENCE
...

thanks a lot!

comment:9 by aboudreault, 12 years ago

Resolution: fixed
Status: newclosed

Backported in branch 6.0 in r12741.

Note: See TracTickets for help on using tickets.