mirror of
https://github.com/csharpee/Map-Projections.git
synced 2025-10-16 00:00:11 -04:00
The illusion of accuracy
I tuned up the Hammer equations so that the areas beyond the ellipse render appropriately in MapAnalyzer.
This commit is contained in:
parent
8fa56caca0
commit
61ba22ce0c
@ -275,10 +275,8 @@ public class MapAnalyzer extends MapApplication {
|
||||
for (int y = 0; y < distortion[0].length; y ++) {
|
||||
for (int x = 0; x < distortion[0][y].length; x ++) {
|
||||
final double sizeDistort = distortion[0][y][x], shapeDistort = distortion[1][y][x];
|
||||
final double sizeContour = Math.round(
|
||||
sizeDistort/(LN_10/10))*LN_10/10;
|
||||
final double shapeContour = Math.exp(Math.round(
|
||||
Math.log(shapeDistort)/(LN_10/10))*LN_10/10);
|
||||
final double sizeContour = Math.round(sizeDistort/(LN_10/10))*LN_10/10; //contour the size by decibels
|
||||
final double shapeContour = Math.round(shapeDistort/(LN_10/20))*LN_10/20; //contour the size by semidecibels
|
||||
if (Double.isNaN(sizeDistort) || Double.isNaN(shapeDistort)) {
|
||||
writer.setArgb(x, y, 0);
|
||||
continue;
|
||||
|
@ -79,21 +79,17 @@ public class MapExplainer {
|
||||
final PrintStream out = System.out;
|
||||
|
||||
for (Projection[] projs: ALL_PROJECTIONS) {
|
||||
out.println("<h2>Map Projections</h2>");
|
||||
out.println("<h1>Map Projections</h1>");
|
||||
|
||||
for (Projection proj: projs) {
|
||||
out.println("<div class=row>");
|
||||
out.println(" <div class=\"col-xs-12 col-sm-10 col-md-8 col-lg-6\">");
|
||||
out.println(" <h3>"+proj.getName()+"</h3>");
|
||||
out.println(" </div>");
|
||||
out.println("</div>");
|
||||
out.println("<h2>"+proj.getName()+"</h2>");
|
||||
|
||||
ImageIO.write(
|
||||
makeImage(proj, proj.hasAspect() ? inputSkew : inputPole),
|
||||
"gif", new File("images/"+proj+".gif"));
|
||||
// ImageIO.write(
|
||||
// makeImage(proj, proj.hasAspect() ? inputSkew : inputPole),
|
||||
// "gif", new File("images/"+proj+".gif"));
|
||||
|
||||
out.println("<div class=row>");
|
||||
out.println(" <div class=\"col-xs-12 col-sm-10 col-md-4 col-lg-3\">");
|
||||
out.println("<div class=\"row\">");
|
||||
out.println(" <div class=\"col-left\">");
|
||||
out.println(" <p>"+proj.getDescription()+"</p>");
|
||||
|
||||
out.println(" <dl>");
|
||||
@ -112,13 +108,16 @@ public class MapExplainer {
|
||||
out.println(" </dl>");
|
||||
out.println(" </div>");
|
||||
|
||||
out.println(" <div class=\"col-xs-12 col-sm-10 col-md-4 col-lg-3\">");
|
||||
out.println(" <div class=\"col-right\">");
|
||||
out.println(" <img src=\"images/"+proj+".gif\" class=\"map\" " +
|
||||
"alt=\"Sorry. This map is not available at the moment. " +
|
||||
"Please leave a message after the beep.\" " +
|
||||
"title=\"I'll think of something to put here later.\">");
|
||||
"title=\"TODO\">");
|
||||
out.println(" </div>");
|
||||
out.println("</div>");
|
||||
|
||||
out.println("<br>");
|
||||
out.println();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,8 +71,9 @@ public class Misc {
|
||||
final double X = x * Math.sqrt(8);
|
||||
final double Y = y * Math.sqrt(2);
|
||||
final double z = Math.sqrt(1 - Math.pow(X/4, 2) - Math.pow(Y/2, 2));
|
||||
final double shift = (Math.hypot(x, y) > 1) ? 2*Math.PI*Math.signum(x) : 0;
|
||||
return new double[] {
|
||||
Math.asin(z * Y), 2*Math.atan(0.5*z*X / (2*z*z - 1))};
|
||||
Math.asin(z * Y), 2*Math.atan(0.5*z*X / (2*z*z - 1)) + shift};
|
||||
}
|
||||
};
|
||||
|
||||
@ -234,7 +235,9 @@ public class Misc {
|
||||
|
||||
|
||||
public static final Projection TWO_POINT_EQUIDISTANT =
|
||||
new Projection("Two-point Equidistant", "A map that preserves distances, but not angles, to two arbitrary points",
|
||||
new Projection(
|
||||
"Two-point Equidistant",
|
||||
"A map that preserves distances, but not azimuths, to two arbitrary points",
|
||||
1., 0b1111, Type.QUASIAZIMUTHAL, Property.EQUIDISTANT,
|
||||
new String[] {"Latitude 1","Longitude 1","Latitude 2","Longitude 2"},
|
||||
new double[][] {{-90,90,41.9},{-180,180,12.5},{-90,90,34.7},{-180,180,112.4}},
|
||||
|
@ -88,9 +88,11 @@ public class MyProjections {
|
||||
2, 0b1111, Type.PSEUDOAZIMUTHAL, Property.COMPROMISE) {
|
||||
|
||||
public double[] project(double lat, double lon) {
|
||||
double[] transverse = Azimuthal.STEREOGRAPHIC.project(
|
||||
obliquifySphc(lat, lon/2, new double[] {0,0,0}));
|
||||
return new double[] {2*transverse[0], transverse[1]};
|
||||
final double a = Math.PI - Math.acos(Math.cos(lat)*Math.cos(lon/2));
|
||||
final double b = Math.acos(Math.sin(lat)/Math.sin(a));
|
||||
return new double[] {
|
||||
Math.PI*Math.signum(lon)/Math.tan(a/2)*Math.sin(b),
|
||||
Math.PI/2/Math.tan(a/2)*Math.cos(b) };
|
||||
}
|
||||
|
||||
public double[] inverse(double x, double y) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user