Changeset 29376 in osm for applications/editors/josm/plugins/imagery_offset_db/src/iodb/GetImageryOffsetAction.java
- Timestamp:
- 2013-03-19T20:46:10+01:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/imagery_offset_db/src/iodb/GetImageryOffsetAction.java
r29371 r29376 9 9 import javax.swing.JOptionPane; 10 10 import org.openstreetmap.josm.Main; 11 import org.openstreetmap.josm.actions.AutoScaleAction;12 import org.openstreetmap.josm.actions.DownloadPrimitiveAction;13 11 import org.openstreetmap.josm.actions.JosmAction; 14 12 import org.openstreetmap.josm.data.coor.LatLon; 15 import org.openstreetmap.josm.data.osm.*;16 13 import org.openstreetmap.josm.data.projection.Projection; 17 14 import org.openstreetmap.josm.gui.layer.ImageryLayer; … … 70 67 Main.map.repaint(); 71 68 } 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 } 77 79 } 78 80 } 79 81 } 80 82 81 class AfterCalibrationDownloadTask implements Runnable {82 private CalibrationObject offset;83 84 public AfterCalibrationDownloadTask( CalibrationObject offset ) {85 this.offset = offset;86 }87 88 @Override89 public void run() {90 OsmPrimitive p = getCurrentDataSet().getPrimitiveById(offset.getObject());91 if( p == null ) {92 return;93 }94 // check for last user95 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 131 83 class DownloadOffsetsTask extends SimpleOffsetQueryTask { 132 84 private ImageryLayer layer; … … 138 90 String query = "get?lat=" + center.lat() + "&lon=" + center.lon() 139 91 + "&imagery=" + URLEncoder.encode(imagery, "UTF8"); 92 int radius = Main.pref.getInteger("iodb.radius", -1); 93 if( radius > 0 ) 94 query = query + "?radius=" + radius; 140 95 setQuery(query); 141 96 } catch( UnsupportedEncodingException e ) {
Note:
See TracChangeset
for help on using the changeset viewer.