17
17
*
18
18
*/
19
19
20
- require dirname ( __FILE__ ). ' /../vendor/autoload.php ' ;
20
+ // php:generate protoc --proto_path=. /../../protos --php_out=./ --grpc_out=./ --plugin=protoc-gen-grpc=./../../../bins/opt/grpc_php_plugin ./../../protos/route_guide.proto
21
21
22
- // The following includes are needed when using protobuf 3.1.0
23
- // and will suppress warnings when using protobuf 3.2.0+
24
- @include_once dirname (__FILE__ ).'/route_guide.pb.php ' ;
25
- @include_once dirname (__FILE__ ).'/route_guide_grpc_pb.php ' ;
22
+ require dirname (__FILE__ ).'/../vendor/autoload.php ' ;
26
23
27
24
define ('COORD_FACTOR ' , 1e7 );
28
25
@@ -38,9 +35,12 @@ function printFeature($feature)
38
35
} else {
39
36
$ name_str = "feature called $ name " ;
40
37
}
41
- echo sprintf ("Found %s \n at %f, %f \n" , $ name_str ,
38
+ echo sprintf (
39
+ "Found %s \n at %f, %f \n" ,
40
+ $ name_str ,
42
41
$ feature ->getLocation ()->getLatitude () / COORD_FACTOR ,
43
- $ feature ->getLocation ()->getLongitude () / COORD_FACTOR );
42
+ $ feature ->getLocation ()->getLongitude () / COORD_FACTOR
43
+ );
44
44
}
45
45
46
46
/**
@@ -122,19 +122,24 @@ function runRecordRoute()
122
122
$ feature_name = $ db [$ index ]['name ' ];
123
123
$ point ->setLatitude ($ lat );
124
124
$ point ->setLongitude ($ long );
125
- echo sprintf ("Visiting point %f, %f, \n with feature name: %s \n" ,
126
- $ lat / COORD_FACTOR , $ long / COORD_FACTOR ,
127
- $ feature_name ? $ feature_name : '<empty> ' );
125
+ echo sprintf (
126
+ "Visiting point %f, %f, \n with feature name: %s \n" ,
127
+ $ lat / COORD_FACTOR ,
128
+ $ long / COORD_FACTOR ,
129
+ $ feature_name ? $ feature_name : '<empty> '
130
+ );
128
131
usleep (rand (300000 , 800000 ));
129
132
$ call ->write ($ point );
130
133
}
131
134
list ($ route_summary , $ status ) = $ call ->wait ();
132
- echo sprintf ("Finished trip with %d points \nPassed %d features \n" .
135
+ echo sprintf (
136
+ "Finished trip with %d points \nPassed %d features \n" .
133
137
"Travelled %d meters \nIt took %d seconds \n" ,
134
138
$ route_summary ->getPointCount (),
135
139
$ route_summary ->getFeatureCount (),
136
140
$ route_summary ->getDistance (),
137
- $ route_summary ->getElapsedTime ());
141
+ $ route_summary ->getElapsedTime ()
142
+ );
138
143
}
139
144
140
145
/**
@@ -166,19 +171,25 @@ function runRouteChat()
166
171
$ route_note ->setLocation ($ point );
167
172
$ route_note ->setMessage ($ message = $ n [2 ]);
168
173
169
- echo sprintf ("Sending message: '%s' at (%d, %d) \n" ,
170
- $ message , $ lat , $ long );
174
+ echo sprintf (
175
+ "Sending message: '%s' at (%d, %d) \n" ,
176
+ $ message ,
177
+ $ lat ,
178
+ $ long
179
+ );
171
180
// send a bunch of messages to the server
172
181
$ call ->write ($ route_note );
173
182
}
174
183
$ call ->writesDone ();
175
184
176
185
// read from the server until there's no more
177
186
while ($ route_note_reply = $ call ->read ()) {
178
- echo sprintf ("Previous left message at (%d, %d): '%s' \n" ,
187
+ echo sprintf (
188
+ "Previous left message at (%d, %d): '%s' \n" ,
179
189
$ route_note_reply ->getLocation ()->getLatitude (),
180
190
$ route_note_reply ->getLocation ()->getLongitude (),
181
- $ route_note_reply ->getMessage ());
191
+ $ route_note_reply ->getMessage ()
192
+ );
182
193
}
183
194
}
184
195
0 commit comments