- double[] startCoords = new double[] { start.getX(), start.getY() };
- double[] endCoords = new double[] { end.getX(), end.getY() };
+
+ double padding = GeometryUtils.getScale(getTransform());
+
+ /*
+ * To convert y-coordinates to map coordinates in ruler, use:
+ * double val = (y-offsetY)/scaleY;
+ * val = Math.toDegrees(Math.atan(Math.sinh(Math.toRadians(val))));
+ * String str = formatValue(val);
+ */
+ // TODO: fix scale
+ double scaleY = getTransform().getScaleY();
+ double scaleX = getTransform().getScaleX();
+
+ double startLat = ModelledCRS.yToLatitude(-start.getY() / scaleY);
+ double startLon = ModelledCRS.xToLongitude(start.getX() / scaleX);
+
+ double endLat = ModelledCRS.yToLatitude(-end.getY() / scaleY);
+ double endLon = ModelledCRS.xToLongitude(end.getX() / scaleX);
+
+ double[] startCoords = new double[] { startLon, startLat };
+ double[] endCoords = new double[] { endLon, endLat };