use of POGOProtos.Map.MapCellOuterClass.MapCell in project PokeGOAPI-Java by Grover-c13.
the class Map method requestMapObjects.
/**
* Requests and returns MapObjects from the server.
*
* @return the returned MapObjects
* @throws RequestFailedException if an exception occurred while sending requests
*/
protected MapObjects requestMapObjects() throws RequestFailedException {
List<Long> cells = getDefaultCells();
GetMapObjectsMessage.Builder builder = GetMapObjectsMessage.newBuilder();
builder.setLatitude(api.getLatitude());
builder.setLongitude(api.getLongitude());
for (Long cell : cells) {
builder.addCellId(cell);
builder.addSinceTimestampMs(0);
}
ServerRequest request = new ServerRequest(RequestType.GET_MAP_OBJECTS, builder.build());
api.getRequestHandler().sendServerRequests(request, true);
try {
GetMapObjectsResponse response = GetMapObjectsResponse.parseFrom(request.getData());
MapObjects mapObjects = new MapObjects(api);
for (MapCell cell : response.getMapCellsList()) {
mapObjects.addCell(cell);
}
return mapObjects;
} catch (InvalidProtocolBufferException e) {
throw new RequestFailedException(e);
}
}
Aggregations