summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2012-08-17 10:36:33 +0100
committerTim Redfern <tim@eclectronics.org>2012-08-17 10:36:33 +0100
commit8323319e8a4759ad4aceac1f72437dfab1221cef (patch)
tree1908666e6ba8ee3972f563a428591082dbec9cdd
parentc4d254f810058b0e1c9586075c8b411212bbe4a8 (diff)
fix reverse coords bug
-rwxr-xr-xlayers.py5
-rw-r--r--tomorrowthegroundGUI/tomorrowthegroundGUI.pde5
-rwxr-xr-xwim.py13
3 files changed, 13 insertions, 10 deletions
diff --git a/layers.py b/layers.py
index a85ded4..66dc888 100755
--- a/layers.py
+++ b/layers.py
@@ -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));
}
}
diff --git a/wim.py b/wim.py
index 9daf13b..29e3ecb 100755
--- a/wim.py
+++ b/wim.py
@@ -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) )