Changeset 25122 in osm for applications/editors/josm/plugins
- Timestamp:
- 2011-01-23T22:47:36+01:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/epsg31287
- Files:
-
- 3 edited
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 24 25 24 private double dx = 0.0; 25 private double dy = 0.0; 26 private final static String projCode = "EPSG:31287"; 26 27 27 28 private final com.jhlabs.map.proj.Projection projection; 28 29 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 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 49 50 public void setupPreferencePanel(JPanel p) {51 52 53 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 56 56 JTextField gdx = new JTextField(""+dx); 57 JTextField gdy = new JTextField(""+dy); 57 58 58 59 60 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 63 64 65 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 70 71 72 73 74 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 78 79 80 81 82 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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 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 105 106 107 105 @Override 106 public double getDefaultZoomInPPD() { 107 return 1.01; 108 } 108 109 109 110 111 112 113 114 115 116 117 118 119 120 121 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 126 127 128 129 130 131 132 133 134 135 136 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 140 141 142 140 @Override 141 public String toString() { 142 return tr(projCode + " - Bessel 1841 in Lambert Conformal Conic"); 143 } 143 144 144 145 146 147 145 @Override 146 public String toCode() { 147 return projCode; 148 } 148 149 149 150 151 152 150 @Override 151 public String getCacheDirectoryName() { 152 return "EPSG_31287"; 153 } 153 154 154 155 156 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.