[Mapserver-users] Zoom error with Python
Sven Jacobi
jacobi at dfki.de
Wed Feb 5 05:43:23 PST 2003
Hello,
I'm using Mapserver inside Zope and I'm writing External methods
(Python Scripts) to call the C-libraries.
I receive errors when I try to zoom in a map, but when using the same code
for zooming out or panning, it works?!
Below there's the small part of code responsible for that. I have no idea
where this might come from...
Any help?
Thanks,
Sven
The error is as follows:
Traceback (most recent call last):
File "/home/jacobi/Funkland/Zope-2.5.1b2-src/Extensions/mapserv.py", line
79, in ?
drawmap(['1','5'], '3', '1', '200', '200')
File "/home/jacobi/Funkland/Zope-2.5.1b2-src/Extensions/mapserv.py", line
45, in drawmap
myimage=mymap.draw()
File "/home/jacobi/Funkland/site-packages/MapScript.py", line 1941, in draw
val = MapScriptc.mapObj_draw(self.this)
RuntimeError: msSearchDiskTree(): Unable to access file.
Exception exceptions.RuntimeError: 'msSearchDiskTree(): Unable to access file.
\n' in <method mapObjPtr.__del__ of mapObj instance at f155c> ignored</italic>
--------------------------------------------------------------------------
def drawmap(layer, zoomfactor, zoomdirection, imgx, imgy):
mymap = mapObj("/home/jacobi/public_html/Funkland/brenschel2.map")
mymap.prepareImage()
mymap.width=600
mymap.height=400
#----- Zooming und Panning
zoomfac = int(zoomfactor)
zoomdir = int(zoomdirection)
xi = int(imgx)
yi = int(imgy)
#Zoomfaktor auslesen
if (zoomdir == 0):
zoom = 1
print 'zoom0'
elif (zoomdir == -1):
zoom = 1.0/zoomfac
print 'zoom-1'
elif (zoomdir == 1):
zoom = zoomfac
print 'zoom1'
print zoom
#Berechnung der "Zellengroesse"
cx = (mymap.extent.maxx - mymap.extent.minx)/mymap.width
cy = (mymap.extent.maxy - mymap.extent.miny)/mymap.height
#Berechnung der Mapkoordinaten aus den Imagekoordinaten
x = mymap.extent.minx + cx * xi
y = mymap.extent.maxy - cy * yi
#Berechnung des neuen Extends
mymap.extent.minx = x - 0.5 * ((mymap.extent.maxx-mymap.extent.minx) / zoom)
mymap.extent.miny = y - 0.5 * ((mymap.extent.maxy-mymap.extent.miny) / zoom)
mymap.extent.maxx = x + 0.5 * ((mymap.extent.maxx-mymap.extent.minx) / zoom)
mymap.extent.maxy = y + 0.5 * ((mymap.extent.maxy-mymap.extent.miny) / zoom)
#print mymap.extent.minx
#----- END Zooming und Panning
myimage=mymap.draw()
#----- Layeroptionen
if (len(layer)!=1):
for i in range (0,len(layer)):
#print i
if (layer[i]=='1'):
layer0 = mymap.getLayer(0)
layer0.status = 1
layer0.draw(mymap, myimage)
elif (layer[i]=='2'):
layer1 = mymap.getLayer(1)
layer1.status = 1
layer1.draw(mymap, myimage)
elif (layer[i]=='3'):
layer2 = mymap.getLayer(2)
layer2.status = 1
layer2.draw(mymap, myimage)
elif (layer[i]=='4'):
layer3 = mymap.getLayer(3)
layer3.status = 1
layer3.draw(mymap, myimage)
elif (layer[i]=='5'):
layer4 = mymap.getLayer(4)
layer4.status = 1
layer4.draw(mymap, myimage)
#----- END Layeroptionen
#myimage=mymap.draw()
mymap.drawLabelCache(myimage)
out = myimage.saveImage("brenschel.png",MS_PNG,50,0,50)
return out
drawmap(['1','5'], '3', '1', '200', '200')</smaller>
More information about the MapServer-users
mailing list