rhodes 2.0.0.beta1 → 2.0.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. data/CHANGELOG +5 -0
  2. data/LICENSE +19 -674
  3. data/Manifest.txt +21 -4
  4. data/README.textile +5 -36
  5. data/Rakefile +5 -0
  6. data/lib/build/jake.rb +3 -1
  7. data/lib/extensions/rexml/rexml/document.rb +2 -0
  8. data/lib/extensions/rexml/rexml/parsers/baseparser.rb +0 -6
  9. data/lib/extensions/rhoxml/rexml/child.rb +96 -0
  10. data/lib/extensions/rhoxml/rexml/document.rb +527 -0
  11. data/lib/extensions/rhoxml/rexml/element.rb +987 -0
  12. data/lib/extensions/rhoxml/rexml/encoding.rb +71 -0
  13. data/lib/extensions/rhoxml/rexml/encodings/US-ASCII.rb +30 -0
  14. data/lib/extensions/rhoxml/rexml/encodings/UTF-16.rb +35 -0
  15. data/lib/extensions/rhoxml/rexml/encodings/UTF-8.rb +18 -0
  16. data/lib/extensions/rhoxml/rexml/namespace.rb +47 -0
  17. data/lib/extensions/rhoxml/rexml/node.rb +76 -0
  18. data/lib/extensions/rhoxml/rexml/parent.rb +166 -0
  19. data/lib/extensions/rhoxml/rexml/parseexception.rb +51 -0
  20. data/lib/extensions/rhoxml/rexml/parsers/baseparser.rb +531 -0
  21. data/lib/extensions/rhoxml/rexml/parsers/treeparser.rb +100 -0
  22. data/lib/extensions/rhoxml/rexml/parsers/xpathparser.rb +698 -0
  23. data/lib/extensions/rhoxml/rexml/set.rb +1274 -0
  24. data/lib/extensions/rhoxml/rexml/source.rb +258 -0
  25. data/lib/extensions/rhoxml/rexml/xmltokens.rb +18 -0
  26. data/lib/extensions/rhoxml/rexml/xpath.rb +77 -0
  27. data/lib/extensions/rhoxml/rexml/xpath_parser.rb +806 -0
  28. data/lib/framework/builtinME.rb +2 -0
  29. data/lib/framework/dateME.rb +5 -1
  30. data/lib/framework/rho/render.rb +10 -2
  31. data/lib/framework/rhom/rhom_object_factory.rb +2 -1
  32. data/lib/framework/singleton.rb +1 -1
  33. data/platform/android/Rhodes/jni/src/rhodes.cpp +2 -4
  34. data/platform/android/Rhodes/src/com/rhomobile/rhodes/NativeBar.java +23 -18
  35. data/platform/android/Rhodes/src/com/rhomobile/rhodes/Rhodes.java +42 -69
  36. data/platform/android/Rhodes/src/com/rhomobile/rhodes/SplashScreen.java +59 -7
  37. data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/Camera.java +1 -1
  38. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/Annotation.java +1 -0
  39. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/MapView.java +97 -85
  40. data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/SmsUriHandler.java +52 -0
  41. data/platform/android/build/RhodesSRC_build.files +1 -0
  42. data/platform/android/build/android.rake +38 -14
  43. data/platform/bb/RubyVM/RubyVM.jdp +1 -0
  44. data/platform/bb/build/RubyVM_build.files +1 -0
  45. data/platform/bb/build/bb.rake +44 -2
  46. data/platform/bb/rhodes/platform/5.0/com/rho/BrowserAdapter5.java +1 -1
  47. data/platform/bb/rhodes/rhodes.jdp +4 -4
  48. data/platform/bb/rhodes/src/com/rho/BrowserAdapter.java +8 -4
  49. data/platform/bb/rhodes/src/com/rho/rubyext/Alert.java +149 -17
  50. data/platform/bb/rhodes/src/rhomobile/PushListeningThread.java +20 -17
  51. data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +54 -28
  52. data/platform/bb/rhodes/src/rhomobile/mapview/Annotation.java +1 -0
  53. data/platform/bb/rhodes/src/rhomobile/mapview/GoogleMapField.java +37 -11
  54. data/platform/bb/rhodes/src/rhomobile/mapview/MapView.java +49 -19
  55. data/platform/bb/rhodes/src/rhomobile/mapview/MapViewScreen.java +6 -0
  56. data/platform/iphone/Classes/MapView/GoogleGeocoder.h +6 -7
  57. data/platform/iphone/Classes/MapView/GoogleGeocoder.m +70 -70
  58. data/platform/iphone/Classes/MapView/MapAnnotation.h +5 -3
  59. data/platform/iphone/Classes/MapView/MapAnnotation.m +10 -8
  60. data/platform/iphone/Classes/MapView/MapViewController.h +13 -10
  61. data/platform/iphone/Classes/MapView/MapViewController.m +131 -72
  62. data/platform/iphone/Classes/Rhodes.h +2 -0
  63. data/platform/iphone/Classes/Rhodes.m +13 -1
  64. data/platform/iphone/Classes/SimpleMainView.m +0 -1
  65. data/platform/iphone/Classes/TabbedMainView.m +5 -6
  66. data/platform/shared/common/RhoTime.h +2 -2
  67. data/platform/shared/common/RhodesApp.cpp +1 -1
  68. data/platform/shared/db/DBAdapter.cpp +6 -0
  69. data/platform/shared/net/CURLNetRequest.cpp +23 -1
  70. data/platform/shared/ruby/thread_win32.c +9 -1
  71. data/platform/shared/rubyJVM/src/com/rho/Capabilities.java +6 -0
  72. data/platform/shared/rubyJVM/src/com/rho/RhodesApp.java +1 -1
  73. data/platform/shared/rubyJVM/src/com/rho/sync/ClientRegister.java +1 -1
  74. data/platform/shared/rubyJVM/src/com/xruby/GeneratedMethods/RubySymbol_Methods.java +6 -1
  75. data/platform/shared/rubyJVM/src/com/xruby/GeneratedMethods/RubyTime_Methods.java +3 -3
  76. data/platform/shared/rubyJVM/src/com/xruby/runtime/builtin/InputStreamExecutor.java +1 -1
  77. data/platform/shared/rubyJVM/src/com/xruby/runtime/builtin/RubyArray.java +15 -3
  78. data/platform/shared/rubyJVM/src/com/xruby/runtime/builtin/RubyString.java +10 -2
  79. data/platform/shared/rubyJVM/src/com/xruby/runtime/builtin/RubyTime.java +12 -1
  80. data/platform/shared/rubyJVM/src/com/xruby/runtime/lang/RubyKernelModule.java +18 -9
  81. data/platform/shared/rubyJVM/src/com/xruby/runtime/lang/RubySymbol.java +5 -0
  82. data/platform/shared/rubyJVM/src/org/json/me/JSONArray.java +2 -1
  83. data/platform/shared/unzip/unzip.cpp +1 -1
  84. data/platform/wm/build/wm.rake +27 -6
  85. data/platform/wm/rhodes/Alert.cpp +335 -5
  86. data/platform/wm/rhodes/Alert.h +84 -1
  87. data/platform/wm/rhodes/MainWindow.cpp +28 -6
  88. data/platform/wm/rhodes/MainWindow.h +7 -2
  89. data/platform/wm/rhodes/Rhodes.cpp +23 -0
  90. data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +2 -1
  91. data/platform/wm/rhodes/stdafx.h +1 -0
  92. data/platform/wm/tools/detool/detool.cpp +405 -14
  93. data/rakefile.rb +5 -0
  94. data/res/build-tools/detool.exe +0 -0
  95. data/res/generators/rhogen.rb +2 -0
  96. data/rhodes.gemspec +1 -1
  97. data/spec/framework_spec/app/spec/fixtures/object_values.txt +1 -1
  98. data/spec/framework_spec/app/spec/pagination/fixtures/object_values.txt +1 -1
  99. data/spec/framework_spec/app/spec/rhom_object_spec.rb +12 -12
  100. metadata +23 -6
  101. data/LICENSING_OPTIONS +0 -1
  102. data/platform/bb/build/rhodesApp.rapc +0 -9
  103. data/res/generators/templates/source/source_adapter.rb +0 -48
  104. data/rhobuild.yml +0 -37
