mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Created Mercator projection to convert between Geo location and planar projection point.
- MapGeo and MapPoint encapsulate geo location and planar projection point into classes. #story[928]
This commit is contained in:
@@ -2,28 +2,27 @@ package seng302.models.map;
|
||||
|
||||
import javafx.scene.image.Image;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
|
||||
import java.lang.Math;
|
||||
|
||||
public class CanvasMap {
|
||||
|
||||
private Bound bound;
|
||||
private Boundary bound;
|
||||
private double width, height; // desired image size
|
||||
private int zoom;
|
||||
|
||||
private int MERCATOR_RANGE = 256;
|
||||
private String KEY = "AIzaSyC-5oOShMCY5Oy_9L7guYMPUPFHDMr37wE";
|
||||
|
||||
public CanvasMap(Bound bound, double width, double height) {
|
||||
public CanvasMap(Boundary bound, double width, double height) {
|
||||
this.bound = bound;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public Image getMapImage() {
|
||||
|
||||
try {
|
||||
System.out.println(getRequest());
|
||||
URL url = new URL(getRequest());
|
||||
@@ -37,13 +36,14 @@ public class CanvasMap {
|
||||
}
|
||||
|
||||
private String getRequest() {
|
||||
zoom = 14;
|
||||
zoom = 15;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("https://maps.googleapis.com/maps/api/staticmap?");
|
||||
sb.append(String.format("center=%f,%f", bound.getCentreLat(), bound.getCentreLng()));
|
||||
sb.append(String.format("&zoom=%d", zoom));
|
||||
sb.append(String.format("&size=%.0fx%.0f&scale=2", width / 2, height / 2));
|
||||
sb.append(String.format("&key=%s", KEY));
|
||||
sb.append("&style=feature:all|element:labels|visibility:off"); // hide all labels on map
|
||||
// sb.append(String.format("&key=%s", KEY));
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user