def guide_list_features(stub): rectangle = routeguide_pb2.Rectangle( lo=routeguide_pb2.Point(latitude=400000000, longitude=-750000000), hi=routeguide_pb2.Point(latitude=420000000, longitude=-730000000)) print("Looking for features between 40, -75 and 42, -73") features = stub.ListFeatures(rectangle) for feature in features: print("Feature called %s at %s" % (feature.name, feature.location))
def read_route_guide_database(): """Reads the route guide database. Returns: The full contents of the route guide database as a sequence of route_guide_pb2.Features. """ feature_list = [] with open("example/proto/routeguide_features.json") as route_guide_db_file: for item in json.load(route_guide_db_file): feature = routeguide_pb2.Feature( name=item["name"], location=routeguide_pb2.Point( latitude=item["location"]["latitude"], longitude=item["location"]["longitude"])) feature_list.append(feature) return feature_list
def guide_get_feature(stub): guide_get_one_feature( stub, routeguide_pb2.Point(latitude=409146138, longitude=-746188906)) guide_get_one_feature(stub, routeguide_pb2.Point(latitude=0, longitude=0))
def make_route_note(message, latitude, longitude): return routeguide_pb2.RouteNote( message=message, location=routeguide_pb2.Point(latitude=latitude, longitude=longitude))