From 33fedc06f818fa201f687ebe65e51d5edfa77253 Mon Sep 17 00:00:00 2001 From: Justin Kunimune Date: Sun, 23 Dec 2018 12:11:54 -1000 Subject: [PATCH] The Rubber Earth I integrated this with my other map projection repository, and laid teh groundwork for the best map projections ever! Check out that Danseiji III! --- src/apps/MapApplication.java | 9 +- src/apps/MapExplainer.java | 4 +- src/apps/MapOptimizer.java | 4 +- src/apps/MapPlotter.java | 6 +- src/apps/MapProducer.java | 4 +- src/data/danseijiIII.csv | 1300 ++++++++++++++++++++++ src/maps/Arbitrary.java | 113 +- src/maps/ArbitraryPseudocylindrical.java | 96 ++ 8 files changed, 1475 insertions(+), 61 deletions(-) create mode 100644 src/data/danseijiIII.csv create mode 100644 src/maps/ArbitraryPseudocylindrical.java diff --git a/src/apps/MapApplication.java b/src/apps/MapApplication.java index 3c53d5a..c46ebf7 100644 --- a/src/apps/MapApplication.java +++ b/src/apps/MapApplication.java @@ -76,6 +76,7 @@ import javafx.scene.text.Text; import javafx.stage.FileChooser; import javafx.stage.Stage; import maps.Arbitrary; +import maps.ArbitraryPseudocylindrical; import maps.Azimuthal; import maps.Conic; import maps.Cylindrical; @@ -114,14 +115,14 @@ public abstract class MapApplication extends Application { private static final KeyCombination CTRL_ENTER = new KeyCodeCombination(KeyCode.ENTER, KeyCodeCombination.CONTROL_DOWN); - public static final Projection[] FEATURED_PROJECTIONS = { Cylindrical.MERCATOR, + public static final Projection[] FEATURED_PROJECTIONS = { Arbitrary.DANSEIJI_III, Cylindrical.MERCATOR, Cylindrical.EQUIRECTANGULAR, Cylindrical.EQUAL_AREA, Cylindrical.GALL_STEREOGRAPHIC, Azimuthal.STEREOGRAPHIC, Azimuthal.POLAR, Azimuthal.EQUAL_AREA, Azimuthal.GNOMONIC, Azimuthal.PERSPECTIVE, Conic.LAMBERT, Conic.EQUIDISTANT, Conic.ALBERS, Polyhedral.LEE_TETRAHEDRAL_RECTANGULAR, Polyhedral.ACTUAUTHAGRAPH, Polyhedral.AUTHAPOWER, Octohedral.KEYES_BASIC_M, Pseudocylindrical.SINUSOIDAL, Pseudocylindrical.MOLLWEIDE, Tobler.TOBLER, Lenticular.AITOFF, - Lenticular.VAN_DER_GRINTEN, Arbitrary.ROBINSON, WinkelTripel.WINKEL_TRIPEL, + Lenticular.VAN_DER_GRINTEN, ArbitraryPseudocylindrical.ROBINSON, WinkelTripel.WINKEL_TRIPEL, Misc.PEIRCE_QUINCUNCIAL, Misc.TWO_POINT_EQUIDISTANT, Pseudocylindrical.LEMONS }; //the set of featured projections for the ComboBox public static final String[] PROJECTION_CATEGORIES = { "Cylindrical", "Azimuthal", "Conic", @@ -138,8 +139,8 @@ public abstract class MapApplication extends Application { Polyhedral.LEE_TETRAHEDRAL_RECTANGULAR, Polyhedral.LEE_TETRAHEDRAL_TRIANGULAR, Octohedral.WATERMAN }, { Pseudocylindrical.ECKERT_IV, Pseudocylindrical.KAVRAYSKIY_VII, - Pseudocylindrical.MOLLWEIDE, Arbitrary.NATURAL_EARTH, Arbitrary.ROBINSON, - Pseudocylindrical.SINUSOIDAL, Tobler.TOBLER }, + Pseudocylindrical.MOLLWEIDE, ArbitraryPseudocylindrical.NATURAL_EARTH, + ArbitraryPseudocylindrical.ROBINSON, Pseudocylindrical.SINUSOIDAL, Tobler.TOBLER }, { Lenticular.AITOFF, Lenticular.HAMMER, Lenticular.STREBE_95, Lenticular.VAN_DER_GRINTEN, WinkelTripel.WINKEL_TRIPEL }, { Snyder.GS50, Misc.GUYOU, Misc.HAMMER_RETROAZIMUTHAL, Pseudocylindrical.LEMONS, diff --git a/src/apps/MapExplainer.java b/src/apps/MapExplainer.java index be65856..12abfa5 100644 --- a/src/apps/MapExplainer.java +++ b/src/apps/MapExplainer.java @@ -32,7 +32,7 @@ import image.SavableImage; import javafx.application.Application; import javafx.concurrent.Task; import javafx.stage.Stage; -import maps.Arbitrary; +import maps.ArbitraryPseudocylindrical; import maps.Azimuthal; import maps.Conic; import maps.Cylindrical; @@ -67,7 +67,7 @@ public class MapExplainer extends Application { Polyhedral.LEE_TETRAHEDRAL_RECTANGULAR, Polyhedral.AUTHAGRAPH, Pseudocylindrical.SINUSOIDAL, Pseudocylindrical.MOLLWEIDE, Tobler.TOBLER, Lenticular.HAMMER, Lenticular.AITOFF, Lenticular.VAN_DER_GRINTEN, - Arbitrary.ROBINSON, WinkelTripel.WINKEL_TRIPEL, Octohedral.CAHILL_KEYES, + ArbitraryPseudocylindrical.ROBINSON, WinkelTripel.WINKEL_TRIPEL, Octohedral.CAHILL_KEYES, Octohedral.CAHILL_CONCIALDI, Misc.PEIRCE_QUINCUNCIAL.transverse(), Snyder.GS50, Misc.TWO_POINT_EQUIDISTANT, Misc.HAMMER_RETROAZIMUTHAL, Misc.FLAT_EARTH }, { MyProjections.PSEUDOSTEREOGRAPHIC, Polyhedral.TETRAGRAPH, Polyhedral.AUTHAPOWER, diff --git a/src/apps/MapOptimizer.java b/src/apps/MapOptimizer.java index e698ace..6ef0c62 100644 --- a/src/apps/MapOptimizer.java +++ b/src/apps/MapOptimizer.java @@ -39,7 +39,7 @@ import javafx.scene.chart.NumberAxis; import javafx.scene.chart.XYChart.Data; import javafx.scene.chart.XYChart.Series; import javafx.stage.Stage; -import maps.Arbitrary; +import maps.ArbitraryPseudocylindrical; import maps.Cylindrical; import maps.Misc; import maps.Polyhedral; @@ -57,7 +57,7 @@ import utils.linalg.Vector; public class MapOptimizer extends Application { private static final Projection[] EXISTING_PROJECTIONS = { Cylindrical.BEHRMANN, - Arbitrary.ROBINSON, Cylindrical.PLATE_CARREE, Cylindrical.GALL_STEREOGRAPHIC, + ArbitraryPseudocylindrical.ROBINSON, Cylindrical.PLATE_CARREE, Cylindrical.GALL_STEREOGRAPHIC, Misc.PEIRCE_QUINCUNCIAL }; private static final Projection[] PROJECTIONS_TO_OPTIMIZE = { Tobler.TOBLER, WinkelTripel.WINKEL_TRIPEL, Polyhedral.AUTHAPOWER }; diff --git a/src/apps/MapPlotter.java b/src/apps/MapPlotter.java index 7993e53..675b04b 100644 --- a/src/apps/MapPlotter.java +++ b/src/apps/MapPlotter.java @@ -47,7 +47,7 @@ import javafx.scene.control.Label; import javafx.scene.layout.AnchorPane; import javafx.scene.layout.StackPane; import javafx.stage.Stage; -import maps.Arbitrary; +import maps.ArbitraryPseudocylindrical; import maps.Azimuthal; import maps.Cylindrical; import maps.Lenticular; @@ -74,8 +74,8 @@ public class MapPlotter extends Application { Cylindrical.PLATE_CARREE, Cylindrical.GALL_ORTHOGRAPHIC, Cylindrical.BEHRMANN, Cylindrical.GALL_STEREOGRAPHIC }; private static final Projection[] AZIMUTHAL = { Azimuthal.POLAR }; - private static final Projection[] PSEUDOCYL = { Pseudocylindrical.MOLLWEIDE, Arbitrary.ROBINSON, - Arbitrary.NATURAL_EARTH, Pseudocylindrical.KAVRAYSKIY_VII, Tobler.TOBLER }; + private static final Projection[] PSEUDOCYL = { Pseudocylindrical.MOLLWEIDE, ArbitraryPseudocylindrical.ROBINSON, + ArbitraryPseudocylindrical.NATURAL_EARTH, Pseudocylindrical.KAVRAYSKIY_VII, Tobler.TOBLER }; private static final Projection[] LENTICULAR = { Lenticular.AITOFF, Lenticular.VAN_DER_GRINTEN, WinkelTripel.WINKEL_TRIPEL }; private static final Projection[] TETRAHEDRAL = { Polyhedral.LEE_TETRAHEDRAL_RECTANGULAR, diff --git a/src/apps/MapProducer.java b/src/apps/MapProducer.java index f073649..772fe97 100644 --- a/src/apps/MapProducer.java +++ b/src/apps/MapProducer.java @@ -8,7 +8,7 @@ import image.SavableImage; import javafx.application.Application; import javafx.concurrent.Task; import javafx.stage.Stage; -import maps.Arbitrary; +import maps.ArbitraryPseudocylindrical; import maps.Azimuthal; import maps.Conic; import maps.Cylindrical; @@ -62,7 +62,7 @@ public class MapProducer extends Application { Cylindrical.BEHRMANN, Cylindrical.HOBO_DYER, Cylindrical.GALL_ORTHOGRAPHIC, Pseudocylindrical.SINUSOIDAL, Pseudocylindrical.MOLLWEIDE, Pseudocylindrical.ECKERT_IV, Pseudocylindrical.KAVRAYSKIY_VII, - Arbitrary.ROBINSON, Arbitrary.NATURAL_EARTH, Tobler.TOBLER, Lenticular.AITOFF, + ArbitraryPseudocylindrical.ROBINSON, ArbitraryPseudocylindrical.NATURAL_EARTH, Tobler.TOBLER, Lenticular.AITOFF, Lenticular.HAMMER, WinkelTripel.WINKEL_TRIPEL, Lenticular.VAN_DER_GRINTEN, Conic.EQUIDISTANT, Conic.LAMBERT, Conic.ALBERS, Azimuthal.POLAR, Azimuthal.GNOMONIC, Azimuthal.EQUAL_AREA, Azimuthal.STEREOGRAPHIC, diff --git a/src/data/danseijiIII.csv b/src/data/danseijiIII.csv new file mode 100644 index 0000000..962fe34 --- /dev/null +++ b/src/data/danseijiIII.csv @@ -0,0 +1,1300 @@ +650,18,36,5.218276,3.769600, +-0.083542,1.147154, +0.359616,1.242609, +0.353992,1.264488, +-0.414561,1.368229, +-0.427111,1.348186, +-0.435539,1.325079, +-0.439699,1.299492, +-0.439542,1.272076, +-0.435168,1.243547, +-0.426771,1.214527, +-0.414601,1.185540, +-0.399041,1.157047, +-0.380504,1.129428, +-0.359648,1.102936, +-0.335548,1.077710, +-0.308964,1.054116, +-0.280169,1.032537, +-0.249321,1.013181, +-0.215773,0.996534, +-0.178952,0.982799, +-0.140103,0.971919, +-0.100085,0.964228, +-0.059812,0.960115, +-0.019060,0.959686, +0.021639,0.962866, +0.061749,0.969494, +0.100703,0.979365, +0.138335,0.992162, +0.174194,1.007648, +0.207919,1.025550, +0.238836,1.045626, +0.267354,1.067553, +0.292820,1.091064, +0.314860,1.115838, +0.333024,1.141515, +0.346871,1.167643, +0.356033,1.193636, +0.360297,1.218824, +0.597777,1.303423, +0.586669,1.357867, +-0.598743,1.518833, +-0.627292,1.470343, +-0.646125,1.417228, +-0.655859,1.361726, +-0.657553,1.305600, +-0.651675,1.249854, +-0.638623,1.195289, +-0.618909,1.142591, +-0.593209,1.092318, +-0.562210,1.044921, +-0.526097,1.000893, +-0.485856,0.960726, +-0.441929,0.924178, +-0.394689,0.890962, +-0.345114,0.861608, +-0.294199,0.835833, +-0.242293,0.813806, +-0.189624,0.796522, +-0.134634,0.784159, +-0.077079,0.777602, +-0.017502,0.777408, +0.043043,0.783059, +0.103655,0.793904, +0.163600,0.809588, +0.222228,0.829879, +0.278975,0.854565, +0.333237,0.883504, +0.384391,0.916602, +0.431748,0.953634, +0.474673,0.994496, +0.512344,1.039075, +0.544095,1.087123, +0.569306,1.138250, +0.587342,1.191933, +0.597391,1.247437, +0.808011,1.319197, +0.805999,1.398433, +-0.779343,1.626918, +-0.812243,1.552101, +-0.836868,1.473995, +-0.852382,1.394262, +-0.857049,1.313950, +-0.850080,1.234439, +-0.832057,1.156876, +-0.804354,1.082283, +-0.768181,1.011549, +-0.724556,0.945409, +-0.674597,0.884489, +-0.618871,0.829682, +-0.559714,0.782364, +-0.499405,0.740006, +-0.440943,0.702878, +-0.383799,0.669695, +-0.323910,0.639991, +-0.256447,0.616375, +-0.181790,0.601397, +-0.103198,0.594301, +-0.023171,0.594774, +0.057139,0.602531, +0.137136,0.617146, +0.216332,0.638252, +0.294217,0.665544, +0.370196,0.698764, +0.443524,0.737703, +0.513272,0.782224, +0.578366,0.832295, +0.637511,0.887900, +0.689287,0.949009, +0.732152,1.015549, +0.765338,1.087058, +0.788552,1.162510, +0.802231,1.240293, +1.043246,1.288506, +1.061670,1.378933, +-0.997964,1.704549, +-1.019679,1.609028, +-1.037151,1.511991, +-1.049620,1.412022, +-1.052779,1.309000, +-1.041419,1.205784, +-1.015954,1.105804, +-0.978628,1.010430, +-0.931111,0.920648, +-0.874544,0.837289, +-0.809637,0.760854, +-0.738733,0.691810, +-0.667765,0.632116, +-0.604340,0.582925, +-0.547436,0.540061, +-0.487646,0.501186, +-0.412340,0.467059, +-0.321339,0.438965, +-0.224540,0.421023, +-0.126316,0.412757, +-0.027733,0.413456, +0.070635,0.422938, +0.168259,0.440970, +0.264742,0.467189, +0.359816,0.501108, +0.453056,0.542193, +0.543872,0.590034, +0.631248,0.644399, +0.713666,0.705455, +0.789384,0.773650, +0.856412,0.849503, +0.912421,0.933149, +0.956031,1.022079, +0.990060,1.112497, +1.019214,1.200970, +1.320892,1.174729, +1.369747,1.263744, +-1.286688,1.728690, +-1.282224,1.620544, +-1.272221,1.513216, +-1.259790,1.402973, +-1.247543,1.284533, +-1.226030,1.161787, +-1.191111,1.041936, +-1.143441,0.928234, +-1.084295,0.821462, +-1.014576,0.722541, +-0.936681,0.632800, +-0.856915,0.553806, +-0.782495,0.485610, +-0.718258,0.427198, +-0.656980,0.375551, +-0.583151,0.330090, +-0.484555,0.292046, +-0.372680,0.262446, +-0.258214,0.242596, +-0.143208,0.233014, +-0.028293,0.233701, +0.085843,0.244562, +0.198682,0.265590, +0.310032,0.296424, +0.419686,0.336442, +0.527857,0.384832, +0.634247,0.440596, +0.738108,0.503285, +0.837766,0.572956, +0.930146,0.650843, +1.012627,0.738349, +1.084595,0.833036, +1.148272,0.927052, +1.208266,1.011702, +1.266813,1.091629, +1.575661,1.002361, +1.648934,1.094241, +-1.577969,1.700182, +-1.550682,1.579206, +-1.516281,1.463014, +-1.476785,1.350382, +-1.439989,1.231901, +-1.404328,1.100368, +-1.358609,0.966068, +-1.300266,0.836912, +-1.229937,0.715890, +-1.148780,0.603948, +-1.060943,0.503058, +-0.976001,0.417082, +-0.898298,0.344110, +-0.824139,0.276262, +-0.750280,0.211756, +-0.657147,0.157136, +-0.537726,0.115814, +-0.411040,0.085016, +-0.283201,0.064327, +-0.154202,0.054506, +-0.024818,0.055563, +0.103716,0.067422, +0.230014,0.090586, +0.353527,0.125655, +0.475357,0.171301, +0.595106,0.225943, +0.714050,0.289174, +0.832625,0.358842, +0.948929,0.434386, +1.059423,0.518110, +1.157882,0.609612, +1.245351,0.700667, +1.331518,0.778336, +1.417485,0.846315, +1.498642,0.919840, +1.787037,0.799778, +1.883097,0.887321, +-1.845788,1.622323, +-1.792985,1.495623, +-1.737831,1.372702, +-1.682475,1.254403, +-1.627858,1.138804, +-1.575927,1.014438, +-1.518959,0.877041, +-1.450719,0.737878, +-1.371302,0.605409, +-1.281790,0.484053, +-1.183946,0.375447, +-1.081318,0.277802, +-0.985081,0.191073, +-0.900876,0.114920, +-0.819522,0.042860, +-0.712698,-0.017407, +-0.579334,-0.061177, +-0.442338,-0.093391, +-0.303097,-0.113852, +-0.161599,-0.122467, +-0.018745,-0.120099, +0.124007,-0.107282, +0.264579,-0.082913, +0.399582,-0.045507, +0.527483,0.004828, +0.656562,0.064918, +0.783629,0.135077, +0.912395,0.210641, +1.043892,0.288569, +1.170916,0.370403, +1.288842,0.450520, +1.394653,0.519340, +1.495192,0.580134, +1.593396,0.645618, +1.690504,0.719313, +1.958902,0.573811, +2.073372,0.649217, +-2.086393,1.499808, +-2.008700,1.376611, +-1.935229,1.253446, +-1.865817,1.130649, +-1.798518,1.009462, +-1.733559,0.888640, +-1.667470,0.761317, +-1.593037,0.625049, +-1.509886,0.487119, +-1.412660,0.359658, +-1.300836,0.245098, +-1.182853,0.138823, +-1.064528,0.039436, +-0.956525,-0.052159, +-0.864226,-0.132650, +-0.755988,-0.194606, +-0.617092,-0.238867, +-0.470610,-0.271970, +-0.320404,-0.291086, +-0.167301,-0.297055, +-0.012171,-0.292324, +0.143658,-0.278307, +0.298760,-0.253928, +0.444392,-0.215769, +0.575828,-0.161164, +0.713025,-0.097363, +0.842748,-0.021457, +0.975727,0.057573, +1.114842,0.133418, +1.252923,0.204608, +1.387776,0.265543, +1.515538,0.311311, +1.632923,0.363878, +1.740470,0.430319, +1.847803,0.501556, +2.090766,0.326925, +2.217515,0.383399, +-2.296333,1.341333, +-2.198887,1.227549, +-2.109282,1.109632, +-2.025956,0.987800, +-1.947084,0.863442, +-1.870881,0.737520, +-1.795140,0.610644, +-1.718401,0.480488, +-1.636716,0.345506, +-1.530740,0.222428, +-1.409267,0.109118, +-1.283869,0.000502, +-1.156260,-0.104176, +-1.027904,-0.204963, +-0.904852,-0.300393, +-0.789531,-0.373568, +-0.649570,-0.417655, +-0.495279,-0.450183, +-0.334369,-0.466529, +-0.170460,-0.468670, +-0.006274,-0.461185, +0.158643,-0.446168, +0.322535,-0.423176, +0.473296,-0.383011, +0.609728,-0.323118, +0.748644,-0.258010, +0.881545,-0.180297, +1.015898,-0.100247, +1.159126,-0.029946, +1.304211,0.030774, +1.444714,0.077301, +1.589122,0.111556, +1.730943,0.151782, +1.854556,0.207456, +1.970486,0.268919, +2.175319,0.063777, +2.308736,0.096342, +-2.472595,1.156013, +-2.360161,1.056905, +-2.258180,0.947759, +-2.164393,0.830487, +-2.076721,0.707095, +-1.993004,0.579912, +-1.911315,0.451058, +-1.831407,0.320972, +-1.747191,0.190383, +-1.635253,0.073285, +-1.507463,-0.033789, +-1.377259,-0.140407, +-1.246001,-0.245989, +-1.112241,-0.349194, +-0.975043,-0.449224, +-0.829924,-0.537735, +-0.669986,-0.593137, +-0.505157,-0.627945, +-0.336702,-0.640025, +-0.167348,-0.637829, +0.000545,-0.628338, +0.167213,-0.612312, +0.331253,-0.590072, +0.483558,-0.546454, +0.626618,-0.482099, +0.767836,-0.412211, +0.906231,-0.336518, +1.044433,-0.260630, +1.187118,-0.195446, +1.330071,-0.144135, +1.476552,-0.105262, +1.628671,-0.074316, +1.781156,-0.046898, +1.921261,-0.015470, +2.047675,0.025916, +2.204451,-0.202431, +2.335032,-0.200451, +-2.612632,0.952547, +-2.492025,0.871021, +-2.382830,0.773190, +-2.282971,0.662743, +-2.190216,0.542805, +-2.102063,0.416730, +-2.016495,0.287219, +-1.930963,0.155815, +-1.839124,0.026710, +-1.725297,-0.084944, +-1.595176,-0.182690, +-1.463987,-0.283583, +-1.332788,-0.387085, +-1.198627,-0.489465, +-1.055045,-0.589138, +-0.881203,-0.681138, +-0.687241,-0.752056, +-0.496971,-0.799413, +-0.322406,-0.812125, +-0.154810,-0.805914, +0.011398,-0.794853, +0.176151,-0.778724, +0.338768,-0.754796, +0.494226,-0.704990, +0.642015,-0.633536, +0.786825,-0.560756, +0.927050,-0.489262, +1.061095,-0.418724, +1.198507,-0.358193, +1.346864,-0.315938, +1.497522,-0.282537, +1.647799,-0.257555, +1.797721,-0.243753, +1.942358,-0.234640, +2.076296,-0.217098, +2.173997,-0.473690, +2.296032,-0.492333, +-2.717339,0.739260, +-2.595492,0.676146, +-2.484892,0.590500, +-2.383641,0.488067, +-2.289098,0.373234, +-2.198631,0.249633, +-2.109084,0.120512, +-2.016566,-0.011625, +-1.915684,-0.140501, +-1.800118,-0.246672, +-1.673874,-0.334917, +-1.547752,-0.427425, +-1.421282,-0.525212, +-1.286905,-0.624563, +-1.123466,-0.723684, +-0.918075,-0.817506, +-0.700087,-0.896472, +-0.485337,-0.956936, +-0.297556,-0.980011, +-0.132890,-0.973812, +0.028753,-0.960219, +0.189999,-0.942723, +0.351803,-0.911603, +0.510703,-0.850841, +0.661607,-0.773604, +0.808494,-0.701245, +0.951367,-0.634107, +1.088794,-0.572295, +1.225305,-0.521602, +1.367061,-0.485733, +1.508533,-0.458006, +1.649742,-0.440091, +1.790697,-0.435194, +1.927694,-0.440026, +2.052641,-0.454143, +2.091342,-0.706581, +2.194832,-0.753865, +-2.789505,0.528205, +-2.673915,0.480030, +-2.567954,0.405415, +-2.469607,0.311575, +-2.376495,0.203020, +-2.285175,0.083705, +-2.191900,-0.043188, +-2.092941,-0.174687, +-1.985218,-0.301391, +-1.869712,-0.402392, +-1.751667,-0.484157, +-1.634039,-0.568433, +-1.510470,-0.658685, +-1.361793,-0.754415, +-1.162622,-0.855269, +-0.938270,-0.949472, +-0.706090,-1.031809, +-0.473483,-1.099628, +-0.268542,-1.136269, +-0.092336,-1.137469, +0.063241,-1.121123, +0.226922,-1.094696, +0.391206,-1.044860, +0.545451,-0.976766, +0.690378,-0.901047, +0.832423,-0.831664, +0.972684,-0.770743, +1.111226,-0.720713, +1.247130,-0.682534, +1.379937,-0.655154, +1.509982,-0.634033, +1.637017,-0.622417, +1.760496,-0.625602, +1.875265,-0.641266, +1.982411,-0.670061, +1.956123,-0.914485, +2.026650,-0.974027, +-2.838968,0.329856, +-2.736130,0.290957, +-2.639540,0.226383, +-2.548241,0.141829, +-2.459159,0.041512, +-2.368310,-0.071342, +-2.271931,-0.194150, +-2.167294,-0.323144, +-2.055404,-0.447113, +-1.942421,-0.547415, +-1.832976,-0.625967, +-1.719818,-0.703589, +-1.585381,-0.787876, +-1.405611,-0.882673, +-1.187273,-0.980348, +-0.950652,-1.074240, +-0.703166,-1.158344, +-0.444999,-1.226758, +-0.186086,-1.280501, +-0.002284,-1.284166, +0.197904,-1.266119, +0.350781,-1.215708, +0.488381,-1.152944, +0.616046,-1.083500, +0.739440,-1.015872, +0.863314,-0.953962, +0.987202,-0.902624, +1.110810,-0.863939, +1.233669,-0.837767, +1.354244,-0.822047, +1.470723,-0.813161, +1.581209,-0.811821, +1.683386,-0.823503, +1.779490,-0.842901, +1.872789,-0.870668, +1.752526,-1.121898, +1.803419,-1.171100, +-2.883243,0.148477, +-2.800003,0.119679, +-2.719664,0.069317, +-2.638745,-0.000816, +-2.554235,-0.088859, +-2.463186,-0.193134, +-2.362947,-0.311426, +-2.252434,-0.439771, +-2.135886,-0.566691, +-2.021900,-0.675370, +-1.915652,-0.755871, +-1.796451,-0.830296, +-1.642211,-0.909332, +-1.443528,-0.998959, +-1.218933,-1.092697, +-0.972282,-1.185052, +-0.710527,-1.268636, +-0.427510,-1.339859, +-0.098409,-1.382001, +0.400402,-1.425624, +0.482003,-1.362194, +0.564192,-1.298822, +0.646245,-1.236235, +0.729878,-1.175617, +0.819006,-1.120533, +0.911370,-1.073711, +1.005488,-1.036886, +1.100556,-1.011252, +1.195214,-0.995859, +1.288178,-0.989788, +1.377474,-0.993870, +1.462348,-1.006518, +1.543119,-1.026056, +1.620038,-1.051531, +1.691097,-1.082447, +1.541530,-1.298802, +1.571344,-1.342096, +1.484404,-1.592877, +1.464851,-1.648187, +1.436810,-1.699384, +1.399954,-1.744907, +1.356683,-1.784768, +1.308383,-1.817600, +1.255243,-1.842173, +1.199319,-1.857377, +1.141482,-1.863653, +1.083003,-1.861444, +1.025514,-1.850499, +0.970306,-1.830285, +0.918870,-1.801243, +0.871908,-1.765558, +0.829933,-1.723287, +0.794412,-1.675100, +0.764806,-1.622456, +0.741189,-1.566939, +0.725092,-1.511262, +0.735081,-1.460681, +0.743572,-1.410307, +0.773055,-1.361987, +0.814622,-1.316286, +0.864267,-1.274365, +0.920168,-1.237818, +0.980704,-1.207648, +1.044145,-1.184468, +1.108992,-1.168628, +1.173954,-1.160381, +1.237747,-1.159700, +1.299379,-1.166424, +1.357668,-1.180587, +1.411658,-1.201453, +1.460390,-1.228578, +1.503722,-1.261273, +1.342543,-1.419920, +1.353007,-1.445535, +1.310422,-1.546559, +1.300990,-1.575127, +1.286979,-1.601820, +1.268796,-1.625916, +1.246710,-1.646509, +1.221376,-1.663088, +1.193642,-1.675373, +1.164247,-1.683244, +1.133991,-1.686562, +1.103717,-1.685195, +1.074034,-1.679219, +1.045769,-1.668917, +1.019458,-1.654621, +0.995709,-1.636652, +0.975010,-1.615603, +0.957769,-1.592016, +0.944831,-1.566502, +0.937094,-1.539493, +0.935433,-1.511837, +0.937505,-1.483358, +0.946765,-1.455616, +0.960093,-1.429423, +0.978586,-1.405249, +1.001927,-1.383746, +1.029187,-1.365405, +1.059462,-1.350537, +1.091823,-1.339433, +1.125426,-1.332281, +1.159437,-1.329251, +1.192928,-1.330426, +1.225208,-1.335843, +1.255458,-1.345347, +1.283028,-1.358829, +1.307183,-1.376030, +1.327187,-1.396540, +1.135064,-1.504954, +1.654940,-1.645206, +1.624114,-1.725469, +1.581959,-1.800257, +1.528517,-1.867280, +1.465674,-1.924984, +1.393448,-1.972863, +1.317097,-2.008026, +1.234340,-2.031501, +1.149230,-2.040910, +1.064100,-2.037064, +0.979306,-2.020503, +0.898239,-1.991576, +0.823483,-1.951302, +0.755395,-1.897722, +0.695650,-1.835994, +0.643109,-1.766660, +0.600567,-1.689576, +0.562370,-1.607133, +0.516358,-1.519535, +0,0,1,2, +0,0,3,4, +0,0,4,5, +0,0,5,6, +0,0,6,7, +0,0,7,8, +0,0,8,9, +0,0,9,10, +0,0,10,11, +0,0,11,12, +0,0,12,13, +0,0,13,14, +0,0,14,15, +0,0,15,16, +0,0,16,17, +0,0,17,18, +0,0,18,19, +0,0,19,20, +0,0,20,21, +0,0,21,22, +0,0,22,23, +0,0,23,24, +0,0,24,25, +0,0,25,26, +0,0,26,27, +0,0,27,28, +0,0,28,29, +0,0,29,30, +0,0,30,31, +0,0,31,32, +0,0,32,33, +0,0,33,34, +0,0,34,35, +0,0,35,36, +0,0,36,37, +0,0,37,1, +2,1,38,39, +4,3,40,41, +5,4,41,42, +6,5,42,43, +7,6,43,44, +8,7,44,45, +9,8,45,46, +10,9,46,47, +11,10,47,48, +12,11,48,49, +13,12,49,50, +14,13,50,51, +15,14,51,52, +16,15,52,53, +17,16,53,54, +18,17,54,55, +19,18,55,56, +20,19,56,57, +21,20,57,58, +22,21,58,59, +23,22,59,60, +24,23,60,61, +25,24,61,62, +26,25,62,63, +27,26,63,64, +28,27,64,65, +29,28,65,66, +30,29,66,67, +31,30,67,68, +32,31,68,69, +33,32,69,70, +34,33,70,71, +35,34,71,72, +36,35,72,73, +37,36,73,74, +1,37,74,38, +39,38,75,76, +41,40,77,78, +42,41,78,79, +43,42,79,80, +44,43,80,81, +45,44,81,82, +46,45,82,83, +47,46,83,84, +48,47,84,85, +49,48,85,86, +50,49,86,87, +51,50,87,88, +52,51,88,89, +53,52,89,90, +54,53,90,91, +55,54,91,92, +56,55,92,93, +57,56,93,94, +58,57,94,95, +59,58,95,96, +60,59,96,97, +61,60,97,98, +62,61,98,99, +63,62,99,100, +64,63,100,101, +65,64,101,102, +66,65,102,103, +67,66,103,104, +68,67,104,105, +69,68,105,106, +70,69,106,107, +71,70,107,108, +72,71,108,109, +73,72,109,110, +74,73,110,111, +38,74,111,75, +76,75,112,113, +78,77,114,115, +79,78,115,116, +80,79,116,117, +81,80,117,118, +82,81,118,119, +83,82,119,120, +84,83,120,121, +85,84,121,122, +86,85,122,123, +87,86,123,124, +88,87,124,125, +89,88,125,126, +90,89,126,127, +91,90,127,128, +92,91,128,129, +93,92,129,130, +94,93,130,131, +95,94,131,132, +96,95,132,133, +97,96,133,134, +98,97,134,135, +99,98,135,136, +100,99,136,137, +101,100,137,138, +102,101,138,139, +103,102,139,140, +104,103,140,141, +105,104,141,142, +106,105,142,143, +107,106,143,144, +108,107,144,145, +109,108,145,146, +110,109,146,147, +111,110,147,148, +75,111,148,112, +113,112,149,150, +115,114,151,152, +116,115,152,153, +117,116,153,154, +118,117,154,155, +119,118,155,156, +120,119,156,157, +121,120,157,158, +122,121,158,159, +123,122,159,160, +124,123,160,161, +125,124,161,162, +126,125,162,163, +127,126,163,164, +128,127,164,165, +129,128,165,166, +130,129,166,167, +131,130,167,168, +132,131,168,169, +133,132,169,170, +134,133,170,171, +135,134,171,172, +136,135,172,173, +137,136,173,174, +138,137,174,175, +139,138,175,176, +140,139,176,177, +141,140,177,178, +142,141,178,179, +143,142,179,180, +144,143,180,181, +145,144,181,182, +146,145,182,183, +147,146,183,184, +148,147,184,185, +112,148,185,149, +150,149,186,187, +152,151,188,189, +153,152,189,190, +154,153,190,191, +155,154,191,192, +156,155,192,193, +157,156,193,194, +158,157,194,195, +159,158,195,196, +160,159,196,197, +161,160,197,198, +162,161,198,199, +163,162,199,200, +164,163,200,201, +165,164,201,202, +166,165,202,203, +167,166,203,204, +168,167,204,205, +169,168,205,206, +170,169,206,207, +171,170,207,208, +172,171,208,209, +173,172,209,210, +174,173,210,211, +175,174,211,212, +176,175,212,213, +177,176,213,214, +178,177,214,215, +179,178,215,216, +180,179,216,217, +181,180,217,218, +182,181,218,219, +183,182,219,220, +184,183,220,221, +185,184,221,222, +149,185,222,186, +187,186,223,224, +189,188,225,226, +190,189,226,227, +191,190,227,228, +192,191,228,229, +193,192,229,230, +194,193,230,231, +195,194,231,232, +196,195,232,233, +197,196,233,234, +198,197,234,235, +199,198,235,236, +200,199,236,237, +201,200,237,238, +202,201,238,239, +203,202,239,240, +204,203,240,241, +205,204,241,242, +206,205,242,243, +207,206,243,244, +208,207,244,245, +209,208,245,246, +210,209,246,247, +211,210,247,248, +212,211,248,249, +213,212,249,250, +214,213,250,251, +215,214,251,252, +216,215,252,253, +217,216,253,254, +218,217,254,255, +219,218,255,256, +220,219,256,257, +221,220,257,258, +222,221,258,259, +186,222,259,223, +224,223,260,261, +226,225,262,263, +227,226,263,264, +228,227,264,265, +229,228,265,266, +230,229,266,267, +231,230,267,268, +232,231,268,269, +233,232,269,270, +234,233,270,271, +235,234,271,272, +236,235,272,273, +237,236,273,274, +238,237,274,275, +239,238,275,276, +240,239,276,277, +241,240,277,278, +242,241,278,279, +243,242,279,280, +244,243,280,281, +245,244,281,282, +246,245,282,283, +247,246,283,284, +248,247,284,285, +249,248,285,286, +250,249,286,287, +251,250,287,288, +252,251,288,289, +253,252,289,290, +254,253,290,291, +255,254,291,292, +256,255,292,293, +257,256,293,294, +258,257,294,295, +259,258,295,296, +223,259,296,260, +261,260,297,298, +263,262,299,300, +264,263,300,301, +265,264,301,302, +266,265,302,303, +267,266,303,304, +268,267,304,305, +269,268,305,306, +270,269,306,307, +271,270,307,308, +272,271,308,309, +273,272,309,310, +274,273,310,311, +275,274,311,312, +276,275,312,313, +277,276,313,314, +278,277,314,315, +279,278,315,316, +280,279,316,317, +281,280,317,318, +282,281,318,319, +283,282,319,320, +284,283,320,321, +285,284,321,322, +286,285,322,323, +287,286,323,324, +288,287,324,325, +289,288,325,326, +290,289,326,327, +291,290,327,328, +292,291,328,329, +293,292,329,330, +294,293,330,331, +295,294,331,332, +296,295,332,333, +260,296,333,297, +298,297,334,335, +300,299,336,337, +301,300,337,338, +302,301,338,339, +303,302,339,340, +304,303,340,341, +305,304,341,342, +306,305,342,343, +307,306,343,344, +308,307,344,345, +309,308,345,346, +310,309,346,347, +311,310,347,348, +312,311,348,349, +313,312,349,350, +314,313,350,351, +315,314,351,352, +316,315,352,353, +317,316,353,354, +318,317,354,355, +319,318,355,356, +320,319,356,357, +321,320,357,358, +322,321,358,359, +323,322,359,360, +324,323,360,361, +325,324,361,362, +326,325,362,363, +327,326,363,364, +328,327,364,365, +329,328,365,366, +330,329,366,367, +331,330,367,368, +332,331,368,369, +333,332,369,370, +297,333,370,334, +335,334,371,372, +337,336,373,374, +338,337,374,375, +339,338,375,376, +340,339,376,377, +341,340,377,378, +342,341,378,379, +343,342,379,380, +344,343,380,381, +345,344,381,382, +346,345,382,383, +347,346,383,384, +348,347,384,385, +349,348,385,386, +350,349,386,387, +351,350,387,388, +352,351,388,389, +353,352,389,390, +354,353,390,391, +355,354,391,392, +356,355,392,393, +357,356,393,394, +358,357,394,395, +359,358,395,396, +360,359,396,397, +361,360,397,398, +362,361,398,399, +363,362,399,400, +364,363,400,401, +365,364,401,402, +366,365,402,403, +367,366,403,404, +368,367,404,405, +369,368,405,406, +370,369,406,407, +334,370,407,371, +372,371,408,409, +374,373,410,411, +375,374,411,412, +376,375,412,413, +377,376,413,414, +378,377,414,415, +379,378,415,416, +380,379,416,417, +381,380,417,418, +382,381,418,419, +383,382,419,420, +384,383,420,421, +385,384,421,422, +386,385,422,423, +387,386,423,424, +388,387,424,425, +389,388,425,426, +390,389,426,427, +391,390,427,428, +392,391,428,429, +393,392,429,430, +394,393,430,431, +395,394,431,432, +396,395,432,433, +397,396,433,434, +398,397,434,435, +399,398,435,436, +400,399,436,437, +401,400,437,438, +402,401,438,439, +403,402,439,440, +404,403,440,441, +405,404,441,442, +406,405,442,443, +407,406,443,444, +371,407,444,408, +409,408,445,446, +411,410,447,448, +412,411,448,449, +413,412,449,450, +414,413,450,451, +415,414,451,452, +416,415,452,453, +417,416,453,454, +418,417,454,455, +419,418,455,456, +420,419,456,457, +421,420,457,458, +422,421,458,459, +423,422,459,460, +424,423,460,461, +425,424,461,462, +426,425,462,463, +427,426,463,464, +428,427,464,465, +429,428,465,466, +430,429,466,467, +431,430,467,468, +432,431,468,469, +433,432,469,470, +434,433,470,471, +435,434,471,472, +436,435,472,473, +437,436,473,474, +438,437,474,475, +439,438,475,476, +440,439,476,477, +441,440,477,478, +442,441,478,479, +443,442,479,480, +444,443,480,481, +408,444,481,445, +446,445,482,483, +448,447,484,485, +449,448,485,486, +450,449,486,487, +451,450,487,488, +452,451,488,489, +453,452,489,490, +454,453,490,491, +455,454,491,492, +456,455,492,493, +457,456,493,494, +458,457,494,495, +459,458,495,496, +460,459,496,497, +461,460,497,498, +462,461,498,499, +463,462,499,500, +464,463,500,501, +465,464,501,502, +466,465,502,503, +467,466,503,504, +468,467,504,505, +469,468,505,506, +470,469,506,507, +471,470,507,508, +472,471,508,509, +473,472,509,510, +474,473,510,511, +475,474,511,512, +476,475,512,513, +477,476,513,514, +478,477,514,515, +479,478,515,516, +480,479,516,517, +481,480,517,518, +445,481,518,482, +483,482,519,520, +485,484,521,522, +486,485,522,523, +487,486,523,524, +488,487,524,525, +489,488,525,526, +490,489,526,527, +491,490,527,528, +492,491,528,529, +493,492,529,530, +494,493,530,531, +495,494,531,532, +496,495,532,533, +497,496,533,534, +498,497,534,535, +499,498,535,536, +500,499,536,537, +501,500,537,538, +502,501,538,539, +503,502,539,540, +504,503,540,541, +505,504,541,542, +506,505,542,543, +507,506,543,544, +508,507,544,545, +509,508,545,546, +510,509,546,547, +511,510,547,548, +512,511,548,549, +513,512,549,550, +514,513,550,551, +515,514,551,552, +516,515,552,553, +517,516,553,554, +518,517,554,555, +482,518,555,519, +520,519,556,557, +632,631,558,559, +633,632,559,560, +634,633,560,561, +635,634,561,562, +636,635,562,563, +637,636,563,564, +638,637,564,565, +639,638,565,566, +640,639,566,567, +641,640,567,568, +642,641,568,569, +643,642,569,570, +644,643,570,571, +645,644,571,572, +646,645,572,573, +647,646,573,574, +648,647,574,575, +649,648,575,576, +540,649,576,577, +541,540,577,578, +542,541,578,579, +543,542,579,580, +544,543,580,581, +545,544,581,582, +546,545,582,583, +547,546,583,584, +548,547,584,585, +549,548,585,586, +550,549,586,587, +551,550,587,588, +552,551,588,589, +553,552,589,590, +554,553,590,591, +555,554,591,592, +519,555,592,556, +557,556,593,594, +559,558,595,596, +560,559,596,597, +561,560,597,598, +562,561,598,599, +563,562,599,600, +564,563,600,601, +565,564,601,602, +566,565,602,603, +567,566,603,604, +568,567,604,605, +569,568,605,606, +570,569,606,607, +571,570,607,608, +572,571,608,609, +573,572,609,610, +574,573,610,611, +575,574,611,612, +576,575,612,613, +577,576,613,614, +578,577,614,615, +579,578,615,616, +580,579,616,617, +581,580,617,618, +582,581,618,619, +583,582,619,620, +584,583,620,621, +585,584,621,622, +586,585,622,623, +587,586,623,624, +588,587,624,625, +589,588,625,626, +590,589,626,627, +591,590,627,628, +592,591,628,629, +556,592,629,593, +594,593,630,630, +596,595,630,630, +597,596,630,630, +598,597,630,630, +599,598,630,630, +600,599,630,630, +601,600,630,630, +602,601,630,630, +603,602,630,630, +604,603,630,630, +605,604,630,630, +606,605,630,630, +607,606,630,630, +608,607,630,630, +609,608,630,630, +610,609,630,630, +611,610,630,630, +612,611,630,630, +613,612,630,630, +614,613,630,630, +615,614,630,630, +616,615,630,630, +617,616,630,630, +618,617,630,630, +619,618,630,630, +620,619,630,630, +621,620,630,630, +622,621,630,630, +623,622,630,630, +624,623,630,630, +625,624,630,630, +626,625,630,630, +627,626,630,630, +628,627,630,630, +629,628,630,630, +593,629,630,630, +0,3,40,77,114,151,188,225,262,299,336,373,410,447,484,521,522,523,524,525,526,527,528,529,530,531,532,533,534,535,536,537,538,539,540,649,648,647,646,645,644,643,642,641,640,639,638,637,636,635,634,633,632,631,558,595,630,594,557,520,483,446,409,372,335,298,261,224,187,150,113,76,39,2, diff --git a/src/maps/Arbitrary.java b/src/maps/Arbitrary.java index d5c833d..2a5960a 100644 --- a/src/maps/Arbitrary.java +++ b/src/maps/Arbitrary.java @@ -1,7 +1,7 @@ /** * MIT License * - * Copyright (c) 2017 Justin Kunimune + * Copyright (c) 2018 Justin Kunimune * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,74 +23,91 @@ */ package maps; -import java.util.Arrays; - -import utils.NumericalAnalysis; +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import maps.Projection.Property; +import maps.Projection.Type; +import utils.Math2; /** - * A class specifically for projections that use arbitrary tables of numbers. + * A class for completely arbitrary projections, where every square degree can be specified anywhere on the plane. * - * @author jkunimune + * @author Justin Kunimune */ public class Arbitrary { - private static final int ORDER = 2; //half the order of the polynomials used + private static final int NE = 0, NW = 1, SW = 2, SE = 3; + private static final int X = 0, Y = 1; - public static final Projection ROBINSON = new ArbitraryProjection( - "Robinson", "Arthur Robinson", 0.5072, new double[][] { - { -90,-85,-80,-75,-70,-65,-60,-55,-50,-45,-40,-35,-30,-25,-20,-15,-10,-05, 00, - 05, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90 }, //Latitude - { 0.5322, 0.5722, 0.6213, 0.6732, 0.7186, 0.7597, 0.7986, 0.8350, 0.8679, 0.8962, 0.9216, 0.9427, 0.9600, 0.9730, 0.9822, 0.9900, 0.9954, 0.9986, 1.0000, - 0.9986, 0.9954, 0.9900, 0.9822, 0.9730, 0.9600, 0.9427, 0.9216, 0.8962, 0.8679, 0.8350, 0.7986, 0.7597, 0.7186, 0.6732, 0.6213, 0.5722, 0.5322 }, //PLEN - { -1.0000,-0.9761,-0.9394,-0.8936,-0.8435,-0.7903,-0.7346,-0.6769,-0.6176,-0.5571,-0.4958,-0.4340,-0.3720,-0.3100,-0.2480,-0.1860,-0.1240,-0.0620, 0.0000, - 0.0620, 0.1240, 0.1860, 0.2480, 0.3100, 0.3720, 0.4340, 0.4958, 0.5571, 0.6176, 0.6769, 0.7346, 0.7903, 0.8435, 0.8936, 0.9394, 0.9761, 1.0000 } //PDFE - }); - - - public static final Projection NATURAL_EARTH = new ArbitraryProjection( - "Natural Earth", "Tom Patterson", 0.520, new double[][] { - { -90,-85,-80,-75,-70,-65,-60,-55,-50,-45,-40,-35,-30,-25,-20,-15,-10,-05, 00, - 05, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90 }, //Latitude - { 0.5630, 0.6270, 0.6754, 0.7160, 0.7525, 0.7874, 0.8196, 0.8492, 0.8763, 0.9006, 0.9222, 0.9409, 0.9570, 0.9703, 0.9811, 0.9894, 0.9953, 0.9988, 1.0000, - 0.9988, 0.9953, 0.9894, 0.9811, 0.9703, 0.9570, 0.9409, 0.9222, 0.9006, 0.8763, 0.8492, 0.8196, 0.7874, 0.7525, 0.7160, 0.6754, 0.6270, 0.5630 }, //PLEN - { -1.0000,-0.9761,-0.9394,-0.8936,-0.8435,-0.7903,-0.7346,-0.6769,-0.6176,-0.5571,-0.4958,-0.4340,-0.3720,-0.3100,-0.2480,-0.1860,-0.1240,-0.06200, 0.0000, - 0.0620, 0.1240, 0.1860, 0.2480, 0.3100, 0.3720, 0.4340, 0.4958, 0.5571, 0.6176, 0.6769, 0.7346, 0.7903, 0.8435, 0.8936, 0.9394, 0.9761, 1.0000 } //PDFE - }); + public static final ArbitraryProjection DANSEIJI_III = new ArbitraryProjection( + "Danseiji III", "A map optimised to move distortion from the continents into the oceans", + true, Type.OTHER, Property.COMPROMISE, "danseijiIII.csv"); private static class ArbitraryProjection extends Projection { - private final double yMax; - private final double[][] table; + private double[][] vertices; // the vertex x-y coordinates + private int[][][] cells; // the indices of the corner of each cell - public ArbitraryProjection(String title, String inventor, double aspectRatio, double[][] table) { - super(title, 2, 2*aspectRatio, 0b1111, Type.PSEUDOCYLINDRICAL, Property.COMPROMISE, 2, - null, "designed by "+inventor); - this.yMax = aspectRatio; - this.table = table; + public ArbitraryProjection(String title, String description, boolean interrupted, Type type, Property property, String filename) { + super(title, description, 0, 0, interrupted ? 0b1010 : 0b1011, type, property, 4); + + BufferedReader in = null; + try { + in = new BufferedReader(new FileReader(String.format("src/data/%s", filename))); // parsing the input mesh is pretty simple + String[] row = in.readLine().split(","); // get the header + vertices = new double[Integer.parseInt(row[0])][2]; + cells = new int[Integer.parseInt(row[1])][Integer.parseInt(row[2])][4]; + width = Double.parseDouble(row[3]); + height = Double.parseDouble(row[4]); + for (int i = 0; i < vertices.length; i ++) { // do the vertex coordinates + row = in.readLine().split(","); + for (int j = 0; j < vertices[i].length; j ++) + vertices[i][j] = Double.parseDouble(row[j]); + } + for (int i = 0; i < cells.length; i ++) { // get the cell vertices + for (int j = 0; j < cells[i].length; j ++) { + row = in.readLine().split(","); + for (int k = 0; k < cells[i][j].length; k ++) + cells[i][j][k] = Integer.parseInt(row[k]); + } + } // and skip the edge; it's not relevant here + } catch (IOException e) { + System.err.println("Could not load mesh: "+e); + width = 2; + height = 2; + vertices = new double[][] {{1,1},{-1,1},{-1,-1},{1,-1}}; + cells = new int[][][] {{{0,1,2,3}}}; + } finally { + try { + if (in != null) in.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } } + public double[] project(double lat, double lon) { + int i = (int)Math2.floorMod((Math.PI/2-lat)/Math.PI*cells.length, cells.length); + int j = (int)Math2.floorMod((lon+Math.PI)/(2*Math.PI)*cells[i].length, cells[i].length); + double cs = Math2.floorMod((Math.PI/2-lat)/Math.PI*cells.length, 1); + double cw = 1 - Math2.floorMod((lon+Math.PI)/(2*Math.PI)*cells[i].length, 1); + double cn = 1 - cs; + double ce = 1 - cw; + double[] ne = vertices[cells[i][j][NE]], nw = vertices[cells[i][j][NW]], + sw = vertices[cells[i][j][SW]], se = vertices[cells[i][j][SE]]; return new double[] { - lon/Math.PI*smartInterpolate(Math.toDegrees(lat), table[0], table[1], ORDER), - yMax*smartInterpolate(Math.toDegrees(lat), table[0], table[2], ORDER) }; + cs*cw*sw[X] + cs*ce*se[X] + cn*cw*nw[X] + cn*ce*ne[X], + cs*cw*sw[Y] + cs*ce*se[Y] + cn*cw*nw[Y] + cn*ce*ne[Y] }; } + public double[] inverse(double x, double y) { - return new double[] { - Math.toRadians(smartInterpolate(y/yMax, table[2], table[0], ORDER)), - Math.PI*x/smartInterpolate(y/yMax, table[2], table[1], ORDER) }; + return null; // TODO } - - private static double smartInterpolate(double x, double[] X, double[] f, int k) { - int i = Arrays.binarySearch(X, x); - if (i < 0) i = -i - 1; //if you couldn't find it, don't worry about it - return NumericalAnalysis.aitkenInterpolate(x, X, f, - Math.max(i-k,0), Math.min(i+k,X.length)); //just call aitken with the correct bounds - } - } - } diff --git a/src/maps/ArbitraryPseudocylindrical.java b/src/maps/ArbitraryPseudocylindrical.java new file mode 100644 index 0000000..2f78439 --- /dev/null +++ b/src/maps/ArbitraryPseudocylindrical.java @@ -0,0 +1,96 @@ +/** + * MIT License + * + * Copyright (c) 2017 Justin Kunimune + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package maps; + +import java.util.Arrays; + +import utils.NumericalAnalysis; + +/** + * A class specifically for pseudocylindrical projections that use arbitrary tables of numbers. + * + * @author jkunimune + */ +public class ArbitraryPseudocylindrical { + + private static final int ORDER = 2; //half the order of the polynomials used + + + public static final Projection ROBINSON = new ArbitraryProjection( + "Robinson", "Arthur Robinson", 0.5072, new double[][] { + { -90,-85,-80,-75,-70,-65,-60,-55,-50,-45,-40,-35,-30,-25,-20,-15,-10,-05, 00, + 05, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90 }, //Latitude + { 0.5322, 0.5722, 0.6213, 0.6732, 0.7186, 0.7597, 0.7986, 0.8350, 0.8679, 0.8962, 0.9216, 0.9427, 0.9600, 0.9730, 0.9822, 0.9900, 0.9954, 0.9986, 1.0000, + 0.9986, 0.9954, 0.9900, 0.9822, 0.9730, 0.9600, 0.9427, 0.9216, 0.8962, 0.8679, 0.8350, 0.7986, 0.7597, 0.7186, 0.6732, 0.6213, 0.5722, 0.5322 }, //PLEN + { -1.0000,-0.9761,-0.9394,-0.8936,-0.8435,-0.7903,-0.7346,-0.6769,-0.6176,-0.5571,-0.4958,-0.4340,-0.3720,-0.3100,-0.2480,-0.1860,-0.1240,-0.0620, 0.0000, + 0.0620, 0.1240, 0.1860, 0.2480, 0.3100, 0.3720, 0.4340, 0.4958, 0.5571, 0.6176, 0.6769, 0.7346, 0.7903, 0.8435, 0.8936, 0.9394, 0.9761, 1.0000 } //PDFE + }); + + + public static final Projection NATURAL_EARTH = new ArbitraryProjection( + "Natural Earth", "Tom Patterson", 0.520, new double[][] { + { -90,-85,-80,-75,-70,-65,-60,-55,-50,-45,-40,-35,-30,-25,-20,-15,-10,-05, 00, + 05, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90 }, //Latitude + { 0.5630, 0.6270, 0.6754, 0.7160, 0.7525, 0.7874, 0.8196, 0.8492, 0.8763, 0.9006, 0.9222, 0.9409, 0.9570, 0.9703, 0.9811, 0.9894, 0.9953, 0.9988, 1.0000, + 0.9988, 0.9953, 0.9894, 0.9811, 0.9703, 0.9570, 0.9409, 0.9222, 0.9006, 0.8763, 0.8492, 0.8196, 0.7874, 0.7525, 0.7160, 0.6754, 0.6270, 0.5630 }, //PLEN + { -1.0000,-0.9761,-0.9394,-0.8936,-0.8435,-0.7903,-0.7346,-0.6769,-0.6176,-0.5571,-0.4958,-0.4340,-0.3720,-0.3100,-0.2480,-0.1860,-0.1240,-0.06200, 0.0000, + 0.0620, 0.1240, 0.1860, 0.2480, 0.3100, 0.3720, 0.4340, 0.4958, 0.5571, 0.6176, 0.6769, 0.7346, 0.7903, 0.8435, 0.8936, 0.9394, 0.9761, 1.0000 } //PDFE + }); + + + + private static class ArbitraryProjection extends Projection { + + private final double yMax; + private final double[][] table; + + public ArbitraryProjection(String title, String inventor, double aspectRatio, double[][] table) { + super(title, 2, 2*aspectRatio, 0b1111, Type.PSEUDOCYLINDRICAL, Property.COMPROMISE, 2, + null, "designed by "+inventor); + this.yMax = aspectRatio; + this.table = table; + } + + public double[] project(double lat, double lon) { + return new double[] { + lon/Math.PI*smartInterpolate(Math.toDegrees(lat), table[0], table[1], ORDER), + yMax*smartInterpolate(Math.toDegrees(lat), table[0], table[2], ORDER) }; + } + + public double[] inverse(double x, double y) { + return new double[] { + Math.toRadians(smartInterpolate(y/yMax, table[2], table[0], ORDER)), + Math.PI*x/smartInterpolate(y/yMax, table[2], table[1], ORDER) }; + } + + private static double smartInterpolate(double x, double[] X, double[] f, int k) { + int i = Arrays.binarySearch(X, x); + if (i < 0) i = -i - 1; //if you couldn't find it, don't worry about it + return NumericalAnalysis.aitkenInterpolate(x, X, f, + Math.max(i-k,0), Math.min(i+k,X.length)); //call aitken with the correct bounds + } + + } + +}