Opened 13 years ago
Closed 13 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 , 13 years ago
comment:2 by , 13 years ago
| Cc: | added |
|---|---|
| Milestone: | → 6.0.2 release |
| Owner: | changed from to |
| Status: | new → assigned |
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 , 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 , 13 years ago
| Cc: | added |
|---|
comment:5 by , 13 years ago
| Cc: | added; removed |
|---|---|
| Owner: | changed from to |
| Status: | assigned → new |
comment:6 by , 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:8 by , 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 , 13 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Backported in branch 6.0 in r12741.

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