source: josm/trunk/src/org/openstreetmap/josm/data/coor/CachedLatLon.java@ 1747

Last change on this file since 1747 was 1747, checked in by stoecker, 15 years ago

close #2874 (NPE), improved external style handling

File size: 1.3 KB
Line 
1// License: GPL. Copyright 2007 by Immanuel Scholz and others
2package org.openstreetmap.josm.data.coor;
3
4import org.openstreetmap.josm.Main;
5import org.openstreetmap.josm.data.projection.Projection;
6
7public class CachedLatLon extends LatLon {
8 private EastNorth eastNorth;
9 private Projection proj;
10
11 public CachedLatLon(double lat, double lon) {
12 super(lat, lon);
13 }
14
15 public CachedLatLon(LatLon coor) {
16 super(coor.lat(), coor.lon());
17 proj = null;
18 }
19
20 public CachedLatLon(EastNorth eastNorth) {
21 super(Main.proj.eastNorth2latlon(eastNorth));
22 proj = Main.proj;
23 this.eastNorth = eastNorth;
24 }
25
26 public final void setCoor(LatLon coor) {
27 setLocation(coor.lon(), coor.lat());
28 proj = null;
29 }
30
31 public final void setEastNorth(EastNorth eastNorth) {
32 proj = Main.proj;
33 this.eastNorth = eastNorth;
34 LatLon l = proj.eastNorth2latlon(eastNorth);
35 setLocation(l.lon(), l.lat());
36 }
37
38 public final EastNorth getEastNorth() {
39 if(proj != Main.proj)
40 {
41 proj = Main.proj;
42 eastNorth = proj.latlon2eastNorth(this);
43 }
44 return eastNorth;
45 }
46 @Override public String toString() {
47 return "CachedLatLon[lat="+lat()+",lon="+lon()+"]";
48 }
49}
Note: See TracBrowser for help on using the repository browser.