[kismac] [binaervarianz] r111 - in KisMACng: . Resources/Nibs/English.lproj/DownloadMap.nib Resources/Nibs/Spanish.lproj/DownloadMap.nib Sources/Support Sources/WindowControllers image

  • From: svn@xxxxxxxxxxxxxxxx
  • To: kismac@xxxxxxxxxxxxx
  • Date: Tue, 21 Mar 2006 17:02:41 +0100

Author: gkruse
Date: 2006-03-21 17:02:40 +0100 (Tue, 21 Mar 2006)
New Revision: 111

Modified:
   KisMACng/CHANGES
   KisMACng/Resources/Nibs/English.lproj/DownloadMap.nib/info.nib
   KisMACng/Resources/Nibs/English.lproj/DownloadMap.nib/keyedobjects.nib
   KisMACng/Resources/Nibs/Spanish.lproj/DownloadMap.nib/info.nib
   KisMACng/Resources/Nibs/Spanish.lproj/DownloadMap.nib/keyedobjects.nib
   KisMACng/Sources/Support/MapDownload.m
   KisMACng/Sources/WindowControllers/DownloadMapController.m
   KisMACng/image/KisMACraw.dmg
Log:
Added Austrailan Map Server Closes #70


Modified: KisMACng/CHANGES
===================================================================
--- KisMACng/CHANGES    2006-03-18 20:21:49 UTC (rev 110)
+++ KisMACng/CHANGES    2006-03-21 16:02:40 UTC (rev 111)
@@ -1,3 +1,5 @@
+R111: - Added Austrailan Map Server Closes #70 
+
 R108: - Fixed #35, #36 and #54.  When not hopping, still set channel in 
hopping method.  This avoids a nasty race condition.
 
 R107: - Fixed #51 - deleting a net causes kismac to crash

Modified: KisMACng/Resources/Nibs/English.lproj/DownloadMap.nib/info.nib
===================================================================
--- KisMACng/Resources/Nibs/English.lproj/DownloadMap.nib/info.nib      
2006-03-18 20:21:49 UTC (rev 110)
+++ KisMACng/Resources/Nibs/English.lproj/DownloadMap.nib/info.nib      
2006-03-21 16:02:40 UTC (rev 111)
@@ -3,10 +3,14 @@
 <plist version="1.0">
 <dict>
        <key>IBDocumentLocation</key>
-       <string>483 188 356 240 0 0 1024 746 </string>
+       <string>346 100 356 240 0 0 1024 746 </string>
        <key>IBFramework Version</key>
        <string>439.0</string>
+       <key>IBOpenObjects</key>
+       <array>
+               <integer>6</integer>
+       </array>
        <key>IBSystem Version</key>
-       <string>8C46</string>
+       <string>8H14</string>
 </dict>
 </plist>

Modified: KisMACng/Resources/Nibs/English.lproj/DownloadMap.nib/keyedobjects.nib
===================================================================
(Binary files differ)

Modified: KisMACng/Resources/Nibs/Spanish.lproj/DownloadMap.nib/info.nib
===================================================================
--- KisMACng/Resources/Nibs/Spanish.lproj/DownloadMap.nib/info.nib      
2006-03-18 20:21:49 UTC (rev 110)
+++ KisMACng/Resources/Nibs/Spanish.lproj/DownloadMap.nib/info.nib      
2006-03-21 16:02:40 UTC (rev 111)
@@ -6,7 +6,11 @@
        <string>483 188 356 240 0 0 1024 746 </string>
        <key>IBFramework Version</key>
        <string>439.0</string>
+       <key>IBOpenObjects</key>
+       <array>
+               <integer>6</integer>
+       </array>
        <key>IBSystem Version</key>
-       <string>8C46</string>
+       <string>8H14</string>
 </dict>
 </plist>

Modified: KisMACng/Resources/Nibs/Spanish.lproj/DownloadMap.nib/keyedobjects.nib
===================================================================
(Binary files differ)

