├── .gitignore ├── LICENSE ├── Logs.txt ├── README.md ├── build.xml ├── nbproject ├── build-impl.xml ├── genfiles.properties ├── private │ ├── config.properties │ └── private.xml.0.nblh~ ├── project.properties └── project.xml └── src ├── ch └── ethz │ └── karto │ ├── data │ └── continents.ung │ └── gui │ ├── LineProjector.java │ ├── Main.java │ ├── MapComponent.java │ ├── MapLine.java │ ├── MapPoint.java │ ├── ProjectionSelectionPanel.form │ ├── ProjectionSelectionPanel.java │ └── UngenerateImporter.java ├── com └── jhlabs │ └── map │ ├── AngleFormat.java │ ├── Datum.java │ ├── DegreeUnit.java │ ├── Ellipsoid.java │ ├── GeodeticPosition.java │ ├── MapMath.java │ ├── Unit.java │ ├── Units.java │ └── proj │ ├── AiryProjection.java │ ├── AitoffProjection.java │ ├── AlbersProjection.java │ ├── Apian1Projection.java │ ├── Apian2Projection.java │ ├── ArdenCloseProjection.java │ ├── AspectAdaptiveProjection.java │ ├── AugustProjection.java │ ├── AzimuthalProjection.java │ ├── BaconProjection.java │ ├── BipolarProjection.java │ ├── BoggsProjection.java │ ├── BonneProjection.java │ ├── BraunCylindricalStereographicProjection.java │ ├── CassiniProjection.java │ ├── CentralCylindricalProjection.java │ ├── CollignonProjection.java │ ├── CompactMillerProjection.java │ ├── ConicProjection.java │ ├── CrasterProjection.java │ ├── CylindricalEqualAreaProjection.java │ ├── CylindricalProjection.java │ ├── DenoyerProjection.java │ ├── Eckert1Projection.java │ ├── Eckert2Projection.java │ ├── Eckert3Projection.java │ ├── Eckert4Projection.java │ ├── Eckert5Projection.java │ ├── Eckert6Projection.java │ ├── EckertGreifendorffProjection.java │ ├── EllipticalPseudoCylindrical.java │ ├── EqualAreaAzimuthalProjection.java │ ├── EqualEarthProjection.java │ ├── EquidistantAzimuthalProjection.java │ ├── EquidistantConicProjection.java │ ├── EquidistantCylindricalProjection.java │ ├── EulerProjection.java │ ├── FaheyProjection.java │ ├── FoucautProjection.java │ ├── FoucautSinusoidalProjection.java │ ├── Fournier2Projection.java │ ├── GallPetersProjection.java │ ├── GallProjection.java │ ├── Ginzburg8Projection.java │ ├── GnomonicAzimuthalProjection.java │ ├── GoodeProjection.java │ ├── HammerProjection.java │ ├── HatanoProjection.java │ ├── HolzelProjection.java │ ├── HufnagelProjection.java │ ├── Kavrayskiy1Projection.java │ ├── Kavrayskiy5Projection.java │ ├── Kavrayskiy7Projection.java │ ├── LagrangeProjection.java │ ├── LambertAzimuthalEqualAreaProjection.java │ ├── LambertConformalConicProjection.java │ ├── LambertEqualAreaConicProjection.java │ ├── LandsatProjection.java │ ├── LarriveeProjection.java │ ├── LaskowskiProjection.java │ ├── LinearProjection.java │ ├── LoximuthalProjection.java │ ├── McBrydeThomasFlatPolarParabolicProjection.java │ ├── McBrydeThomasFlatPolarQuarticProjection.java │ ├── McBrydeThomasFlatPolarSine2Projection.java │ ├── McBrydeThomasFlatPolarSinusoidalProjection.java │ ├── McBrydeThomasSine1Projection.java │ ├── MercatorProjection.java │ ├── MillerCylindrical1Projection.java │ ├── MillerCylindrical2Projection.java │ ├── ModStereoProjection.java │ ├── ModifiedAzimuthalProjection.java │ ├── MollweideProjection.java │ ├── Murdoch1Projection.java │ ├── Murdoch2Projection.java │ ├── Murdoch3Projection.java │ ├── NZMGProjection.java │ ├── NaturalEarth2Projection.java │ ├── NaturalEarthProjection.java │ ├── NellHammerProjection.java │ ├── NellProjection.java │ ├── NicolosiProjection.java │ ├── NullProjection.java │ ├── ObliqueMercatorProjection.java │ ├── OrteliusProjection.java │ ├── OrthographicAzimuthalProjection.java │ ├── OtherProjections.java │ ├── PattersonProjection.java │ ├── PerspectiveConicProjection.java │ ├── PerspectiveProjection.java │ ├── PolyconicProjection.java │ ├── Projection.java │ ├── ProjectionException.java │ ├── ProjectionFactory.java │ ├── PseudoCylindricalProjection.java │ ├── PutninsP1Projection.java │ ├── PutninsP2Projection.java │ ├── PutninsP4PProjection.java │ ├── PutninsP5PProjection.java │ ├── PutninsP5Projection.java │ ├── QuarticAuthalicProjection.java │ ├── RectangularPolyconicProjection.java │ ├── RobinsonProjection.java │ ├── STSProjection.java │ ├── SimpleConicProjection.java │ ├── SinusoidalProjection.java │ ├── StereographicAzimuthalProjection.java │ ├── SwissObliqueMercatorProjection.java │ ├── TCCProjection.java │ ├── TCEAProjection.java │ ├── TissotProjection.java │ ├── ToblerMercator.java │ ├── TransformedLambertAzimuthalTransverse.java │ ├── TransverseMercatorProjection.java │ ├── URMFPSProjection.java │ ├── UniversalTransverseMercatorProjection.java │ ├── VanDerGrintenProjection.java │ ├── VitkovskyProjection.java │ ├── Wagner1Projection.java │ ├── Wagner2Projection.java │ ├── Wagner3Projection.java │ ├── Wagner4Projection.java │ ├── Wagner5Projection.java │ ├── Wagner6Projection.java │ ├── Wagner7Projection.java │ ├── Werenskiold1Projection.java │ ├── Winkel1Projection.java │ ├── Winkel2Projection.java │ └── WinkelTripelProjection.java └── coordsys ├── epsg ├── esri ├── nad27 ├── nad83 └── world /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.class 3 | *.DS_Store 4 | dist/* 5 | build/* 6 | nbproject/private/* -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | JMapProjLib 2 | =========== 3 | 4 | Java Map Projection Library 5 | 6 | A partial Java port of the PROJ.4 map projection library. Most projections are implemented, but datum conversion support is lacking. EPSG parameter support is preliminary and contains bugs. Usage of EPSG with JMapProjLib is not currently recommended. 7 | 8 | JMapProjLib currently has various [bugs](https://github.com/OSUCartography/JMapProjLib/issues). Please let us know if you find undocumented bugs. 9 | 10 | Original port by Jerry Huxtable www.jhlabs.com, now maintained by the [Cartography and Geovisualization Group](http://cartography.oregonstate.edu), Oregon State University. 11 | 12 | A Netbeans project is included, but only the demo application in [src/ch/ethz/karto](src/ch/ethz/karto) uses the Netbeans GUI builder. 13 | -------------------------------------------------------------------------------- /build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Builds, tests, and runs the project JMapProjLib. 12 | 13 | 73 | 74 | -------------------------------------------------------------------------------- /nbproject/genfiles.properties: -------------------------------------------------------------------------------- 1 | build.xml.data.CRC32=2f6619f6 2 | build.xml.script.CRC32=ca84e39b 3 | build.xml.stylesheet.CRC32=8064a381@1.75.2.48 4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. 5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. 6 | nbproject/build-impl.xml.data.CRC32=2f6619f6 7 | nbproject/build-impl.xml.script.CRC32=2924a279 8 | nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48 9 | -------------------------------------------------------------------------------- /nbproject/private/config.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSUCartography/JMapProjLib/61429b4edb79885f12d7b0e73ad870bd37a3dbe2/nbproject/private/config.properties -------------------------------------------------------------------------------- /nbproject/private/private.xml.0.nblh~: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /nbproject/project.properties: -------------------------------------------------------------------------------- 1 | annotation.processing.enabled=true 2 | annotation.processing.enabled.in.editor=false 3 | annotation.processing.processors.list= 4 | annotation.processing.run.all.processors=true 5 | application.title=JMapProjLib 6 | application.vendor= 7 | build.classes.dir=${build.dir}/classes 8 | build.classes.excludes=**/*.java,**/*.form 9 | # This directory is removed when the project is cleaned: 10 | build.dir=build 11 | build.generated.dir=${build.dir}/generated 12 | build.generated.sources.dir=${build.dir}/generated-sources 13 | # Only compile against the classpath explicitly listed here: 14 | build.sysclasspath=ignore 15 | build.test.classes.dir=${build.dir}/test/classes 16 | build.test.results.dir=${build.dir}/test/results 17 | # Uncomment to specify the preferred debugger connection transport: 18 | #debug.transport=dt_socket 19 | debug.classpath=\ 20 | ${run.classpath} 21 | debug.test.classpath=\ 22 | ${run.test.classpath} 23 | # This directory is removed when the project is cleaned: 24 | dist.dir=dist 25 | dist.jar=${dist.dir}/JMapProjLib.jar 26 | dist.javadoc.dir=${dist.dir}/javadoc 27 | endorsed.classpath= 28 | excludes= 29 | includes=** 30 | jar.archive.disabled=${jnlp.enabled} 31 | jar.compress=false 32 | jar.index=${jnlp.enabled} 33 | javac.classpath= 34 | # Space-separated list of extra javac options 35 | javac.compilerargs= 36 | javac.deprecation=true 37 | javac.external.vm=false 38 | javac.processorpath=\ 39 | ${javac.classpath} 40 | javac.source=1.8 41 | javac.target=1.8 42 | javac.test.classpath=\ 43 | ${javac.classpath}:\ 44 | ${build.classes.dir} 45 | javadoc.additionalparam= 46 | javadoc.author=false 47 | javadoc.encoding=${source.encoding} 48 | javadoc.noindex=false 49 | javadoc.nonavbar=false 50 | javadoc.notree=false 51 | javadoc.private=false 52 | javadoc.splitindex=true 53 | javadoc.use=true 54 | javadoc.version=false 55 | javadoc.windowtitle= 56 | jnlp.codebase.type=no.codebase 57 | jnlp.descriptor=application 58 | jnlp.enabled=false 59 | jnlp.mixed.code=default 60 | jnlp.offline-allowed=false 61 | jnlp.signed=false 62 | jnlp.signing= 63 | jnlp.signing.alias= 64 | jnlp.signing.keystore= 65 | main.class=ch.ethz.karto.gui.Main 66 | meta.inf.dir=${src.dir}/META-INF 67 | mkdist.disabled=false 68 | platform.active=default_platform 69 | run.classpath=\ 70 | ${javac.classpath}:\ 71 | ${build.classes.dir} 72 | # Space-separated list of JVM arguments used when running the project 73 | # (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value 74 | # or test-sys-prop.name=value to set system properties for unit tests): 75 | run.jvmargs= 76 | run.test.classpath=\ 77 | ${javac.test.classpath}:\ 78 | ${build.test.classes.dir} 79 | source.encoding=MacRoman 80 | src.dir=src 81 | test.src.dir=test 82 | -------------------------------------------------------------------------------- /nbproject/project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.netbeans.modules.java.j2seproject 4 | 5 | 6 | JMapProjLib 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/ch/ethz/karto/gui/Main.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Main.java 3 | * 4 | * Created on September 15, 2006, 4:59 PM 5 | * 6 | */ 7 | 8 | package ch.ethz.karto.gui; 9 | 10 | import java.awt.BorderLayout; 11 | import java.io.InputStream; 12 | import java.net.URL; 13 | import java.util.ArrayList; 14 | import javax.swing.JFrame; 15 | 16 | /** 17 | * The main class. 18 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich. 19 | */ 20 | public class Main { 21 | 22 | private static final String CONTINENTS_PATH = "/ch/ethz/karto/data/continents.ung"; 23 | 24 | /** 25 | * The program starts with this method. 26 | * @param args the command line arguments 27 | */ 28 | public static void main(String[] args) { 29 | 30 | java.awt.EventQueue.invokeLater(new Runnable() { 31 | public void run() { 32 | createWindow(); 33 | } 34 | }); 35 | } 36 | 37 | /** 38 | * Create a window, ask the user for lines to display, import the lines, 39 | * and display them. 40 | **/ 41 | private static void createWindow() { 42 | 43 | try { 44 | 45 | // create a new window 46 | JFrame mapWindow = new JFrame("JMapProjLib"); 47 | mapWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 48 | ProjectionSelectionPanel panel = new ProjectionSelectionPanel(); 49 | mapWindow.getContentPane().add(panel, BorderLayout.CENTER); 50 | mapWindow.pack(); 51 | mapWindow.setLocationRelativeTo(null); // center on screen 52 | mapWindow.setVisible(true); 53 | 54 | URL url = Main.class.getResource(CONTINENTS_PATH); 55 | InputStream stream = url.openStream(); 56 | ArrayList lines = UngenerateImporter.importData(stream); 57 | 58 | // pass the lines to the map component 59 | panel.setLines(lines); 60 | 61 | } catch (Exception exc) { 62 | exc.printStackTrace(); 63 | System.exit(1); 64 | } 65 | 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/ch/ethz/karto/gui/MapPoint.java: -------------------------------------------------------------------------------- 1 | package ch.ethz.karto.gui; 2 | 3 | public final class MapPoint { 4 | 5 | public MapPoint() { 6 | } 7 | 8 | public MapPoint (double x, double y) { 9 | this.x = x; 10 | this.y = y; 11 | } 12 | 13 | @Override 14 | public boolean equals(Object obj) { 15 | MapPoint p = (MapPoint)obj; 16 | return x == p.x && y == p.y; 17 | } 18 | 19 | public double x; 20 | public double y; 21 | } 22 | -------------------------------------------------------------------------------- /src/ch/ethz/karto/gui/ProjectionSelectionPanel.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSUCartography/JMapProjLib/61429b4edb79885f12d7b0e73ad870bd37a3dbe2/src/ch/ethz/karto/gui/ProjectionSelectionPanel.java -------------------------------------------------------------------------------- /src/ch/ethz/karto/gui/UngenerateImporter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * UngenerateImporter.java 3 | * 4 | * Created on April 1, 2005, 12:02 PM 5 | */ 6 | 7 | package ch.ethz.karto.gui; 8 | 9 | import java.io.BufferedReader; 10 | import java.io.FileInputStream; 11 | import java.io.IOException; 12 | import java.io.InputStream; 13 | import java.io.InputStreamReader; 14 | import java.util.ArrayList; 15 | import java.util.NoSuchElementException; 16 | import java.util.StringTokenizer; 17 | 18 | 19 | /** 20 | * An importer for the ESRI Ungenerate file format. 21 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich. 22 | */ 23 | public class UngenerateImporter { 24 | 25 | private UngenerateImporter() { 26 | } 27 | 28 | /** 29 | * Reads an Ungenerate file and returns the found lines in a Vector. 30 | * @param filePath The file to import. 31 | * @return A Vector containing all read MapLines. 32 | */ 33 | public static ArrayList importData(String filePath) throws IOException { 34 | return importData (new FileInputStream(filePath)); 35 | } 36 | 37 | public static ArrayList importData(InputStream inputStream) throws IOException { 38 | // store the read lines in this vector. 39 | ArrayList lines = new ArrayList(); 40 | 41 | // open the file 42 | BufferedReader in = new BufferedReader(new InputStreamReader(inputStream)); 43 | 44 | // read lines until we reach the end of the file 45 | try { 46 | String idStr; 47 | while ((idStr = in.readLine()) != null) { 48 | MapLine line = readLine(in); 49 | if (line != null) { 50 | lines.add(line); 51 | } 52 | } 53 | } finally { 54 | in.close(); 55 | } 56 | 57 | // return the read lines 58 | return lines; 59 | } 60 | 61 | /** 62 | * Reads a MapLine from the current file position. 63 | * @param in The reader that provides the data to read. 64 | * @return MapLine The read line. 65 | */ 66 | private static MapLine readLine(BufferedReader in) throws java.io.IOException { 67 | String str; 68 | MapLine line = new MapLine(); 69 | 70 | while (true) { 71 | str = in.readLine(); 72 | if (str == null || str.length() == 0) { 73 | break; 74 | } 75 | str = str.trim().toLowerCase(); 76 | if (str.startsWith("end") ) { 77 | break; 78 | } 79 | try { 80 | StringTokenizer tokenizer = new StringTokenizer(str, " \t,"); 81 | double x = Double.parseDouble((String)tokenizer.nextToken()); 82 | double y = Double.parseDouble((String)tokenizer.nextToken()); 83 | line.addPoint(x, y); 84 | } catch (NoSuchElementException e) { 85 | // found a line without any readable data. Just read the next line 86 | } 87 | } 88 | return line; 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/DegreeUnit.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package com.jhlabs.map; 18 | 19 | import java.text.*; 20 | 21 | public class DegreeUnit extends Unit { 22 | 23 | static final long serialVersionUID = -3212757578604686538L; 24 | 25 | private static AngleFormat format = new AngleFormat(AngleFormat.ddmmssPattern, true); 26 | 27 | public DegreeUnit() { 28 | super("degree", "degrees", "deg", 1); 29 | } 30 | 31 | public double parse(String s) throws NumberFormatException { 32 | try { 33 | return format.parse(s).doubleValue(); 34 | } 35 | catch (java.text.ParseException e) { 36 | throw new NumberFormatException(e.getMessage()); 37 | } 38 | } 39 | 40 | public String format(double n) { 41 | return format.format(n)+" "+abbreviation; 42 | } 43 | 44 | public String format(double n, boolean abbrev) { 45 | if (abbrev) 46 | return format.format(n)+" "+abbreviation; 47 | return format.format(n); 48 | } 49 | 50 | public String format(double x, double y, boolean abbrev) { 51 | if (abbrev) 52 | return format.format(x)+"/"+format.format(y)+" "+abbreviation; 53 | return format.format(x)+"/"+format.format(y); 54 | } 55 | } 56 | 57 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/GeodeticPosition.java: -------------------------------------------------------------------------------- 1 | package com.jhlabs.map; 2 | 3 | public class GeodeticPosition { 4 | 5 | public double lat; 6 | public double lon; 7 | public double h; 8 | 9 | public GeodeticPosition() { 10 | lat = 0; 11 | lon = 0; 12 | h = 0; 13 | } 14 | 15 | public GeodeticPosition(double lat, double lon) { 16 | this.lat = lat; 17 | this.lon = lon; 18 | this.h = 0; 19 | } 20 | 21 | public GeodeticPosition(double lat, double lon, double h) { 22 | this.lat = lat; 23 | this.lon = lon; 24 | this.h = h; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/Unit.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package com.jhlabs.map; 18 | 19 | import java.io.*; 20 | import java.text.*; 21 | 22 | public class Unit implements Serializable { 23 | 24 | static final long serialVersionUID = -6704954923429734628L; 25 | 26 | public final static int ANGLE_UNIT = 0; 27 | public final static int LENGTH_UNIT = 1; 28 | public final static int AREA_UNIT = 2; 29 | public final static int VOLUME_UNIT = 3; 30 | 31 | public String name, plural, abbreviation; 32 | public double value; 33 | public static NumberFormat format; 34 | 35 | static { 36 | format = NumberFormat.getNumberInstance(); 37 | format.setMaximumFractionDigits(2); 38 | format.setGroupingUsed(false); 39 | } 40 | 41 | public Unit(String name, String plural, String abbreviation, double value) { 42 | this.name = name; 43 | this.plural = plural; 44 | this.abbreviation = abbreviation; 45 | this.value = value; 46 | } 47 | 48 | public double toBase(double n) { 49 | return n * value; 50 | } 51 | 52 | public double fromBase(double n) { 53 | return n / value; 54 | } 55 | 56 | public double parse(String s) throws NumberFormatException { 57 | try { 58 | return format.parse(s).doubleValue(); 59 | } 60 | catch (java.text.ParseException e) { 61 | throw new NumberFormatException(e.getMessage()); 62 | } 63 | } 64 | 65 | public String format(double n) { 66 | return format.format(n)+" "+abbreviation; 67 | } 68 | 69 | public String format(double n, boolean abbrev) { 70 | if (abbrev) 71 | return format.format(n)+" "+abbreviation; 72 | return format.format(n); 73 | } 74 | 75 | public String format(double x, double y, boolean abbrev) { 76 | if (abbrev) 77 | return format.format(x)+"/"+format.format(y)+" "+abbreviation; 78 | return format.format(x)+"/"+format.format(y); 79 | } 80 | 81 | public String format(double x, double y) { 82 | return format(x, y, true); 83 | } 84 | 85 | public String toString() { 86 | return plural; 87 | } 88 | 89 | public boolean equals(Object o) { 90 | if (o instanceof Unit) { 91 | return ((Unit)o).value == value; 92 | } 93 | return false; 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/Units.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package com.jhlabs.map; 18 | 19 | import java.io.*; 20 | import java.text.*; 21 | 22 | public class Units { 23 | 24 | // Angular units 25 | public final static Unit DEGREES = new DegreeUnit(); 26 | public final static Unit RADIANS = new Unit("radian", "radians", "rad", Math.toDegrees(1)); 27 | public final static Unit ARC_MINUTES = new Unit("arc minute", "arc minutes", "min", 1/60.0); 28 | public final static Unit ARC_SECONDS = new Unit("arc second", "arc seconds", "sec", 1/3600.0); 29 | 30 | // Distance units 31 | 32 | // Metric units 33 | public final static Unit KILOMETRES = new Unit("kilometre", "kilometres", "km", 1000); 34 | public final static Unit METRES = new Unit("metre", "metres", "m", 1); 35 | public final static Unit DECIMETRES = new Unit("decimetre", "decimetres", "dm", 0.1); 36 | public final static Unit CENTIMETRES = new Unit("centimetre", "centimetres", "cm", 0.01); 37 | public final static Unit MILLIMETRES = new Unit("millimetre", "millimetres", "mm", 0.001); 38 | 39 | // International units 40 | public final static Unit NAUTICAL_MILES = new Unit("nautical mile", "nautical miles", "kmi", 1852); 41 | public final static Unit MILES = new Unit("mile", "miles", "mi", 1609.344); 42 | public final static Unit CHAINS = new Unit("chain", "chains", "ch", 20.1168); 43 | public final static Unit YARDS = new Unit("yard", "yards", "yd", 0.9144); 44 | public final static Unit FEET = new Unit("foot", "feet", "ft", 0.3048); 45 | public final static Unit INCHES = new Unit("inch", "inches", "in", 0.0254); 46 | 47 | // U.S. units 48 | public final static Unit US_MILES = new Unit("U.S. mile", "U.S. miles", "us-mi", 1609.347218694437); 49 | public final static Unit US_CHAINS = new Unit("U.S. chain", "U.S. chains", "us-ch", 20.11684023368047); 50 | public final static Unit US_YARDS = new Unit("U.S. yard", "U.S. yards", "us-yd", 0.914401828803658); 51 | public final static Unit US_FEET = new Unit("U.S. foot", "U.S. feet", "us-ft", 0.304800609601219); 52 | public final static Unit US_INCHES = new Unit("U.S. inch", "U.S. inches", "us-in", 1.0/39.37); 53 | 54 | // Miscellaneous units 55 | public final static Unit FATHOMS = new Unit("fathom", "fathoms", "fath", 1.8288); 56 | public final static Unit LINKS = new Unit("link", "links", "link", 0.201168); 57 | 58 | public final static Unit POINTS = new Unit("point", "points", "point", 0.0254/72.27); 59 | 60 | public static Unit[] units = { 61 | DEGREES, 62 | KILOMETRES, METRES, DECIMETRES, CENTIMETRES, MILLIMETRES, 63 | MILES, YARDS, FEET, INCHES, 64 | US_MILES, US_YARDS, US_FEET, US_INCHES, 65 | NAUTICAL_MILES 66 | }; 67 | 68 | public static Unit findUnits(String name) { 69 | for (int i = 0; i < units.length; i++) { 70 | if (name.equals(units[i].name) || name.equals(units[i].plural) || name.equals(units[i].abbreviation)) 71 | return units[i]; 72 | } 73 | return METRES; 74 | } 75 | 76 | public static double convert(double value, Unit from, Unit to) { 77 | if (from == to) 78 | return value; 79 | return to.fromBase(from.toBase(value)); 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/AitoffProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | * 20 | * Bernhard Jenny, May 2007: Separated Aitoff from Winkel Tripel. 21 | * 23 September 2010: changed base class to ModifiedAzimuthalProjection. 22 | */ 23 | package com.jhlabs.map.proj; 24 | 25 | import java.awt.geom.Point2D; 26 | 27 | public class AitoffProjection extends ModifiedAzimuthalProjection { 28 | 29 | public AitoffProjection() { 30 | } 31 | 32 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 33 | double c = 0.5 * lplam; 34 | double d = Math.acos(Math.cos(lpphi) * Math.cos(c)); 35 | 36 | if (d != 0) { 37 | out.x = 2. * d * Math.cos(lpphi) * Math.sin(c) * (out.y = 1. / Math.sin(d)); 38 | out.y *= d * Math.sin(lpphi); 39 | } else { 40 | out.x = out.y = 0.0; 41 | } 42 | 43 | return out; 44 | } 45 | 46 | public String toString() { 47 | return "Aitoff"; 48 | } 49 | } 50 | 51 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/Apian1Projection.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSUCartography/JMapProjLib/61429b4edb79885f12d7b0e73ad870bd37a3dbe2/src/com/jhlabs/map/proj/Apian1Projection.java -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/Apian2Projection.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSUCartography/JMapProjLib/61429b4edb79885f12d7b0e73ad870bd37a3dbe2/src/com/jhlabs/map/proj/Apian2Projection.java -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/ArdenCloseProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Bernhard Jenny 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | package com.jhlabs.map.proj; 17 | 18 | import com.jhlabs.map.MapMath; 19 | import java.awt.geom.Point2D; 20 | 21 | /** 22 | * Arden-Close Projection 23 | * Arithmetic mean of the Mercator and the cylindrical equal-area projections 24 | * Code from proj4. 25 | * @author Bernhard Jenny, Oregon State University 26 | */ 27 | public class ArdenCloseProjection extends CylindricalProjection { 28 | 29 | public ArdenCloseProjection() { 30 | minLatitude = MapMath.degToRad(-85); 31 | maxLatitude = MapMath.degToRad(85); 32 | } 33 | 34 | @Override 35 | public Point2D.Double project(double lam, double phi, Point2D.Double out) { 36 | out.x = lam; 37 | final double yMercator = Math.log(Math.tan(MapMath.QUARTERPI + 0.5 * phi)); 38 | final double yCylEA = Math.sin(phi); 39 | out.y = 0.5 * (yMercator + yCylEA); 40 | return out; 41 | } 42 | 43 | public String toString() { 44 | return "Arden-Close"; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/AugustProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | package com.jhlabs.map.proj; 21 | 22 | import java.awt.geom.Point2D; 23 | 24 | public class AugustProjection extends Projection { 25 | 26 | private final static double M = 1.333333333333333; 27 | 28 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 29 | double t, c1, c, x1, x12, y1, y12; 30 | 31 | t = Math.tan(.5 * lpphi); 32 | c1 = Math.sqrt(1. - t * t); 33 | c = 1. + c1 * Math.cos(lplam *= .5); 34 | x1 = Math.sin(lplam) * c1 / c; 35 | y1 = t / c; 36 | out.x = M * x1 * (3. + (x12 = x1 * x1) - 3. * (y12 = y1 * y1)); 37 | out.y = M * y1 * (3. + 3. * x12 - y12); 38 | return out; 39 | } 40 | 41 | /** 42 | * Returns true if this projection is conformal 43 | */ 44 | public boolean isConformal() { 45 | return true; 46 | } 47 | 48 | public boolean hasInverse() { 49 | return false; 50 | } 51 | 52 | public String toString() { 53 | return "August Epicycloidal"; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/AzimuthalProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package com.jhlabs.map.proj; 18 | 19 | import com.jhlabs.map.MapMath; 20 | 21 | 22 | /** 23 | * The superclass for all azimuthal map projections 24 | */ 25 | public class AzimuthalProjection extends Projection { 26 | 27 | public final static int NORTH_POLE = 1; 28 | public final static int SOUTH_POLE = 2; 29 | public final static int EQUATOR = 3; 30 | public final static int OBLIQUE = 4; 31 | 32 | protected int mode; 33 | protected double sinphi0, cosphi0; 34 | private double mapRadius = 90.0; 35 | 36 | public AzimuthalProjection() { 37 | this( 0,0);//Math.toRadians(45.0), Math.toRadians(45.0) ); 38 | } 39 | 40 | public AzimuthalProjection(double projectionLatitude, double projectionLongitude) { 41 | this.projectionLatitude = projectionLatitude; 42 | this.projectionLongitude = projectionLongitude; 43 | initialize(); 44 | } 45 | 46 | public void initialize() { 47 | super.initialize(); 48 | if (Math.abs(Math.abs(projectionLatitude) - MapMath.HALFPI) < EPS10) 49 | mode = projectionLatitude < 0. ? SOUTH_POLE : NORTH_POLE; 50 | else if (Math.abs(projectionLatitude) > EPS10) { 51 | mode = OBLIQUE; 52 | sinphi0 = Math.sin(projectionLatitude); 53 | cosphi0 = Math.cos(projectionLatitude); 54 | } else 55 | mode = EQUATOR; 56 | } 57 | 58 | public boolean inside(double lon, double lat) { 59 | return MapMath.greatCircleDistance( Math.toRadians(lon), Math.toRadians(lat), projectionLongitude, projectionLatitude) < Math.toRadians(mapRadius); 60 | } 61 | 62 | /** 63 | * Set the map radius (in degrees). 180 shows a hemisphere, 360 shows the whole globe. 64 | */ 65 | public void setMapRadius(double mapRadius) { 66 | this.mapRadius = mapRadius; 67 | } 68 | 69 | public double getMapRadius() { 70 | return mapRadius; 71 | } 72 | 73 | } 74 | 75 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/BaconProjection.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSUCartography/JMapProjLib/61429b4edb79885f12d7b0e73ad870bd37a3dbe2/src/com/jhlabs/map/proj/BaconProjection.java -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/BoggsProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | package com.jhlabs.map.proj; 21 | 22 | import com.jhlabs.map.MapMath; 23 | import java.awt.geom.Point2D; 24 | 25 | public class BoggsProjection extends PseudoCylindricalProjection { 26 | 27 | private final static int NITER = 20; 28 | private final static double EPS = 1e-7; 29 | private final static double ONETOL = 1.000001; 30 | private final static double FXC = 2.00276; 31 | private final static double FXC2 = 1.11072; 32 | private final static double FYC = 0.49931; 33 | private final static double FYC2 = 1.41421356237309504880; 34 | 35 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 36 | double theta, th1, c; 37 | int i; 38 | 39 | theta = lpphi; 40 | if (Math.abs(Math.abs(lpphi) - MapMath.HALFPI) < EPS) 41 | out.x = 0.; 42 | else { 43 | c = Math.sin(theta) * Math.PI; 44 | for (i = NITER; i > 0; --i) { 45 | theta -= th1 = (theta + Math.sin(theta) - c) / 46 | (1. + Math.cos(theta)); 47 | if (Math.abs(th1) < EPS) break; 48 | } 49 | theta *= 0.5; 50 | out.x = FXC * lplam / (1. / Math.cos(lpphi) + FXC2 / Math.cos(theta)); 51 | } 52 | out.y = FYC * (lpphi + FYC2 * Math.sin(theta)); 53 | return out; 54 | } 55 | 56 | /** 57 | * Returns true if this projection is equal area 58 | */ 59 | public boolean isEqualArea() { 60 | return true; 61 | } 62 | 63 | public boolean hasInverse() { 64 | return false; 65 | } 66 | 67 | public String toString() { 68 | return "Boggs Eumorphic"; 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/BonneProjection.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSUCartography/JMapProjLib/61429b4edb79885f12d7b0e73ad870bd37a3dbe2/src/com/jhlabs/map/proj/BonneProjection.java -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/BraunCylindricalStereographicProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2014 Bojan Savric 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | package com.jhlabs.map.proj; 17 | 18 | import java.awt.geom.Point2D; 19 | 20 | public class BraunCylindricalStereographicProjection extends CylindricalProjection { 21 | 22 | private double cosTrueScaleLatitude = 1.0; 23 | 24 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 25 | out.x = lplam * cosTrueScaleLatitude; 26 | out.y = (1 + cosTrueScaleLatitude) * Math.tan(lpphi / 2.); 27 | return out; 28 | } 29 | 30 | public Point2D.Double projectInverse(double x, double y, Point2D.Double lp) { 31 | lp.x = x / cosTrueScaleLatitude; 32 | lp.y = 2.0 * Math.atan(y / (1 + cosTrueScaleLatitude)); 33 | return lp; 34 | } 35 | 36 | public boolean hasInverse() { 37 | return true; 38 | } 39 | 40 | public String toString() { 41 | return "Cylindrical Stereographic (Braun)"; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/CassiniProjection.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSUCartography/JMapProjLib/61429b4edb79885f12d7b0e73ad870bd37a3dbe2/src/com/jhlabs/map/proj/CassiniProjection.java -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/CentralCylindricalProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | package com.jhlabs.map.proj; 21 | 22 | import com.jhlabs.map.MapMath; 23 | import java.awt.geom.Point2D; 24 | 25 | public class CentralCylindricalProjection extends CylindricalProjection { 26 | 27 | private double ap; 28 | 29 | private final static double EPS10 = 1.e-10; 30 | 31 | public CentralCylindricalProjection() { 32 | minLatitude = Math.toRadians(-80); 33 | maxLatitude = Math.toRadians(80); 34 | } 35 | 36 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 37 | if (Math.abs(Math.abs(lpphi) - MapMath.HALFPI) <= EPS10) throw new ProjectionException("F"); 38 | out.x = lplam; 39 | out.y = Math.tan(lpphi); 40 | return out; 41 | } 42 | 43 | public Point2D.Double projectInverse(double xyx, double xyy, Point2D.Double out) { 44 | out.y = Math.atan(xyy); 45 | out.x = xyx; 46 | return out; 47 | } 48 | 49 | public boolean hasInverse() { 50 | return true; 51 | } 52 | 53 | public String toString() { 54 | return "Central Cylindrical"; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/CollignonProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | * 20 | * Bernhard Jenny, 19 September 2010: fixed inverse. 21 | * 23 September 2010: changed super class to PseudoCylindricalProjection. 22 | */ 23 | package com.jhlabs.map.proj; 24 | 25 | import com.jhlabs.map.MapMath; 26 | import java.awt.geom.Point2D; 27 | 28 | public class CollignonProjection extends PseudoCylindricalProjection { 29 | 30 | private final static double FXC = 1.12837916709551257390; 31 | private final static double FYC = 1.77245385090551602729; 32 | private final static double ONEEPS = 1.0000001; 33 | 34 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 35 | if ((out.y = 1. - Math.sin(lpphi)) <= 0.) { 36 | out.y = 0.; 37 | } else { 38 | out.y = Math.sqrt(out.y); 39 | } 40 | out.x = FXC * lplam * out.y; 41 | out.y = FYC * (1. - out.y); 42 | return out; 43 | } 44 | 45 | public Point2D.Double projectInverse(double xyx, double xyy, Point2D.Double out) { 46 | double lpphi = xyy / FYC - 1.; 47 | if (Math.abs(lpphi = 1. - lpphi * lpphi) < 1.) { 48 | lpphi = Math.asin(lpphi); 49 | } else if (Math.abs(lpphi) > ONEEPS) { 50 | throw new ProjectionException("I"); 51 | } else { 52 | lpphi = lpphi < 0. ? -MapMath.HALFPI : MapMath.HALFPI; 53 | } 54 | if ((out.x = 1. - Math.sin(lpphi)) <= 0.) { 55 | out.x = 0.; 56 | } else { 57 | out.x = xyx / (FXC * Math.sqrt(out.x)); 58 | } 59 | out.y = lpphi; 60 | return out; 61 | } 62 | 63 | /** 64 | * Returns true if this projection is equal area 65 | */ 66 | public boolean isEqualArea() { 67 | return true; 68 | } 69 | 70 | public boolean hasInverse() { 71 | return true; 72 | } 73 | 74 | public String toString() { 75 | return "Collignon"; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/CompactMillerProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2014 Bojan Savric 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | package com.jhlabs.map.proj; 17 | 18 | import java.awt.geom.*; 19 | 20 | public class CompactMillerProjection extends CylindricalProjection { 21 | 22 | private final static double K1 = 0.9902; 23 | private final static double K2 = 0.1604; 24 | private final static double K3 = -0.03054; 25 | private final static double C1 = K1; 26 | private final static double C2 = 3 * K2; 27 | private final static double C3 = 5 * K3; 28 | private final static double EPS = 1e-11; 29 | private final static double MAX_Y = 0.6000207669862655 * Math.PI; 30 | 31 | @Override 32 | public Point2D.Double project(double lon, double lat, Point2D.Double out) { 33 | final double lat_sq = lat * lat; 34 | out.x = lon; 35 | out.y = lat * (K1 + lat_sq * (K2 + K3 * lat_sq)); 36 | return out; 37 | } 38 | 39 | @Override 40 | public boolean hasInverse() { 41 | return true; 42 | } 43 | 44 | @Override 45 | public Point2D.Double projectInverse(double x, double y, Point2D.Double lp) { 46 | 47 | // make sure y is inside valid range 48 | if (y > MAX_Y) { 49 | y = MAX_Y; 50 | } else if (y < -MAX_Y) { 51 | y = -MAX_Y; 52 | } 53 | 54 | // latitude 55 | double yc = y; 56 | double tol; 57 | for (;;) { // Newton-Raphson 58 | double y2 = yc * yc; 59 | double f = (yc * (K1 + y2 * (K2 + K3 * y2))) - y; 60 | double fder = C1 + y2 * (C2 + C3 * y2); 61 | yc -= tol = f / fder; 62 | if (Math.abs(tol) < EPS) { 63 | break; 64 | } 65 | } 66 | lp.y = yc; 67 | 68 | // longitude 69 | lp.x = x; 70 | 71 | return lp; 72 | } 73 | 74 | @Override 75 | public String toString() { 76 | return "Compact Miller"; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/ConicProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | package com.jhlabs.map.proj; 17 | 18 | /** 19 | * The superclass for all Conic projections. 20 | * 21 | * Bernhard Jenny, 17 September 2010: 22 | * Moved projectionLatitude1 and projectionLatitude2 from super class to 23 | * ConicProjection, as these are specific to conics. 24 | * 25 October 2010: Constructors initializes projectionLatitude1 and 25 | * projectionLatitude2 to the value of projectionLatitude. 26 | */ 27 | public class ConicProjection extends Projection { 28 | 29 | /** 30 | * Standard parallel 1 (for projections which use it). 31 | */ 32 | protected double projectionLatitude1; 33 | /** 34 | * Standard parallel 2 (for projections which use it) 35 | */ 36 | protected double projectionLatitude2; 37 | 38 | protected ConicProjection() { 39 | projectionLatitude1 = projectionLatitude; 40 | projectionLatitude2 = projectionLatitude; 41 | } 42 | 43 | public void setProjectionLatitude1(double projectionLatitude1) { 44 | this.projectionLatitude1 = projectionLatitude1; 45 | } 46 | 47 | public double getProjectionLatitude1() { 48 | return projectionLatitude1; 49 | } 50 | 51 | public final void setProjectionLatitude1Degrees(double projectionLatitude1) { 52 | setProjectionLatitude1(DTR * projectionLatitude1); 53 | } 54 | 55 | public final double getProjectionLatitude1Degrees() { 56 | return getProjectionLatitude1() * RTD; 57 | } 58 | 59 | public void setProjectionLatitude2(double projectionLatitude2) { 60 | this.projectionLatitude2 = projectionLatitude2; 61 | } 62 | 63 | public double getProjectionLatitude2() { 64 | return projectionLatitude2; 65 | } 66 | 67 | public final void setProjectionLatitude2Degrees(double projectionLatitude2) { 68 | setProjectionLatitude2(DTR * projectionLatitude2); 69 | } 70 | 71 | public final double getProjectionLatitude2Degrees() { 72 | return getProjectionLatitude2() * RTD; 73 | } 74 | 75 | public String toString() { 76 | return "Conic"; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/CrasterProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | /** 21 | * Changed super class from Projection to PseudoCylindricalProjection. 22 | * Bernhard Jenny, May 25 2010. 23 | */ 24 | package com.jhlabs.map.proj; 25 | 26 | import java.awt.geom.Point2D; 27 | 28 | public class CrasterProjection extends PseudoCylindricalProjection { 29 | 30 | private final static double XM = 0.97720502380583984317; 31 | private final static double RXM = 1.02332670794648848847; 32 | private final static double YM = 3.06998012383946546542; 33 | private final static double RYM = 0.32573500793527994772; 34 | private final static double THIRD = 0.333333333333333333; 35 | 36 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 37 | lpphi *= THIRD; 38 | out.x = XM * lplam * (2. * Math.cos(lpphi + lpphi) - 1.); 39 | out.y = YM * Math.sin(lpphi); 40 | return out; 41 | } 42 | 43 | public Point2D.Double projectInverse(double xyx, double xyy, Point2D.Double out) { 44 | out.y = 3. * Math.asin(xyy * RYM); 45 | out.x = xyx * RXM / (2. * Math.cos((out.y + out.y) * THIRD) - 1); 46 | return out; 47 | } 48 | 49 | /** 50 | * Returns true if this projection is equal area 51 | */ 52 | public boolean isEqualArea() { 53 | return true; 54 | } 55 | 56 | public boolean hasInverse() { 57 | return true; 58 | } 59 | 60 | public String toString() { 61 | return "Craster Parabolic (Putnins P4)"; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/CylindricalEqualAreaProjection.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSUCartography/JMapProjLib/61429b4edb79885f12d7b0e73ad870bd37a3dbe2/src/com/jhlabs/map/proj/CylindricalEqualAreaProjection.java -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/CylindricalProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | /** 17 | * Removed long unrelated commented method for geometrical path splitting 18 | * by Bernhard Jenny, May 18 2010. 19 | */ 20 | package com.jhlabs.map.proj; 21 | 22 | /** 23 | * The superclass for all cylindrical projections. 24 | */ 25 | public class CylindricalProjection extends Projection { 26 | 27 | public boolean isRectilinear() { 28 | return true; 29 | } 30 | 31 | public String toString() { 32 | return "Cylindrical"; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/DenoyerProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | * Bernhard Jenny, 23 September 2010: change super class to 20 | * PseudoCylindricalProjection, removed parallelsAreParallel. 21 | */ 22 | package com.jhlabs.map.proj; 23 | 24 | import java.awt.geom.Point2D; 25 | 26 | public class DenoyerProjection extends PseudoCylindricalProjection { 27 | 28 | public final static double C0 = 0.95; 29 | public final static double C1 = -.08333333333333333333; 30 | public final static double C3 = 0.00166666666666666666; 31 | public final static double D1 = 0.9; 32 | public final static double D5 = 0.03; 33 | 34 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 35 | out.y = lpphi; 36 | out.x = lplam; 37 | double aphi = Math.abs(lplam); 38 | out.x *= Math.cos((C0 + aphi * (C1 + aphi * aphi * C3)) 39 | * (lpphi * (D1 + D5 * lpphi * lpphi * lpphi * lpphi))); 40 | return out; 41 | } 42 | 43 | public String toString() { 44 | return "Denoyer Semi-elliptical"; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/Eckert1Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | /** 21 | * Changed super class from Projection to PseudoCylindricalProjection. 22 | * Bernhard Jenny, May 25 2010. 23 | */ 24 | package com.jhlabs.map.proj; 25 | 26 | import java.awt.geom.Point2D; 27 | 28 | public class Eckert1Projection extends PseudoCylindricalProjection { 29 | 30 | private final static double FC = .92131773192356127802; 31 | private final static double RP = .31830988618379067154; 32 | 33 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 34 | out.x = FC * lplam * (1. - RP * Math.abs(lpphi)); 35 | out.y = FC * lpphi; 36 | return out; 37 | } 38 | 39 | public Point2D.Double projectInverse(double xyx, double xyy, Point2D.Double out) { 40 | out.y = xyy / FC; 41 | out.x = xyx / (FC * (1. - RP * Math.abs(out.y))); 42 | return out; 43 | } 44 | 45 | public boolean hasInverse() { 46 | return true; 47 | } 48 | 49 | public String toString() { 50 | return "Eckert I"; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/Eckert2Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | * 20 | * Bernhard Jenny, 23 September 2010: changed base class to PseudoCylindricalProjection. 21 | */ 22 | package com.jhlabs.map.proj; 23 | 24 | import com.jhlabs.map.MapMath; 25 | import java.awt.geom.Point2D; 26 | 27 | public class Eckert2Projection extends PseudoCylindricalProjection { 28 | 29 | private final static double FXC = 0.46065886596178063902; 30 | private final static double FYC = 1.44720250911653531871; 31 | private final static double C13 = 0.33333333333333333333; 32 | private final static double ONEEPS = 1.0000001; 33 | 34 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 35 | out.x = FXC * lplam * (out.y = Math.sqrt(4. - 3. * Math.sin(Math.abs(lpphi)))); 36 | out.y = FYC * (2. - out.y); 37 | if ( lpphi < 0.) out.y = -out.y; 38 | return out; 39 | } 40 | 41 | public Point2D.Double projectInverse(double xyx, double xyy, Point2D.Double out) { 42 | out.x = xyx / (FXC * ( out.y = 2. - Math.abs(xyy) / FYC) ); 43 | out.y = (4. - out.y * out.y) * C13; 44 | if (Math.abs(out.y) >= 1.) { 45 | if (Math.abs(out.y) > ONEEPS) throw new ProjectionException("I"); 46 | else 47 | out.y = out.y < 0. ? -MapMath.HALFPI : MapMath.HALFPI; 48 | } else 49 | out.y = Math.asin(out.y); 50 | if (xyy < 0) 51 | out.y = -out.y; 52 | return out; 53 | } 54 | 55 | public boolean hasInverse() { 56 | return true; 57 | } 58 | 59 | public String toString() { 60 | return "Eckert II"; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/Eckert3Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2007 Bernhard Jenny 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | 16 | * Eckert3Projection.java 17 | * 18 | * Created March 2007 19 | * 20 | */ 21 | 22 | package com.jhlabs.map.proj; 23 | 24 | /** 25 | * Eckert 3 Projection. Based on Proj4. 26 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich 27 | */ 28 | public class Eckert3Projection extends EllipticalPseudoCylindrical{ 29 | 30 | /** Creates a new instance of Eckert3Projection */ 31 | public Eckert3Projection() { 32 | super(0.42223820031577120149, 33 | 0.84447640063154240298, 34 | 1., 35 | 0.4052847345693510857755); 36 | } 37 | 38 | public String toString() { 39 | return "Eckert III"; 40 | } 41 | } -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/Eckert4Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | * 20 | * Added isEqualArea; removed two unused static variables. Changed super class 21 | * from Projection to PseudoCylindricalProjection. 22 | * Modified by Bernhard Jenny, May 2007 and May 2010. 23 | */ 24 | package com.jhlabs.map.proj; 25 | 26 | import com.jhlabs.map.MapMath; 27 | import java.awt.geom.Point2D; 28 | 29 | public class Eckert4Projection extends PseudoCylindricalProjection { 30 | 31 | private final static double C_x = .42223820031577120149; 32 | private final static double C_y = 1.32650042817700232218; 33 | private final static double C_p = 3.57079632679489661922; 34 | private final static double EPS = 1e-7; 35 | private final int NITER = 6; 36 | 37 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 38 | double p, V, s, c; 39 | int i; 40 | 41 | p = C_p * Math.sin(lpphi); 42 | V = lpphi * lpphi; 43 | lpphi *= 0.895168 + V * (0.0218849 + V * 0.00826809); 44 | for (i = NITER; i > 0; --i) { 45 | c = Math.cos(lpphi); 46 | s = Math.sin(lpphi); 47 | lpphi -= V = (lpphi + s * (c + 2.) - p) 48 | / (1. + c * (c + 2.) - s * s); 49 | if (Math.abs(V) < EPS) { 50 | break; 51 | } 52 | } 53 | if (i == 0) { 54 | out.x = C_x * lplam; 55 | out.y = lpphi < 0. ? -C_y : C_y; 56 | } else { 57 | out.x = C_x * lplam * (1. + Math.cos(lpphi)); 58 | out.y = C_y * Math.sin(lpphi); 59 | } 60 | return out; 61 | } 62 | 63 | public Point2D.Double projectInverse(double xyx, double xyy, Point2D.Double out) { 64 | double c; 65 | 66 | out.y = MapMath.asin(xyy / C_y); 67 | out.x = xyx / (C_x * (1. + (c = Math.cos(out.y)))); 68 | out.y = MapMath.asin((out.y + Math.sin(out.y) * (c + 2.)) / C_p); 69 | return out; 70 | } 71 | 72 | public boolean hasInverse() { 73 | return true; 74 | } 75 | 76 | public String toString() { 77 | return "Eckert IV"; 78 | } 79 | 80 | public boolean isEqualArea() { 81 | return true; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/Eckert5Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | /** 21 | * Changed super class from Projection to PseudoCylindricalProjection. 22 | * Bernhard Jenny, May 25 2010. 23 | */ 24 | package com.jhlabs.map.proj; 25 | 26 | import java.awt.geom.Point2D; 27 | 28 | public class Eckert5Projection extends PseudoCylindricalProjection { 29 | 30 | private final static double XF = 0.44101277172455148219; 31 | private final static double RXF = 2.26750802723822639137; 32 | private final static double YF = 0.88202554344910296438; 33 | private final static double RYF = 1.13375401361911319568; 34 | 35 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 36 | out.x = XF * (1. + Math.cos(lpphi)) * lplam; 37 | out.y = YF * lpphi; 38 | return out; 39 | } 40 | 41 | public Point2D.Double projectInverse(double xyx, double xyy, Point2D.Double out) { 42 | out.x = RXF * xyx / (1. + Math.cos(out.y = RYF * xyy)); 43 | return out; 44 | } 45 | 46 | public boolean hasInverse() { 47 | return true; 48 | } 49 | 50 | public String toString() { 51 | return "Eckert V"; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/Eckert6Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2010 Bernhard Jenny 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | package com.jhlabs.map.proj; 17 | 18 | import com.jhlabs.map.MapMath; 19 | import java.awt.geom.Point2D; 20 | 21 | public class Eckert6Projection extends PseudoCylindricalProjection { 22 | 23 | private static final double n = 2.570796326794896619231321691; 24 | private static final double C_y = Math.sqrt((2) / n); 25 | private static final double C_x = C_y / 2; 26 | private static final int MAX_ITER = 8; 27 | private static final double LOOP_TOL = 1e-7; 28 | 29 | public Point2D.Double project(double lam, double phi, Point2D.Double xy) { 30 | 31 | int i; 32 | double k, V; 33 | k = n * Math.sin(phi); 34 | for (i = MAX_ITER; i > 0;) { 35 | phi -= V = (phi + Math.sin(phi) - k) / (1 + Math.cos(phi)); 36 | if (Math.abs(V) < LOOP_TOL) { 37 | break; 38 | } 39 | --i; 40 | } 41 | if (i == 0) { 42 | throw new ProjectionException("F_ERROR"); 43 | } 44 | 45 | xy.x = C_x * lam * (1 + Math.cos(phi)); 46 | xy.y = C_y * phi; 47 | return xy; 48 | } 49 | 50 | public Point2D.Double projectInverse(double x, double y, Point2D.Double lp) { 51 | y /= C_y; 52 | lp.y = MapMath.asin((y + Math.sin(y)) / n); 53 | lp.x = x / (C_x * (1 + Math.cos(y))); 54 | return lp; 55 | } 56 | 57 | public boolean hasInverse() { 58 | return true; 59 | } 60 | 61 | public boolean isEqualArea() { 62 | return true; 63 | } 64 | 65 | public String toString() { 66 | return "Eckert VI"; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/EckertGreifendorffProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | * 20 | * Bernhard Jenny, May 07: split Hammer and Eckert-Greifendorff projections. 21 | * 22 | * FIXME: remove m and rm, copy inverse from Hammer projection, 23 | * remove initialize() 24 | */ 25 | package com.jhlabs.map.proj; 26 | 27 | import java.awt.geom.Point2D; 28 | 29 | public class EckertGreifendorffProjection extends Projection { 30 | 31 | private final double w = 0.25; 32 | private double m = 1; 33 | private double rm; 34 | 35 | public EckertGreifendorffProjection() { 36 | } 37 | 38 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double xy) { 39 | double cosphi, d; 40 | 41 | d = Math.sqrt(2. / (1. + (cosphi = Math.cos(lpphi)) * Math.cos(lplam *= w))); 42 | xy.x = m * d * cosphi * Math.sin(lplam); 43 | xy.y = rm * d * Math.sin(lpphi); 44 | return xy; 45 | } 46 | 47 | public void initialize() { 48 | super.initialize(); 49 | if ((m = Math.abs(m)) <= 0.) { 50 | throw new ProjectionException("-27"); 51 | } else { 52 | m = 1.; 53 | } 54 | rm = 1. / m; 55 | m /= w; 56 | es = 0.; 57 | } 58 | 59 | /** 60 | * Returns true if this projection is equal area 61 | */ 62 | public boolean isEqualArea() { 63 | return true; 64 | } 65 | 66 | public void setM(double m) { 67 | this.m = m; 68 | } 69 | 70 | public double getM() { 71 | return m; 72 | } 73 | 74 | public String toString() { 75 | return "Eckert-Greifendorff"; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/EllipticalPseudoCylindrical.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2007 Bernhard Jenny 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | 16 | * EllipticalPseudoCylindrical.java 17 | * 18 | * Created on March 11, 2007, 11:21 PM 19 | * 20 | */ 21 | 22 | package com.jhlabs.map.proj; 23 | 24 | import java.awt.geom.Point2D; 25 | 26 | /** 27 | * Abstract base class for Eckert 3, Putnins P1, Wagner VI (Putnin P'1), and 28 | * Kavraisky VII. Based on Proj4. 29 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich 30 | */ 31 | public abstract class EllipticalPseudoCylindrical extends PseudoCylindricalProjection { 32 | 33 | private final double C_x; 34 | private final double C_y; 35 | private final double A; 36 | private final double B; 37 | 38 | /** Creates a new instance of EllipticalPseudocylindrical */ 39 | protected EllipticalPseudoCylindrical(double C_x, double C_y, 40 | double A, double B) { 41 | this.C_x = C_x; 42 | this.C_y = C_y; 43 | this.A = A; 44 | this.B = B; 45 | } 46 | 47 | public Point2D.Double project(double x, double y, Point2D.Double dst) { 48 | dst.y = C_y * y; 49 | dst.x = C_x * x * (A + this.asqrt(1. - B * y * y)); 50 | return dst; 51 | } 52 | 53 | public boolean hasInverse() { 54 | return true; 55 | } 56 | 57 | public Point2D.Double projectInverse(double x, double y, Point2D.Double dst) { 58 | dst.y = y / C_y; 59 | dst.x = x / (C_x * (A + this.asqrt(1. - B * y * y))); 60 | return dst; 61 | } 62 | 63 | private double asqrt(double v) { 64 | return ((v <= 0) ? 0. : Math.sqrt(v)); 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/EquidistantCylindricalProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | /** 17 | * Removed isRectilinear (duplicate of super class), changed class name from 18 | * PlateCarreeProjection to EquidistantCylindricalProjection, changed 19 | * name to "Equidistant Cylindrical (Plate Carr\u00e9e)", added support for 20 | * latitude of true scale. 21 | * by Bernhard Jenny, June 26, 2008 and July 13, 2010. 22 | */ 23 | package com.jhlabs.map.proj; 24 | 25 | import java.awt.geom.Point2D; 26 | import java.time.Year; 27 | 28 | public class EquidistantCylindricalProjection extends CylindricalProjection { 29 | 30 | private double cosTrueScaleLatitude; 31 | 32 | @Override 33 | public Point2D.Double project(double x, double y, Point2D.Double dst) { 34 | dst.x = x * cosTrueScaleLatitude; 35 | dst.y = y; 36 | return dst; 37 | } 38 | 39 | @Override 40 | public Point2D.Double projectInverse(double x, double y, Point2D.Double lp) { 41 | lp.y = y; 42 | lp.x = x / cosTrueScaleLatitude; 43 | return lp; 44 | } 45 | 46 | @Override 47 | public void initialize() { 48 | super.initialize(); 49 | cosTrueScaleLatitude = Math.cos(trueScaleLatitude); 50 | es = 0.; 51 | } 52 | 53 | @Override 54 | public boolean hasInverse() { 55 | return true; 56 | } 57 | 58 | @Override 59 | public String toString() { 60 | return "Equirectangular"; 61 | } 62 | 63 | public String getDescription() { 64 | return super.getDescription() + " Plate Carr\u00e9e if the equator is the parallel of true scale."; 65 | } 66 | 67 | @Override 68 | public Year getYear() { 69 | return Year.of(100); 70 | } 71 | 72 | @Override 73 | public String getAuthor() { 74 | return "Marinus of Tyre"; 75 | } 76 | 77 | @Override 78 | public String getHistoryDescription() { 79 | return super.getHistoryDescription() + " Used in the 13th century and later for maps of Ptolemy's Geography."; 80 | } 81 | } -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/EulerProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | * 20 | * Bernhard Jenny, 17 September 2010: 21 | * Euler projection does no longer derive from SimpleConicProjection base class, 22 | * but from ConicProjection. 23 | * Fixed bugs in projectInverse(). 24 | */ 25 | package com.jhlabs.map.proj; 26 | 27 | import com.jhlabs.map.MapMath; 28 | import java.awt.geom.Point2D; 29 | import java.time.Year; 30 | 31 | public class EulerProjection extends ConicProjection { 32 | 33 | private final static double EPS = 1e-10; 34 | private double rho_c, rho_0, n; 35 | 36 | public EulerProjection() { 37 | projectionLatitude = Math.toRadians(45); 38 | projectionLatitude1 = Math.toRadians(35); 39 | projectionLatitude2 = Math.toRadians(60); 40 | } 41 | 42 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 43 | double rho = rho_c - lpphi; 44 | out.x = rho * Math.sin(lplam *= n); 45 | out.y = rho_0 - rho * Math.cos(lplam); 46 | return out; 47 | } 48 | 49 | public Point2D.Double projectInverse(double xyx, double xyy, Point2D.Double out) { 50 | xyy = rho_0 - xyy; 51 | double rho = MapMath.distance(xyx, xyy); 52 | if (n < 0.) { 53 | rho = -rho; 54 | xyx = -xyx; 55 | xyy = -xyy; 56 | } 57 | out.x = Math.atan2(xyx, xyy) / n; 58 | out.y = rho_c - rho; 59 | return out; 60 | } 61 | 62 | public void initialize() { 63 | 64 | super.initialize(); 65 | 66 | double del = 0.5 * (projectionLatitude2 - projectionLatitude1); 67 | double sig = 0.5 * (projectionLatitude2 + projectionLatitude1); 68 | 69 | if (Math.abs(del) < EPS || Math.abs(sig) < EPS) { 70 | throw new ProjectionException("-42"); 71 | } 72 | n = Math.sin(sig) * Math.sin(del) / del; 73 | del *= 0.5; 74 | rho_c = del / (Math.tan(del) * Math.tan(sig)) + sig; 75 | rho_0 = rho_c - projectionLatitude; 76 | 77 | } 78 | 79 | public boolean hasInverse() { 80 | return true; 81 | } 82 | 83 | public String toString() { 84 | return "Euler"; 85 | } 86 | 87 | @Override 88 | public Year getYear() { 89 | return Year.of(1777); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/FaheyProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | * 20 | * Bernhard Jenny, May 25 2010: 21 | * Changed super class from Projection to PseudoCylindricalProjection. 22 | * Bernhard Jenny, 19 September 2010: 23 | * Fixed inverse projection. 24 | */ 25 | package com.jhlabs.map.proj; 26 | 27 | import com.jhlabs.map.MapMath; 28 | import java.awt.geom.Point2D; 29 | 30 | public class FaheyProjection extends PseudoCylindricalProjection { 31 | 32 | private final static double TOL = 1e-6; 33 | 34 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 35 | out.y = 1.819152 * (out.x = Math.tan(0.5 * lpphi)); 36 | out.x = 0.819152 * lplam * asqrt(1 - out.x * out.x); 37 | return out; 38 | } 39 | 40 | public Point2D.Double projectInverse(double xyx, double xyy, Point2D.Double out) { 41 | out.y = 2. * Math.atan(xyy /= 1.819152); 42 | out.x = Math.abs(xyy = 1. - xyy * xyy) < TOL ? 0. 43 | : xyx / (0.819152 * Math.sqrt(xyy)); 44 | return out; 45 | } 46 | 47 | private double asqrt(double v) { 48 | return (v <= 0) ? 0. : Math.sqrt(v); 49 | } 50 | 51 | public boolean hasInverse() { 52 | return true; 53 | } 54 | 55 | public String toString() { 56 | return "Fahey"; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/FoucautProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | * 20 | * Bernhard Jenny, 23 September 2010: fixed wrong parameter in call to super, 21 | * added isEqualArea. 22 | */ 23 | package com.jhlabs.map.proj; 24 | 25 | public class FoucautProjection extends STSProjection { 26 | 27 | public FoucautProjection() { 28 | super(1.772453850905516027298167483, 2., true); 29 | } 30 | 31 | public boolean isEqualArea() { 32 | return true; 33 | } 34 | 35 | public String toString() { 36 | return "Foucaut"; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/FoucautSinusoidalProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | * 20 | */ 21 | 22 | /** 23 | * Modified by Bernhard Jenny: added setter for parameter n, 24 | * added missing initialization of n to 0.5, as is done by proj4, 25 | * added missing isEqualArea, change superclass from Projection to 26 | * PseudocylindricalProjection. 27 | */ 28 | 29 | package com.jhlabs.map.proj; 30 | 31 | import com.jhlabs.map.MapMath; 32 | import java.awt.geom.Point2D; 33 | 34 | public class FoucautSinusoidalProjection extends PseudoCylindricalProjection { 35 | 36 | private double n = 0.5; 37 | private double n1; 38 | private final static int MAX_ITER = 10; 39 | private final static double LOOP_TOL = 1e-7; 40 | 41 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 42 | double t; 43 | 44 | t = Math.cos(lpphi); 45 | out.x = lplam * t / (n + n1 * t); 46 | out.y = n * lpphi + n1 * Math.sin(lpphi); 47 | return out; 48 | } 49 | 50 | public Point2D.Double projectInverse(double xyx, double xyy, Point2D.Double out) { 51 | double V; 52 | int i; 53 | 54 | if (n != 0) { 55 | out.y = xyy; 56 | for (i = MAX_ITER; i > 0; --i) { 57 | out.y -= V = (n * out.y + n1 * Math.sin(out.y) - xyy) 58 | / (n + n1 * Math.cos(out.y)); 59 | if (Math.abs(V) < LOOP_TOL) { 60 | break; 61 | } 62 | } 63 | if (i == 0) { 64 | out.y = xyy < 0. ? -MapMath.HALFPI : MapMath.HALFPI; 65 | } 66 | } else { 67 | out.y = MapMath.asin(xyy); 68 | } 69 | V = Math.cos(out.y); 70 | out.x = xyx * (n + n1 * V) / V; 71 | return out; 72 | } 73 | 74 | public void initialize() { 75 | super.initialize(); 76 | // n = pj_param(params, "dn").f; 77 | if (n < 0. || n > 1.) { 78 | throw new ProjectionException("-99"); 79 | } 80 | n1 = 1. - n; 81 | } 82 | 83 | public boolean hasInverse() { 84 | return true; 85 | } 86 | 87 | public boolean isEqualArea() { 88 | return true; 89 | } 90 | 91 | public String toString() { 92 | return "Foucaut Sinusoidal"; 93 | } 94 | 95 | public double getN() { 96 | return n; 97 | } 98 | 99 | public void setN(double n) { 100 | if (n < 0 || n > 1) { 101 | throw new IllegalArgumentException(); 102 | } 103 | this.n = n; 104 | this.n1 = 1d - n; 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/Fournier2Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2010 Bernhard Jenny 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | package com.jhlabs.map.proj; 17 | 18 | import java.awt.geom.Point2D; 19 | 20 | /** 21 | * Fournier II projection. 22 | * Code from PROJ.4. 23 | * 23 September: changed super class to PseudoCylindricalProjection. 24 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich 25 | */ 26 | public class Fournier2Projection extends PseudoCylindricalProjection { 27 | 28 | private static final double Cx = 0.5641895835477562869480794515; 29 | private static final double Cy = 0.8862269254527580136490837416; 30 | 31 | public Fournier2Projection() { 32 | } 33 | 34 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 35 | out.x = Cx * lplam * Math.cos(lpphi); 36 | out.y = Cy * Math.sin(lpphi); 37 | return out; 38 | } 39 | 40 | public Point2D.Double projectInverse(double xyx, double xyy, Point2D.Double out) { 41 | out.y = Math.asin(xyy / Cy); 42 | out.x = xyx / (Cx * Math.cos(out.y)); 43 | return out; 44 | } 45 | 46 | public boolean hasInverse() { 47 | return true; 48 | } 49 | 50 | public String toString() { 51 | return "Fournier II"; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/GallPetersProjection.java: -------------------------------------------------------------------------------- 1 | package com.jhlabs.map.proj; 2 | 3 | import java.time.Year; 4 | 5 | /** 6 | * 7 | * @author Bernhard Jenny, Faculty of Information Technology, Monash University, 8 | * Melbourne, Australia 9 | */ 10 | public class GallPetersProjection extends CylindricalEqualAreaProjection { 11 | public GallPetersProjection() { 12 | super(0, 0, Math.PI / 4); 13 | } 14 | 15 | @Override 16 | public String toString() { 17 | return "Gall-Peters"; 18 | } 19 | 20 | @Override 21 | public String getAuthor() { 22 | return "James Gall"; 23 | } 24 | 25 | @Override 26 | public Year getYear() { 27 | return Year.of(1855); 28 | } 29 | 30 | @Override 31 | public String getHistoryDescription() { 32 | return super.getHistoryDescription() + " Popularized by Arno Peters in the early 1970s."; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/GallProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | /** 21 | * Changed superclass from Projection to CylindricalProjection. 22 | * Bernhard Jenny, May 25 2010. 23 | */ 24 | package com.jhlabs.map.proj; 25 | 26 | import java.awt.geom.Point2D; 27 | 28 | public class GallProjection extends CylindricalProjection { 29 | 30 | private final static double YF = 1.70710678118654752440; 31 | private final static double XF = 0.70710678118654752440; 32 | private final static double RYF = 0.58578643762690495119; 33 | private final static double RXF = 1.41421356237309504880; 34 | 35 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 36 | out.x = XF * lplam; 37 | out.y = YF * Math.tan(.5 * lpphi); 38 | return out; 39 | } 40 | 41 | public Point2D.Double projectInverse(double xyx, double xyy, Point2D.Double out) { 42 | out.x = RXF * xyx; 43 | out.y = 2. * Math.atan(xyy * RYF); 44 | return out; 45 | } 46 | 47 | public boolean hasInverse() { 48 | return true; 49 | } 50 | 51 | public String toString() { 52 | return "Gall (Gall Stereographic)"; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/Ginzburg8Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | /** 21 | * Changes by Bernhard Jenny: Changed Ginsburg to Ginzburg, including the name 22 | * of this class file. Added "1944" in toString. Change superclass from 23 | * Projection to PseudoCylindricalProjection. 24 | */ 25 | package com.jhlabs.map.proj; 26 | 27 | import java.awt.geom.Point2D; 28 | 29 | public class Ginzburg8Projection extends PseudoCylindricalProjection { 30 | 31 | private final static double Cl = 0.000952426; 32 | private final static double Cp = 0.162388; 33 | private final static double C12 = 0.08333333333333333; 34 | 35 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 36 | double t = lpphi * lpphi; 37 | out.y = lpphi * (1. + t * C12); 38 | out.x = lplam * (1. - Cp * t); 39 | t = lplam * lplam; 40 | out.x *= (0.87 - Cl * t * t); 41 | return out; 42 | } 43 | 44 | public String toString() { 45 | return "Ginzburg VIII (TsNIIGAiK 1944)"; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/GoodeProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | /** 21 | * Changed superclass from Projection to PseudoCylindricalProjection. 22 | * Bernhard Jenny, May 25 2010. 23 | */ 24 | package com.jhlabs.map.proj; 25 | 26 | import java.awt.geom.Point2D; 27 | 28 | public class GoodeProjection extends PseudoCylindricalProjection { 29 | 30 | private final static double Y_COR = 0.05280; 31 | private final static double PHI_LIM = .71093078197902358062; 32 | private SinusoidalProjection sinu = new SinusoidalProjection(); 33 | private MollweideProjection moll = new MollweideProjection(); 34 | 35 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 36 | if (Math.abs(lpphi) <= PHI_LIM) { 37 | out = sinu.project(lplam, lpphi, out); 38 | } else { 39 | out = moll.project(lplam, lpphi, out); 40 | out.y -= lpphi >= 0.0 ? Y_COR : -Y_COR; 41 | } 42 | return out; 43 | } 44 | 45 | public Point2D.Double projectInverse(double xyx, double xyy, Point2D.Double out) { 46 | if (Math.abs(xyy) <= PHI_LIM) { 47 | out = sinu.projectInverse(xyx, xyy, out); 48 | } else { 49 | xyy += xyy >= 0.0 ? Y_COR : -Y_COR; 50 | out = moll.projectInverse(xyx, xyy, out); 51 | } 52 | return out; 53 | } 54 | 55 | public boolean hasInverse() { 56 | return true; 57 | } 58 | 59 | public String toString() { 60 | return "Goode Homolosine"; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/HammerProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | /** 21 | * split Hammer and Eckert-Greifendorff projections. 22 | * added inverse, removed m parameter, 23 | * changed super class to Projection 24 | * Bernhard Jenny 25 | */ 26 | package com.jhlabs.map.proj; 27 | 28 | import java.awt.geom.Point2D; 29 | 30 | public class HammerProjection extends Projection { 31 | 32 | private final double w = 0.5; 33 | 34 | public HammerProjection() { 35 | } 36 | 37 | @Override 38 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double xy) { 39 | lplam *= w; 40 | double cosphi = Math.cos(lpphi); 41 | double d = Math.sqrt(2. / (1. + cosphi * Math.cos(lplam))); 42 | xy.x = d * cosphi * Math.sin(lplam) / w; 43 | xy.y = d * Math.sin(lpphi); 44 | return xy; 45 | } 46 | 47 | @Override 48 | public Point2D.Double projectInverse(double xyx, double xyy, Point2D.Double out) { 49 | final double EPS = 1.0e-10; 50 | double wx = w * xyx; 51 | double z = Math.sqrt(1. - 0.25 * (wx * wx + xyy * xyy)); 52 | double zz2_1 = 2 * z * z - 1; 53 | if (Math.abs(zz2_1) < EPS) { 54 | out.x = Double.NaN; 55 | out.y = Double.NaN; 56 | } else { 57 | out.x = Math.atan2(wx * z, zz2_1) / w; // FIXME aatan2 58 | out.y = Math.asin(z * xyy); // FIXME aasin 59 | } 60 | return out; 61 | } 62 | 63 | /** 64 | * Returns true if this projection is equal area 65 | */ 66 | @Override 67 | public boolean isEqualArea() { 68 | return true; 69 | } 70 | 71 | @Override 72 | public String toString() { 73 | return "Hammer"; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/HatanoProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | * 20 | * Bernhard Jenny, 23 September 2010: changed name to Hatano Asymmetrical, added 21 | * isEqualArea 22 | */ 23 | package com.jhlabs.map.proj; 24 | 25 | import com.jhlabs.map.MapMath; 26 | import java.awt.geom.Point2D; 27 | 28 | public class HatanoProjection extends Projection { 29 | 30 | private final static int NITER = 20; 31 | private final static double EPS = 1e-7; 32 | private final static double ONETOL = 1.000001; 33 | private final static double CN = 2.67595; 34 | private final static double CS = 2.43763; 35 | private final static double RCN = 0.37369906014686373063; 36 | private final static double RCS = 0.41023453108141924738; 37 | private final static double FYCN = 1.75859; 38 | private final static double FYCS = 1.93052; 39 | private final static double RYCN = 0.56863737426006061674; 40 | private final static double RYCS = 0.51799515156538134803; 41 | private final static double FXC = 0.85; 42 | private final static double RXC = 1.17647058823529411764; 43 | 44 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 45 | double th1, c; 46 | int i; 47 | 48 | c = Math.sin(lpphi) * (lpphi < 0. ? CS : CN); 49 | for (i = NITER; i > 0; --i) { 50 | lpphi -= th1 = (lpphi + Math.sin(lpphi) - c) / (1. + Math.cos(lpphi)); 51 | if (Math.abs(th1) < EPS) { 52 | break; 53 | } 54 | } 55 | out.x = FXC * lplam * Math.cos(lpphi *= .5); 56 | out.y = Math.sin(lpphi) * (lpphi < 0. ? FYCS : FYCN); 57 | return out; 58 | } 59 | 60 | public Point2D.Double projectInverse(double xyx, double xyy, Point2D.Double out) { 61 | double th; 62 | 63 | th = xyy * (xyy < 0. ? RYCS : RYCN); 64 | if (Math.abs(th) > 1.) { 65 | if (Math.abs(th) > ONETOL) { 66 | throw new ProjectionException("I"); 67 | } else { 68 | th = th > 0. ? MapMath.HALFPI : -MapMath.HALFPI; 69 | } 70 | } else { 71 | th = Math.asin(th); 72 | } 73 | out.x = RXC * xyx / Math.cos(th); 74 | th += th; 75 | out.y = (th + Math.sin(th)) * (xyy < 0. ? RCS : RCN); 76 | if (Math.abs(out.y) > 1.) { 77 | if (Math.abs(out.y) > ONETOL) { 78 | throw new ProjectionException("I"); 79 | } else { 80 | out.y = out.y > 0. ? MapMath.HALFPI : -MapMath.HALFPI; 81 | } 82 | } else { 83 | out.y = Math.asin(out.y); 84 | } 85 | return out; 86 | } 87 | 88 | public boolean hasInverse() { 89 | return true; 90 | } 91 | 92 | public boolean isEqualArea() { 93 | return true; 94 | } 95 | 96 | public String toString() { 97 | return "Hatano Asymmetrical"; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/HolzelProjection.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | Copyright 2007 Bernhard Jenny 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | 17 | * HolzelProjection.java 18 | * 19 | * Created October 3, 2008 20 | * 21 | */ 22 | package com.jhlabs.map.proj; 23 | 24 | import java.awt.geom.Point2D; 25 | /** 26 | * Hoelzel Projection. Based on Proj4. 27 | */ 28 | public class HolzelProjection extends PseudoCylindricalProjection { 29 | 30 | @Override 31 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 32 | 33 | double aphi = Math.abs(lpphi); 34 | out.y = lpphi; 35 | if (aphi <= 1.39634) { 36 | out.x = lplam * 0.441013 * (1. + Math.cos(aphi)); 37 | } else { 38 | double t = (aphi - 0.40928) / 1.161517; 39 | out.x = lplam * (0.322673 + 0.369722 * Math.sqrt(Math.abs(1. - t * t))); 40 | } 41 | return out; 42 | 43 | } 44 | 45 | @Override 46 | public String toString() { 47 | return "H\u00F6lzel"; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/HufnagelProjection.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSUCartography/JMapProjLib/61429b4edb79885f12d7b0e73ad870bd37a3dbe2/src/com/jhlabs/map/proj/HufnagelProjection.java -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/Kavrayskiy1Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Bernhard Jenny 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | package com.jhlabs.map.proj; 17 | 18 | import com.jhlabs.map.MapMath; 19 | import java.awt.geom.Point2D; 20 | 21 | /** 22 | * Kavrayskiy I Projection Arithmetic mean of the Mercator and the cylindrical 23 | * equal-area projections Code from proj4. 24 | * 25 | * @author Bernhard Jenny, Oregon State University 26 | */ 27 | public class Kavrayskiy1Projection extends CylindricalProjection { 28 | 29 | final double MERCATOR_MAX_LAT = Math.toRadians(70); 30 | final double DY = Math.log(Math.tan(0.5 * (MapMath.HALFPI + MERCATOR_MAX_LAT))); 31 | final double C = 1 / Math.cos(MERCATOR_MAX_LAT); 32 | 33 | public Kavrayskiy1Projection() { 34 | } 35 | 36 | @Override 37 | public Point2D.Double project(double lon, double lat, Point2D.Double out) { 38 | out.x = lon; 39 | // out.y = lat * C; // the scaled equirectangular secant at 70deg 40 | if (lat > MERCATOR_MAX_LAT) { 41 | out.y = (lat - MERCATOR_MAX_LAT) * C + DY; 42 | } else if (lat < -MERCATOR_MAX_LAT) { 43 | out.y = (lat + MERCATOR_MAX_LAT) * C - DY; 44 | } else { 45 | out.y = Math.log(Math.tan(0.5 * (Math.PI / 2 + lat))); 46 | } 47 | return out; 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | return "Kavrayskiy I"; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/Kavrayskiy5Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | 21 | /** 22 | * Added missing isEqualArea method by Bernhard Jenny, October 2007. 23 | * Renamed from KavraiskyVProjection to Kavraisky5Projection, May 19 2010. 24 | * Renamed to Kavrayskiy5Projection, April 26, 2013. Kavrayskiy is the notation 25 | * used by Snyder. 26 | */ 27 | 28 | package com.jhlabs.map.proj; 29 | 30 | public class Kavrayskiy5Projection extends STSProjection { 31 | 32 | public Kavrayskiy5Projection() { 33 | super(1.50488, 1.35439, false); 34 | } 35 | 36 | public boolean isEqualArea() { 37 | return true; 38 | } 39 | 40 | public String toString() { 41 | return "Kavrayskiy V"; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/Kavrayskiy7Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2009 Bernhard Jenny 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /** 18 | * Renamed to Kavrayskiy5Projection, April 26, 2013. Kavrayskiy is the notation 19 | * used by Snyder. 20 | */ 21 | 22 | package com.jhlabs.map.proj; 23 | 24 | /** 25 | * Kavraisky 7 Projection. Based on Proj4. 26 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich 27 | */ 28 | public class Kavrayskiy7Projection extends EllipticalPseudoCylindrical { 29 | 30 | public Kavrayskiy7Projection() { 31 | super(Math.sqrt(3.) / 2., 32 | 1., 33 | 0., 34 | 3. / Math.PI / Math.PI); 35 | } 36 | 37 | public String toString() { 38 | return "Kavrayskiy VII"; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/LagrangeProjection.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSUCartography/JMapProjLib/61429b4edb79885f12d7b0e73ad870bd37a3dbe2/src/com/jhlabs/map/proj/LagrangeProjection.java -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/LambertAzimuthalEqualAreaProjection.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSUCartography/JMapProjLib/61429b4edb79885f12d7b0e73ad870bd37a3dbe2/src/com/jhlabs/map/proj/LambertAzimuthalEqualAreaProjection.java -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/LambertConformalConicProjection.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSUCartography/JMapProjLib/61429b4edb79885f12d7b0e73ad870bd37a3dbe2/src/com/jhlabs/map/proj/LambertConformalConicProjection.java -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/LambertEqualAreaConicProjection.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSUCartography/JMapProjLib/61429b4edb79885f12d7b0e73ad870bd37a3dbe2/src/com/jhlabs/map/proj/LambertEqualAreaConicProjection.java -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/LarriveeProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | 21 | /** 22 | * Added acute on e in string returned by toString by Bernhard Jenny, July 2007. 23 | */ 24 | package com.jhlabs.map.proj; 25 | 26 | import java.awt.geom.Point2D; 27 | 28 | public class LarriveeProjection extends Projection { 29 | 30 | private final static double SIXTH = .16666666666666666; 31 | 32 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 33 | out.x = 0.5 * lplam * (1. + Math.sqrt(Math.cos(lpphi))); 34 | out.y = lpphi / (Math.cos(0.5 * lpphi) * Math.cos(SIXTH * lplam)); 35 | return out; 36 | } 37 | 38 | public String toString() { 39 | return "Larriv\u00E9e"; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/LaskowskiProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | package com.jhlabs.map.proj; 21 | 22 | import java.awt.geom.Point2D; 23 | 24 | public class LaskowskiProjection extends Projection { 25 | 26 | private final static double a10 = 0.975534; 27 | private final static double a12 = -0.119161; 28 | private final static double a32 = -0.0143059; 29 | private final static double a14 = -0.0547009; 30 | private final static double b01 = 1.00384; 31 | private final static double b21 = 0.0802894; 32 | private final static double b03 = 0.0998909; 33 | private final static double b41 = 0.000199025; 34 | private final static double b23 = -0.0285500; 35 | private final static double b05 = -0.0491032; 36 | 37 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 38 | double l2, p2; 39 | 40 | l2 = lplam * lplam; 41 | p2 = lpphi * lpphi; 42 | out.x = lplam * (a10 + p2 * (a12 + l2 * a32 + p2 * a14)); 43 | out.y = lpphi * (b01 + l2 * (b21 + p2 * b23 + l2 * b41) + 44 | p2 * (b03 + p2 * b05)); 45 | return out; 46 | } 47 | 48 | public String toString() { 49 | return "Laskowski"; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/LinearProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package com.jhlabs.map.proj; 18 | 19 | import java.awt.geom.Point2D; 20 | 21 | public class LinearProjection extends Projection { 22 | 23 | public Point2D.Double transform(Point2D.Double src, Point2D.Double dst) { 24 | dst.x = src.x; 25 | dst.y = src.y; 26 | return dst; 27 | } 28 | 29 | public void transform(double[] srcPoints, int srcOffset, double[] dstPoints, int dstOffset, int numPoints) { 30 | for (int i = 0; i < numPoints; i++) { 31 | dstPoints[dstOffset++] = srcPoints[srcOffset++]; 32 | dstPoints[dstOffset++] = srcPoints[srcOffset++]; 33 | } 34 | } 35 | 36 | public Point2D.Double inverseTransform(Point2D.Double src, Point2D.Double dst) { 37 | dst.x = src.x; 38 | dst.y = src.y; 39 | return dst; 40 | } 41 | 42 | public void inverseTransform(double[] srcPoints, int srcOffset, double[] dstPoints, int dstOffset, int numPoints) { 43 | for (int i = 0; i < numPoints; i++) { 44 | dstPoints[dstOffset++] = srcPoints[srcOffset++]; 45 | dstPoints[dstOffset++] = srcPoints[srcOffset++]; 46 | } 47 | } 48 | 49 | public boolean hasInverse() { 50 | return true; 51 | } 52 | 53 | public boolean isRectilinear() { 54 | return true; 55 | } 56 | 57 | public String toString() { 58 | return "Linear"; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/LoximuthalProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | * 20 | * Bernhard Jenny, 19 September 2010: 21 | * Fixed forward and inverse projections, removed unused constants, added validity 22 | * test for parameter phi1. 23 | */ 24 | package com.jhlabs.map.proj; 25 | 26 | import com.jhlabs.map.MapMath; 27 | import java.awt.geom.Point2D; 28 | 29 | public class LoximuthalProjection extends PseudoCylindricalProjection { 30 | 31 | private final static double EPS = 1e-8; 32 | private double phi1; 33 | private double cosphi1; 34 | private double tanphi1; 35 | 36 | public LoximuthalProjection() { 37 | phi1 = Math.toRadians(40.0);//FIXME - param 38 | cosphi1 = Math.cos(phi1); 39 | if (cosphi1 < EPS) { 40 | throw new ProjectionException("-22"); 41 | } 42 | tanphi1 = Math.tan(MapMath.QUARTERPI + 0.5 * phi1); 43 | } 44 | 45 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 46 | double x; 47 | double y = lpphi - phi1; 48 | if (Math.abs(y) < EPS) { 49 | x = lplam * cosphi1; 50 | } else { 51 | x = MapMath.QUARTERPI + 0.5 * lpphi; 52 | if (Math.abs(x) < EPS || Math.abs(Math.abs(x) - MapMath.HALFPI) < EPS) { 53 | x = 0.; 54 | } else { 55 | x = lplam * y / Math.log(Math.tan(x) / tanphi1); 56 | } 57 | } 58 | out.x = x; 59 | out.y = y; 60 | return out; 61 | } 62 | 63 | public Point2D.Double projectInverse(double xyx, double xyy, Point2D.Double out) { 64 | double latitude = xyy + phi1; 65 | double longitude; 66 | if (Math.abs(xyy) < EPS) { 67 | longitude = xyx / cosphi1; 68 | } else if (Math.abs(longitude = MapMath.QUARTERPI + 0.5 * latitude) < EPS 69 | || Math.abs(Math.abs(xyx) - MapMath.HALFPI) < EPS) { 70 | longitude = 0.; 71 | } else { 72 | longitude = xyx * Math.log(Math.tan(longitude) / tanphi1) / xyy; 73 | } 74 | 75 | out.x = longitude; 76 | out.y = latitude; 77 | return out; 78 | } 79 | 80 | public boolean hasInverse() { 81 | return true; 82 | } 83 | 84 | public String toString() { 85 | return "Loximuthal"; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/McBrydeThomasFlatPolarParabolicProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | * 20 | * Bernhard Jenny, 19 September 2010: Fixed forward projection. 21 | * 22 September 2010: changed name from MBTFPPProjection to 22 | * McBrydeThomasFlatPolarParabolicProjection 23 | * 23 September 2010: changed super class to PseudoCylindricalProjection, added 24 | * isEqualArea. 25 | */ 26 | package com.jhlabs.map.proj; 27 | 28 | import com.jhlabs.map.MapMath; 29 | import java.awt.geom.Point2D; 30 | 31 | public class McBrydeThomasFlatPolarParabolicProjection extends PseudoCylindricalProjection { 32 | 33 | private final static double CS = .95257934441568037152; 34 | private final static double FXC = .92582009977255146156; 35 | private final static double FYC = 3.40168025708304504493; 36 | private final static double C23 = .66666666666666666666; 37 | private final static double C13 = .33333333333333333333; 38 | private final static double ONEEPS = 1.0000001; 39 | 40 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 41 | lpphi = Math.asin(CS * Math.sin(lpphi)); 42 | out.x = FXC * lplam * (2. * Math.cos(C23 * lpphi) - 1.); 43 | out.y = FYC * Math.sin(C13 * lpphi); 44 | return out; 45 | } 46 | 47 | public Point2D.Double projectInverse(double xyx, double xyy, Point2D.Double out) { 48 | out.y = xyy / FYC; 49 | if (Math.abs(out.y) >= 1.) { 50 | if (Math.abs(out.y) > ONEEPS) { 51 | throw new ProjectionException("I"); 52 | } else { 53 | out.y = (out.y < 0.) ? -MapMath.HALFPI : MapMath.HALFPI; 54 | } 55 | } else { 56 | out.y = Math.asin(out.y); 57 | } 58 | out.x = xyx / (FXC * (2. * Math.cos(C23 * (out.y *= 3.)) - 1.)); 59 | if (Math.abs(out.y = Math.sin(out.y) / CS) >= 1.) { 60 | if (Math.abs(out.y) > ONEEPS) { 61 | throw new ProjectionException("I"); 62 | } else { 63 | out.y = (out.y < 0.) ? -MapMath.HALFPI : MapMath.HALFPI; 64 | } 65 | } else { 66 | out.y = Math.asin(out.y); 67 | } 68 | return out; 69 | } 70 | 71 | public boolean hasInverse() { 72 | return true; 73 | } 74 | 75 | public boolean isEqualArea() { 76 | return true; 77 | } 78 | 79 | public String toString() { 80 | return "McBride-Thomas Flat-Pole Parabolic"; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/McBrydeThomasFlatPolarQuarticProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | * 20 | * Bernhard Jenny, 21 September 2010: changed name from MBTFPQProjection to 21 | * McBrydeThomasFlatPolarQuarticProjection. 22 | * 23 September 2010: changed super class to PseudoCylindricalProjection, added 23 | * isEqualArea. 24 | */ 25 | package com.jhlabs.map.proj; 26 | 27 | import com.jhlabs.map.MapMath; 28 | import java.awt.geom.Point2D; 29 | 30 | public class McBrydeThomasFlatPolarQuarticProjection extends PseudoCylindricalProjection { 31 | 32 | private final static int NITER = 20; 33 | private final static double EPS = 1e-7; 34 | private final static double ONETOL = 1.000001; 35 | private final static double C = 1.70710678118654752440; 36 | private final static double RC = 0.58578643762690495119; 37 | private final static double FYC = 1.87475828462269495505; 38 | private final static double RYC = 0.53340209679417701685; 39 | private final static double FXC = 0.31245971410378249250; 40 | private final static double RXC = 3.20041258076506210122; 41 | 42 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 43 | double th1, c; 44 | int i; 45 | 46 | c = C * Math.sin(lpphi); 47 | for (i = NITER; i > 0; --i) { 48 | out.y -= th1 = (Math.sin(.5 * lpphi) + Math.sin(lpphi) - c) 49 | / (.5 * Math.cos(.5 * lpphi) + Math.cos(lpphi)); 50 | if (Math.abs(th1) < EPS) { 51 | break; 52 | } 53 | } 54 | out.x = FXC * lplam * (1.0 + 2. * Math.cos(lpphi) / Math.cos(0.5 * lpphi)); 55 | out.y = FYC * Math.sin(0.5 * lpphi); 56 | return out; 57 | } 58 | 59 | public Point2D.Double projectInverse(double xyx, double xyy, Point2D.Double out) { 60 | double t = 0; 61 | 62 | double lpphi = RYC * xyy; 63 | if (Math.abs(lpphi) > 1.) { 64 | if (Math.abs(lpphi) > ONETOL) { 65 | throw new ProjectionException("I"); 66 | } else if (lpphi < 0.) { 67 | t = -1.; 68 | lpphi = -Math.PI; 69 | } else { 70 | t = 1.; 71 | lpphi = Math.PI; 72 | } 73 | } else { 74 | lpphi = 2. * Math.asin(t = lpphi); 75 | } 76 | out.x = RXC * xyx / (1. + 2. * Math.cos(lpphi) / Math.cos(0.5 * lpphi)); 77 | lpphi = RC * (t + Math.sin(lpphi)); 78 | if (Math.abs(lpphi) > 1.) { 79 | if (Math.abs(lpphi) > ONETOL) { 80 | throw new ProjectionException("I"); 81 | } else { 82 | lpphi = lpphi < 0. ? -MapMath.HALFPI : MapMath.HALFPI; 83 | } 84 | } else { 85 | lpphi = Math.asin(lpphi); 86 | } 87 | out.y = lpphi; 88 | return out; 89 | } 90 | 91 | public boolean hasInverse() { 92 | return true; 93 | } 94 | 95 | public boolean isEqualArea() { 96 | return true; 97 | } 98 | 99 | public String toString() { 100 | return "McBryde-Thomas Flat-Pole Quartic"; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/McBrydeThomasFlatPolarSine2Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | * 20 | * Bernhard Jenny, 21 September 2010: Changed name from MBTFPSProjection to 21 | * McBrydeThomasFlatPolarSine2Projection. 22 | * 23 September 2010: changed super class to PseudoCylindricalProjection, added 23 | * isEqualArea. 24 | */ 25 | package com.jhlabs.map.proj; 26 | 27 | import com.jhlabs.map.MapMath; 28 | import java.awt.geom.Point2D; 29 | 30 | public class McBrydeThomasFlatPolarSine2Projection extends PseudoCylindricalProjection { 31 | 32 | private final static int MAX_ITER = 10; 33 | private final static double LOOP_TOL = 1e-7; 34 | private final static double C1 = 0.45503; 35 | private final static double C2 = 1.36509; 36 | private final static double C3 = 1.41546; 37 | private final static double C_x = 0.22248; 38 | private final static double C_y = 1.44492; 39 | private final static double C1_2 = 0.33333333333333333333333333; 40 | 41 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 42 | double k, V, t; 43 | int i; 44 | 45 | k = C3 * Math.sin(lpphi); 46 | for (i = MAX_ITER; i > 0; i--) { 47 | t = lpphi / C2; 48 | out.y -= V = (C1 * Math.sin(t) + Math.sin(lpphi) - k) 49 | / (C1_2 * Math.cos(t) + Math.cos(lpphi)); 50 | if (Math.abs(V) < LOOP_TOL) { 51 | break; 52 | } 53 | } 54 | t = lpphi / C2; 55 | out.x = C_x * lplam * (1. + 3. * Math.cos(lpphi) / Math.cos(t)); 56 | out.y = C_y * Math.sin(t); 57 | return out; 58 | } 59 | 60 | public Point2D.Double projectInverse(double xyx, double xyy, Point2D.Double out) { 61 | double t, s; 62 | 63 | out.y = C2 * (t = MapMath.asin(xyy / C_y)); 64 | out.x = xyx / (C_x * (1. + 3. * Math.cos(out.y) / Math.cos(t))); 65 | out.y = MapMath.asin((C1 * Math.sin(t) + Math.sin(out.y)) / C3); 66 | return out; 67 | } 68 | 69 | public boolean hasInverse() { 70 | return true; 71 | } 72 | 73 | public boolean isEqualArea() { 74 | return true; // FIXME verify if correct. 75 | } 76 | 77 | public String toString() { 78 | return "McBryde-Thomas Flat-Pole Sine (No. 2)"; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/McBrydeThomasFlatPolarSinusoidalProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2014 Bojan Savric 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | package com.jhlabs.map.proj; 17 | 18 | import com.jhlabs.map.MapMath; 19 | import java.awt.geom.*; 20 | 21 | public class McBrydeThomasFlatPolarSinusoidalProjection extends PseudoCylindricalProjection { 22 | 23 | private static final double m = 0.5; 24 | private static final double n = 1 + 0.25 * Math.PI; 25 | private static final double C_y = Math.sqrt((m + 1) / n); 26 | private static final double C_x = C_y / (m + 1); 27 | private static final int MAX_ITER = 8; 28 | private static final double LOOP_TOL = 1e-7; 29 | 30 | public Point2D.Double project(double lam, double phi, Point2D.Double xy) { 31 | 32 | int i; 33 | double k, V; 34 | k = n * Math.sin(phi); 35 | for (i = MAX_ITER; i > 0;) { 36 | phi -= V = (m * phi + Math.sin(phi) - k) / (m + Math.cos(phi)); 37 | if (Math.abs(V) < LOOP_TOL) { 38 | break; 39 | } 40 | --i; 41 | } 42 | if (i == 0) { 43 | throw new ProjectionException("F_ERROR"); 44 | } 45 | 46 | xy.x = C_x * lam * (m + Math.cos(phi)); 47 | xy.y = C_y * phi; 48 | return xy; 49 | } 50 | 51 | public Point2D.Double projectInverse(double x, double y, Point2D.Double lp) { 52 | y /= C_y; 53 | lp.y = MapMath.asin((m * y + Math.sin(y)) / n); 54 | lp.x = x / (C_x * (m + Math.cos(y))); 55 | return lp; 56 | } 57 | 58 | public boolean hasInverse() { 59 | return true; 60 | } 61 | 62 | public boolean isEqualArea() { 63 | return true; 64 | } 65 | 66 | public String toString() { 67 | return "McBryde-Thomas Flat Polar Sinusoidal"; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/McBrydeThomasSine1Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | * 20 | * Bernhard Jenny, 22 September 2010: 21 | * changed file name from MBTFPS1Projection to McBrydeThomasSine1Projection 22 | */ 23 | package com.jhlabs.map.proj; 24 | 25 | public class McBrydeThomasSine1Projection extends STSProjection { 26 | 27 | public McBrydeThomasSine1Projection() { 28 | super( 1.48875, 1.36509, false ); 29 | } 30 | 31 | public String toString() { 32 | return "McBryde-Thomas Sine (No. 1)"; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/MercatorProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | /** 21 | * Added isConformal method, removed isRectilinear (duplicate of super class) 22 | * by Bernhard Jenny, June 26, 2008. 23 | */ 24 | package com.jhlabs.map.proj; 25 | 26 | import com.jhlabs.map.MapMath; 27 | import java.awt.geom.Point2D; 28 | import java.time.Year; 29 | 30 | public class MercatorProjection extends CylindricalProjection { 31 | 32 | public MercatorProjection() { 33 | minLatitude = MapMath.degToRad(-85); 34 | maxLatitude = MapMath.degToRad(85); 35 | } 36 | 37 | public Point2D.Double project(double lam, double phi, Point2D.Double out) { 38 | if (spherical) { 39 | out.x = scaleFactor * lam; 40 | if (phi > maxLatitude) { 41 | phi = maxLatitude; 42 | } else if (phi < minLatitude) { 43 | phi = minLatitude; 44 | } 45 | out.y = scaleFactor * Math.log(Math.tan(MapMath.QUARTERPI + 0.5 * phi)); 46 | } else { 47 | out.x = scaleFactor * lam; 48 | out.y = -scaleFactor * Math.log(MapMath.tsfn(phi, Math.sin(phi), e)); 49 | } 50 | return out; 51 | } 52 | 53 | public Point2D.Double projectInverse(double x, double y, Point2D.Double out) { 54 | if (spherical) { 55 | out.y = MapMath.HALFPI - 2. * Math.atan(Math.exp(-y / scaleFactor)); 56 | out.x = x / scaleFactor; 57 | } else { 58 | out.y = MapMath.phi2(Math.exp(-y / scaleFactor), e); 59 | out.x = x / scaleFactor; 60 | } 61 | return out; 62 | } 63 | 64 | public boolean hasInverse() { 65 | return true; 66 | } 67 | 68 | public boolean isConformal() { 69 | return true; 70 | } 71 | 72 | /** 73 | * Returns the ESPG code for this projection, or 0 if unknown. 74 | */ 75 | public int getEPSGCode() { 76 | return 9804; 77 | } 78 | 79 | public String toString() { 80 | return "Mercator"; 81 | } 82 | 83 | @Override 84 | public Year getYear() { 85 | return Year.of(1569); 86 | } 87 | 88 | @Override 89 | public String getAuthor() { 90 | return "Gerardus Mercator (1512-94)"; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/MillerCylindrical1Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | 21 | /** 22 | * Changed name from Miller Cylindrical to Miller Cylindrical I 23 | * Bernhard Jenny, May 20 2010. 24 | */ 25 | package com.jhlabs.map.proj; 26 | 27 | import com.jhlabs.map.MapMath; 28 | import java.awt.geom.Point2D; 29 | 30 | public class MillerCylindrical1Projection extends CylindricalProjection { 31 | 32 | public MillerCylindrical1Projection() { 33 | } 34 | 35 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 36 | out.x = lplam; 37 | out.y = Math.log(Math.tan(MapMath.QUARTERPI + lpphi * .4)) * 1.25; 38 | return out; 39 | } 40 | 41 | public Point2D.Double projectInverse(double xyx, double xyy, Point2D.Double out) { 42 | out.x = xyx; 43 | out.y = 2.5 * (Math.atan(Math.exp(.8 * xyy)) - MapMath.QUARTERPI); 44 | return out; 45 | } 46 | 47 | public boolean hasInverse() { 48 | return true; 49 | } 50 | 51 | public String toString() { 52 | return "Miller Cylindrical I"; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/MillerCylindrical2Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2008 Bernhard Jenny 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package com.jhlabs.map.proj; 18 | 19 | import com.jhlabs.map.MapMath; 20 | import java.awt.geom.Point2D; 21 | 22 | /** 23 | * Miller's second cylindrical projection, which is not used as often as his 24 | * first one. Very similar to Braun's cylindrical stereographic projection. 25 | * Based on proj4. 26 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich. 27 | */ 28 | public class MillerCylindrical2Projection extends CylindricalProjection { 29 | 30 | public MillerCylindrical2Projection() { 31 | } 32 | 33 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 34 | out.x = lplam; 35 | out.y = Math.log(Math.tan(MapMath.QUARTERPI + lpphi / 3.)) * 1.5; 36 | return out; 37 | } 38 | 39 | public Point2D.Double projectInverse(double xyx, double xyy, Point2D.Double out) { 40 | out.x = xyx; 41 | out.y = 2.5 * (Math.atan(Math.exp(.8 * xyy)) - MapMath.QUARTERPI); 42 | return out; 43 | } 44 | 45 | public boolean hasInverse() { 46 | return true; 47 | } 48 | 49 | public String toString() { 50 | return "Miller Cylindrical II"; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/ModifiedAzimuthalProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2010 Bernhard Jenny 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package com.jhlabs.map.proj; 18 | 19 | /** 20 | * 21 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich. 22 | */ 23 | public abstract class ModifiedAzimuthalProjection extends Projection { 24 | 25 | public String toString() { 26 | return "Modified Azimuthal"; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/Murdoch1Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | package com.jhlabs.map.proj; 21 | 22 | public class Murdoch1Projection extends SimpleConicProjection { 23 | 24 | public Murdoch1Projection() { 25 | super( SimpleConicProjection.MURD1 ); 26 | } 27 | 28 | public String toString() { 29 | return "Murdoch I"; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/Murdoch2Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | package com.jhlabs.map.proj; 21 | 22 | public class Murdoch2Projection extends SimpleConicProjection { 23 | 24 | public Murdoch2Projection() { 25 | super( SimpleConicProjection.MURD2 ); 26 | } 27 | 28 | public String toString() { 29 | return "Murdoch II"; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/Murdoch3Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | package com.jhlabs.map.proj; 21 | 22 | public class Murdoch3Projection extends SimpleConicProjection { 23 | 24 | public Murdoch3Projection() { 25 | super( SimpleConicProjection.MURD3 ); 26 | } 27 | 28 | public String toString() { 29 | return "Murdoch III"; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/NZMGProjection.java: -------------------------------------------------------------------------------- 1 | /** 2 | Contributed by Andrey Novikov, September 2011. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package com.jhlabs.map.proj; 18 | 19 | import com.jhlabs.map.MapMath; 20 | import java.awt.geom.Point2D; 21 | 22 | public class NZMGProjection extends Projection { 23 | 24 | private static final double SEC5_TO_RAD = 0.4848136811095359935899141023; 25 | private static final double RAD_TO_SEC5 = 2.062648062470963551564733573; 26 | private static final double bf[][] = { 27 | {.7557853228, 0.0}, 28 | {.249204646, .003371507}, 29 | {-.001541739, .041058560}, 30 | {-.10162907, .01727609}, 31 | {-.26623489, -.36249218}, 32 | {-.6870983, -1.1651967}}; 33 | private static final double tphi[] = {1.5627014243, .5185406398, -.03333098, -.1052906, -.0368594, 34 | .007317, .01220, .00394, -.0013}; 35 | private static final double tpsi[] = {.6399175073, -.1358797613, .063294409, -.02526853, .0117879, 36 | -.0055161, .0026906, -.001333, .00067, -.00034}; 37 | 38 | public void initialize() { 39 | // force to International major axis 40 | a = 6378388.0; 41 | super.initialize(); 42 | //ra = 1. / a; 43 | projectionLongitude = DTR * 173.; 44 | projectionLatitude = DTR * -41.; 45 | falseEasting = 2510000.; 46 | falseNorthing = 6023150.; 47 | } 48 | 49 | public Point2D.Double project(double lam, double phi, Point2D.Double xy) { 50 | double[] p = new double[2]; 51 | 52 | phi = (phi - projectionLatitude) * RAD_TO_SEC5; 53 | p[0] = tpsi[tpsi.length - 1]; 54 | for (int i = tpsi.length - 2; i >= 0; i--) { 55 | p[0] = tpsi[i] + phi * p[0]; 56 | } 57 | p[0] *= phi; 58 | p[1] = lam; 59 | p = MapMath.zpoly1(p, bf, bf.length); 60 | xy.x = p[1]; 61 | xy.y = p[0]; 62 | return xy; 63 | } 64 | 65 | public Point2D.Double projectInverse(double x, double y, Point2D.Double lp) { 66 | int nn, i; 67 | double[] p = new double[2], f, fp = new double[2], dp = new double[2]; 68 | double den; 69 | 70 | p[0] = y; 71 | p[1] = x; 72 | for (nn = 20; nn > 0; --nn) { 73 | f = MapMath.zpolyd1(p, bf, bf.length, fp); 74 | f[0] -= y; 75 | f[1] -= x; 76 | den = fp[0] * fp[0] + fp[1] * fp[1]; 77 | p[0] += dp[0] = -(f[0] * fp[0] + f[1] * fp[1]) / den; 78 | p[1] += dp[1] = -(f[1] * fp[0] - f[0] * fp[1]) / den; 79 | if ((Math.abs(dp[0]) + Math.abs(dp[1])) <= EPS10) { 80 | break; 81 | } 82 | } 83 | lp.x = p[1]; 84 | lp.y = tphi[tphi.length - 1]; 85 | for (i = tphi.length - 2; i >= 0; --i) { 86 | lp.y = tphi[i] + p[0] * lp.y; 87 | } 88 | lp.y = projectionLatitude + p[0] * lp.y * SEC5_TO_RAD; 89 | return lp; 90 | } 91 | 92 | public boolean hasInverse() { 93 | return true; 94 | } 95 | 96 | public String toString() { 97 | return "New Zealand Map Grid"; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/NaturalEarth2Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2014 Bojan Savric 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | package com.jhlabs.map.proj; 17 | 18 | import java.awt.geom.*; 19 | 20 | /** 21 | * The Natural Earth II projection was designed by Tom Patterson, US National 22 | * Park Service, in 2012, using Flex Projector. The polynomial equations for the 23 | * projection were developed by Bojan Savric, Oregon State University, in 24 | * collaboration with Tom Patterson and Bernhard Jenny, Oregon State University. 25 | * 26 | * @author Bojan Savric 27 | */ 28 | public class NaturalEarth2Projection extends PseudoCylindricalProjection { 29 | 30 | private static final double A0 = 0.84719; 31 | private static final double A1 = -0.13063; 32 | private static final double A2 = -0.04515; 33 | private static final double A3 = 0.05494; 34 | private static final double A4 = -0.02326; 35 | private static final double A5 = 0.00331; 36 | private static final double B0 = 1.01183; 37 | private static final double B1 = -0.02625; 38 | private static final double B2 = 0.01926; 39 | private static final double B3 = -0.00396; 40 | private static final double C0 = B0; 41 | private static final double C1 = 9 * B1; 42 | private static final double C2 = 11 * B2; 43 | private static final double C3 = 13 * B3; 44 | private static final double EPS = 1e-11; 45 | private static final double MAX_Y = 0.84719 * 0.5351175 * Math.PI; 46 | 47 | @Override 48 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 49 | 50 | double phi2 = lpphi * lpphi; 51 | double phi4 = phi2 * phi2; 52 | double phi6 = phi4 * phi2; 53 | 54 | out.x = lplam * (A0 + A1 * phi2 + phi6 * phi6 * (A2 + A3 * phi2 + A4 * phi4 + A5 * phi6)); 55 | out.y = lpphi * (B0 + phi4 * phi4 * (B1 + B2 * phi2 + B3 * phi4)); 56 | 57 | return out; 58 | } 59 | 60 | @Override 61 | public boolean hasInverse() { 62 | return true; 63 | } 64 | 65 | @Override 66 | public Point2D.Double projectInverse(double x, double y, Point2D.Double lp) { 67 | 68 | // make sure y is inside valid range 69 | if (y > MAX_Y) { 70 | y = MAX_Y; 71 | } else if (y < -MAX_Y) { 72 | y = -MAX_Y; 73 | } 74 | 75 | // latitude 76 | double yc = y; 77 | double tol; 78 | for (;;) { // Newton-Raphson 79 | double y2 = yc * yc; 80 | double y4 = y2 * y2; 81 | double f = (yc * (B0 + y4 * y4 * (B1 + B2 * y2 + B3 * y4))) - y; 82 | double fder = C0 + y4 * y4 * (C1 + C2 * y2 + C3 * y4); 83 | yc -= tol = f / fder; 84 | if (Math.abs(tol) < EPS) { 85 | break; 86 | } 87 | } 88 | lp.y = yc; 89 | 90 | // longitude 91 | double y2 = yc * yc; 92 | double y4 = y2 * y2; 93 | double y6 = y4 * y2; 94 | 95 | double phi = A0 + A1 * y2 + y6 * y6 * (A2 + A3 * y2 + A4 * y4 + A5 * y6); 96 | lp.x = x / phi; 97 | 98 | return lp; 99 | } 100 | 101 | @Override 102 | public String toString() { 103 | return "Natural Earth II"; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/NellHammerProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | * 20 | * Nell-Hammer is a mean of the Cylindical Equal-Area and the Sinusoidal. 21 | * PROJ.4 contains code for weighted means. Here n = 0.5 22 | * 23 | * Bernhard Jenny, July 2007: 24 | * Changed name from NellHProjection, changed superclass to 25 | * PseudoCylindricalProjection. 26 | * 27 | * Bernhard Jenny, 19 September 2010: Fixed inverse projection. 28 | * 29 | */ 30 | package com.jhlabs.map.proj; 31 | 32 | import com.jhlabs.map.MapMath; 33 | import java.awt.geom.Point2D; 34 | 35 | public class NellHammerProjection extends PseudoCylindricalProjection { 36 | 37 | private final static int NITER = 9; 38 | private final static double EPS = 1e-7; 39 | 40 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 41 | out.x = 0.5 * lplam * (1. + Math.cos(lpphi)); 42 | out.y = 2.0 * (lpphi - Math.tan(0.5 * lpphi)); 43 | return out; 44 | } 45 | 46 | public Point2D.Double projectInverse(double xyx, double xyy, Point2D.Double out) { 47 | double V, c, p; 48 | int i; 49 | 50 | p = 0.5 * xyy; 51 | double phi = 0; // PROJ.4 does not implicitly initialize phi! 52 | for (i = NITER; i > 0; --i) { 53 | c = Math.cos(0.5 * phi); 54 | phi -= V = (phi - Math.tan(phi / 2) - p) / (1. - 0.5 / (c * c)); 55 | if (Math.abs(V) < EPS) { 56 | break; 57 | } 58 | } 59 | if (i == 0) { 60 | out.y = p < 0. ? -MapMath.HALFPI : MapMath.HALFPI; 61 | out.x = 2. * xyx; 62 | } else { 63 | out.x = 2. * xyx / (1. + Math.cos(phi)); 64 | out.y = phi; 65 | } 66 | return out; 67 | } 68 | 69 | public boolean hasInverse() { 70 | return true; 71 | } 72 | 73 | public String toString() { 74 | return "Nell-Hammer"; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/NellProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | * 20 | * Bernhard Jenny, 19 September 2010: fixed forward projection. 21 | * 23 September 2010: changed super class to PseudoCylindricalProjection. 22 | */ 23 | package com.jhlabs.map.proj; 24 | 25 | import com.jhlabs.map.MapMath; 26 | import java.awt.geom.Point2D; 27 | 28 | public class NellProjection extends PseudoCylindricalProjection { 29 | 30 | private final static int MAX_ITER = 10; 31 | private final static double LOOP_TOL = 1e-7; 32 | 33 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 34 | double k, V; 35 | int i; 36 | 37 | k = 2. * Math.sin(lpphi); 38 | V = lpphi * lpphi; 39 | lpphi *= 1.00371 + V * (-0.0935382 + V * -0.011412); 40 | for (i = MAX_ITER; i > 0; --i) { 41 | lpphi -= V = (lpphi + Math.sin(lpphi) - k) / (1. + Math.cos(lpphi)); 42 | if (Math.abs(V) < LOOP_TOL) { 43 | break; 44 | } 45 | } 46 | out.x = 0.5 * lplam * (1. + Math.cos(lpphi)); 47 | out.y = lpphi; 48 | return out; 49 | } 50 | 51 | public Point2D.Double projectInverse(double xyx, double xyy, Point2D.Double out) { 52 | out.x = 2. * xyx / (1. + Math.cos(xyy)); 53 | out.y = MapMath.asin(0.5 * (xyy + Math.sin(xyy))); 54 | return out; 55 | } 56 | 57 | public boolean hasInverse() { 58 | return true; 59 | } 60 | 61 | public String toString() { 62 | return "Nell"; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/NicolosiProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | 21 | /** 22 | * Added initialization for minLongitude and maxLongitude. 23 | * Bernhard Jenny, 15 July 2010. 24 | */ 25 | package com.jhlabs.map.proj; 26 | 27 | import com.jhlabs.map.MapMath; 28 | import java.awt.geom.Point2D; 29 | import java.time.Year; 30 | 31 | public class NicolosiProjection extends Projection { 32 | 33 | private final static double EPS = 1e-10; 34 | 35 | public NicolosiProjection() { 36 | minLongitude = Math.toRadians(-90); 37 | maxLongitude = Math.toRadians(90); 38 | } 39 | 40 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 41 | if (Math.abs(lplam) < EPS) { 42 | out.x = 0; 43 | out.y = lpphi; 44 | } else if (Math.abs(lpphi) < EPS) { 45 | out.x = lplam; 46 | out.y = 0.; 47 | } else if (Math.abs(Math.abs(lplam) - MapMath.HALFPI) < EPS) { 48 | out.x = lplam * Math.cos(lpphi); 49 | out.y = MapMath.HALFPI * Math.sin(lpphi); 50 | } else if (Math.abs(Math.abs(lpphi) - MapMath.HALFPI) < EPS) { 51 | out.x = 0; 52 | out.y = lpphi; 53 | } else { 54 | double tb, c, d, m, n, r2, sp; 55 | 56 | tb = MapMath.HALFPI / lplam - lplam / MapMath.HALFPI; 57 | c = lpphi / MapMath.HALFPI; 58 | d = (1 - c * c) / ((sp = Math.sin(lpphi)) - c); 59 | r2 = tb / d; 60 | r2 *= r2; 61 | m = (tb * sp / d - 0.5 * tb) / (1. + r2); 62 | n = (sp / r2 + 0.5 * d) / (1. + 1. / r2); 63 | double x = Math.cos(lpphi); 64 | x = Math.sqrt(m * m + x * x / (1. + r2)); 65 | out.x = MapMath.HALFPI * (m + (lplam < 0. ? -x : x)); 66 | double y = Math.sqrt(n * n - (sp * sp / r2 + d * sp - 1.) 67 | / (1. + 1. / r2)); 68 | out.y = MapMath.HALFPI * (n + (lpphi < 0. ? y : -y)); 69 | } 70 | return out; 71 | } 72 | 73 | @Override 74 | public Point2D.Double projectInverse(double x, double y, Point2D.Double out) { 75 | binarySearchInverse(x, y, out); 76 | return out; 77 | } 78 | 79 | @Override 80 | public boolean hasInverse() { 81 | return true; 82 | } 83 | 84 | public String toString() { 85 | return "Nicolosi Globular"; 86 | } 87 | 88 | @Override 89 | public Year getYear() { 90 | return Year.of(1660); 91 | } 92 | 93 | @Override 94 | public String getAuthor() { 95 | return "Giambattista Nicolosi (1610-1670)"; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/NullProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package com.jhlabs.map.proj; 18 | 19 | import java.awt.Shape; 20 | import java.awt.geom.Point2D; 21 | 22 | /** 23 | * A projection which does nothing. Use this for drawing non-geographical overlays. 24 | */ 25 | public class NullProjection extends Projection { 26 | 27 | public Point2D.Double transform( Point2D.Double src, Point2D.Double dst ) { 28 | dst.x = src.x; 29 | dst.y = src.y; 30 | return dst; 31 | } 32 | 33 | public Shape getBoundingShape() { 34 | return null; 35 | } 36 | 37 | public boolean isRectilinear() { 38 | return true; 39 | } 40 | 41 | public String toString() { 42 | return "Null"; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/OrteliusProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2010 Bernhard Jenny 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | package com.jhlabs.map.proj; 17 | 18 | import com.jhlabs.map.MapMath; 19 | import java.awt.geom.Point2D; 20 | import java.time.Year; 21 | 22 | /** 23 | * Code from proj4. 24 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich 25 | */ 26 | public class OrteliusProjection extends Projection { 27 | 28 | private static final double HLFPI2 = 2.46740110027233965467; 29 | private static final double EPS = 1e-10; 30 | 31 | public OrteliusProjection() { 32 | minLongitude = Math.toRadians(-90); 33 | maxLongitude = Math.toRadians(90); 34 | initialize(); 35 | } 36 | 37 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 38 | 39 | out.y = lpphi; 40 | final double ax = Math.abs(lplam); 41 | if (ax >= EPS) { 42 | if (ax >= MapMath.HALFPI) { 43 | out.x = Math.sqrt(HLFPI2 - lpphi * lpphi + EPS) + ax - MapMath.HALFPI; 44 | } else { 45 | final double f = 0.5 * (HLFPI2 / ax + ax); 46 | out.x = ax - f + Math.sqrt(f * f - out.y * out.y); 47 | } 48 | if (lplam < 0.) { 49 | out.x = -out.x; 50 | } 51 | } else { 52 | out.x = 0.; 53 | } 54 | return out; 55 | } 56 | 57 | @Override 58 | public Point2D.Double projectInverse(double x, double y, Point2D.Double out) { 59 | binarySearchInverse(x, y, out); 60 | return out; 61 | } 62 | 63 | @Override 64 | public boolean hasInverse() { 65 | return true; 66 | } 67 | 68 | public String toString() { 69 | return "Ortelius Oval"; 70 | } 71 | 72 | @Override 73 | public String getAuthor() { 74 | return "Battista Agnese (1514-64) in 1544, Abraham Ortelius (1527-98) in 1570"; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/OtherProjections.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | package com.jhlabs.map.proj; 21 | 22 | public class OtherProjections { 23 | public Object createPlugin() { 24 | return new Object[] { 25 | //new SimpleConicProjection(SimpleConicProjection.TISSOT), 26 | new SimpleConicProjection(SimpleConicProjection.MURD1), 27 | new SimpleConicProjection(SimpleConicProjection.MURD2), 28 | new SimpleConicProjection(SimpleConicProjection.MURD3), 29 | new SimpleConicProjection(SimpleConicProjection.PCONIC), 30 | new SimpleConicProjection(SimpleConicProjection.VITK1), 31 | new MollweideProjection(MollweideProjection.WAGNER4), 32 | new MollweideProjection(MollweideProjection.WAGNER5), 33 | }; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/PattersonProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2014 Bojan Savric 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | package com.jhlabs.map.proj; 17 | 18 | import java.awt.geom.Point2D; 19 | 20 | /** 21 | * The Patterson projection was designed by Tom Patterson, US National 22 | * Park Service, in 2014, using Flex Projector. The polynomial equations for the 23 | * projection were developed by Bojan Savric, Oregon State University, in 24 | * collaboration with Tom Patterson and Bernhard Jenny, Oregon State University. 25 | * 26 | * @author Bojan Savric 27 | */ 28 | 29 | public class PattersonProjection extends CylindricalProjection { 30 | 31 | private final static double K1 = 1.0148; 32 | private final static double K2 = 0.23185; 33 | private final static double K3 = -0.14499; 34 | private final static double K4 = 0.02406; 35 | private final static double C1 = K1; 36 | private final static double C2 = 5 * K2; 37 | private final static double C3 = 7 * K3; 38 | private final static double C4 = 9 * K4; 39 | private final static double EPS = 1e-11; 40 | private final static double MAX_Y = 1.790857183; 41 | 42 | @Override 43 | public Point2D.Double project(double lon, double lat, Point2D.Double out) { 44 | final double lat_sq = lat * lat; 45 | out.x = lon; 46 | out.y = lat * (K1 + lat_sq * lat_sq * (K2 + lat_sq * (K3 + K4 * lat_sq))); 47 | return out; 48 | } 49 | 50 | @Override 51 | public boolean hasInverse() { 52 | return true; 53 | } 54 | 55 | @Override 56 | public Point2D.Double projectInverse(double x, double y, Point2D.Double lp) { 57 | 58 | // make sure y is inside valid range 59 | if (y > MAX_Y) { 60 | y = MAX_Y; 61 | } else if (y < -MAX_Y) { 62 | y = -MAX_Y; 63 | } 64 | 65 | // latitude 66 | double yc = y; 67 | double tol; 68 | for (;;) { // Newton-Raphson 69 | double y2 = yc * yc; 70 | double f = (yc * (K1 + y2 * y2 * (K2 + y2 * (K3 + K4 * y2)))) - y; 71 | double fder = C1 + y2 * y2 * (C2 + y2 * (C3 + C4 * y2)); 72 | yc -= tol = f / fder; 73 | if (Math.abs(tol) < EPS) { 74 | break; 75 | } 76 | } 77 | lp.y = yc; 78 | 79 | // longitude 80 | lp.x = x; 81 | 82 | return lp; 83 | } 84 | 85 | @Override 86 | public String toString() { 87 | return "Patterson"; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/PerspectiveConicProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | package com.jhlabs.map.proj; 21 | 22 | public class PerspectiveConicProjection extends SimpleConicProjection { 23 | 24 | public PerspectiveConicProjection() { 25 | super( SimpleConicProjection.PCONIC ); 26 | } 27 | 28 | public String toString() { 29 | return "Perspective Conic"; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/ProjectionException.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package com.jhlabs.map.proj; 18 | 19 | public class ProjectionException extends RuntimeException { 20 | public ProjectionException() { 21 | super(); 22 | } 23 | 24 | public ProjectionException(String message) { 25 | super(message); 26 | } 27 | 28 | /* 29 | * const PROJ_ERR_LIST proj_err_list[] = { 30 | {-1, "no arguments in initialization list"}, 31 | {-2, "no options found in 'init' file"}, 32 | {-3, "no colon in init= string"}, 33 | {-4, "projection not named"}, 34 | {-5, "unknown projection id"}, 35 | {-6, "effective eccentricity = 1."}, 36 | {-7, "unknown unit conversion id"}, 37 | {-8, "invalid boolean param argument"}, 38 | {-9, "unknown elliptical parameter name"}, 39 | {-10, "reciprocal flattening (1/f) = 0"}, 40 | {-11, "|radius reference latitude| > 90"}, 41 | {-12, "squared eccentricity < 0"}, 42 | {-13, "major axis or radius = 0 or not given"}, 43 | {-14, "latitude or longitude exceeded limits"}, 44 | {-15, "invalid x or y"}, 45 | {-16, "improperly formed DMS value"}, 46 | {-17, "non-convergent inverse meridinal dist"}, 47 | {-18, "non-convergent inverse phi2"}, 48 | {-19, "acos/asin: |arg| >1.+1e-14"}, 49 | {-20, "tolerance condition error"}, 50 | {-21, "conic lat_1 = -lat_2"}, 51 | {-22, "lat_1 >= 90"}, 52 | {-23, "lat_1 = 0"}, 53 | {-24, "lat_ts >= 90"}, 54 | {-25, "no distance between control points"}, 55 | {-26, "projection not selected to be rotated"}, 56 | {-27, "W <= 0 or M <= 0"}, 57 | {-28, "lsat not in 1-5 range"}, 58 | {-29, "path not in range"}, 59 | {-30, "h <= 0"}, 60 | {-31, "k <= 0"}, 61 | {-32, "lat_0 = 0 or 90 or alpha = 90"}, 62 | {-33, "lat_1=lat_2 or lat_1=0 or lat_2=90"}, 63 | {-34, "elliptical usage required"}, 64 | {-35, "invalid UTM zone number"}, 65 | {-36, "arg(s) out of range for Tcheby eval"}, 66 | {-37, "failed to find projection to be rotated"}, 67 | {-38, "failed to load NAD27-83 correction file"}, 68 | {-39, "both n & m must be spec'd and > 0"}, 69 | {-40, "n <= 0, n > 1 or not specified"}, 70 | {-41, "lat_1 or lat_2 not specified"}, 71 | {-42, "|lat_1| == |lat_2|"}, 72 | {-43, "lat_0 is pi/2 from mean lat"}, 73 | {-44, "lat_0 not specified"}, 74 | {-45, "lat_0 == 0"}, 75 | {-46, "lat_0 != 0"}, 76 | {-47, "compiled/linked ONLY with libproj4 and standard libaries"}, 77 | {-48, "failed to select tangent or sine mode"}, 78 | {-49, "failed to set both +p and +q"}, 79 | {0, "0 or invalid projection system error number"} 80 | }; 81 | 82 | */ 83 | } 84 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/PseudoCylindricalProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /** 18 | * Bernhard Jenny, May 18 2010: 19 | * Changed base class from CylindricalProjection to Projection, removed 20 | * isRectilinear method, changed description of class. 21 | * 23 September 2010: added parallelsAreParallel 22 | */ 23 | package com.jhlabs.map.proj; 24 | 25 | /** 26 | * The superclass for all pseudo-cylindrical projections - eg. sinusoidal 27 | * These are projections where parallels are straight and parallel, and 28 | * meridians are curved. 29 | */ 30 | public abstract class PseudoCylindricalProjection extends Projection { 31 | 32 | public String toString() { 33 | return "Pseudo-Cylindrical"; 34 | } 35 | 36 | public boolean parallelsAreParallel() { 37 | return true; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/PutninsP1Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2007 Bernhard Jenny 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | 16 | * PutninsP1Projection.java 17 | * 18 | * Created on May 19, 2007, 7:23 PM 19 | * 20 | */ 21 | 22 | package com.jhlabs.map.proj; 23 | 24 | /** 25 | * Putnins P1 projection. Based on Proj4. 26 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich 27 | */ 28 | public class PutninsP1Projection extends EllipticalPseudoCylindrical{ 29 | 30 | /** Creates a new instance of PutninP1Projection */ 31 | public PutninsP1Projection() { 32 | super(1.89490, 33 | 0.94745, 34 | -0.5, 35 | 0.30396355092701331433); 36 | } 37 | 38 | public String toString() { 39 | return "Putnins P1"; 40 | } 41 | } -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/PutninsP2Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | * 20 | * Bernhard Jenny, 19 September 2010: fixed forward projection. 21 | * 23 September 2010: changed super class to PseudoCylindricalProjection. 22 | */ 23 | package com.jhlabs.map.proj; 24 | 25 | import com.jhlabs.map.MapMath; 26 | import java.awt.geom.Point2D; 27 | 28 | public class PutninsP2Projection extends PseudoCylindricalProjection { 29 | 30 | private final static double C_x = 1.89490; 31 | private final static double C_y = 1.71848; 32 | private final static double C_p = 0.6141848493043784; 33 | private final static double EPS = 1e-10; 34 | private final static int NITER = 10; 35 | private final static double PI_DIV_3 = 1.0471975511965977; 36 | 37 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 38 | double p, c, s, V; 39 | int i; 40 | 41 | p = C_p * Math.sin(lpphi); 42 | s = lpphi * lpphi; 43 | lpphi *= 0.615709 + s * (0.00909953 + s * 0.0046292); 44 | for (i = NITER; i > 0; --i) { 45 | c = Math.cos(lpphi); 46 | s = Math.sin(lpphi); 47 | lpphi -= V = (lpphi + s * (c - 1.) - p) 48 | / (1. + c * (c - 1.) - s * s); 49 | if (Math.abs(V) < EPS) { 50 | break; 51 | } 52 | } 53 | if (i == 0) { 54 | lpphi = lpphi < 0 ? -PI_DIV_3 : PI_DIV_3; 55 | } 56 | out.x = C_x * lplam * (Math.cos(lpphi) - 0.5); 57 | out.y = C_y * Math.sin(lpphi); 58 | return out; 59 | } 60 | 61 | public Point2D.Double projectInverse(double xyx, double xyy, Point2D.Double out) { 62 | double c; 63 | 64 | out.y = MapMath.asin(xyy / C_y); 65 | out.x = xyx / (C_x * ((c = Math.cos(out.y)) - 0.5)); 66 | out.y = MapMath.asin((out.y + Math.sin(out.y) * (c - 1.)) / C_p); 67 | return out; 68 | } 69 | 70 | public boolean hasInverse() { 71 | return true; 72 | } 73 | 74 | public String toString() { 75 | return "Putnins P2"; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/PutninsP4PProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | 21 | /** 22 | * Was confounded with Putnins P4. Corrected name of projection, changed 23 | * name of class from PutninsP4Projection to PutninsP4PProjection, changed 24 | * superclass to PseudoCylindricalProjection. 25 | * Bernhard Jenny, October 28 2008. 26 | */ 27 | package com.jhlabs.map.proj; 28 | 29 | import java.awt.geom.*; 30 | import com.jhlabs.map.*; 31 | 32 | public class PutninsP4PProjection extends PseudoCylindricalProjection { 33 | 34 | protected double C_x; 35 | protected double C_y; 36 | 37 | public PutninsP4PProjection() { 38 | C_x = 0.874038744; 39 | C_y = 3.883251825; 40 | } 41 | 42 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double xy) { 43 | lpphi = MapMath.asin(0.883883476 * Math.sin(lpphi)); 44 | xy.x = C_x * lplam * Math.cos(lpphi); 45 | xy.x /= Math.cos(lpphi *= 0.333333333333333); 46 | xy.y = C_y * Math.sin(lpphi); 47 | return xy; 48 | } 49 | 50 | public Point2D.Double projectInverse(double xyx, double xyy, Point2D.Double lp) { 51 | lp.y = MapMath.asin(xyy / C_y); 52 | lp.x = xyx * Math.cos(lp.y) / C_x; 53 | lp.y *= 3.; 54 | lp.x /= Math.cos(lp.y); 55 | lp.y = MapMath.asin(1.13137085 * Math.sin(lp.y)); 56 | return lp; 57 | } 58 | 59 | public boolean isEqualArea() { 60 | return true; 61 | } 62 | 63 | public boolean hasInverse() { 64 | return true; 65 | } 66 | 67 | public String toString() { 68 | return "Putnins P4'"; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/PutninsP5PProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | 21 | /** 22 | * Changed name string fom "Putnins P5P" to "Putnins P5'" by Bernhard Jenny, 23 | * October 28 2008. 24 | */ 25 | package com.jhlabs.map.proj; 26 | 27 | public class PutninsP5PProjection extends PutninsP5Projection { 28 | 29 | public PutninsP5PProjection() { 30 | A = 1.5; 31 | B = 0.5; 32 | } 33 | 34 | public String toString() { 35 | return "Putnins P5'"; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/PutninsP5Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | 21 | /** 22 | * Changed superclass to PseudoCylindricalProjection. 23 | * Bernhard Jenny, May 25 2010. 24 | */ 25 | package com.jhlabs.map.proj; 26 | 27 | import java.awt.geom.Point2D; 28 | 29 | public class PutninsP5Projection extends PseudoCylindricalProjection { 30 | 31 | protected double A; 32 | protected double B; 33 | 34 | private final static double C = 1.01346; 35 | private final static double D = 1.2158542; 36 | 37 | public PutninsP5Projection() { 38 | A = 2; 39 | B = 1; 40 | } 41 | 42 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double xy) { 43 | xy.x = C * lplam * (A - B * Math.sqrt(1. + D * lpphi * lpphi)); 44 | xy.y = C * lpphi; 45 | return xy; 46 | } 47 | 48 | public Point2D.Double projectInverse(double xyx, double xyy, Point2D.Double lp) { 49 | lp.y = xyy / C; 50 | lp.x = xyx / (C * (A - B * Math.sqrt(1. + D * lp.y * lp.y))); 51 | return lp; 52 | } 53 | 54 | public boolean hasInverse() { 55 | return true; 56 | } 57 | 58 | public String toString() { 59 | return "Putnins P5"; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/QuarticAuthalicProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | /** 21 | * Added isEqualArea by Bernhard Jenny, May 19 2010. 22 | */ 23 | package com.jhlabs.map.proj; 24 | 25 | public class QuarticAuthalicProjection extends STSProjection { 26 | 27 | public QuarticAuthalicProjection() { 28 | super(2., 2., false); 29 | } 30 | 31 | public boolean isEqualArea() { 32 | return true; 33 | } 34 | 35 | public String toString() { 36 | return "Quartic Authalic"; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/RectangularPolyconicProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | package com.jhlabs.map.proj; 21 | 22 | import java.awt.geom.Point2D; 23 | 24 | public class RectangularPolyconicProjection extends Projection { 25 | 26 | private double phi0; 27 | private double phi1; 28 | private double fxa; 29 | private double fxb; 30 | private boolean mode; 31 | 32 | private final static double EPS = 1e-9; 33 | 34 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 35 | double fa; 36 | 37 | if (mode) 38 | fa = Math.tan(lplam * fxb) * fxa; 39 | else 40 | fa = 0.5 * lplam; 41 | if (Math.abs(lpphi) < EPS) { 42 | out.x = fa + fa; 43 | out.y = - phi0; 44 | } else { 45 | out.y = 1. / Math.tan(lpphi); 46 | out.x = Math.sin(fa = 2. * Math.atan(fa * Math.sin(lpphi))) * out.y; 47 | out.y = lpphi - phi0 + (1. - Math.cos(fa)) * out.y; 48 | } 49 | return out; 50 | } 51 | 52 | public void initialize() { // rpoly 53 | super.initialize(); 54 | /*FIXME 55 | if ((mode = (phi1 = Math.abs(pj_param(params, "rlat_ts").f)) > EPS)) { 56 | fxb = 0.5 * Math.sin(phi1); 57 | fxa = 0.5 / fxb; 58 | } 59 | */ 60 | } 61 | 62 | public String toString() { 63 | return "Rectangular Polyconic"; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/STSProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | /** 21 | * Bernhard Jenny, May 25 2010: 22 | * Changed superclass from ConicProjection to PseudoCylindricalProjection, and 23 | * made abstract. 24 | * Bernhard Jenny, 19 September 2010: 25 | * Fixed inverse projection. 26 | */ 27 | package com.jhlabs.map.proj; 28 | 29 | import com.jhlabs.map.MapMath; 30 | import java.awt.geom.Point2D; 31 | 32 | /** 33 | * Sine-Tangent Series 34 | * Abstract base class for Kavraisky5Projection, McBrydeThomasSine1Projection, 35 | * FoucautProjection, and QuarticAuthalicProjection. 36 | */ 37 | public abstract class STSProjection extends PseudoCylindricalProjection { 38 | 39 | private double C_x; 40 | private double C_y; 41 | private double C_p; 42 | private boolean tan_mode; 43 | 44 | protected STSProjection(double p, double q, boolean mode) { 45 | es = 0.; 46 | C_x = q / p; 47 | C_y = p; 48 | C_p = 1 / q; 49 | tan_mode = mode; 50 | initialize(); 51 | } 52 | 53 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double xy) { 54 | double c; 55 | 56 | xy.x = C_x * lplam * Math.cos(lpphi); 57 | xy.y = C_y; 58 | lpphi *= C_p; 59 | c = Math.cos(lpphi); 60 | if (tan_mode) { 61 | xy.x *= c * c; 62 | xy.y *= Math.tan(lpphi); 63 | } else { 64 | xy.x /= c; 65 | xy.y *= Math.sin(lpphi); 66 | } 67 | return xy; 68 | } 69 | 70 | public Point2D.Double projectInverse(double xyx, double xyy, Point2D.Double lp) { 71 | double c; 72 | 73 | xyy /= C_y; 74 | c = Math.cos(lp.y = tan_mode ? Math.atan(xyy) : MapMath.asin(xyy)); 75 | lp.x = xyx / (C_x * Math.cos(lp.y /= C_p)); 76 | if (tan_mode) { 77 | lp.x /= c * c; 78 | } else { 79 | lp.x *= c; 80 | } 81 | return lp; 82 | } 83 | 84 | public boolean hasInverse() { 85 | return true; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/SinusoidalProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | /** 21 | * Added isEqualArea by Bernhard Jenny, October 28 2008. 22 | */ 23 | package com.jhlabs.map.proj; 24 | 25 | import com.jhlabs.map.MapMath; 26 | import java.awt.geom.Point2D; 27 | 28 | public class SinusoidalProjection extends PseudoCylindricalProjection { 29 | 30 | public Point2D.Double project(double lam, double phi, Point2D.Double xy) { 31 | xy.x = lam * Math.cos(phi); 32 | xy.y = phi; 33 | return xy; 34 | } 35 | 36 | public Point2D.Double projectInverse(double x, double y, Point2D.Double lp) { 37 | lp.x = x / Math.cos(y); 38 | lp.y = y; 39 | return lp; 40 | } 41 | 42 | public double getWidth(double y) { 43 | return MapMath.normalizeLongitude(Math.PI) * Math.cos(y); // FIXME 44 | } 45 | 46 | public boolean hasInverse() { 47 | return true; 48 | } 49 | 50 | public boolean isEqualArea() { 51 | return true; 52 | } 53 | 54 | public String toString() { 55 | return "Sinusoidal"; 56 | } 57 | 58 | @Override 59 | public String getDescription() { 60 | return super.getDescription() + " Also called Sanson-Flamsteed."; 61 | } 62 | 63 | @Override 64 | public String getHistoryDescription() { 65 | return "16th century. Used by Cossin in 1570."; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/SwissObliqueMercatorProjection.java: -------------------------------------------------------------------------------- 1 | /** 2 | Contributed by Andrey Novikov, September 2011. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package com.jhlabs.map.proj; 18 | 19 | import com.jhlabs.map.MapMath; 20 | import java.awt.geom.Point2D; 21 | 22 | public class SwissObliqueMercatorProjection extends CylindricalProjection { 23 | 24 | private double K, c, hlf_e, kR, cosp0, sinp0; 25 | private static final int NITER = 6; 26 | 27 | public void initialize() { 28 | super.initialize(); 29 | 30 | double cp, phip0, sp; 31 | 32 | hlf_e = 0.5 * e; 33 | cp = Math.cos(projectionLatitude); 34 | cp *= cp; 35 | c = Math.sqrt(1 + es * cp * cp * rone_es); 36 | sp = Math.sin(projectionLatitude); 37 | phip0 = Math.asin(sinp0 = sp / c); 38 | cosp0 = Math.cos(phip0); 39 | sp *= e; 40 | K = Math.log(Math.tan(MapMath.QUARTERPI + 0.5 * phip0)) - c * (Math.log(Math.tan(MapMath.QUARTERPI + 0.5 * projectionLatitude)) - hlf_e 41 | * Math.log((1. + sp) / (1. - sp))); 42 | kR = scaleFactor * Math.sqrt(one_es) / (1. - sp * sp); 43 | } 44 | 45 | public Point2D.Double project(double lam, double phi, Point2D.Double xy) { 46 | double phip, lamp, phipp, lampp, sp, cp; 47 | 48 | sp = e * Math.sin(phi); 49 | phip = 2. * Math.atan(Math.exp(c * (Math.log(Math.tan(MapMath.QUARTERPI + 0.5 * phi)) - hlf_e * Math.log((1. + sp) / (1. - sp))) 50 | + K)) - MapMath.HALFPI; 51 | lamp = c * lam; 52 | cp = Math.cos(phip); 53 | phipp = Math.asin(cosp0 * Math.sin(phip) - sinp0 * cp * Math.cos(lamp)); 54 | lampp = Math.asin(cp * Math.sin(lamp) / Math.cos(phipp)); 55 | xy.x = kR * lampp; 56 | xy.y = kR * Math.log(Math.tan(MapMath.QUARTERPI + 0.5 * phipp)); 57 | return xy; 58 | } 59 | 60 | public Point2D.Double projectInverse(double x, double y, Point2D.Double lp) { 61 | double phip, lamp, phipp, lampp, cp, esp, con, delp; 62 | int i; 63 | 64 | phipp = 2. * (Math.atan(Math.exp(y / kR)) - MapMath.QUARTERPI); 65 | lampp = x / kR; 66 | cp = Math.cos(phipp); 67 | phip = Math.asin(cosp0 * Math.sin(phipp) + sinp0 * cp * Math.cos(lampp)); 68 | lamp = Math.asin(cp * Math.sin(lampp) / Math.cos(phip)); 69 | con = (K - Math.log(Math.tan(MapMath.QUARTERPI + 0.5 * phip))) / c; 70 | for (i = NITER; i >= 0; i--) { 71 | esp = e * Math.sin(phip); 72 | delp = (con + Math.log(Math.tan(MapMath.QUARTERPI + 0.5 * phip)) - hlf_e 73 | * Math.log((1. + esp) / (1. - esp))) 74 | * (1. - esp * esp) * Math.cos(phip) * rone_es; 75 | phip -= delp; 76 | if (Math.abs(delp) < EPS10) { 77 | break; 78 | } 79 | } 80 | 81 | // FIXME TODO error was set in C on this condition 82 | if (i == 0) { 83 | } 84 | 85 | lp.x = phip; 86 | lp.y = lamp / c; 87 | 88 | return lp; 89 | } 90 | 91 | public boolean hasInverse() { 92 | return true; 93 | } 94 | 95 | public String toString() { 96 | // For CH1903 97 | return "Swiss Oblique Mercator"; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/TCCProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | package com.jhlabs.map.proj; 21 | 22 | import com.jhlabs.map.MapMath; 23 | import java.awt.geom.Point2D; 24 | 25 | public class TCCProjection extends CylindricalProjection { 26 | 27 | public TCCProjection() { 28 | minLongitude = MapMath.degToRad(-60); 29 | maxLongitude = MapMath.degToRad(60); 30 | } 31 | 32 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 33 | double b, bt; 34 | 35 | b = Math.cos(lpphi) * Math.sin(lplam); 36 | if ((bt = 1. - b * b) < EPS10) 37 | throw new ProjectionException("F"); 38 | out.x = b / Math.sqrt(bt); 39 | out.y = Math.atan2(Math.tan(lpphi), Math.cos(lplam)); 40 | return out; 41 | } 42 | 43 | public boolean isRectilinear() { 44 | return false; 45 | } 46 | 47 | public String toString() { 48 | return "Transverse Central Cylindrical"; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/TCEAProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | 21 | /** 22 | * Added isEqualArea and changed base class to CylindricalProjection 23 | * by Bernhard Jenny, July 12 2010. 24 | */ 25 | package com.jhlabs.map.proj; 26 | 27 | import java.awt.geom.Point2D; 28 | 29 | public class TCEAProjection extends CylindricalProjection { 30 | 31 | private double rk0; 32 | 33 | public TCEAProjection() { 34 | initialize(); 35 | } 36 | 37 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 38 | out.x = rk0 * Math.cos(lpphi) * Math.sin(lplam); 39 | out.y = scaleFactor * (Math.atan2(Math.tan(lpphi), Math.cos(lplam)) - projectionLatitude); 40 | return out; 41 | } 42 | 43 | public Point2D.Double projectInverse(double xyx, double xyy, Point2D.Double out) { 44 | double t; 45 | 46 | out.y = xyy * rk0 + projectionLatitude; 47 | out.x *= scaleFactor; 48 | t = Math.sqrt(1. - xyx * xyx); 49 | out.y = Math.asin(t * Math.sin(xyy)); 50 | out.x = Math.atan2(xyx, t * Math.cos(xyy)); 51 | return out; 52 | } 53 | 54 | public void initialize() { // tcea 55 | super.initialize(); 56 | rk0 = 1 / scaleFactor; 57 | } 58 | 59 | public boolean isRectilinear() { 60 | return false; 61 | } 62 | 63 | public boolean hasInverse() { 64 | return true; 65 | } 66 | 67 | public boolean isEqualArea() { 68 | return false; 69 | } 70 | 71 | public String toString() { 72 | return "Transverse Cylindrical Equal Area"; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/TissotProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | * 20 | * Bernhard Jenny, 17 September 2010: 21 | * Tissot projection does no longer derive from SimpleConicProjection base class, 22 | * but from ConicProjection. 23 | * Fixed bugs in projectInverse(). 24 | */ 25 | package com.jhlabs.map.proj; 26 | 27 | import com.jhlabs.map.MapMath; 28 | import java.awt.geom.Point2D; 29 | 30 | public class TissotProjection extends ConicProjection { 31 | 32 | private final static double EPS = 1e-10; 33 | private double rho_c, rho_0, n; 34 | 35 | public TissotProjection() { 36 | projectionLatitude = Math.toRadians(45); 37 | projectionLatitude1 = Math.toRadians(35); 38 | projectionLatitude2 = Math.toRadians(60); 39 | } 40 | 41 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 42 | double rho = rho_c - lpphi; 43 | out.x = rho * Math.sin(lplam *= n); 44 | out.y = rho_0 - rho * Math.cos(lplam); 45 | return out; 46 | } 47 | 48 | public Point2D.Double projectInverse(double xyx, double xyy, Point2D.Double out) { 49 | xyy = rho_0 - xyy; 50 | double rho = MapMath.distance(xyx, xyy); 51 | if (n < 0.) { 52 | rho = -rho; 53 | xyx = -xyx; 54 | xyy = -xyy; 55 | } 56 | out.x = Math.atan2(xyx, xyy) / n; 57 | out.y = rho_c - rho; 58 | return out; 59 | } 60 | 61 | public void initialize() { 62 | 63 | super.initialize(); 64 | // FIXME this will throw an exception with lat1 = lat2, which is the default. 65 | double del = 0.5 * (projectionLatitude2 - projectionLatitude1); 66 | double sig = 0.5 * (projectionLatitude2 + projectionLatitude1); 67 | 68 | if (Math.abs(del) < EPS || Math.abs(sig) < EPS) { 69 | throw new ProjectionException("-42"); 70 | } 71 | n = Math.sin(sig); 72 | double cs = Math.cos(del); 73 | rho_c = n / cs + cs / n; 74 | rho_0 = Math.sqrt((rho_c - 2 * Math.sin(projectionLatitude)) / n); 75 | 76 | } 77 | 78 | public boolean hasInverse() { 79 | return true; 80 | } 81 | 82 | public String toString() { 83 | return "Tissot"; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/ToblerMercator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Bernie Jenny, Monash University, Melbourne, Australia. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * An equal-area version of the Mercator projection by Waldo Tobler. 17 | * 18 | * Tobler, W. (2018). A new companion for Mercator. Cartography and Geographic 19 | * Information Science, 45 (3), p. 284-285. 20 | * 21 | * @author Bernie Jenny 22 | */ 23 | package com.jhlabs.map.proj; 24 | 25 | import com.jhlabs.map.MapMath; 26 | import java.awt.geom.Point2D; 27 | import java.time.Year; 28 | 29 | public class ToblerMercator extends CylindricalProjection { 30 | 31 | public ToblerMercator() { 32 | minLatitude = MapMath.degToRad(-85); 33 | maxLatitude = MapMath.degToRad(85); 34 | } 35 | 36 | @Override 37 | public Point2D.Double project(double lon, double lat, Point2D.Double out) { 38 | if (lat > maxLatitude) { 39 | lat = maxLatitude; 40 | } else if (lat < minLatitude) { 41 | lat = minLatitude; 42 | } 43 | double cosLat = Math.cos(lat); 44 | out.x = scaleFactor * lon * cosLat * cosLat; 45 | out.y = scaleFactor * Math.log(Math.tan(MapMath.QUARTERPI + 0.5 * lat)); 46 | 47 | return out; 48 | } 49 | 50 | @Override 51 | public Point2D.Double projectInverse(double x, double y, Point2D.Double out) { 52 | double lat = MapMath.HALFPI - 2. * Math.atan(Math.exp(-y / scaleFactor)); 53 | double cosLat = Math.cos(lat); 54 | double lon = x / scaleFactor / (cosLat * cosLat); 55 | out.x = lon; 56 | out.y = lat; 57 | return out; 58 | } 59 | 60 | @Override 61 | public boolean hasInverse() { 62 | return true; 63 | } 64 | 65 | @Override 66 | public boolean isEqualArea() { 67 | return true; 68 | } 69 | 70 | @Override 71 | public String toString() { 72 | return "Tobler-Mercator"; 73 | } 74 | 75 | @Override 76 | public Year getYear() { 77 | return Year.of(2018); 78 | } 79 | 80 | @Override 81 | public String getAuthor() { 82 | return "Waldo R. Tobler"; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/TransverseMercatorProjection.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSUCartography/JMapProjLib/61429b4edb79885f12d7b0e73ad870bd37a3dbe2/src/com/jhlabs/map/proj/TransverseMercatorProjection.java -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/URMFPSProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | * 20 | * With the default parameter n, this is identical to Wagner I. 21 | * 22 | * Bernhard Jenny, 19 September 2010: fixed forward projection. 23 | * 23 September 2010: fixed type in toString, changed super class to 24 | * PseudoCylindricalProjection. 25 | */ 26 | package com.jhlabs.map.proj; 27 | 28 | import com.jhlabs.map.MapMath; 29 | import java.awt.geom.Point2D; 30 | 31 | public class URMFPSProjection extends PseudoCylindricalProjection { 32 | 33 | private final static double C_x = 0.8773826753; 34 | private final static double Cy = 1.139753528477; 35 | private double n = 0.8660254037844386467637231707;// wag1 36 | private double C_y; 37 | 38 | public URMFPSProjection() { 39 | } 40 | 41 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 42 | lpphi = MapMath.asin(n * Math.sin(lpphi)); 43 | out.x = C_x * lplam * Math.cos(lpphi); 44 | out.y = C_y * lpphi; 45 | return out; 46 | } 47 | 48 | public Point2D.Double projectInverse(double xyx, double xyy, Point2D.Double out) { 49 | xyy /= C_y; 50 | out.y = MapMath.asin(Math.sin(xyy) / n); 51 | out.x = xyx / (C_x * Math.cos(xyy)); 52 | return out; 53 | } 54 | 55 | public boolean hasInverse() { 56 | return true; 57 | } 58 | 59 | public void initialize() { // urmfps 60 | super.initialize(); 61 | if (n <= 0. || n > 1.) { 62 | throw new ProjectionException("-40"); 63 | } 64 | C_y = Cy / n; 65 | } 66 | 67 | // Properties 68 | public void setN(double n) { 69 | this.n = n; 70 | } 71 | 72 | public double getN() { 73 | return n; 74 | } 75 | 76 | public String toString() { 77 | return "Urmayev Flat-Polar Sinusoidal"; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/UniversalTransverseMercatorProjection.java: -------------------------------------------------------------------------------- 1 | /** 2 | Contributed by Andrey Novikov, September 2011. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | package com.jhlabs.map.proj; 17 | 18 | import com.jhlabs.map.MapMath; 19 | 20 | public class UniversalTransverseMercatorProjection extends TransverseMercatorProjection { 21 | 22 | protected int utmzone = -1; 23 | 24 | public void initialize() { 25 | // TODO 26 | // if (!P->es) E_ERROR(-34); FIXME 27 | if (utmzone < 0) { 28 | int zone = (int) getZoneFromNearestMeridian(projectionLongitude * RTD); 29 | setUTMZone(zone); 30 | } 31 | super.initialize(); 32 | } 33 | 34 | public int getRowFromNearestParallel(double latitude) { 35 | int degrees = (int)MapMath.radToDeg(MapMath.normalizeLatitude(latitude)); 36 | if (degrees < -80 || degrees > 84) { 37 | return 0; 38 | } 39 | if (degrees > 80) { 40 | return 24; 41 | } 42 | return (degrees + 80) / 8 + 3; 43 | } 44 | 45 | public int getZoneFromNearestMeridian(double longitude) { 46 | 47 | // int zone = (int) (Math.floor(((180.0 + longitude) / 6)) + 1); FIXME 48 | int zone = (int) Math.floor((MapMath.normalizeLongitude(longitude) + Math.PI) * 30.0 / Math.PI) + 1; 49 | if (zone < 1) { 50 | zone = 1; 51 | } else if (zone > 60) { 52 | zone = 60; 53 | } 54 | 55 | /* 56 | if( Lat >= 56.0 && Lat < 64.0 && LongTemp >= 3.0 && LongTemp < 12.0 ) 57 | ZoneNumber = 32; 58 | 59 | // Special zones for Svalbard 60 | if( Lat >= 72.0 && Lat < 84.0 ) 61 | { 62 | if( LongTemp >= 0.0 && LongTemp < 9.0 ) ZoneNumber = 31; 63 | else if( LongTemp >= 9.0 && LongTemp < 21.0 ) ZoneNumber = 33; 64 | else if( LongTemp >= 21.0 && LongTemp < 33.0 ) ZoneNumber = 35; 65 | else if( LongTemp >= 33.0 && LongTemp < 42.0 ) ZoneNumber = 37; 66 | } 67 | */ 68 | 69 | 70 | return zone; 71 | } 72 | 73 | public void setIsSouth(boolean south) { 74 | falseNorthing = south ? 10000000. : 0.; 75 | } 76 | 77 | public void clearUTMZone() { 78 | utmzone = -1; 79 | } 80 | 81 | public void setUTMZone(int zone) { 82 | utmzone = zone - 1; 83 | 84 | projectionLongitude = (utmzone * 6 - 180 + 3) * DTR; //+3 puts origin in middle of zone 85 | projectionLatitude = 0.0; 86 | scaleFactor = 0.9996; 87 | falseNorthing = 0.; 88 | falseEasting = 500000; 89 | //initialize(); FIXME 90 | } 91 | 92 | public String toString() { 93 | return "Universal Transverse Mercator"; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/VitkovskyProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | * Bernhard Jenny, 17 September 2010: added missing toString(). 20 | */ 21 | package com.jhlabs.map.proj; 22 | 23 | public class VitkovskyProjection extends SimpleConicProjection { 24 | 25 | public VitkovskyProjection() { 26 | super(SimpleConicProjection.VITK1); 27 | } 28 | 29 | public String toString() { 30 | return "Vitkovsky"; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/Wagner1Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | * 20 | * Bernhard Jenny, 23 September 2010: added isEqualArea. 21 | */ 22 | package com.jhlabs.map.proj; 23 | 24 | public class Wagner1Projection extends URMFPSProjection { 25 | 26 | public String toString() { 27 | return "Wagner I"; 28 | } 29 | 30 | public boolean isEqualArea() { 31 | return true; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/Wagner2Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | 21 | /** 22 | * Fixed bug in forward projection and increased precisions of constants. 23 | * Changed superclass to PseudoCylindricalProjection. 24 | * Bernhard Jenny, October 28 2008 25 | */ 26 | package com.jhlabs.map.proj; 27 | 28 | import com.jhlabs.map.MapMath; 29 | import java.awt.geom.Point2D; 30 | 31 | public class Wagner2Projection extends PseudoCylindricalProjection { 32 | 33 | private final static double C_x = 0.9248327337222211159780313106; 34 | private final static double C_y = 1.387249100583331673967046966; 35 | private final static double C_p1 = 0.8855017059025996450524064573; 36 | private final static double C_p2 = 0.8802234877744129284498330453; 37 | 38 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 39 | lpphi = MapMath.asin(C_p1 * Math.sin(C_p2 * lpphi)); 40 | out.x = C_x * lplam * Math.cos(lpphi); 41 | out.y = C_y * lpphi; 42 | return out; 43 | } 44 | 45 | public Point2D.Double projectInverse(double xyx, double xyy, Point2D.Double out) { 46 | out.y = xyy / C_y; 47 | out.x = xyx / (C_x * Math.cos(out.y)); 48 | out.y = MapMath.asin(Math.sin(out.y) / C_p1) / C_p2; 49 | return out; 50 | } 51 | 52 | public boolean hasInverse() { 53 | return true; 54 | } 55 | 56 | public String toString() { 57 | return "Wagner II"; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/Wagner3Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | package com.jhlabs.map.proj; 21 | 22 | import java.awt.geom.Point2D; 23 | 24 | public class Wagner3Projection extends PseudoCylindricalProjection { 25 | 26 | private final static double TWOTHIRD = 0.6666666666666666666667; 27 | 28 | private double C_x; 29 | 30 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double xy) { 31 | xy.x = C_x * lplam * Math.cos(TWOTHIRD * lpphi); 32 | xy.y = lpphi; 33 | return xy; 34 | } 35 | 36 | public Point2D.Double projectInverse(double x, double y, Point2D.Double lp) { 37 | lp.y = y; 38 | lp.x = x / (C_x * Math.cos(TWOTHIRD * lp.y)); 39 | return lp; 40 | } 41 | 42 | public void initialize() { 43 | super.initialize(); 44 | C_x = Math.cos(trueScaleLatitude) / Math.cos(2.*trueScaleLatitude/3.); 45 | es = 0.; 46 | } 47 | 48 | public boolean hasInverse() { 49 | return true; 50 | } 51 | 52 | public String toString() { 53 | return "Wagner III"; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/Wagner4Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | package com.jhlabs.map.proj; 21 | 22 | public class Wagner4Projection extends MollweideProjection { 23 | 24 | public Wagner4Projection() { 25 | super( MollweideProjection.WAGNER4 ); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/Wagner5Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | package com.jhlabs.map.proj; 21 | 22 | public class Wagner5Projection extends MollweideProjection { 23 | 24 | public Wagner5Projection() { 25 | super( MollweideProjection.WAGNER5 ); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/Wagner6Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2007 Bernhard Jenny 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package com.jhlabs.map.proj; 18 | 19 | /** 20 | * Wagner VI projection. Based on Proj4. 21 | * @author Bernhard Jenny, May 2007, Institute of Cartography, ETH Zurich 22 | */ 23 | public class Wagner6Projection extends EllipticalPseudoCylindrical{ 24 | 25 | /** Creates a new instance of Wagner6Projection */ 26 | public Wagner6Projection() { 27 | super(1., 28 | 1., 29 | 0., 30 | 0.3039635509270133143316383896); 31 | } 32 | 33 | public String toString() { 34 | return "Wagner VI"; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/Wagner7Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | * 20 | * Bernhard Jenny, 23 September 2010: changed super class to ModifiedAzimuthalProjection. 21 | */ 22 | package com.jhlabs.map.proj; 23 | 24 | import java.awt.geom.Point2D; 25 | 26 | public class Wagner7Projection extends ModifiedAzimuthalProjection { 27 | 28 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 29 | double theta, ct, D; 30 | 31 | theta = Math.asin(out.y = 0.90630778703664996 * Math.sin(lpphi)); 32 | out.x = 2.66723 * (ct = Math.cos(theta)) * Math.sin(lplam /= 3.); 33 | out.y *= 1.24104 * (D = 1 / (Math.sqrt(0.5 * (1 + ct * Math.cos(lplam))))); 34 | out.x *= D; 35 | return out; 36 | } 37 | 38 | public boolean isEqualArea() { 39 | return true; 40 | } 41 | 42 | public String toString() { 43 | return "Wagner VII"; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/Werenskiold1Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | */ 20 | 21 | /** 22 | * Renamed from WerenskioldProjection to Werenskiold1Projection as there are 23 | * more projections by Werenskiold. Change by Bernhard Jenny, May 19 2010. 24 | */ 25 | package com.jhlabs.map.proj; 26 | 27 | /** 28 | * Werenskiold I Projection, identical to Putnins P4', just a bit larger. 29 | */ 30 | public class Werenskiold1Projection extends PutninsP4PProjection { 31 | 32 | public Werenskiold1Projection() { 33 | C_x = 1; 34 | C_y = 4.442882938; 35 | } 36 | 37 | public String toString() { 38 | return "Werenskiold I"; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/Winkel1Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Winkel1Projection.java 3 | * 4 | * Created on July 17, 2007, 9:04 AM 5 | * 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | * 18 | */ 19 | package com.jhlabs.map.proj; 20 | 21 | import com.jhlabs.map.MapMath; 22 | import java.awt.geom.Point2D; 23 | 24 | /** 25 | * Ported from Proj4 by Bernhard Jenny, Institute of Cartography, ETH Zurich. 26 | */ 27 | public class Winkel1Projection extends PseudoCylindricalProjection { 28 | 29 | /** 30 | * latitude of true scale on central meridian. 31 | * Default is 50 degree and 28 minutes. This differs from the default value 32 | * of proj4, which uses 0 degrees. 0 degrees is not appropriate, 33 | * as in this case the Winkel I projection is equal to the Eckert V projection. 34 | */ 35 | private double phi1 = Math.toRadians(50. + 28. / 60.); 36 | /** 37 | * cosine of latitude of true scale on central meridian 38 | */ 39 | private double cosphi1 = Math.cos(phi1); 40 | 41 | public Winkel1Projection() { 42 | } 43 | 44 | public void setLatitudeOfTrueScale(double phi1) { 45 | if (phi1 < -MapMath.HALFPI || phi1 > MapMath.HALFPI) { 46 | throw new ProjectionException(); 47 | } 48 | this.phi1 = phi1; 49 | this.cosphi1 = Math.cos(this.phi1); 50 | } 51 | 52 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 53 | 54 | out.x = .5 * lplam * (cosphi1 + Math.cos(lpphi)); 55 | out.y = lpphi; 56 | return out; 57 | 58 | } 59 | 60 | public Point2D.Double projectInverse(double xyx, double xyy, Point2D.Double out) { 61 | 62 | out.y = xyy; 63 | out.x = 2. * xyx / (this.cosphi1 + Math.cos(xyy)); 64 | return out; 65 | 66 | } 67 | 68 | public boolean hasInverse() { 69 | return true; 70 | } 71 | 72 | public String toString() { 73 | return "Winkel I"; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/Winkel2Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Winkel1Projection.java 3 | * 4 | * Created on July 17, 2007, 9:04 AM 5 | * 6 | */ 7 | 8 | package com.jhlabs.map.proj; 9 | 10 | import com.jhlabs.map.MapMath; 11 | import java.awt.geom.Point2D; 12 | 13 | /** 14 | * Ported from Proj4 by Bernhard Jenny, Institute of Cartography, ETH Zurich. 15 | */ 16 | public class Winkel2Projection extends PseudoCylindricalProjection { 17 | 18 | /** 19 | * latitude of true scale on central meridian. Default: arccos(2/Pi) 20 | */ 21 | private double phi1 = Math.acos(2./Math.PI); 22 | 23 | /** 24 | * cosine of latitude of true scale on central meridian 25 | */ 26 | private double cosphi1 = 2./Math.PI; 27 | 28 | private static final int MAX_ITER = 10; 29 | private static final double LOOP_TOL = 1e-7; 30 | private static final double TWO_D_PI = 0.636619772367581343; 31 | 32 | public Winkel2Projection() { 33 | } 34 | 35 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 36 | 37 | double k, V; 38 | int i; 39 | 40 | out.y = lpphi * TWO_D_PI; 41 | k = Math.PI * Math.sin(lpphi); 42 | lpphi *= 1.8; 43 | for (i = MAX_ITER; i > 0; --i) { 44 | lpphi -= V = (lpphi + Math.sin(lpphi) - k) / (1. + Math.cos(lpphi)); 45 | if (Math.abs(V) < LOOP_TOL) 46 | break; 47 | } 48 | if (i == 0) 49 | lpphi = (lpphi < 0.) ? -MapMath.HALFPI : MapMath.HALFPI; 50 | else 51 | lpphi *= 0.5; 52 | out.x = 0.5 * lplam * (Math.cos(lpphi) + cosphi1); 53 | out.y = MapMath.QUARTERPI * (Math.sin(lpphi) + out.y); 54 | 55 | return out; 56 | 57 | } 58 | 59 | public void setLatitudeOfTrueScale(double phi1) { 60 | if (phi1 < -MapMath.HALFPI || phi1 > MapMath.HALFPI) 61 | throw new ProjectionException(); 62 | this.phi1 = phi1; 63 | this.cosphi1 = Math.cos(this.phi1); 64 | } 65 | 66 | public String toString() { 67 | return "Winkel II"; 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/com/jhlabs/map/proj/WinkelTripelProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006 Jerry Huxtable 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file was semi-automatically converted from the public-domain USGS PROJ source. 19 | * 20 | * Bernhard Jenny, May 2007: Separated Aitoff from Winkel Tripel. 21 | * 23 September 2010: Changed super class to ModifiedAzimuthalProjection. 22 | */ 23 | package com.jhlabs.map.proj; 24 | 25 | import java.awt.geom.Point2D; 26 | 27 | public class WinkelTripelProjection extends ModifiedAzimuthalProjection { 28 | 29 | public WinkelTripelProjection() { 30 | } 31 | 32 | public Point2D.Double project(double lplam, double lpphi, Point2D.Double out) { 33 | double c = 0.5 * lplam; 34 | double d = Math.acos(Math.cos(lpphi) * Math.cos(c)); 35 | 36 | if (d != 0) { 37 | out.x = 2. * d * Math.cos(lpphi) * Math.sin(c) * (out.y = 1. / Math.sin(d)); 38 | out.y *= d * Math.sin(lpphi); 39 | } else { 40 | out.x = out.y = 0.0; 41 | } 42 | out.x = (out.x + lplam * 0.636619772367581343) * 0.5; 43 | out.y = (out.y + lpphi) * 0.5; 44 | return out; 45 | } 46 | 47 | public String toString() { 48 | return "Winkel Tripel"; 49 | } 50 | } 51 | --------------------------------------------------------------------------------