| 1 | // License: GPL. Copyright 2007 by Immanuel Scholz and others
|
|---|
| 2 | package org.openstreetmap.josm.data.projection;
|
|---|
| 3 |
|
|---|
| 4 | import java.util.ArrayList;
|
|---|
| 5 | import java.util.Arrays;
|
|---|
| 6 |
|
|---|
| 7 | import org.openstreetmap.josm.Main;
|
|---|
| 8 | import org.openstreetmap.josm.data.coor.EastNorth;
|
|---|
| 9 | import org.openstreetmap.josm.data.coor.LatLon;
|
|---|
| 10 |
|
|---|
| 11 | /**
|
|---|
| 12 | * Class to handle projections
|
|---|
| 13 | *
|
|---|
| 14 | */
|
|---|
| 15 | public class Projections {
|
|---|
| 16 | /**
|
|---|
| 17 | * List of all available projections.
|
|---|
| 18 | */
|
|---|
| 19 | private static ArrayList<Projection> allProjections =
|
|---|
| 20 | new ArrayList<Projection>(Arrays.asList(new Projection[] {
|
|---|
| 21 | // global projections
|
|---|
| 22 | new Epsg4326(),
|
|---|
| 23 | new Mercator(),
|
|---|
| 24 | new UTM(),
|
|---|
| 25 | // regional - alphabetical order by country name
|
|---|
| 26 | new GaussKrueger(),
|
|---|
| 27 | new BelgianLambert1972(),
|
|---|
| 28 | new BelgianLambert2008(),
|
|---|
| 29 | new LambertEST(),
|
|---|
| 30 | new Lambert(),
|
|---|
| 31 | new Lambert93(),
|
|---|
| 32 | new LambertCC9Zones(),
|
|---|
| 33 | new UTM_France_DOM(),
|
|---|
| 34 | new TransverseMercatorLV(),
|
|---|
| 35 | new Puwg(),
|
|---|
| 36 | new Epsg3008(), // SWEREF99 13 30
|
|---|
| 37 | new SwissGrid(),
|
|---|
| 38 | }));
|
|---|
| 39 |
|
|---|
| 40 | public static ArrayList<Projection> getProjections() {
|
|---|
| 41 | return allProjections;
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 | /**
|
|---|
| 45 | * Adds a new projection to the list of known projections.
|
|---|
| 46 | *
|
|---|
| 47 | * For Plugins authors: make sure your plugin is an early plugin, i.e. put
|
|---|
| 48 | * Plugin-Early=true in your Manifest.
|
|---|
| 49 | */
|
|---|
| 50 | public static void addProjection(Projection proj) {
|
|---|
| 51 | allProjections.add(proj);
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 | static public EastNorth project(LatLon ll) {
|
|---|
| 55 | if (ll == null) return null;
|
|---|
| 56 | return Main.getProjection().latlon2eastNorth(ll);
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
| 59 | static public LatLon inverseProject(EastNorth en) {
|
|---|
| 60 | if (en == null) return null;
|
|---|
| 61 | return Main.getProjection().eastNorth2latlon(en);
|
|---|
| 62 | }
|
|---|
| 63 | }
|
|---|