Ignore:
Timestamp:
2007-08-17T23:04:07+02:00 (17 years ago)
Author:
brent
Message:

More Lakewalker preferences

Location:
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/DoubleConfigurer.java

    r4189 r4209  
    2626public class DoubleConfigurer extends StringConfigurer {
    2727
    28   final static DecimalFormat df = new DecimalFormat("##0.0000000");
     28  final static DecimalFormat df = new DecimalFormat("#0.0##########");
    2929 
    3030  public DoubleConfigurer() {
  • applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerAction.java

    r4189 r4209  
    107107    target += " --threshold=" + Main.pref.get(LakewalkerPreferences.PREF_THRESHOLD, "35");
    108108    target += " --dp-epsilon=" + Main.pref.get(LakewalkerPreferences.PREF_EPSILON, "0.0003");
     109    target += " --landsat-res=" + Main.pref.get(LakewalkerPreferences.PREF_LANDSAT_RES, "4000");
     110    target += " --tilesize=" + Main.pref.get(LakewalkerPreferences.PREF_LANDSAT_SIZE, "2000");
    109111    target += " --josm";
     112   
    110113
    111114    try {
  • applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerPreferences.java

    r4189 r4209  
    55import javax.swing.JLabel;
    66import javax.swing.JPanel;
    7 import javax.swing.JTextField;
    87
    98import org.openstreetmap.josm.Main;
     
    1918  public static final String PREF_THRESHOLD = "lakewalker.threshold";
    2019  public static final String PREF_EPSILON = "lakewalker.epsilon";
     20  public static final String PREF_LANDSAT_RES = "lakewalker.landsat_res";
     21  public static final String PREF_LANDSAT_SIZE = "lakewalker.landsat_size";
     22  public static final String PREF_EAST_OFFSET = "lakewalker.east_offset";
     23  public static final String PREF_NORTH_OFFSET = "lakewalker.north_offset";
    2124 
    22   protected JTextField python = new JTextField(10);
    23   protected IntConfigurer maxSegs = new IntConfigurer();
    24   protected IntConfigurer maxNodes = new IntConfigurer();
    25   protected IntConfigurer threshold = new IntConfigurer();
    26   protected DoubleConfigurer epsilon = new DoubleConfigurer();
     25  protected StringConfigurer pythonConfig = new StringConfigurer();
     26  protected JLabel pythonLabel = new JLabel(tr("Python executable"));
     27  protected IntConfigurer maxSegsConfig = new IntConfigurer();
     28  protected JLabel maxSegsLabel = new JLabel(tr("Maximum number of segments per way"));
     29  protected IntConfigurer maxNodesConfig = new IntConfigurer();
     30  protected JLabel maxNodesLabel = new JLabel(tr("Maximum number of nodes in initial trace"));
     31  protected IntConfigurer thresholdConfig = new IntConfigurer();
     32  protected JLabel thresholdLabel = new JLabel(tr("Maximum gray value to count as water (0-255)"));
     33  protected DoubleConfigurer epsilonConfig = new DoubleConfigurer();
     34  protected JLabel epsilonLabel = new JLabel(tr("Line simplification accuracy (degrees)"));
     35  protected IntConfigurer landsatResConfig = new IntConfigurer();
     36  protected JLabel landsatResLabel = new JLabel(tr("Resolution of Landsat tiles (pixels per degree)"));
     37  protected IntConfigurer landsatSizeConfig = new IntConfigurer();
     38  protected JLabel landsatSizeLabel = new JLabel(tr("Size of Landsat tiles (pixels)"));
     39  protected DoubleConfigurer eastOffsetConfig = new DoubleConfigurer();
     40  protected JLabel eastOffsetLabel = new JLabel(tr("Shift all traces to east (degrees)"));
     41  protected DoubleConfigurer northOffsetConfig = new DoubleConfigurer();
     42  protected JLabel northOffsetLabel = new JLabel(tr("Shift all traces to north (degrees)"));
    2743 
    2844  public void addGui(PreferenceDialog gui) {
    29     python.setToolTipText(tr("Path to python executable."));
    30     maxSegs.setToolTipText(tr("Maximum nuber of nodes allowed in one way."));
    31     maxNodes.setToolTipText(tr("Maximum number of nodes to generate before bailing out (before simplifying lines)."));
    32     maxNodes.setToolTipText(tr("Maximum gray value to accept as water (based on Landsat IR-1 data). Can be in the range 0-255."));
    33     epsilon.setToolTipText(tr("Accuracy of Douglas-Peucker line simplification, measured in degrees. Lower values give more nodes, and more accurate lines. Defaults to 0.0003."));   
    34    
     45    pythonConfig.setToolTipText(tr("Path to python executable."));
     46    maxSegsConfig.setToolTipText(tr("Maximum number of segments allowed in each generated way. Default 250."));
     47    maxNodesConfig.setToolTipText(tr("Maximum number of nodes to generate before bailing out (before simplifying lines). Default 50000."));
     48    thresholdConfig.setToolTipText(tr("Maximum gray value to accept as water (based on Landsat IR-1 data). Can be in the range 0-255. Default 35."));
     49    epsilonConfig.setToolTipText(tr("Accuracy of Douglas-Peucker line simplification, measured in degrees.<br>Lower values give more nodes, and more accurate lines. Default 0.0003."));
     50    landsatResConfig.setToolTipText(tr("Resolution of Landsat tiles, measured in pixels per degree. Default 4000."));
     51    landsatSizeConfig.setToolTipText(tr("Size of one landsat tile, measured in pixels. Default 2000."));
     52    eastOffsetConfig.setToolTipText(tr("Offset all points in East direction (degrees). Default 0."));   
     53    northOffsetConfig.setToolTipText(tr("Offset all points in North direction (degrees). Default 0."));   
     54
    3555    String description = tr("An interlude to the Lakewalker Python module to trace water bodies on Landsat imagery.<br><br>Version: {0}", LakewalkerPlugin.VERSION);
    36    
    3756    JPanel prefPanel = gui.createPreferenceTab("lakewalker.png", I18n.tr("Lakewalker Plugin Preferences"), description);
    3857    buildPreferences(prefPanel);
    3958   
    40     python.setText(Main.pref.get(PREF_PYTHON, "python.exe"));
    41     maxSegs.setValue(Main.pref.get(PREF_MAX_SEG, "250"));
    42     maxNodes.setValue(Main.pref.get(PREF_MAX_NODES, "50000"));
    43     threshold.setValue(Main.pref.get(PREF_THRESHOLD, "35"));
    44     epsilon.setValue(Main.pref.get(PREF_EPSILON, "0.0003"));
     59    pythonConfig.setValue(Main.pref.get(PREF_PYTHON, "python.exe"));
     60    maxSegsConfig.setValue(Main.pref.get(PREF_MAX_SEG, "250"));
     61    maxNodesConfig.setValue(Main.pref.get(PREF_MAX_NODES, "50000"));
     62    thresholdConfig.setValue(Main.pref.get(PREF_THRESHOLD, "35"));
     63    epsilonConfig.setValue(Main.pref.get(PREF_EPSILON, "0.0003"));
     64    landsatResConfig.setValue(Main.pref.get(PREF_LANDSAT_RES, "4000"));
     65    landsatSizeConfig.setValue(Main.pref.get(PREF_LANDSAT_SIZE, "2000"));
     66    eastOffsetConfig.setValue(Main.pref.get(PREF_EAST_OFFSET, "0.0"));
     67    northOffsetConfig.setValue(Main.pref.get(PREF_NORTH_OFFSET, "0.0"));
    4568  }
    4669 
    4770  public void buildPreferences(JPanel prefPanel) {
    48     prefPanel.add(new JLabel(tr("Python executable")), GBC.std().insets(10,5,5,0));
    49     prefPanel.add(python, GBC.eol().insets(0,5,0,0).fill(GBC.HORIZONTAL));
    50     prefPanel.add(new JLabel(tr("Maximum number of segments per way")), GBC.std().insets(10,5,5,0));
    51     prefPanel.add(maxSegs.getControls(), GBC.eol().insets(0,5,0,0).fill(GBC.HORIZONTAL));
    52     prefPanel.add(new JLabel(tr("Maximum number of nodes to trace")), GBC.std().insets(10,5,5,0));
    53     prefPanel.add(maxNodes.getControls(), GBC.eol().insets(0,5,0,0).fill(GBC.HORIZONTAL));
    54     prefPanel.add(new JLabel(tr("Maximum gray value to count as water")), GBC.std().insets(10,5,5,0));
    55     prefPanel.add(threshold.getControls(), GBC.eol().insets(0,5,0,0).fill(GBC.HORIZONTAL));
    56     prefPanel.add(new JLabel(tr("Line simplification accuracy, measured in degrees.")), GBC.std().insets(10,5,5,0));
    57     prefPanel.add(epsilon.getControls(), GBC.eol().insets(0,5,0,0).fill(GBC.HORIZONTAL));
    58 
     71    GBC labelConstraints = GBC.std().insets(10,5,5,0);
     72    GBC dataConstraints = GBC.eol().insets(0,5,0,0).fill(GBC.HORIZONTAL);
     73   
     74    prefPanel.add(pythonLabel, labelConstraints);
     75    prefPanel.add(pythonConfig.getControls(), dataConstraints);
     76    prefPanel.add(maxSegsLabel, labelConstraints);
     77    prefPanel.add(maxSegsConfig.getControls(), dataConstraints);
     78    prefPanel.add(maxNodesLabel, labelConstraints);
     79    prefPanel.add(maxNodesConfig.getControls(), dataConstraints);
     80    prefPanel.add(thresholdLabel, labelConstraints);
     81    prefPanel.add(thresholdConfig.getControls(), dataConstraints);
     82    prefPanel.add(epsilonLabel, labelConstraints);
     83    prefPanel.add(epsilonConfig.getControls(), dataConstraints);
     84    prefPanel.add(landsatResLabel, labelConstraints);
     85    prefPanel.add(landsatResConfig.getControls(), dataConstraints);
     86    prefPanel.add(landsatSizeLabel, labelConstraints);
     87    prefPanel.add(landsatSizeConfig.getControls(), dataConstraints);   
     88    prefPanel.add(eastOffsetLabel, labelConstraints);
     89    prefPanel.add(eastOffsetConfig.getControls(), dataConstraints);
     90    prefPanel.add(northOffsetLabel, labelConstraints);
     91    prefPanel.add(northOffsetConfig.getControls(), dataConstraints);
    5992  }
    6093
     94  /*
     95   * Save entered preference values on OK button
     96   */
    6197  public void ok() {
    62     Main.pref.put(PREF_PYTHON, python.getText());
    63     Main.pref.put(PREF_MAX_SEG, maxSegs.getValueString());   
    64     Main.pref.put(PREF_MAX_NODES, maxNodes.getValueString());
    65     Main.pref.put(PREF_THRESHOLD, threshold.getValueString());
    66     Main.pref.put(PREF_EPSILON, epsilon.getValueString());
     98    Main.pref.put(PREF_PYTHON, pythonConfig.getValueString());
     99    Main.pref.put(PREF_MAX_SEG, maxSegsConfig.getValueString());   
     100    Main.pref.put(PREF_MAX_NODES, maxNodesConfig.getValueString());
     101    Main.pref.put(PREF_THRESHOLD, thresholdConfig.getValueString());
     102    Main.pref.put(PREF_EPSILON, epsilonConfig.getValueString());
     103    Main.pref.put(PREF_LANDSAT_RES, landsatResConfig.getValueString());
     104    Main.pref.put(PREF_LANDSAT_SIZE, landsatSizeConfig.getValueString());
     105    Main.pref.put(PREF_EAST_OFFSET, eastOffsetConfig.getValueString());
     106    Main.pref.put(PREF_NORTH_OFFSET, northOffsetConfig.getValueString());
    67107  }
    68108 
  • applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerReader.java

    r4189 r4209  
    4848    Node firstNode = null;
    4949    String line;
    50     Main.pleaseWaitDlg.currentAction.setText("Initializing");
    51     Main.pleaseWaitDlg.repaint();
     50    setStatus("Initializing");
     51    double eastOffset = 0.0;
     52    double northOffset = 0.0;
     53    try {
     54      eastOffset = Double.parseDouble(Main.pref.get(LakewalkerPreferences.PREF_EAST_OFFSET, "0.0"));
     55      northOffset = Double.parseDouble(Main.pref.get(LakewalkerPreferences.PREF_NORTH_OFFSET, "0.0"));
     56    }
     57    catch (Exception e) {
     58     
     59    }
    5260
    5361    try {
     
    6270          String[] tokens = line.split(" ");
    6371          try {
    64             LatLon ll = new LatLon(Double.parseDouble(tokens[1]), Double.parseDouble(tokens[2]));
     72            LatLon ll = new LatLon(Double.parseDouble(tokens[1])+northOffset, Double.parseDouble(tokens[2])+eastOffset);
    6573            Node n = new Node(ll);
    6674            commands.add(new AddCommand(n));
     
    8189
    8290        case 's':
    83           Main.pleaseWaitDlg.currentAction.setText(line.substring(2));
    84           Main.pleaseWaitDlg.repaint();
     91          setStatus(line.substring(2));
    8592          break;
    8693         
     
    113120  }
    114121 
     122  protected void setStatus(String s) {
     123    Main.pleaseWaitDlg.currentAction.setText(s);
     124    Main.pleaseWaitDlg.repaint();
     125  }
     126 
    115127}
Note: See TracChangeset for help on using the changeset viewer.