source: josm/trunk/src/org/openstreetmap/josm/data/projection/proj/LonLat.java

Last change on this file was 12013, checked in by bastiK, 7 years ago

see #11889 - backport improved version of Math.toDegrees and Math.toRadians from Java 9

  • Property svn:eol-style set to native
File size: 1.4 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.projection.proj;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import org.openstreetmap.josm.data.Bounds;
7import org.openstreetmap.josm.data.projection.ProjectionConfigurationException;
8import org.openstreetmap.josm.tools.CheckParameterUtil;
9import org.openstreetmap.josm.tools.Utils;
10
11/**
12 * Simple Lat/Lon (pseudo-)projection.
13 */
14public class LonLat implements Proj {
15
16 private double a;
17
18 @Override
19 public String getName() {
20 return tr("Lat/lon (Geodetic)");
21 }
22
23 @Override
24 public String getProj4Id() {
25 return "lonlat";
26 }
27
28 @Override
29 public void initialize(ProjParameters params) throws ProjectionConfigurationException {
30 CheckParameterUtil.ensureParameterNotNull(params, "params");
31 CheckParameterUtil.ensureParameterNotNull(params.ellps, "params.ellps");
32 a = params.ellps.a;
33 }
34
35 @Override
36 public double[] project(double latRad, double lonRad) {
37 return new double[] {Utils.toDegrees(lonRad) / a, Utils.toDegrees(latRad) / a};
38 }
39
40 @Override
41 public double[] invproject(double east, double north) {
42 return new double[] {Utils.toRadians(north * a), Utils.toRadians(east * a)};
43 }
44
45 @Override
46 public Bounds getAlgorithmBounds() {
47 return new Bounds(-90, -180, 90, 180, false);
48 }
49
50 @Override
51 public boolean isGeographic() {
52 return true;
53 }
54}
Note: See TracBrowser for help on using the repository browser.