Modified: KisMACng/Sources/Support/MapDownload.m
===================================================================
--- KisMACng/Sources/Support/MapDownload.m      2006-03-18 20:21:49 UTC (rev 
110)
+++ KisMACng/Sources/Support/MapDownload.m      2006-03-21 16:02:40 UTC (rev 
111)
@@ -33,7 +33,11 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <netdb.h>
+#include <math.h>
 
+#define a_WGS84 6378137
+#define b_WGS84 6356752.3142
+
 @implementation MapDownload
 
 + (MapDownload*)mapDownload {
@@ -214,8 +218,10 @@
 
 - (BOOL)downloadMapFrom:(NSString*)server forPoint:(waypoint)w 
resolution:(NSSize)size zoomLevel:(int)zoom {
     NSString *req;
-    int scale;
+    int scale,zone;
     float scalef;
+       double 
utme,utmn,K1,K2,K3,K4,K5,p,S,k0,sin1sec,nu,eprimesqd,e,rlat,rlong,mperdeglat,mperdeglon,numpx,lon0;
+
     
     if ((int)size.width == 0) { size.width = 1000; }
     if ((int)size.height == 0) { size.height = 1000; }
@@ -224,7 +230,7 @@
     if (!server) return NO;
     if ((int)size.height < 0 || (int)size.width < 0 || (int)size.height > 
10000 || (int)size.width > 10000) return NO;
     if (w._lat > 90 || w._lat < -90 || w._long < -180 || w._long > 180) return 
NO;
-    if (zoom > 5 || zoom < 1) return NO;
+    if (zoom > 7 || zoom < 1) return NO;
     
     _p1.x = size.width / 2.0;
     _p1.y = size.height / 2.0;
@@ -262,6 +268,126 @@
         
         req = [NSString 
stringWithFormat:@"http://tiger.census.gov/cgi-bin/mapper/map.gif?&lat=%f&lon=%f&ht=%f&wid=%f&conf=mapnew.con&iht=%d&iwd=%d";,
             w._lat, w._long, 0.065/scalef, 0.180/scalef, (int)size.height, 
(int)size.width];
+    } else if ([server isEqualToString:@"Street-Directory.com.au"]) {
+        size = NSMakeSize(1200,1200);
+        
+        _p1.x = size.width;
+        _p1.y = size.height;
+        _p2 = NSZeroPoint;
+
+               numpx = 55;
+        
+               if ((w._lat > -39.52350013) || (w._long < 143.7716731)|| 
(w._long > 150)) {
+               // use non-Tassie scale factors, lat and long
+                       switch (zoom) {
+                               case 1:
+                                       scalef = 106;
+                                       break;
+                               case 2:
+                                       scalef = 19;
+                                       break;
+                               case 3:
+                                       scalef = 8;
+                                       numpx = 55.1;
+                                       break;
+                               case 4:
+                                       scalef = 2;
+                                       numpx = 56.7;
+                                       break;
+                               case 5:
+                                       scalef = 0.3;
+                                       numpx = 53.1;
+                                       break;
+                               case 6:
+                                       scalef = 0.15;
+                                       numpx = 53.1;
+                                       break;
+                               case 7:
+                                       scalef = 0.075;
+                                       numpx = 53.3;
+                                       break;
+                               default:
+                                       scalef= 1;
+                                       NSLog(@"Warning Invalid Zoom Size!");
+                                       NSBeep();
+                       }
+                       req = [NSString 
stringWithFormat:@"http://www.street-directory.com.au/sd_new/genmap.cgi?x=%f&y=%f&sizex=%d&sizey=%d&level=%d&star=&circle=";,
 w._long, w._lat, (int)size.width, (int)size.height, zoom];    
+               } else {
+               // use Tasmania scale factors, eastings and northings (UTM zone 
55)
+                       switch (zoom) {
+                               case 1:
+                                       scalef = 106;
+                                       break;
+                               case 2:
+                                       scalef = 15;
+                                       break;
+                               case 3:
+                                       scalef = 7.5;
+                                       break;
+                               case 4:
+                                       scalef = 2.4;
+                                       break;
+                               case 5:
+                                       scalef = 0.489;
+                                       break;
+                               case 6:
+                                       scalef = 0.244;
+                                       break;
+                               case 7:
+                                       scalef = 0.136;
+                                       break;
+                               default:
+                                       scalef= 1;
+                                       NSLog(@"Warning Invalid Zoom Size!");
+                                       NSBeep();
+                       }
+
+                       // code here to convert lat & long to UTM
+                       /* formulae taken from 
http://www.uwgb.edu/dutchs/UsefulData/UTMFormulas.HTM */
+
+                       // figure out zone:
+                       if (w._long < 0) zone = floor((w._long + 180)/6)+1;
+                       else zone = floor(w._long/6)+31;
+                       lon0 = zone * 6 - 183;
+
+                       NSLog([NSString stringWithFormat:@"UTM zone %d, central 
meridian %d",zone,(int)lon0]);
+
+                       e = sqrt(1 - pow(b_WGS84,2)/pow(a_WGS84,2));
+                       eprimesqd = pow(e,2)/(1-pow(e,2));
+                       rlat = w._lat * pi / 180;
+                       rlong = w._long * pi / 180;
+
+                       S = a_WGS84 * ((1 - pow(e,2)/4 - 3*pow(e,4)/64 - 
5*pow(e,6)/256)*rlat - (3*pow(e,2)/8 + 3*pow(e,4)/32 + 
45*pow(e,6)/1024)*sin(2*rlat) + (15*pow(e,4)/256 + 
45*pow(e,6)/1024)*sin(4*rlat) - (35*pow(e,6)/3072)*sin(6*rlat));
+                       k0 = 0.9996;
+                       K1 = S * k0;
+                       p = (w._long - lon0)*3600/10000;
+
+                       sin1sec = pi/(180*60*60);
+                       nu = a_WGS84/sqrt(1 - pow(e,2) * pow(sin(rlat),2));
+                       K2 = k0 * pow(sin1sec,2) * nu * sin(rlat) * 
cos(rlat)*100000000/2;
+                       K3 = k0 * pow(sin1sec,4) * nu * sin(rlat) * 
pow(cos(rlat),3)/24 * (5 - pow(tan(rlat),2) + 9*eprimesqd*pow(cos(rlat),2) + 
4*pow(eprimesqd,2)*pow(cos(rlat),4))*10000000000000000;
+
+                       utmn = K1 + K2*pow(p,2) + K3*pow(p,4);
+                       if (w._lat < 0) utmn += 10000000;
+
+                       K4 = k0 * sin1sec * nu * cos(rlat) * 10000;
+                       K5 = k0 * pow(sin1sec,3) * nu * pow(cos(rlat),3)/6 * (1 
- pow(tan(rlat),2) + eprimesqd * pow(cos(rlat),2)) * 1000000000000;
+
+                       utme = K4*p + K5*pow(p,3) + 500000;
+
+                       // I hope those formulae are right... if not, someone 
in Tasmania can fix them
+                       req = [NSString 
stringWithFormat:@"http://www.street-directory.com.au/sd_new/tas_genmap.cgi?x=%f&y=%f&sizex=%d&sizey=%d&level=%d&star=&circle=";,
 utme, utmn, (int)size.width, (int)size.height, zoom];    
+               }
+               // scalef now equals number of km in approx 68?? (using numpx) 
px, and we should have a 1200x1200 map image request ready to go
+               // distance to edge of map = scalef*600/numpx km north AND east
+                               mperdeglon = pi / 180 * (a_WGS84 - 
(21384*fabs(w._lat)/90)) * cos(rlat);
+                               mperdeglat = 111132;
+               // degrees to north/south edge from centre = 1000 * scalef * 
size.height / 2 / numpx / mperdeglat
+               // trying my own conversion... may or may not work well
+        _w1._lat  = w._lat  + 1000 * scalef * size.height / 2 / numpx / 
mperdeglat;
+        _w1._long = w._long + 1000 * scalef * size.width / 2 / numpx / 
mperdeglon; 
+        _w2._lat  = w._lat  - 1000 * scalef * size.height / 2 / numpx / 
mperdeglat;
+        _w2._long = w._long - 1000 * scalef * size.width / 2 / numpx / 
mperdeglon;
     } else {
         NSLog(@"Invalid server!");
         return NO;

Modified: KisMACng/Sources/WindowControllers/DownloadMapController.m
===================================================================
--- KisMACng/Sources/WindowControllers/DownloadMapController.m  2006-03-18 
20:21:49 UTC (rev 110)
+++ KisMACng/Sources/WindowControllers/DownloadMapController.m  2006-03-21 
16:02:40 UTC (rev 111)
@@ -49,13 +49,18 @@
 
 - (IBAction)selectOtherServer:(id)sender {
     BOOL map24 = [[sender titleOfSelectedItem] 
isEqualToString:NSLocalizedString(@"Map24", "menu item, needs to be like in 
DownloadMap.nib")];
+    BOOL sdau = [[sender titleOfSelectedItem] 
isEqualToString:NSLocalizedString(@"Street-Directory.com.au", "menu item, needs 
to be like in DownloadMap.nib")];
     [_scale  setEnabled:!map24];
-    [_height setEnabled:!map24];
-    [_width  setEnabled:!map24];
+    [_height setEnabled:!(map24 || sdau)];
+    [_width  setEnabled:!(map24 || sdau)];
     if (map24) {
         [_height setIntValue:1000];
         [_width  setIntValue:1000];
     }
+       if (sdau) {
+        [_height setIntValue:1200];
+        [_width  setIntValue:1200];
+       }
 }
 
 - (IBAction)okAction:(id)sender {
@@ -65,7 +70,8 @@
     NSMutableDictionary *d;
     NSAppleEventDescriptor *serv, *lat, *lon, *zoom, *width, *height;
     BOOL map24 = NO;
-    
+    BOOL sdau = NO;
+
     w._lat  = [_latitude  floatValue] * ([[_nsButton titleOfSelectedItem] 
isEqualToString:@"N"] ? 1.0 : -1.0);
     w._long = [_longitude floatValue] * ([[_ewButton titleOfSelectedItem] 
isEqualToString:@"E"] ? 1.0 : -1.0);
     
@@ -80,6 +86,9 @@
     } else if ([[_server titleOfSelectedItem] 
isEqualToString:NSLocalizedString(@"Map24", "menu item, needs to be like in 
DownloadMap.nib")]) {
         server = @"Map24";
         map24 = YES;
+    } else if ([[_server titleOfSelectedItem] 
isEqualToString:NSLocalizedString(@"Street-Directory.com.au", "menu item, needs 
to be like in DownloadMap.nib")]) {
+        server = @"Street-Directory.com.au";
+        sdau = YES;
     } else if ([[_server titleOfSelectedItem] 
isEqualToString:NSLocalizedString(@"Census Bureau Maps (United States)", "menu 
item, needs to be like in DownloadMap.nib")]) {
         server = @"Census Bureau Maps (United States)";
     } else {

Modified: KisMACng/image/KisMACraw.dmg
===================================================================
(Binary files differ)


Other related posts:

  • » [kismac] [binaervarianz] r111 - in KisMACng: . Resources/Nibs/English.lproj/DownloadMap.nib Resources/Nibs/Spanish.lproj/DownloadMap.nib Sources/Support Sources/WindowControllers image