I'm developing a graph generator to monitor the navigation of a robot. The data of the coordinates by which the robot passes are stored in a txt file, with each line having a latitude and a longitude, as described in that question . I'm using the @VictorStafusa example
But I'm having trouble accessing data from class Coordenada
.
To plot a line in my graph, I use the latitude and longitude of two coordinates. Therefore, each object must have the coordinates of a line of the txt. The code I use to plot a line is linha.drawLine(longitudeCoordenada1, latitudeCoordenada1, longitudeCoordenada2, latitudeCoordenada2)
. I then thought of instantiating objects as follows Coordenada c = new Coordenada()
, to use: linha.drawLine(c.getLongitude(), c.getLatitude(), c2.getLongitude(), c2.getLatitude())
. But I did not succeed.
I have little object-oriented experience, so could you tell me how to do each object have the coordinate of a txt line and how to access those coordinates?
To test I'm using the following main class.
public class Main {
public static void main(String[] args) throws IOException {
double longitude1 = 0;
double latitude1 = 0;
double longitude2 = 0;
double latitude2 = 0;
Leitura l = new Leitura();
l.lerCoordenadas();
Coordenada c1 = new Coordenada(longitude1, latitude1);
Coordenada c2 = new Coordenada(longitude2, latitude2);
System.out.println(c1.getLongitude());
System.out.println(c1.getLatitude());
System.out.println(c2.getLongitude());
System.out.println(c2.getLatitude());
}
}