markCell method

void markCell(
  1. List<List<(GpsCoordinates, AutonomyCell)>> list,
  2. GpsCoordinates gps,
  3. AutonomyCell value
)

Calculates a new position for gps based on offset and adds it to the list.

This function filters out any coordinates that shouldn't be shown based on gridSize.

Implementation

void markCell(List<List<(GpsCoordinates, AutonomyCell)>> list, GpsCoordinates gps, AutonomyCell value) {
	// Latitude is y-axis, longitude is x-axis
	// The rover will occupy the center of the grid, so
	// - rover.longitude => (gridSize - 1) / 2
	// - rover.latitude => (gridSize - 1) / 2
	// Then, everything else should be offset by that
	final x = -1 * gpsToBlock(gps.longitude) + offset.x;
	final y = gpsToBlock(gps.latitude) + offset.y;
	if (x < 0 || x >= gridSize) return;
	if (y < 0 || y >= gridSize) return;
	list[y][x] = (gps, value);
}