diff options
| author | Tim Redfern <tim@eclectronics.org> | 2012-08-17 10:36:33 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2012-08-17 10:36:33 +0100 |
| commit | 8323319e8a4759ad4aceac1f72437dfab1221cef (patch) | |
| tree | 1908666e6ba8ee3972f563a428591082dbec9cdd | |
| parent | c4d254f810058b0e1c9586075c8b411212bbe4a8 (diff) | |
fix reverse coords bug
| -rwxr-xr-x | layers.py | 5 | ||||
| -rw-r--r-- | tomorrowthegroundGUI/tomorrowthegroundGUI.pde | 5 | ||||
| -rwxr-xr-x | wim.py | 13 |
3 files changed, 13 insertions, 10 deletions
@@ -25,13 +25,14 @@ class layer: print "gps layer: failed to parse", file def checkcoord(self,pos): p=self.findpixel(pos) + #print "pixel:",p[0],p[1] if p!=self.pixel: self.pixel=p return self.setcoord(p) else: return None def findpixel(self,pos): - return (int((pos.lng-self.tl.lng)/self.pixsize.lng),int((pos.lat-self.br.lat)/self.pixsize.lat)) + return (int((pos.lng-self.tl.lng)/self.pixsize.lng),int((self.tl.lat-pos.lat)/self.pixsize.lat)) def setcoord(self,pos): """to be overwritten: gets a messages when values change" @@ -73,7 +74,7 @@ class scalelayer(layer): uses sub pixel position""" def findpixel(self,pos): #float version - return ((pos.lng-self.tl.lng)/self.pixsize.lng,(pos.lat-self.br.lat)/self.pixsize.lat) + return ((pos.lng-self.tl.lng)/self.pixsize.lng,(self.tl.lat-pos.lat)/self.pixsize.lat) def setcommand(self,command): self.command=command def setcoord(self,pos): diff --git a/tomorrowthegroundGUI/tomorrowthegroundGUI.pde b/tomorrowthegroundGUI/tomorrowthegroundGUI.pde index 29fe559..7c2cf6b 100644 --- a/tomorrowthegroundGUI/tomorrowthegroundGUI.pde +++ b/tomorrowthegroundGUI/tomorrowthegroundGUI.pde @@ -12,7 +12,7 @@ void setup() { bgmaps=new PImage[2]; sendIP="127.0.0.1"; - int map=2; + int map=3; switch (map) { case 1: bgmaps[0] = loadImage("gentmap.png"); @@ -65,7 +65,8 @@ void mouseDragged() y=mouseY; float fx=((float)mouseX)/width; float fy=((float)mouseY)/height; - udp.send(((fy*fh)+lat2)+","+((fx*fw)+lng1)+"\n",sendIP,5400); + udp.send(lat1-((fy*fh))+","+((fx*fw)+lng1)+"\n",sendIP,5400); + //println(lat1-((fy*fh))+","+((fx*fw)+lng1)); } } @@ -16,13 +16,14 @@ from xml2obj import * if len(sys.argv)<2: - print "wim: usage: tomorrowtheground configfile [-D] (debug)][-T] (test)]" + print "wim: usage: tomorrowtheground configfile [-D debug][-T test]" + sys.exit(0) -debug=False +Debug=False test=False if len(sys.argv)>2: if sys.argv[2]=="-D" or sys.argv[2]=="-d": - debug=True + Debug=True print "wim: DEBUG mode" if len(sys.argv)>3: if sys.argv[3]=="-T" or sys.argv[3]=="-t": @@ -96,7 +97,7 @@ while True: data="" try: data, addr = insock.recvfrom(128) - if debug==True: + if Debug: print "wim: received:",data pos.parse(data) posChanged=True @@ -112,7 +113,7 @@ while True: outsock.sendto( "gps status 0\n", (PD_IP, PD_PORT) ) check=gpsp.check() if check!=False: - if debug==True: + if Debug: print "wim: received from gps",check[0],check[1] outsock.sendto("gps data "+str(check[0])+" "+str(check[1])+"\n",(PD_IP, PD_PORT) ) pos=latLng(check[0],check[1]) @@ -122,7 +123,7 @@ while True: for layer in gpslayers: r=layer.checkcoord(pos) #returns a message or None if r!=None: - if debug==True: + if Debug: print "wim: sending:",str(r[0]),str(r[1]) #pd needs \n at end of message outsock.sendto( str(r[0])+' '+str(r[1])+'\n', (PD_IP, PD_PORT) ) |
