From 5cf6bcd6e237c66b4565ee93773b9d82a1fba85c Mon Sep 17 00:00:00 2001 From: Justin Kunimune Date: Tue, 15 Oct 2019 22:41:17 -0400 Subject: [PATCH] So many cones I fixed up American polyconic, and I'm kind of glad I have it, even though it's a terrible map projection whose only application is making gores and Cassini is better for that, anyway. --- src/apps/MapApplication.java | 5 +++-- src/maps/Lenticular.java | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/apps/MapApplication.java b/src/apps/MapApplication.java index 37ec021..2bd8e9b 100644 --- a/src/apps/MapApplication.java +++ b/src/apps/MapApplication.java @@ -145,8 +145,9 @@ public abstract class MapApplication extends Application { Pseudocylindrical.MOLLWEIDE, ArbitraryPseudocylindrical.NATURAL_EARTH, ArbitraryPseudocylindrical.ROBINSON, Pseudocylindrical.SINUSOIDAL, Tobler.TOBLER, Pseudocylindrical.WAGNER_II, Pseudocylindrical.WAGNER_V }, - { Lenticular.EISENLOHR, Gyorffy.E, Lenticular.HAMMER, Lenticular.LAGRANGE, - Lenticular.STREBE_95, Lenticular.VAN_DER_GRINTEN, Lenticular.WAGNER_VIII, + { Lenticular.AITOFF, Lenticular.POLYCONIC, Lenticular.EISENLOHR, Gyorffy.E, + Lenticular.HAMMER, Lenticular.LAGRANGE, Lenticular.STREBE_95, + Lenticular.VAN_DER_GRINTEN, Lenticular.WAGNER_VIII, WinkelTripel.WINKEL_TRIPEL }, { Misc.BONNE, Snyder.GS50, Misc.GUYOU, Misc.HAMMER_RETROAZIMUTHAL, Pseudocylindrical.LEMONS, Misc.PEIRCE_QUINCUNCIAL, Misc.T_SHIRT, diff --git a/src/maps/Lenticular.java b/src/maps/Lenticular.java index 1bdeadd..b1f43d9 100644 --- a/src/maps/Lenticular.java +++ b/src/maps/Lenticular.java @@ -286,7 +286,7 @@ public class Lenticular { public static final Projection POLYCONIC = new Projection( "American polyconic", "A map made for narrow strips of longitude that was really popular with the USGS for a while.", - 2*Math.PI, 3.5, 0b1011, Type.OTHER, Property.EQUIDISTANT, 3) { + 2*Math.PI, 4.81527, 0b1011, Type.OTHER, Property.EQUIDISTANT, 3) { public double[] project(double lat, double lon) { if (lat == 0) @@ -296,7 +296,21 @@ public class Lenticular { } public double[] inverse(double x, double y) { - return null; + if (y < 0) { // the math gets inconvenient in the Southern Hemisphere + double[] refl = inverse(x, -y); + return new double[] {-refl[0], refl[1]}; + } + else if (y == 0) + return new double[] {0, x}; + + double logitLatGuess = Math.log(Math.hypot(x, y+Math.PI/2)/Math.hypot(x, y-Math.PI/2)); + double lat = NumericalAnalysis.bisectionFind( + (ph)->(Math.pow(x, 2) + Math.pow(y - ph, 2) - 2*(y - ph)/Math.tan(ph)), + 0, Math.PI/2*(Math.exp(logitLatGuess) - 1)/(Math.exp(logitLatGuess) + 1), // this guess is pretty complicated, but I'm proud of it + 1e-4); + if (Double.isNaN(lat)) + return null; + return new double[] { lat, Math.atan2(x, -(y - lat - 1/Math.tan(lat)))/Math.sin(lat) }; } };