[Mapserver-users] MapScript: map-Y coordinate is always wrong while map-X is right
Lowell Filak
lfilak at medinaco.org
Tue Jul 8 08:01:41 PDT 2003
By any chance does the Y result appear to be "mirrored" about the center
of the extent/map?
It may just be a matter of:
yMap = float(currentExtend[1])-cy*clickY
vs.
yMap = float(currentExtend[1])+cy*clickY
due to 0,0 on the image being top left and 0,0 in the extent being lower
left.
HTH
Lowell
The following message was sent by Bjoern Platzen <bplatzen at sosnetz.de>
on Tue, 8 Jul 2003 15:57:20 +0200.
> Hello List,
>
> maybe I'm just to blind, but I can't figure out, what is going wrong.
>
> I wrote a small Program using PythonMapscript.
>
> I'm calculating the following to get the Map-Coordinates from the
> Click-Coordinates (where clickX and clickY come as img.x and img.y from
> a HTML-form, Extend is the [mapext]):
>
> def _click2map(self,clickX, clickY, Extend):
> '''Uebersetze Klick-Koordinaten in Kartenkoordinaten'''
> Extend = Extend.split(" ")
>
> cx = (float(Extend[2])-float(Extend[0]))/(self.mymap.width-1)
> cy = (float(Extend[3])-float(Extend[1]))/(self.mymap.height-1)
>
> xMap = float(currentExtend[0])+cx*clickX
> yMap = float(currentExtend[1])+cy*clickY
>
> return (xMap,yMap)
>
> I took the function from a PerlMapScript Example. But it doesn't work
> for me. The yMap is always wrong while the xMap is always right...
>
> Maybe this comes because I have a mistake in my function that calculates
> the Extend (mapext):
>
> def _newExtend(self, Extend, zoomdir=0, zoomsize=1):
>
> currentExtend = Extend.split(" ")
>
> if zoomdir == 0:
> zoom = 1
> else:
> zoom = zoomsize * zoomdir
> if zoom < 0:
> zoom = 1.0/abs(zoom)
>
> cx = self.mapXY[0]
> cy = self.mapXY[1]
>
> he = float(currentExtend[2])-float(currentExtend[0])
> wi = float(currentExtend[3])-float(currentExtend[1])
>
> self.mymap.extent.maxx = cx + (he/zoom)/2
> self.mymap.extent.minx = cx - (he/zoom)/2
> self.mymap.extent.maxy = cy + (wi/zoom)/2
> self.mymap.extent.miny = cy - (wi/zoom)/2
> return 1
>
> The imgext is calculated this way:
>
> def _imageExtend(self):
> '''Finde den tatsaechlich sichtbaren Extent heraus'''
> loleft = self._click2map(0,self.mymap.height,self.mapExtent)
> upright = self._click2map(self.mymap.width,0,self.mapExtent)
> Ext = str(loleft[0])+" "+str(loleft[1])+" "+str(upright[0])+"
> "+str(upright[1])
> return Ext
>
> I hope, that there is anyone on the list, who can push me in the right
> direction.
>
> Thanks in advance,
>
> Bjoern
>
> --
> small office solutions
> info at sosnetz.de - http://www.sosnetz.de
>
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
More information about the MapServer-users
mailing list