Changeset 25122 in osm for applications/editors/josm/plugins
- Timestamp:
- 2011-01-23T22:47:36+01:00 (15 years ago)
- Location:
- applications/editors/josm/plugins/epsg31287
- Files:
-
- 3 edited
-
.classpath (modified) (1 diff)
-
build.xml (modified) (1 diff)
-
src/org/openstreetmap/josm/plugins/epsg31287/ProjectionEPSG31287.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/epsg31287/.classpath
r23660 r25122 3 3 <classpathentry kind="src" path="src"/> 4 4 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> 5 <classpathentry kind="lib" path="/JOSM/build"/>5 <classpathentry combineaccessrules="false" kind="src" path="/JOSM"/> 6 6 <classpathentry kind="output" path="bin"/> 7 7 </classpath> -
applications/editors/josm/plugins/epsg31287/build.xml
r24044 r25122 37 37 <property name="commit.message" value="fixed proj4 Parameters (thanks to Hetzi + Mikael Rittri)" /> 38 38 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 39 <property name="plugin.main.version" value="3 592" />39 <property name="plugin.main.version" value="3779" /> 40 40 41 41 -
applications/editors/josm/plugins/epsg31287/src/org/openstreetmap/josm/plugins/epsg31287/ProjectionEPSG31287.java
r24042 r25122 5 5 import static org.openstreetmap.josm.tools.I18n.tr; 6 6 7 import java.awt.GridBagLayout; 8 import java.awt.event.ActionListener; 9 import java.awt.geom.Point2D; 10 import java.util.Arrays; 7 11 import java.util.Collection; 8 import java.util.Arrays;9 12 13 import javax.swing.JLabel; 10 14 import javax.swing.JPanel; 11 import javax.swing.JLabel;12 15 import javax.swing.JTextField; 13 import java.awt.GridBagLayout;14 import java.awt.geom.Point2D;15 16 16 17 import org.openstreetmap.josm.data.Bounds; … … 21 22 public class ProjectionEPSG31287 implements org.openstreetmap.josm.data.projection.Projection, org.openstreetmap.josm.data.projection.ProjectionSubPrefs { 22 23 23 private double dx = 0.0;24 private double dy = 0.0;25 private final static String projCode = "EPSG:31287";24 private double dx = 0.0; 25 private double dy = 0.0; 26 private final static String projCode = "EPSG:31287"; 26 27 27 private final com.jhlabs.map.proj.Projection projection;28 private final com.jhlabs.map.proj.Projection projection; 28 29 29 public ProjectionEPSG31287() {30 super();31 // use use com.jhlabs.map.proj.ProjectionFactory for doing all the math32 projection = com.jhlabs.map.proj.ProjectionFactory.fromPROJ4Specification(33 new String[] {34 "+datum=WGS84"35 ,"+proj=lcc"36 ,"+lat_1=46.0103424"37 ,"+lat_2=48.988621"38 ,"+lat_0=47.5"39 ,"+lon_0=13.33616275"40 ,"+x_0=400268.785"41 ,"+y_0=400057.553"42 ,"+units=m"43 ,"+no_defs"44 }45 );46 }30 public ProjectionEPSG31287() { 31 super(); 32 // use use com.jhlabs.map.proj.ProjectionFactory for doing all the math 33 projection = com.jhlabs.map.proj.ProjectionFactory.fromPROJ4Specification( 34 new String[] { 35 "+datum=WGS84" 36 ,"+proj=lcc" 37 ,"+lat_1=46.0103424" 38 ,"+lat_2=48.988621" 39 ,"+lat_0=47.5" 40 ,"+lon_0=13.33616275" 41 ,"+x_0=400268.785" 42 ,"+y_0=400057.553" 43 ,"+units=m" 44 ,"+no_defs" 45 } 46 ); 47 } 47 48 48 // PreferencePanel, not used in plugin mode, useful for JOSM custom-build49 @Override50 public void setupPreferencePanel(JPanel p) {51 //p.add(new HtmlPanel("<i>EPSG:31287 - Bessel 1841 in Lambert_Conformal_Conic_2SP</i>"), GBC.eol().fill(GBC.HORIZONTAL));52 //p.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.BOTH));53 p.setLayout(new GridBagLayout());49 // PreferencePanel, not used in plugin mode, useful for JOSM custom-build 50 @Override 51 public void setupPreferencePanel(JPanel p, ActionListener actionListener) { 52 //p.add(new HtmlPanel("<i>EPSG:31287 - Bessel 1841 in Lambert_Conformal_Conic_2SP</i>"), GBC.eol().fill(GBC.HORIZONTAL)); 53 //p.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.BOTH)); 54 p.setLayout(new GridBagLayout()); 54 55 55 JTextField gdx = new JTextField(""+dx);56 JTextField gdy = new JTextField(""+dy);56 JTextField gdx = new JTextField(""+dx); 57 JTextField gdy = new JTextField(""+dy); 57 58 58 p.add(new JLabel(tr("dx")), GBC.std().insets(5,5,0,5));59 p.add(GBC.glue(1, 0), GBC.std().fill(GBC.HORIZONTAL));60 p.add(gdx, GBC.eop().fill(GBC.HORIZONTAL));59 p.add(new JLabel(tr("dx")), GBC.std().insets(5,5,0,5)); 60 p.add(GBC.glue(1, 0), GBC.std().fill(GBC.HORIZONTAL)); 61 p.add(gdx, GBC.eop().fill(GBC.HORIZONTAL)); 61 62 62 p.add(new JLabel(tr("dy")), GBC.std().insets(5,5,0,5));63 p.add(GBC.glue(1, 0), GBC.std().fill(GBC.HORIZONTAL));64 p.add(gdy, GBC.eop().fill(GBC.HORIZONTAL));65 p.add(GBC.glue(1, 1), GBC.eol().fill(GBC.BOTH));63 p.add(new JLabel(tr("dy")), GBC.std().insets(5,5,0,5)); 64 p.add(GBC.glue(1, 0), GBC.std().fill(GBC.HORIZONTAL)); 65 p.add(gdy, GBC.eop().fill(GBC.HORIZONTAL)); 66 p.add(GBC.glue(1, 1), GBC.eol().fill(GBC.BOTH)); 66 67 67 }68 } 68 69 69 // for PreferencePanel, not used in plugin mode, useful for JOSM custom-build70 @Override71 public Collection<String> getPreferences(JPanel p) {72 dx = new Double(((JTextField)p.getComponent(2)).getText());73 dy = new Double(((JTextField)p.getComponent(5)).getText());74 return Arrays.asList(""+dx,""+dy);75 }70 // for PreferencePanel, not used in plugin mode, useful for JOSM custom-build 71 @Override 72 public Collection<String> getPreferences(JPanel p) { 73 dx = new Double(((JTextField)p.getComponent(2)).getText()); 74 dy = new Double(((JTextField)p.getComponent(5)).getText()); 75 return Arrays.asList(""+dx,""+dy); 76 } 76 77 77 // for PreferencePanel, not used in plugin mode, useful for JOSM custom-build78 @Override79 public Collection<String> getPreferencesFromCode(String code) {80 dx = 85.0;81 dy = 45.0;82 return null;83 }78 // for PreferencePanel, not used in plugin mode, useful for JOSM custom-build 79 @Override 80 public Collection<String> getPreferencesFromCode(String code) { 81 dx = 85.0; 82 dy = 45.0; 83 return null; 84 } 84 85 85 // for PreferencePanel, not used in plugin mode, useful for JOSM custom-build86 @Override87 public void setPreferences(Collection<String> args) {88 if(args != null)89 {90 String[] array = args.toArray(new String[0]);91 if (array.length > 0) {92 try {93 dx = Double.parseDouble(array[0]);94 } catch(NumberFormatException e) {}95 }96 if (array.length > 1) {97 try {98 dy = Double.parseDouble(array[1]);99 } catch(NumberFormatException e) {}100 }101 }102 }86 // for PreferencePanel, not used in plugin mode, useful for JOSM custom-build 87 @Override 88 public void setPreferences(Collection<String> args) { 89 if(args != null) 90 { 91 String[] array = args.toArray(new String[0]); 92 if (array.length > 0) { 93 try { 94 dx = Double.parseDouble(array[0]); 95 } catch(NumberFormatException e) {} 96 } 97 if (array.length > 1) { 98 try { 99 dy = Double.parseDouble(array[1]); 100 } catch(NumberFormatException e) {} 101 } 102 } 103 } 103 104 104 @Override105 public double getDefaultZoomInPPD() {106 return 1.01;107 }105 @Override 106 public double getDefaultZoomInPPD() { 107 return 1.01; 108 } 108 109 109 /**110 * @param LatLon WGS84 (in degree)111 * @return xy epsg31287 east/north (in meters)112 */113 @Override114 public EastNorth latlon2eastNorth(LatLon p) {115 Point2D.Double c = new Point2D.Double();116 c.x = p.lon();117 c.y = p.lat();118 //System.out.println("From " + c.x + " " + c.y);119 projection.transform( c, c );120 //System.out.println("To " + c.x + " " + c.y);121 return new EastNorth(c.x+dx, c.y+dy);122 }110 /** 111 * @param LatLon WGS84 (in degree) 112 * @return xy epsg31287 east/north (in meters) 113 */ 114 @Override 115 public EastNorth latlon2eastNorth(LatLon p) { 116 Point2D.Double c = new Point2D.Double(); 117 c.x = p.lon(); 118 c.y = p.lat(); 119 //System.out.println("From " + c.x + " " + c.y); 120 projection.transform( c, c ); 121 //System.out.println("To " + c.x + " " + c.y); 122 return new EastNorth(c.x+dx, c.y+dy); 123 } 123 124 124 /**125 * @param xy epsg31287 east/north (in meters)126 * @return LatLon WGS84 (in degree)127 */128 @Override129 public LatLon eastNorth2latlon(EastNorth p) {130 Point2D.Double c = new Point2D.Double();131 c.x = p.east()-dx;132 c.y = p.north()-dy;133 //System.out.println("InvFrom " + c.x + " " + c.y);134 projection.inverseTransform( c, c );135 //System.out.println("InvTo " + c.x + " " + c.y);136 return new LatLon(c.y, c.x);137 }125 /** 126 * @param xy epsg31287 east/north (in meters) 127 * @return LatLon WGS84 (in degree) 128 */ 129 @Override 130 public LatLon eastNorth2latlon(EastNorth p) { 131 Point2D.Double c = new Point2D.Double(); 132 c.x = p.east()-dx; 133 c.y = p.north()-dy; 134 //System.out.println("InvFrom " + c.x + " " + c.y); 135 projection.inverseTransform( c, c ); 136 //System.out.println("InvTo " + c.x + " " + c.y); 137 return new LatLon(c.y, c.x); 138 } 138 139 139 @Override140 public String toString() {141 return tr(projCode + " - Bessel 1841 in Lambert Conformal Conic");142 }140 @Override 141 public String toString() { 142 return tr(projCode + " - Bessel 1841 in Lambert Conformal Conic"); 143 } 143 144 144 @Override145 public String toCode() {146 return projCode;147 }145 @Override 146 public String toCode() { 147 return projCode; 148 } 148 149 149 @Override150 public String getCacheDirectoryName() {151 return "EPSG_31287";152 }150 @Override 151 public String getCacheDirectoryName() { 152 return "EPSG_31287"; 153 } 153 154 154 @Override155 public Bounds getWorldBoundsLatLon() {156 return new Bounds(new LatLon(45.4, 8.7), new LatLon(49.4, 17.5));157 }155 @Override 156 public Bounds getWorldBoundsLatLon() { 157 return new Bounds(new LatLon(45.4, 8.7), new LatLon(49.4, 17.5)); 158 } 158 159 159 public static String getProjCode() { 160 return projCode; 161 } 160 public static String getProjCode() { 161 return projCode; 162 } 163 164 @Override 165 public String[] allCodes() { 166 return new String[] {projCode}; 167 } 162 168 163 169 }
Note:
See TracChangeset
for help on using the changeset viewer.
