34 #include "examples/protos/route_guide.grpc.pb.h"
36 #include "route_guide.grpc.pb.h"
49 using routeguide::RouteGuide;
52 using std::chrono::system_clock;
58 const float kCoordFactor = 10000000.0;
59 float lat_1 =
start.latitude() / kCoordFactor;
60 float lat_2 =
end.latitude() / kCoordFactor;
61 float lon_1 =
start.longitude() / kCoordFactor;
62 float lon_2 =
end.longitude() / kCoordFactor;
68 float a = pow(sin(delta_lat_rad / 2), 2) +
69 cos(lat_rad_1) * cos(lat_rad_2) * pow(sin(delta_lon_rad / 2), 2);
70 float c = 2 * atan2(sqrt(
a), sqrt(1 -
a));
77 const std::vector<Feature>& feature_list) {
78 for (
const Feature&
f : feature_list) {
79 if (
f.location().latitude() ==
point.latitude() &&
80 f.location().longitude() ==
point.longitude()) {
96 feature->mutable_location()->CopyFrom(*
point);
103 auto lo = rectangle->lo();
104 auto hi = rectangle->hi();
105 long left = (
std::min)(lo.longitude(), hi.longitude());
106 long right = (
std::max)(lo.longitude(), hi.longitude());
107 long top = (
std::max)(lo.latitude(), hi.latitude());
108 long bottom = (
std::min)(lo.latitude(), hi.latitude());
110 if (
f.location().longitude() >= left &&
111 f.location().longitude() <= right &&
112 f.location().latitude() >= bottom &&
f.location().latitude() <=
top) {
123 int feature_count = 0;
124 float distance = 0.0;
133 if (point_count != 1) {
139 summary->set_point_count(point_count);
140 summary->set_feature_count(feature_count);
141 summary->set_distance(
static_cast<long>(distance));
144 summary->set_elapsed_time(secs.count());
153 std::unique_lock<std::mutex> lock(
mu_);
155 if (
n.location().latitude() ==
note.location().latitude() &&
156 n.location().longitude() ==
note.location().longitude()) {
180 std::cout <<
"Server listening on " <<
server_address << std::endl;
184 int main(
int argc,
char** argv) {