@@ -22,6 +22,7 @@ public class Annotation {
22
22
  }
23
23
  };
24
24
 
25
+ public String type = null;
25
26
  public String title = null;
26
27
  public String subtitle = null;
27
28
  public String street_address = null;
@@ -6,6 +6,10 @@ import java.util.Enumeration;
6
6
  import java.util.Hashtable;
7
7
  import java.util.Vector;
8
8
 
9
+ import org.json.me.JSONArray;
10
+ import org.json.me.JSONException;
11
+ import org.json.me.JSONObject;
12
+
9
13
  import j2me.lang.MathEx;
10
14
 
11
15
  import com.rho.RhoClassFactory;
@@ -374,7 +378,7 @@ public class GoogleMapField extends Field implements RhoMapField {
374
378
  cmd.mapField.draw(cmd.latitude, cmd.longitude, cmd.zoom, img);
375
379
  }
376
380
 
377
- private void processCommand(MapGeocodingCommand cmd) throws IOException {
381
+ private void processCommand(MapGeocodingCommand cmd) throws IOException, JSONException {
378
382
  LOG.TRACE("Processing map geocoding command (thread #" + hashCode() + "): " + cmd.description());
379
383
 
380
384
  if (cmd.annotation.street_address == null) {
@@ -385,7 +389,7 @@ public class GoogleMapField extends Field implements RhoMapField {
385
389
  StringBuffer url = new StringBuffer();
386
390
  url.append("http://maps.google.com/maps/geo?");
387
391
  url.append("q=" + URI.urlEncode(cmd.annotation.street_address));
388
- url.append("&output=csv&mobile=true&sensor=false");
392
+ url.append("&output=json&mobile=true&sensor=false");
389
393
  url.append("&key=" + mapkey);
390
394
 
391
395
  String finalUrl = url.toString();
@@ -393,6 +397,30 @@ public class GoogleMapField extends Field implements RhoMapField {
393
397
  byte[] data = fetchData(finalUrl);
394
398
  String response = new String(data);
395
399
 
400
+ JSONObject resp = new JSONObject(response);
401
+ JSONObject status = resp.getJSONObject("Status");
402
+ int statusCode = status.getInt("code");
403
+ if (statusCode/100 != 2) {
404
+ LOG.ERROR("Error received from geocoding service: " + statusCode);
405
+ return;
406
+ }
407
+
408
+ JSONArray placemarks = resp.getJSONArray("Placemark");
409
+ if (placemarks.length() == 0) {
410
+ LOG.ERROR("Geocoding request return empty response");
411
+ return;
412
+ }
413
+ JSONObject placemark = placemarks.getJSONObject(0);
414
+ JSONObject point = placemark.getJSONObject("Point");
415
+ JSONArray coordinates = point.getJSONArray("coordinates");
416
+ if (coordinates.length() < 2) {
417
+ LOG.ERROR("Geocoding response contains less than 2 coordinates");
418
+ return;
419
+ }
420
+ double longitude = coordinates.getDouble(0);
421
+ double latitude = coordinates.getDouble(1);
422
+
423
+ /*
396
424
  // Parse response
397
425
  Vector res = split(response, ",");
398
426
  if (res.size() != 4) {
@@ -404,9 +432,10 @@ public class GoogleMapField extends Field implements RhoMapField {
404
432
  int accuracy = Integer.parseInt((String)res.elementAt(1));
405
433
  double latitude = Double.parseDouble((String)res.elementAt(2));
406
434
  double longitude = Double.parseDouble((String)res.elementAt(3));
435
+ */
407
436
 
408
437
  LOG.TRACE("Geocoding request done, pass results back");
409
- cmd.mapField.geocodingDone(cmd.annotation, statusCode, accuracy, latitude, longitude);
438
+ cmd.mapField.geocodingDone(cmd.annotation, latitude, longitude);
410
439
  }
411
440
 
412
441
  public void run() {
@@ -903,19 +932,16 @@ public class GoogleMapField extends Field implements RhoMapField {
903
932
  fetchThreadPool.send(new MapGeocodingCommand(ann, this));
904
933
  }
905
934
 
906
- private void geocodingDone(Annotation ann, int statusCode,
907
- int accuracy, double lat, double lon) {
935
+ private void geocodingDone(Annotation ann, double lat, double lon) {
908
936
 
909
- LOG.TRACE("Apply geocoding result: " + statusCode + "," + accuracy +
910
- "," + lat + "," + lon);
911
- if (statusCode/100 != 2) {
912
- LOG.ERROR("Error received from geocoding service: " + statusCode);
913
- return;
914
- }
937
+ LOG.TRACE("Apply geocoding result: " + lat + "," + lon);
915
938
  ann.coordinates = new Annotation.Coordinates(lat, lon);
916
939
  long nlat = degreesToPixelsY(lat, MAX_ZOOM);
917
940
  long nlon = degreesToPixelsX(lon, MAX_ZOOM);
918
941
  ann.normalized_coordinates = new Annotation.NormalizedCoordinates(nlat, nlon);
942
+ if (ann.type.equals("center")) {
943
+ moveTo(lat, lon);
944
+ }
919
945
  }
920
946
 
921
947
  private static int calcZoom(double degrees, int pixels) {
@@ -117,28 +117,57 @@ public class MapView extends RubyBasic {
117
117
  else if (strKey.equals("shows_user_location"))
118
118
  settings.put(strKey, new Boolean(value.toString().equalsIgnoreCase("true")));
119
119
  else if (strKey.equals("region")) {
120
- if (!(value instanceof RubyArray))
121
- throw new RubyException(RubyRuntime.ArgumentErrorClass,
122
- "Wrong 'region' type, should be Array");
123
- RubyArray arr = (RubyArray)value;
124
- if (arr.size() == 4) {
125
- Hashtable region = new Hashtable();
126
- double[] cs = {0.0, 0.0, 0.0, 0.0};
127
- for (int k = 0; k != 4; ++k) {
128
- String v = arr.get(k).toString();
129
- try {
130
- cs[k] = Double.parseDouble(v);
120
+ if (value instanceof RubyArray) {
121
+ RubyArray arr = (RubyArray)value;
122
+ if (arr.size() == 4) {
123
+ Hashtable region = new Hashtable();
124
+ double[] cs = {0.0, 0.0, 0.0, 0.0};
125
+ for (int k = 0; k != 4; ++k) {
126
+ String v = arr.get(k).toString();
127
+ try {
128
+ cs[k] = Double.parseDouble(v);
129
+ }
130
+ catch (NumberFormatException e) {
131
+ throw new RubyException(RubyRuntime.ArgumentErrorClass,
132
+ "Wrong region value: " + v + ", should be Float");
133
+ }
134
+ }
135
+ region.put("latitude", new Double(cs[0]));
136
+ region.put("longitude", new Double(cs[1]));
137
+ region.put("latDelta", new Double(cs[2]));
138
+ region.put("lonDelta", new Double(cs[3]));
139
+ settings.put(strKey, region);
140
+ }
141
+ }
142
+ else if (value instanceof RubyHash) {
143
+ RubyHash hsh = (RubyHash)value;
144
+ RubyArray hKeys = hsh.keys();
145
+ RubyArray hValues = hsh.values();
146
+ for (int j = 0; j < hKeys.size(); ++j) {
147
+ RubyValue hKey = hKeys.get(j);
148
+ RubyValue hValue = hValues.get(j);
149
+ if (hKey == null || hValue == null)
150
+ continue;
151
+
152
+ String strHKey = hKey.toString();
153
+ if (strHKey.equals("center")) {
154
+ Annotation ann = new Annotation();
155
+ ann.type = "center";
156
+ ann.street_address = hValue.toString();
157
+ annotations.addElement(ann);
131
158
  }
132
- catch (NumberFormatException e) {
133
- throw new RubyException(RubyRuntime.ArgumentErrorClass,
134
- "Wrong region value: " + v + ", should be Float");
159
+ else if (strHKey.equals("radius")) {
160
+ String strHValue = hValue.toString();
161
+ try {
162
+ double radius = Double.parseDouble(strHValue);
163
+ settings.put("radius", new Double(radius));
164
+ }
165
+ catch (NumberFormatException e) {
166
+ throw new RubyException(RubyRuntime.ArgumentErrorClass,
167
+ "Wrong 'radius' parameter: " + strHValue + ", should be Float");
168
+ }
135
169
  }
136
170
  }
137
- region.put("latitude", new Double(cs[0]));
138
- region.put("longitude", new Double(cs[1]));
139
- region.put("latDelta", new Double(cs[2]));
140
- region.put("lonDelta", new Double(cs[3]));
141
- settings.put(strKey, region);
142
171
  }
143
172
  }
144
173
  }
@@ -147,6 +176,7 @@ public class MapView extends RubyBasic {
147
176
  if (annotationsArray != null) {
148
177
  for (int i = 0; i != annotationsArray.size(); ++i) {
149
178
  Annotation annotation = new Annotation();
179
+ annotation.type = "ann";
150
180
  RubyValue val = annotationsArray.get(i);
151
181
  if (!(val instanceof RubyHash))
152
182
  throw new RubyException(RubyRuntime.ArgumentErrorClass,
@@ -129,6 +129,12 @@ public class MapViewScreen extends MainScreen {
129
129
  }
130
130
  }
131
131
 
132
+ Double radius = (Double)settings.get("radius");
133
+ if (radius != null) {
134
+ int zoom = mapField.calculateZoom(radius.doubleValue(), radius.doubleValue());
135
+ mapField.setZoom(zoom);
136
+ }
137
+
132
138
  // Annotations
133
139
  Enumeration e = annotations.elements();
134
140
  while (e.hasMoreElements()) {
@@ -7,14 +7,13 @@
7
7
  #define kGeoCodeURL @"http://maps.google.com/maps/geo?q="
8
8
 
9
9
  @interface GoogleGeocoder : NSObject {
10
- NSMutableArray *annotations;
11
- MapAnnotation* currentAnnotation;
12
- NSString *theElement;
13
- NSString *gapikey;
10
+ NSMutableArray *annotations;
11
+ MapAnnotation* currentAnnotation;
12
+ NSString *theElement;
13
+ NSString *gapikey;
14
14
  @public
15
- id actionTarget;
16
- SEL onDidFindAddress;
17
-
15
+ id actionTarget;
16
+ SEL onDidFindAddress;
18
17
  }
19
18
 
20
19
  //
@@ -11,88 +11,88 @@
11
11
  @synthesize actionTarget,onDidFindAddress,theElement,annotations,gapikey;
12
12
 
13
13
  -(void)doGeocoding:(NSMutableArray*)items {
14
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
15
-
16
- NSEnumerator * enumerator = [items objectEnumerator];
17
- MapAnnotation* annotation, *element;
18
- while(element = [enumerator nextObject]) {
19
- annotation = nil;
20
- if ( (element.coordinate.latitude==10000) ||
21
- (element.coordinate.longitude==10000) ) {
22
- NSString* address = [element address];
23
- if ( ([address length] > 0) && [self geocode:element]) {
24
- annotation = element;
25
- }
26
- } else {
27
- annotation = element;
28
- }
29
-
30
- if(annotation && actionTarget && [actionTarget respondsToSelector:onDidFindAddress]) {
31
- [actionTarget performSelectorOnMainThread:onDidFindAddress withObject:annotation waitUntilDone:NO];
32
- }
33
- }
34
-
14
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
15
+
16
+ NSEnumerator * enumerator = [items objectEnumerator];
17
+ MapAnnotation* annotation, *element;
18
+ while(element = [enumerator nextObject]) {
19
+ annotation = nil;
20
+ if ( (element.coordinate.latitude==10000) ||
21
+ (element.coordinate.longitude==10000) ) {
22
+ NSString* address = [element address];
23
+ if ( ([address length] > 0) && [self geocode:element]) {
24
+ annotation = element;
25
+ }
26
+ } else {
27
+ annotation = element;
28
+ }
29
+
30
+ if(annotation && actionTarget && [actionTarget respondsToSelector:onDidFindAddress]) {
31
+ [actionTarget performSelectorOnMainThread:onDidFindAddress withObject:annotation waitUntilDone:NO];
32
+ }
33
+ }
34
+
35
35
  [pool release];
36
36
  }
37
37
 
38
38
  -(void)start {
39
- if (annotations) {
40
- [NSThread detachNewThreadSelector:@selector(doGeocoding:) toTarget:self withObject:annotations];
41
- }
39
+ if (annotations) {
40
+ [NSThread detachNewThreadSelector:@selector(doGeocoding:) toTarget:self withObject:annotations];
41
+ }
42
42
  }
43
43
 
44
44
  -(id)initWithAnnotations:(NSMutableArray*)_annotations apikey:(NSString*)key{
45
- self = [super init];
45
+ self = [super init];
46
46
  annotations = _annotations;
47
- gapikey = [key copy];
47
+ gapikey = [key copy];
48
48
  return self;
49
49
  }
50
50
 
51
51
  -(BOOL)geocode:(MapAnnotation *)annotation
52
52
  {
53
- BOOL retvar = TRUE;
54
- currentAnnotation = annotation;
55
- NSMutableString *url = [[NSMutableString alloc] initWithString:kGeoCodeURL];
56
- [url appendString:[annotation address]];
57
- [url appendFormat:@"&output=xml"];
58
- [url replaceOccurrencesOfString:@"ä" withString:@"ae" options:1 range:(NSRange){0,[url length]}];
59
- [url replaceOccurrencesOfString:@"ö" withString:@"oe" options:1 range:(NSRange){0,[url length]}];
60
- [url replaceOccurrencesOfString:@"ü" withString:@"ue" options:1 range:(NSRange){0,[url length]}];
61
- [url replaceOccurrencesOfString:@"ß" withString:@"ss" options:1 range:(NSRange){0,[url length]}];
62
- [url replaceOccurrencesOfString:@" " withString:@"+" options:1 range:(NSRange){0,[url length]}];
63
- if (gapikey) {
64
- [url appendString:@"&key="];
65
- [url appendString:gapikey];
66
- }
67
- NSLog(@"Geocoding url = %@\n", url);
68
- NSURLRequest *request=[NSURLRequest requestWithURL:[NSURL URLWithString:url]
69
- cachePolicy:NSURLRequestUseProtocolCachePolicy
70
- timeoutInterval:60.0];
71
- @try {
72
- NSHTTPURLResponse *response = NULL;
73
- NSData* data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:nil];
74
- NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data];
75
- [parser setDelegate:self];
76
- [parser parse];
77
- [self stringCooridinatesToCLLocation];
78
- }
79
- @catch (NSException *exception) {
80
- NSLog(@"Geocoding failed");
81
- retvar = FALSE;
82
- }
83
- @finally {
84
- //NSLog(@"finally");
85
- }
86
- return retvar;
53
+ BOOL retvar = TRUE;
54
+ currentAnnotation = annotation;
55
+ NSMutableString *url = [[NSMutableString alloc] initWithString:kGeoCodeURL];
56
+ [url appendString:[annotation address]];
57
+ [url appendFormat:@"&output=xml"];
58
+ [url replaceOccurrencesOfString:@"ä" withString:@"ae" options:1 range:(NSRange){0,[url length]}];
59
+ [url replaceOccurrencesOfString:@"ö" withString:@"oe" options:1 range:(NSRange){0,[url length]}];
60
+ [url replaceOccurrencesOfString:@"ü" withString:@"ue" options:1 range:(NSRange){0,[url length]}];
61
+ [url replaceOccurrencesOfString:@"ß" withString:@"ss" options:1 range:(NSRange){0,[url length]}];
62
+ [url replaceOccurrencesOfString:@" " withString:@"+" options:1 range:(NSRange){0,[url length]}];
63
+ if (gapikey) {
64
+ [url appendString:@"&key="];
65
+ [url appendString:gapikey];
66
+ }
67
+ NSLog(@"Geocoding url = %@\n", url);
68
+ NSURLRequest *request=[NSURLRequest requestWithURL:[NSURL URLWithString:url]
69
+ cachePolicy:NSURLRequestUseProtocolCachePolicy
70
+ timeoutInterval:60.0];
71
+ @try {
72
+ NSHTTPURLResponse *response = NULL;
73
+ NSData* data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:nil];
74
+ NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data];
75
+ [parser setDelegate:self];
76
+ [parser parse];
77
+ [self stringCooridinatesToCLLocation];
78
+ }
79
+ @catch (NSException *exception) {
80
+ NSLog(@"Geocoding failed");
81
+ retvar = FALSE;
82
+ }
83
+ @finally {
84
+ //NSLog(@"finally");
85
+ }
86
+ return retvar;
87
87
  }
88
88
 
89
89
  -(CLLocation *)stringCooridinatesToCLLocation{
90
- NSArray *array = [[currentAnnotation coordinateString] componentsSeparatedByString:@","];
91
- double longitude = [[array objectAtIndex:0] doubleValue];
92
- double lattitude = [[array objectAtIndex:1] doubleValue];
93
- CLLocation *location = [[[CLLocation alloc] initWithLatitude:lattitude longitude:longitude] autorelease];
94
- [currentAnnotation setCoordinate:location.coordinate];
95
- return location;
90
+ NSArray *array = [[currentAnnotation coordinateString] componentsSeparatedByString:@","];
91
+ double longitude = [[array objectAtIndex:0] doubleValue];
92
+ double lattitude = [[array objectAtIndex:1] doubleValue];
93
+ CLLocation *location = [[[CLLocation alloc] initWithLatitude:lattitude longitude:longitude] autorelease];
94
+ [currentAnnotation setCoordinate:location.coordinate];
95
+ return location;
96
96
  }
97
97
 
98
98
  #pragma mark -
@@ -101,8 +101,8 @@
101
101
  -(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName
102
102
  namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName
103
103
  attributes:(NSDictionary *)attributeDict {
104
- if(theElement) [theElement release];
105
- theElement = [[NSString alloc] initWithString:elementName];
104
+ if(theElement) [theElement release];
105
+ theElement = [[NSString alloc] initWithString:elementName];
106
106
  }
107
107
 
108
108
  -(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
@@ -111,10 +111,10 @@
111
111
  if ([string length] == 0)
112
112
  return;
113
113
 
114
- if([theElement isEqualToString:@"address"])
114
+ if([theElement isEqualToString:@"address"])
115
115
  [currentAnnotation setResolvedAddress:string];
116
116
 
117
- if([theElement isEqualToString:@"coordinates"])
117
+ if([theElement isEqualToString:@"coordinates"])
118
118
  [currentAnnotation setCoordinateString:string];
119
119
  }
120
120
 
@@ -13,11 +13,13 @@
13
13
 
14
14
 
15
15
  @interface MapAnnotation : NSObject<MKAnnotation> {
16
- NSString *title, *subtitle, *address, *url;
17
- NSString *coordinateString,*resolvedAddress;
18
- CLLocationCoordinate2D coordinate;
16
+ NSString *type;
17
+ NSString *title, *subtitle, *address, *url;
18
+ NSString *coordinateString,*resolvedAddress;
19
+ CLLocationCoordinate2D coordinate;
19
20
  }
20
21
 
22
+ @property (nonatomic,copy) NSString *type;
21
23
  @property (nonatomic,copy) NSString *title;
22
24
  @property (nonatomic,copy) NSString *subtitle;
23
25
  @property (nonatomic,copy) NSString *address;
@@ -12,20 +12,22 @@
12
12
 
13
13
  @implementation MapAnnotation
14
14
 
15
- @synthesize title, subtitle, address, url, coordinateString, resolvedAddress, coordinate;
15
+ @synthesize type, title, subtitle, address, url, coordinateString, resolvedAddress, coordinate;
16
16
 
17
17
  -(id) init {
18
- [super init];
19
- title = [[NSString alloc] initWithFormat:@""];
20
- subtitle = [[NSString alloc] initWithFormat:@""];
18
+ [super init];
19
+ type = [[NSString alloc] initWithFormat:@"ann"];
20
+ title = [[NSString alloc] initWithFormat:@""];
21
+ subtitle = [[NSString alloc] initWithFormat:@""];
21
22
  address = [[NSString alloc] initWithFormat:@""];
22
- coordinateString = [[NSMutableString alloc] initWithFormat:@""];
23
- resolvedAddress = [[NSMutableString alloc] initWithFormat:@""];
24
- url = [[NSString alloc] initWithFormat:@""];
25
- return self;
23
+ coordinateString = [[NSMutableString alloc] initWithFormat:@""];
24
+ resolvedAddress = [[NSMutableString alloc] initWithFormat:@""];
25
+ url = [[NSString alloc] initWithFormat:@""];
26
+ return self;
26
27
  }
27
28
 
28
29
  -(void) dealloc {
30
+ [type release];
29
31
  [title release];
30
32
  [subtitle release];
31
33
  [address release];