blob: 6a1e8b9db4e4e3e3160732f744290ee96ed1493d [file] [log] [blame]
Jorge Canizales34b26292015-06-02 02:11:09 -07001/*
2 *
3 * Copyright 2015, Google Inc.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following disclaimer
14 * in the documentation and/or other materials provided with the
15 * distribution.
16 * * Neither the name of Google Inc. nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
33
34#import <UIKit/UIKit.h>
35#import <RouteGuide/RouteGuide.pbrpc.h>
36
37static NSString * const kHostAddress = @"http://localhost:50051";
38
39#pragma mark Get Feature
40
Jorge Canizales3aed7172015-06-04 22:56:21 -070041// Run the getFeature demo. Calls getFeature with a point known to have a feature and a point known
42// not to have a feature.
43
Jorge Canizales34b26292015-06-02 02:11:09 -070044@interface GetFeatureViewController : UIViewController
45@end
46
47@implementation GetFeatureViewController
48
49- (void)viewDidLoad {
50 [super viewDidLoad];
51
52 RTGRouteGuide *client = [[RTGRouteGuide alloc] initWithHost:kHostAddress];
53
Jorge Canizales3aed7172015-06-04 22:56:21 -070054 void (^handler)(RTGFeature *response, NSError *error) = ^(RTGFeature *response, NSError *error) {
55 if (response.name.length) {
56 NSLog(@"Found feature called %@ at %@.", response.name, response.location);
57 } else if (response) {
58 NSLog(@"Found no features at %@", response.location);
59 } else {
60 NSLog(@"RPC error: %@", error);
61 }
62 };
63
Jorge Canizales34b26292015-06-02 02:11:09 -070064 RTGPoint *point = [RTGPoint message];
65 point.latitude = 409146138;
66 point.longitude = -746188906;
67
Jorge Canizales3aed7172015-06-04 22:56:21 -070068 [client getFeatureWithRequest:point handler:handler];
69 [client getFeatureWithRequest:[RTGPoint message] handler:handler];
Jorge Canizales34b26292015-06-02 02:11:09 -070070}
71
72@end
73
74#pragma mark List Features
75
Jorge Canizales4694cdb2015-06-04 23:06:13 -070076// Run the listFeatures demo. Calls listFeatures with a rectangle containing all of the features in
77// the pre-generated database. Prints each response as it comes in.
78
Jorge Canizales34b26292015-06-02 02:11:09 -070079@interface ListFeaturesViewController : UIViewController
80@end
81
82@implementation ListFeaturesViewController
83
84- (void)viewDidLoad {
85 [super viewDidLoad];
Jorge Canizales4694cdb2015-06-04 23:06:13 -070086
87 RTGRouteGuide *client = [[RTGRouteGuide alloc] initWithHost:kHostAddress];
88
89 RTGRectangle *rectangle = [RTGRectangle message];
90 rectangle.lo.latitude = 40E7;
91 rectangle.lo.longitude = -75E7;
92 rectangle.hi.latitude = 42E7;
93 rectangle.hi.longitude = -73E7;
94
95 NSLog(@"Looking for features between 40, -75 and 42, -73");
96 [client listFeaturesWithRequest:rectangle handler:^(BOOL done, RTGFeature *response, NSError *error) {
97 if (response) {
98 NSLog(@"Found feature called %@ at %@.", response.name, response.location);
99 } else if (error) {
100 NSLog(@"RPC error: %@", error);
101 }
102 }];
Jorge Canizales34b26292015-06-02 02:11:09 -0700103}
104
105@end
106
107#pragma mark Record Route
108
109@interface RecordRouteViewController : UIViewController
110@end
111
112@implementation RecordRouteViewController
113
114- (void)viewDidLoad {
115 [super viewDidLoad];
116 // Do any additional setup after loading the view.
117}
118
119@end
120
121#pragma mark Route Chat
122
123@interface RouteChatViewController : UIViewController
124@end
125
126@implementation RouteChatViewController
127
128- (void)viewDidLoad {
129 [super viewDidLoad];
130 // Do any additional setup after loading the view.
131}
132
133@end