- Created Coordinate class with getters - Created Map class - Created convertGPS method in Map #story [9], #pair [cbt24,fwy13]main
parent
a7c64dc401
commit
fbb3094da8
@ -0,0 +1,19 @@
|
||||
package seng302;
|
||||
|
||||
/**
|
||||
* Created by cbt24 on 15/03/17.
|
||||
*/
|
||||
public class Coordinate {
|
||||
private int x;
|
||||
private int y;
|
||||
|
||||
public Coordinate(int x, int y) { this.x = x; this.y = y; }
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package seng302;
|
||||
|
||||
/**
|
||||
* Created by cbt24 on 15/03/17.
|
||||
*/
|
||||
public class Map {
|
||||
private double x1, x2, y1, y2;
|
||||
private int width, height;
|
||||
|
||||
public Map(double x1, double y1, double x2, double y2, int width, int height) {
|
||||
this.x1 = x1; this.x2 = x2; this.y1 = y1; this.y2 = y2; this.width = width; this.height = height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts GPS coordinates to coordinates for container
|
||||
* @param lat GPS latitude
|
||||
* @param lon GPS longitude
|
||||
* @return Coordinate (pair of doubles)
|
||||
* @see seng302.Coordinate
|
||||
*/
|
||||
public Coordinate convertGPS(double lat, double lon) {
|
||||
return new Coordinate((int)(width * (lat-x1)/(x2-x1)), (int)(height * (lon-x1)/(x2-x1)));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue