Ignore:
Timestamp:
2013-03-19T20:46:10+01:00 (12 years ago)
Author:
zverik
Message:

another iteration

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/imagery_offset_db/src/iodb/GetImageryOffsetAction.java

    r29371 r29376  
    99import javax.swing.JOptionPane;
    1010import org.openstreetmap.josm.Main;
    11 import org.openstreetmap.josm.actions.AutoScaleAction;
    12 import org.openstreetmap.josm.actions.DownloadPrimitiveAction;
    1311import org.openstreetmap.josm.actions.JosmAction;
    1412import org.openstreetmap.josm.data.coor.LatLon;
    15 import org.openstreetmap.josm.data.osm.*;
    1613import org.openstreetmap.josm.data.projection.Projection;
    1714import org.openstreetmap.josm.gui.layer.ImageryLayer;
     
    7067                Main.map.repaint();
    7168            } else if( offset instanceof CalibrationObject ) {
    72                 OsmPrimitive obj = ((CalibrationObject)offset).getObject();
    73                 final List<PrimitiveId> ids = new ArrayList<PrimitiveId>(1);
    74                 ids.add(obj);
    75                 DownloadPrimitiveAction.processItems(false, ids, false, true);
    76                 Main.worker.submit(new AfterCalibrationDownloadTask((CalibrationObject)offset));
     69                CalibrationLayer clayer = new CalibrationLayer((CalibrationObject)offset);
     70                Main.map.mapView.addLayer(clayer);
     71                clayer.panToCenter();
     72                if( !Main.pref.getBoolean("iodb.calibration.message", false) ) {
     73                    JOptionPane.showMessageDialog(Main.parent, // todo: update text
     74                            tr("A layer has been added with a calibration geometry. Hide data layers,\n"
     75                            + "find the corresponding feature on the imagery layer and move it accordingly."),
     76                            ImageryOffsetTools.DIALOG_TITLE, JOptionPane.INFORMATION_MESSAGE);
     77                    Main.pref.put("iodb.calibration.message", true);
     78                }
    7779            }
    7880        }
    7981    }
    8082
    81     class AfterCalibrationDownloadTask implements Runnable {
    82         private CalibrationObject offset;
    83 
    84         public AfterCalibrationDownloadTask( CalibrationObject offset ) {
    85             this.offset = offset;
    86         }
    87 
    88         @Override
    89         public void run() {
    90             OsmPrimitive p = getCurrentDataSet().getPrimitiveById(offset.getObject());
    91             if( p == null ) {
    92                 return;
    93             }
    94             // check for last user
    95             if( offset.getLastUserId() > 0 ) {
    96                 long uid = p.getUser().getId();
    97                 Date ts = p.getTimestamp();
    98                 if( p instanceof Way ) {
    99                     for( Node n : ((Way)p).getNodes() ) {
    100                         if( n.getTimestamp().after(ts) ) {
    101                             ts = n.getTimestamp();
    102                             uid = n.getUser().getId();
    103                         }
    104                     }
    105                 }
    106                 if( uid != offset.getLastUserId() ) {
    107                     int result = JOptionPane.showConfirmDialog(Main.parent,
    108                             tr("The calibration object has been changed in unknown way.\n"
    109                              + "It may be moved or extended, thus ceasing to be a reliable mark\n"
    110                              + "for imagery calibration. Do you want to notify the server of this?"),
    111                             ImageryOffsetTools.DIALOG_TITLE, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
    112                     if( result == JOptionPane.YES_OPTION ) {
    113                         DeprecateOffsetAction.deprecateOffset(offset);
    114                         return;
    115                     }
    116                 }
    117             }
    118             Main.main.getCurrentDataSet().setSelected(p);
    119             AutoScaleAction.zoomTo(Collections.singleton(p));
    120             if( !Main.pref.getBoolean("iodb.calibration.message", false) ) {
    121                 JOptionPane.showMessageDialog(Main.parent,
    122                         tr("An object has been selected on the map. Find the corresponding feature\n"
    123                          + "on the imagery layer and move that layer accordingly.\n"
    124                          + "DO NOT touch the selected object, so it can be used by others later."),
    125                         ImageryOffsetTools.DIALOG_TITLE, JOptionPane.INFORMATION_MESSAGE);
    126                 Main.pref.put("iodb.calibration.message", true);
    127             }
    128         }
    129     }
    130    
    13183    class DownloadOffsetsTask extends SimpleOffsetQueryTask {
    13284        private ImageryLayer layer;
     
    13890                String query = "get?lat=" + center.lat() + "&lon=" + center.lon()
    13991                        + "&imagery=" + URLEncoder.encode(imagery, "UTF8");
     92                int radius = Main.pref.getInteger("iodb.radius", -1);
     93                if( radius > 0 )
     94                    query = query + "?radius=" + radius;
    14095                setQuery(query);
    14196            } catch( UnsupportedEncodingException e ) {
Note: See TracChangeset for help on using the changeset viewer.