blob: efcb2e7158f166a8ca94df9fe708107e34a1add8 [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
Jorge Canizales3fda5482015-06-05 12:05:00 -070039
Jorge Canizales34b26292015-06-02 02:11:09 -070040#pragma mark Get Feature
41
Jorge Canizales3aed7172015-06-04 22:56:21 -070042// Run the getFeature demo. Calls getFeature with a point known to have a feature and a point known
43// not to have a feature.
44
Jorge Canizales34b26292015-06-02 02:11:09 -070045@interface GetFeatureViewController : UIViewController
46@end
47
48@implementation GetFeatureViewController
49
50- (void)viewDidLoad {
51 [super viewDidLoad];
52
53 RTGRouteGuide *client = [[RTGRouteGuide alloc] initWithHost:kHostAddress];
54
Jorge Canizales3aed7172015-06-04 22:56:21 -070055 void (^handler)(RTGFeature *response, NSError *error) = ^(RTGFeature *response, NSError *error) {
56 if (response.name.length) {
57 NSLog(@"Found feature called %@ at %@.", response.name, response.location);
58 } else if (response) {
59 NSLog(@"Found no features at %@", response.location);
60 } else {
61 NSLog(@"RPC error: %@", error);
62 }
63 };
64
Jorge Canizales34b26292015-06-02 02:11:09 -070065 RTGPoint *point = [RTGPoint message];
66 point.latitude = 409146138;
67 point.longitude = -746188906;
68
Jorge Canizales3aed7172015-06-04 22:56:21 -070069 [client getFeatureWithRequest:point handler:handler];
70 [client getFeatureWithRequest:[RTGPoint message] handler:handler];
Jorge Canizales34b26292015-06-02 02:11:09 -070071}
72
73@end
74
Jorge Canizales3fda5482015-06-05 12:05:00 -070075
Jorge Canizales34b26292015-06-02 02:11:09 -070076#pragma mark List Features
77
Jorge Canizales4694cdb2015-06-04 23:06:13 -070078// Run the listFeatures demo. Calls listFeatures with a rectangle containing all of the features in
79// the pre-generated database. Prints each response as it comes in.
80
Jorge Canizales34b26292015-06-02 02:11:09 -070081@interface ListFeaturesViewController : UIViewController
82@end
83
84@implementation ListFeaturesViewController
85
86- (void)viewDidLoad {
87 [super viewDidLoad];
Jorge Canizales4694cdb2015-06-04 23:06:13 -070088
89 RTGRouteGuide *client = [[RTGRouteGuide alloc] initWithHost:kHostAddress];
90
91 RTGRectangle *rectangle = [RTGRectangle message];
92 rectangle.lo.latitude = 40E7;
93 rectangle.lo.longitude = -75E7;
94 rectangle.hi.latitude = 42E7;
95 rectangle.hi.longitude = -73E7;
96
97 NSLog(@"Looking for features between 40, -75 and 42, -73");
98 [client listFeaturesWithRequest:rectangle handler:^(BOOL done, RTGFeature *response, NSError *error) {
99 if (response) {
100 NSLog(@"Found feature called %@ at %@.", response.name, response.location);
101 } else if (error) {
102 NSLog(@"RPC error: %@", error);
103 }
104 }];
Jorge Canizales34b26292015-06-02 02:11:09 -0700105}
106
107@end
108
Jorge Canizales3fda5482015-06-05 12:05:00 -0700109
Jorge Canizales34b26292015-06-02 02:11:09 -0700110#pragma mark Record Route
111
112@interface RecordRouteViewController : UIViewController
113@end
114
115@implementation RecordRouteViewController
116
117- (void)viewDidLoad {
118 [super viewDidLoad];
119 // Do any additional setup after loading the view.
120}
121
122@end
123
Jorge Canizales3fda5482015-06-05 12:05:00 -0700124
Jorge Canizales34b26292015-06-02 02:11:09 -0700125#pragma mark Route Chat
126
127@interface RouteChatViewController : UIViewController
128@end
129
130@implementation RouteChatViewController
131
132- (void)viewDidLoad {
133 [super viewDidLoad];
134 // Do any additional setup after loading the view.
135}
136
137@end