|
@@ -1,5 +1,7 @@
|
|
|
package de.tu_darmstadt.informatik.tk.scopviz.ui.mapView;
|
|
|
|
|
|
+import java.awt.Rectangle;
|
|
|
+import java.awt.geom.Point2D;
|
|
|
import java.io.IOException;
|
|
|
import java.net.MalformedURLException;
|
|
|
import java.net.URL;
|
|
@@ -13,11 +15,15 @@ import org.jxmapviewer.JXMapViewer;
|
|
|
import org.jxmapviewer.OSMTileFactoryInfo;
|
|
|
import org.jxmapviewer.painter.CompoundPainter;
|
|
|
import org.jxmapviewer.painter.Painter;
|
|
|
+import org.jxmapviewer.viewer.GeoBounds;
|
|
|
import org.jxmapviewer.viewer.GeoPosition;
|
|
|
import org.jxmapviewer.viewer.TileFactoryInfo;
|
|
|
import org.jxmapviewer.viewer.WaypointPainter;
|
|
|
+import org.jxmapviewer.viewer.util.GeoUtil;
|
|
|
|
|
|
+import de.tu_darmstadt.informatik.tk.scopviz.debug.Debug;
|
|
|
import de.tu_darmstadt.informatik.tk.scopviz.ui.GUIController;
|
|
|
+import javafx.geometry.Rectangle2D;
|
|
|
|
|
|
public class WorldView {
|
|
|
|
|
@@ -122,9 +128,11 @@ public class WorldView {
|
|
|
|
|
|
// Use 8 threads in parallel to load the tiles
|
|
|
tileFactory.setThreadPoolSize(8);
|
|
|
+
|
|
|
+ showAllWaypoints(nodePositions);
|
|
|
|
|
|
// set Zoom and Center to show all node positions
|
|
|
- internMapViewer.zoomToBestFit(nodePositions, 1);
|
|
|
+ //internMapViewer.zoomToBestFit(nodePositions, 1);
|
|
|
|
|
|
if (internMapViewer.getOverlayPainter() == null) {
|
|
|
internMapViewer.setOverlayPainter(painter);
|
|
@@ -154,5 +162,47 @@ public class WorldView {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * centers map, so that all waypoints are shown
|
|
|
+ * @param positions
|
|
|
+ */
|
|
|
+ public static void showAllWaypoints(HashSet<GeoPosition> positions) {
|
|
|
+
|
|
|
+ ArrayList<Point2D> points = new ArrayList<Point2D>(positions.size());
|
|
|
+
|
|
|
+ internMapViewer.calculateZoomFrom(positions);
|
|
|
+
|
|
|
+ positions.forEach((geoPos) -> points.add(internMapViewer.convertGeoPositionToPoint(geoPos)));
|
|
|
+
|
|
|
+ double minX = Double.MAX_VALUE;
|
|
|
+ double maxX = Double.MIN_VALUE;
|
|
|
+
|
|
|
+ double minY = Double.MAX_VALUE;
|
|
|
+ double maxY = Double.MIN_VALUE;
|
|
|
+
|
|
|
+ for(Point2D p : points){
|
|
|
+ if(p.getX() < minX){
|
|
|
+ minX = p.getX();
|
|
|
+ }
|
|
|
+ if(p.getX() > maxX){
|
|
|
+ maxX = p.getX();
|
|
|
+ }
|
|
|
+
|
|
|
+ if(p.getY() < minY){
|
|
|
+ minY = p.getY();
|
|
|
+ }
|
|
|
+ if(p.getY() > maxY){
|
|
|
+ maxY = p.getY();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Rectangle2D rect = new Rectangle2D(minX, minY, maxX - minX, maxY - minY);
|
|
|
+
|
|
|
+ Point2D center = new Point2D.Double(rect.getWidth() / 2, rect.getHeight() / 2);
|
|
|
+
|
|
|
+ internMapViewer.setCenterPosition(internMapViewer.convertPointToGeoPosition(center));
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|