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 LambertEST(),
|
---|
28 | new Lambert(),
|
---|
29 | new LambertCC9Zones(),
|
---|
30 | new UTM_France_DOM(),
|
---|
31 | new TransverseMercatorLV(),
|
---|
32 | new Puwg(),
|
---|
33 | new Epsg3008(), // SWEREF99 13 30
|
---|
34 | new SwissGrid(),
|
---|
35 | }));
|
---|
36 |
|
---|
37 | public static ArrayList<Projection> getProjections() {
|
---|
38 | return allProjections;
|
---|
39 | }
|
---|
40 |
|
---|
41 | /**
|
---|
42 | * Adds a new projection to the list of known projections.
|
---|
43 | *
|
---|
44 | * For Plugins authors: make sure your plugin is an early plugin, i.e. put
|
---|
45 | * Plugin-Early=true in your Manifest.
|
---|
46 | */
|
---|
47 | public static void addProjection(Projection proj) {
|
---|
48 | allProjections.add(proj);
|
---|
49 | }
|
---|
50 |
|
---|
51 | static public EastNorth project(LatLon ll) {
|
---|
52 | if (ll == null) return null;
|
---|
53 | return Main.getProjection().latlon2eastNorth(ll);
|
---|
54 | }
|
---|
55 |
|
---|
56 | static public LatLon inverseProject(EastNorth en) {
|
---|
57 | if (en == null) return null;
|
---|
58 | return Main.getProjection().eastNorth2latlon(en);
|
---|
59 | }
|
---|
60 | }
|
---|