diff --git a/src/main/java/seng302/Coordinate.java b/src/main/java/seng302/Coordinate.java new file mode 100644 index 00000000..a2b19e33 --- /dev/null +++ b/src/main/java/seng302/Coordinate.java @@ -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; + } +} diff --git a/src/main/java/seng302/Map.java b/src/main/java/seng302/Map.java new file mode 100644 index 00000000..5646ccc8 --- /dev/null +++ b/src/main/java/seng302/Map.java @@ -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))); + } +}