def guide_list_features(stub): rectangle = example_pb2.Rectangle( lo=example_pb2.Point(latitude=400000000, longitude=-750000000), hi=example_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("tests/example/route_db.json") as route_guide_db_file: for item in json.load(route_guide_db_file): feature = example_pb2.Feature( name=item["name"], location=example_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, example_pb2.Point(latitude=409146138, longitude=-746188906)) guide_get_one_feature(stub, example_pb2.Point(latitude=0, longitude=0))
def make_route_note(message, latitude, longitude): return example_pb2.RouteNote(message=message, location=example_pb2.Point( latitude=latitude, longitude=longitude))