source: josm/trunk/src/org/openstreetmap/josm/data/projection/Projections.java@ 4126

Last change on this file since 4126 was 4126, checked in by bastiK, 13 years ago

memory optimizations for Node & WayPoint (Patch by Gubaer, modified)

The field 'proj' in CachedLatLon is a waste of memory. For the 2 classes where this has the greatest impact, the cache for the projected coordinates is replaced by 2 simple double fields (east & north). On projection change, they have to be invalidated explicitly. This is handled by the DataSet & the GpxLayer.

File size: 1.8 KB
Line 
1// License: GPL. Copyright 2007 by Immanuel Scholz and others
2package org.openstreetmap.josm.data.projection;
3
4import java.util.ArrayList;
5import java.util.Arrays;
6
7import org.openstreetmap.josm.Main;
8import org.openstreetmap.josm.data.coor.EastNorth;
9import org.openstreetmap.josm.data.coor.LatLon;
10
11/**
12 * Class to handle projections
13 *
14 */
15public 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 LambertEST(), // Still needs proper default zoom
27 new Lambert(), // Still needs proper default zoom
28 new LambertCC9Zones(), // Still needs proper default zoom
29 new UTM_France_DOM(),
30 new TransverseMercatorLV(),
31 new Puwg(),
32 new Epsg3008(), // SWEREF99 13 30
33 new SwissGrid(),
34 }));
35
36 public static ArrayList<Projection> getProjections() {
37 return allProjections;
38 }
39
40 /**
41 * Adds a new projection to the list of known projections.
42 *
43 * For Plugins authors: make sure your plugin is an early plugin, i.e. put
44 * Plugin-Early=true in your Manifest.
45 */
46 public static void addProjection(Projection proj) {
47 allProjections.add(proj);
48 }
49
50 static public EastNorth project(LatLon ll) {
51 if (ll == null) return null;
52 return Main.getProjection().latlon2eastNorth(ll);
53 }
54
55 static public LatLon inverseProject(EastNorth en) {
56 if (en == null) return null;
57 return Main.getProjection().eastNorth2latlon(en);
58 }
59}
Note: See TracBrowser for help on using the repository browser.