Open tbonfort opened 12 years ago
Author: hrz@geodata.soton.ac.uk Date: 2004/06/02 - 18:21
I have just noticed that this bug is also present in the msDrawPoint function.
Again this is particularly an issue when using $pointObj->draw in mapscript as
the rendered points are not be scaled.
Author: sdlime Date: 2004/06/02 - 18:54
I know there's a reason for this, but I'll have to think about it for a
minute...
Author: sgillies@frii.com Date: 2004/06/02 - 20:03
Hey, I couldn't resist adding myself to this issue since I have been thinking
very hard about the mapscript drawing API.
Instead of adding more logic to the msDrawLayer* functions, I suggest that we
enhance the draw method of mapObj, making it:
draw([imageObj image=NULL]) : imageObj
Have the draw method accept an optional imageObj argument. If this argument
is provided, we draw on it and return the result. Easy to implement and test
and only requires adding an imageObj argument to msDrawMap.
You'd take advantage of this enhancement like
# Base image, might also come from prepareImage()
image = mapscript.imageObj(200, 200, 'GD/PNG', 'example.png')
# Turn off all map layers
for i in range(the_map.numlayers):
the_map.getLayer(i).status = mapscript.MS_OFF
# Draw layer of interest
the_map.getLayerByName('example').status = mapscript.MS_ON
image = the_map.draw(image)
To make it even more user-friendly, maybe we give mapObj a new drawLayer()
method like
drawLayer(layerObj layer [, imageObj image]) : image
so that you don't have to fiddle with status of all layers.
Author: hrz@geodata.soton.ac.uk Date: 2004/06/03 - 12:46
Having thought about it a bit more it's clear to me that the problem stems from
the fact that the layer scaling is being done in the wrong place; instead of
occurring whenever something needs to be drawn it should be done whenever the
scale changes.
This could be accomplished, for instance, by wrapping the msAdjustExtent and
msCalculateScale functions in a function (e.g. msScaleMap/msRescale) which
additionally sets the scalefactor for all the layers.
Regarding Sean's proposed mapscript API change, I can see how this would solve
the layer scaling issue but what about the point drawing? Also it seems to me
that conceptually any method dealing with drawing a specific layer should be
associated with the layer object and not the map object.
Author: hrz@geodata.soton.ac.uk Date: 2004/06/03 - 12:55
I forgot to mention in Comment #4 that the only place the msScaleMap/msRescale
need be called is from within the mapscript zoom* and setextent functions...
Author: sdlime Date: 2004/06/03 - 16:12
The point drawing methods are pure convience. I got sick of wrapping points in
shapeObj's. If one needed the full capabilities then shapeObj's would have to
be used.
I don't like placing the scaling functionality in any of the zoom* functions.
Too far away from the drawing, and those functions are not required to draw
anything. Once the image is created, either with a draw or a prepare image
seems the logical place, that was the plan anyway. That scalefactor should
only have to be computed once per map.
Do you have a code snippet? I'm just curious of the sequence you're going
through in MapScript.
Steve
Author: sgillies@frii.com Date: 2004/06/03 - 16:44
Homme, we are already adjusting extent and re-calculating the map scale inside
mapObj.setExtent and mapObj.zoom* so that should be fine.
There is a related issue that when you resize a map through setting map.width
and map.height, the extents and scale are not adjusted. My work-around has
been to call map.prepareImage after zooming or re-sizing. This method has
some side-effects on the map that adjust it properly.
About the drawing API:
I disagree that the Layer is the most natural main noun in the drawing API.
A Layer is the only object which defines the symbols and styles used to render
the data. These are like our brushes or pens (to use terms from other
graphical software). The Layer doesn't know anything about the size of our
mapping canvas and doesn't know anything about spatial extents or mapping
scale.
Also, in a well designed object oriented API, objects should modify only
themselves. This principle leads me to conclude that the best drawing API to
aim for in the future has imageObj.drawLayer, imageObj.drawPoint, &c. I'm
putting more thoughts about this in the mapserver wiki at
http://mapserver.gis.umn.edu/cgi-bin/wiki.pl?RefactoringDrawingAPI
Reporter: hrz@geodata.soton.ac.uk Date: 2004/06/02 - 16:45