RecordRoute demo
This commit is contained in:
parent
c9885954a2
commit
59fdf71844
|
|
@ -12,6 +12,7 @@
|
|||
632527861B1D0396003073D9 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 632527851B1D0396003073D9 /* AppDelegate.m */; };
|
||||
6325278F1B1D0396003073D9 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6325278D1B1D0396003073D9 /* Main.storyboard */; };
|
||||
632527911B1D0396003073D9 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 632527901B1D0396003073D9 /* Images.xcassets */; };
|
||||
6367B55B1B223AFA008861F5 /* route_guide_db.json in Resources */ = {isa = PBXBuildFile; fileRef = 6367B55A1B223AFA008861F5 /* route_guide_db.json */; };
|
||||
63A6015C1B1DAB5000FA5B86 /* ViewControllers.m in Sources */ = {isa = PBXBuildFile; fileRef = 63A6015B1B1DAB5000FA5B86 /* ViewControllers.m */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
|
|
@ -23,6 +24,7 @@
|
|||
632527851B1D0396003073D9 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
|
||||
6325278E1B1D0396003073D9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
|
||||
632527901B1D0396003073D9 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
|
||||
6367B55A1B223AFA008861F5 /* route_guide_db.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = route_guide_db.json; sourceTree = "<group>"; };
|
||||
63A6015B1B1DAB5000FA5B86 /* ViewControllers.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewControllers.m; sourceTree = "<group>"; };
|
||||
71CEE03D66D40FC37264D6E4 /* libPods-RouteGuideClient.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RouteGuideClient.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
ADA4C647BAE906F79AD9A45E /* Pods-RouteGuideClient.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RouteGuideClient.debug.xcconfig"; path = "Pods/Target Support Files/Pods-RouteGuideClient/Pods-RouteGuideClient.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
|
|
@ -83,6 +85,7 @@
|
|||
isa = PBXGroup;
|
||||
children = (
|
||||
63A6015B1B1DAB5000FA5B86 /* ViewControllers.m */,
|
||||
6367B55A1B223AFA008861F5 /* route_guide_db.json */,
|
||||
6325278D1B1D0396003073D9 /* Main.storyboard */,
|
||||
631C63891B1DBC41001295D5 /* Misc */,
|
||||
);
|
||||
|
|
@ -167,6 +170,7 @@
|
|||
files = (
|
||||
6325278F1B1D0396003073D9 /* Main.storyboard in Resources */,
|
||||
632527911B1D0396003073D9 /* Images.xcassets in Resources */,
|
||||
6367B55B1B223AFA008861F5 /* route_guide_db.json in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@
|
|||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <gRPC/GRXWriter+Immediate.h>
|
||||
#import <gRPC/GRXWriter+Transformations.h>
|
||||
#import <RouteGuide/RouteGuide.pbrpc.h>
|
||||
|
||||
static NSString * const kHostAddress = @"http://localhost:50051";
|
||||
|
|
@ -123,6 +125,10 @@ static NSString * const kHostAddress = @"http://localhost:50051";
|
|||
|
||||
#pragma mark Record Route
|
||||
|
||||
// Run the recordRoute demo. Sends several randomly chosen points from the pre-generated feature
|
||||
// database with a variable delay in between. Prints the statistics when they are sent from the
|
||||
// server.
|
||||
|
||||
@interface RecordRouteViewController : UIViewController
|
||||
@end
|
||||
|
||||
|
|
@ -145,7 +151,32 @@ static NSString * const kHostAddress = @"http://localhost:50051";
|
|||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
|
||||
NSString *dataBasePath = [NSBundle.mainBundle pathForResource:@"route_guide_db"
|
||||
ofType:@"json"];
|
||||
NSData *dataBaseContent = [NSData dataWithContentsOfFile:dataBasePath];
|
||||
NSArray *features = [NSJSONSerialization JSONObjectWithData:dataBaseContent options:0 error:NULL];
|
||||
|
||||
GRXWriter *locations = [[GRXWriter writerWithContainer:features] map:^id(id feature) {
|
||||
RTGPoint *location = [RTGPoint message];
|
||||
location.longitude = [((NSNumber *) feature[@"location"][@"longitude"]) intValue];
|
||||
location.latitude = [((NSNumber *) feature[@"location"][@"latitude"]) intValue];
|
||||
NSLog(@"Visiting point %@", location);
|
||||
return location;
|
||||
}];
|
||||
|
||||
RTGRouteGuide *client = [[RTGRouteGuide alloc] initWithHost:kHostAddress];
|
||||
|
||||
[client recordRouteWithRequestsWriter:locations handler:^(RTGRouteSummary *response, NSError *error) {
|
||||
if (response) {
|
||||
NSLog(@"Finished trip with %i points", response.pointCount);
|
||||
NSLog(@"Passed %i features", response.featureCount);
|
||||
NSLog(@"Travelled %i meters", response.distance);
|
||||
NSLog(@"It took %i seconds", response.elapsedTime);
|
||||
} else {
|
||||
NSLog(@"RPC error: %@", error);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -0,0 +1,121 @@
|
|||
[{
|
||||
"location": {
|
||||
"latitude": 407838351,
|
||||
"longitude": -746143763
|
||||
},
|
||||
"name": "Patriots Path, Mendham, NJ 07945, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 408122808,
|
||||
"longitude": -743999179
|
||||
},
|
||||
"name": "101 New Jersey 10, Whippany, NJ 07981, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 413628156,
|
||||
"longitude": -749015468
|
||||
},
|
||||
"name": "U.S. 6, Shohola, PA 18458, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 419999544,
|
||||
"longitude": -740371136
|
||||
},
|
||||
"name": "5 Conners Road, Kingston, NY 12401, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 414008389,
|
||||
"longitude": -743951297
|
||||
},
|
||||
"name": "Mid Hudson Psychiatric Center, New Hampton, NY 10958, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 419611318,
|
||||
"longitude": -746524769
|
||||
},
|
||||
"name": "287 Flugertown Road, Livingston Manor, NY 12758, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 406109563,
|
||||
"longitude": -742186778
|
||||
},
|
||||
"name": "4001 Tremley Point Road, Linden, NJ 07036, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 416802456,
|
||||
"longitude": -742370183
|
||||
},
|
||||
"name": "352 South Mountain Road, Wallkill, NY 12589, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 412950425,
|
||||
"longitude": -741077389
|
||||
},
|
||||
"name": "Bailey Turn Road, Harriman, NY 10926, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 412144655,
|
||||
"longitude": -743949739
|
||||
},
|
||||
"name": "193-199 Wawayanda Road, Hewitt, NJ 07421, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 404306372,
|
||||
"longitude": -741079661
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 403966326,
|
||||
"longitude": -748519297
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 405002031,
|
||||
"longitude": -748407866
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 409532885,
|
||||
"longitude": -742200683
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 416851321,
|
||||
"longitude": -742674555
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 406411633,
|
||||
"longitude": -741722051
|
||||
},
|
||||
"name": "3387 Richmond Terrace, Staten Island, NY 10303, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 413069058,
|
||||
"longitude": -744597778
|
||||
},
|
||||
"name": "261 Van Sickle Road, Goshen, NY 10924, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 418465462,
|
||||
"longitude": -746859398
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 411733222,
|
||||
"longitude": -744228360
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 410248224,
|
||||
"longitude": -747127767
|
||||
},
|
||||
"name": "3 Hasta Way, Newton, NJ 07860, USA"
|
||||
}]
|
||||
Loading…
Reference in New Issue