- Timestamp:
- 2006-06-10T23:45:21+02:00 (18 years ago)
- Location:
- src/org/openstreetmap/josm
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/actions/mapmode/AddNodeAction.java
r101 r102 17 17 import org.openstreetmap.josm.command.Command; 18 18 import org.openstreetmap.josm.command.SequenceCommand; 19 import org.openstreetmap.josm.data.coor.EastNorth; 19 20 import org.openstreetmap.josm.data.osm.Node; 20 21 import org.openstreetmap.josm.data.osm.Segment; … … 88 89 return; 89 90 91 if ((e.getModifiersEx() & MouseEvent.ALT_DOWN_MASK) == 0) { 92 // moving the new point to the perpendicular point 93 EastNorth A = s.from.eastNorth; 94 EastNorth B = s.to.eastNorth; 95 double ab = A.distance(B); 96 double nb = n.eastNorth.distance(B); 97 double na = n.eastNorth.distance(A); 98 double q = (nb-na+ab)/ab/2; 99 n.eastNorth = new EastNorth(B.east() + q*(A.east()-B.east()), B.north() + q*(A.north()-B.north())); 100 n.coor = Main.proj.eastNorth2latlon(n.eastNorth); 101 } 102 90 103 Collection<Command> cmds = new LinkedList<Command>(); 91 104 cmds.add(c); -
src/org/openstreetmap/josm/data/osm/visitor/MergeVisitor.java
r100 r102 238 238 */ 239 239 private boolean match(Segment ls1, Segment ls2) { 240 if (ls1.id == ls2.id )240 if (ls1.id == ls2.id && ls1.id != 0) 241 241 return true; 242 242 if (ls1.incomplete || ls2.incomplete) … … 294 294 if (my.realEqual(other)) 295 295 return true; // no merge needed. 296 if (my.id == other.id ) {296 if (my.id == other.id && my.id != 0) { 297 297 if (my instanceof Segment && ((Segment)my).incomplete) 298 298 return false; // merge always over an incomplete -
src/org/openstreetmap/josm/gui/ConflictResolver.java
r86 r102 120 120 } 121 121 122 public final List<ConflictItem> conflicts ;122 public final List<ConflictItem> conflicts = new ArrayList<ConflictItem>(); 123 123 124 124 private final ConflictTableModel my = new ConflictTableModel(Resolution.MY); 125 private final JTable myTable = new JTable(my);125 private final JTable myTable; 126 126 private final ConflictTableModel their = new ConflictTableModel(Resolution.THEIR); 127 private final JTable theirTable = new JTable(their);127 private final JTable theirTable; 128 128 private final ConflictTableModel resolve = new ConflictTableModel(null); 129 private final JTable resolveTable = new JTable(resolve);129 private final JTable resolveTable; 130 130 131 131 132 132 public ConflictResolver(Map<OsmPrimitive, OsmPrimitive> conflicts) { 133 133 super(new GridBagLayout()); 134 this.conflicts = new ArrayList<ConflictItem>();135 134 Collection<ConflictItem> possibleConflicts = new ArrayList<ConflictItem>(); 136 135 possibleConflicts.add(new DeleteConflict()); … … 161 160 throw new RuntimeException("No conflicts but in conflict list:\n" + Arrays.toString(conflicts.entrySet().toArray())); 162 161 162 // have to initialize the JTables here and not in the declaration, because its constructor 163 // may access this.conflicts (indirectly) 164 myTable = new JTable(my); 165 theirTable = new JTable(their); 166 resolveTable = new JTable(resolve); 167 163 168 myTable.setPreferredScrollableViewportSize(new Dimension(250,70)); 164 169 theirTable.setPreferredScrollableViewportSize(new Dimension(250,70)); -
src/org/openstreetmap/josm/gui/MapMover.java
r101 r102 2 2 3 3 import java.awt.Cursor; 4 import java.awt.Point; 4 5 import java.awt.event.ActionEvent; 5 6 import java.awt.event.KeyEvent; … … 32 33 public void actionPerformed(ActionEvent e) { 33 34 if (action.equals("+") || action.equals("-")) { 34 MouseWheelEvent we = new MouseWheelEvent(nc, e.getID(), e.getWhen(), e.getModifiers(), nc.getMousePosition().x, nc.getMousePosition().y, 0, false, MouseWheelEvent.WHEEL_UNIT_SCROLL, 1, action.equals("+") ? -1 : 1); 35 Point mouse = nc.getMousePosition(); 36 if (mouse == null) 37 mouse = new Point((int)nc.getBounds().getCenterX(), (int)nc.getBounds().getCenterY()); 38 MouseWheelEvent we = new MouseWheelEvent(nc, e.getID(), e.getWhen(), e.getModifiers(), mouse.x, mouse.y, 0, false, MouseWheelEvent.WHEEL_UNIT_SCROLL, 1, action.equals("+") ? -1 : 1); 35 39 mouseWheelMoved(we); 36 40 } else { -
src/org/openstreetmap/josm/gui/layer/GeoImageLayer.java
r101 r102 53 53 import org.openstreetmap.josm.gui.dialogs.LayerListPopup; 54 54 import org.openstreetmap.josm.gui.layer.RawGpsLayer.GpsPoint; 55 import org.openstreetmap.josm.tools.DateParser; 55 56 import org.openstreetmap.josm.tools.ExifReader; 56 57 import org.openstreetmap.josm.tools.GBC; … … 97 98 if (!m.matches()) 98 99 throw new IOException("Cannot read time from point "+p.latlon.lat()+","+p.latlon.lon()); 99 Date d = dateFormat.parse(m.group(1)+" "+m.group(2));100 Date d = DateParser.parse(m.group(1)+" "+m.group(2)); 100 101 gps.add(new TimedPoint(d, p.eastNorth)); 101 102 if (last != null && last.after(d)) … … 381 382 return; 382 383 try { 383 delta = dateFormat.parse(gpsText.getText()).getTime() - exifDate.getTime();384 delta = DateParser.parse(gpsText.getText()).getTime() - exifDate.getTime(); 384 385 Main.pref.put("tagimages.delta", ""+delta); 385 386 String time = gpsTimezone.getText(); -
src/org/openstreetmap/josm/gui/layer/RawGpsLayer.java
r100 r102 10 10 import java.util.LinkedList; 11 11 12 import javax.swing.AbstractAction; 12 13 import javax.swing.Icon; 13 14 import javax.swing.JColorChooser; … … 23 24 import org.openstreetmap.josm.data.coor.EastNorth; 24 25 import org.openstreetmap.josm.data.coor.LatLon; 26 import org.openstreetmap.josm.data.osm.DataSet; 27 import org.openstreetmap.josm.data.osm.Node; 28 import org.openstreetmap.josm.data.osm.Segment; 29 import org.openstreetmap.josm.data.osm.Way; 25 30 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 26 31 import org.openstreetmap.josm.gui.MapView; … … 36 41 */ 37 42 public class RawGpsLayer extends Layer implements PreferenceChangedListener { 43 44 public class ConvertToOsmAction extends AbstractAction { 45 public ConvertToOsmAction() { 46 super("Convert layer to OSM"); 47 } 48 public void actionPerformed(ActionEvent e) { 49 DataSet ds = new DataSet(); 50 for (Collection<GpsPoint> c : data) { 51 Way w = new Way(); 52 Node start = null; 53 for (GpsPoint p : c) { 54 Node end = new Node(p.latlon); 55 ds.nodes.add(end); 56 if (start != null) { 57 Segment segment = new Segment(start,end); 58 w.segments.add(segment); 59 ds.segments.add(segment); 60 } 61 start = end; 62 } 63 ds.ways.add(w); 64 } 65 Main.main.addLayer(new OsmDataLayer(ds, "Data Layer", true)); 66 Main.main.removeLayer(RawGpsLayer.this); 67 } 68 } 38 69 39 70 public static class GpsPoint { … … 184 215 menu.add(tagimage); 185 216 217 menu.add(new JMenuItem(new ConvertToOsmAction())); 218 186 219 menu.addSeparator(); 187 220 menu.add(new LayerListPopup.InfoAction(this)); -
src/org/openstreetmap/josm/test/MergeVisitorTest.java
r100 r102 48 48 n.modified = true; 49 49 dsNode.modified = true; 50 v.visit(n); 51 assertEquals(1, v.conflicts.size()); 52 assertFalse(n.equals(dsNode)); 50 n.id = 1; 51 dsNode.id = 1; 52 v.visit(n); 53 assertEquals(1, v.conflicts.size()); 53 54 } 54 55 public void testNodesConflict() { … … 91 92 } 92 93 94 public void testNoConflictNewNodesMerged() { 95 assertEquals(0, n.id); 96 assertEquals(0, dsNode.id); 97 v.visit(n); 98 v.fixReferences(); 99 assertEquals(0,v.conflicts.size()); 100 assertTrue(ds.nodes.contains(n)); 101 assertEquals(2, ds.nodes.size()); 102 } 103 104 /** 105 * Test that two new segments that have different from/to are not merged 106 */ 107 @Bug(101) 108 public void testNewSegmentNotMerged() { 109 v.visit(n); 110 Segment s1 = new Segment(n, dsNode); 111 v.visit(s1); 112 Segment s2 = new Segment(dsNode, n); 113 v.visit(s2); 114 assertEquals(2, ds.segments.size()); 115 } 116 93 117 public void testFixReferencesConflicts() { 94 118 // make two nodes mergable … … 198 222 assertSame("Do not import incomplete segments when merging ways.", s, w.segments.iterator().next()); 199 223 } 200 224 201 225 /** 202 226 * Create that amount of nodes and add them to the dataset. The id will be 1,2,3,4... -
src/org/openstreetmap/josm/tools/SearchCompiler.java
r90 r102 20 20 abstract public boolean match(OsmPrimitive osm); 21 21 } 22 22 23 23 private static class Always extends Match { 24 24 @Override public boolean match(OsmPrimitive osm) { … … 35 35 @Override public String toString() {return "!"+match;} 36 36 } 37 37 38 38 private static class And extends Match { 39 39 private Match lhs; … … 45 45 @Override public String toString() {return lhs+" && "+rhs;} 46 46 } 47 47 48 48 private static class Or extends Match { 49 49 private Match lhs; … … 55 55 @Override public String toString() {return lhs+" || "+rhs;} 56 56 } 57 57 58 58 private static class Id extends Match { 59 59 private long id; … … 64 64 @Override public String toString() {return "id="+id;} 65 65 } 66 66 67 67 private static class KeyValue extends Match { 68 68 private String key; … … 111 111 @Override public String toString() {return "type="+type;} 112 112 } 113 114 113 114 private static class Modified extends Match { 115 @Override public boolean match(OsmPrimitive osm) { 116 return osm.modified; 117 } 118 @Override public String toString() {return "modified";} 119 } 120 115 121 public static Match compile(String searchStr) { 116 122 return new SearchCompiler().parse(new PushbackReader(new StringReader(searchStr))); … … 152 158 default: 153 159 s = new StringBuilder(); 154 for (;;) { 155 s.append(c); 156 next = search.read(); 157 if (next == -1) { 158 if (s.toString().equals("OR")) 159 return "|"; 160 return " "+s.toString(); 161 } 162 c = (char)next; 163 if (c == ' ' || c == '\t' || c == ':' || c == '"') { 164 if (c == ':') 165 return ":"+s.toString(); 166 search.unread(next); 167 if (s.toString().equals("OR")) 168 return "|"; 169 return " "+s.toString(); 170 } 160 for (;;) { 161 s.append(c); 162 next = search.read(); 163 if (next == -1) { 164 if (s.toString().equals("OR")) 165 return "|"; 166 return " "+s.toString(); 171 167 } 168 c = (char)next; 169 if (c == ' ' || c == '\t' || c == ':' || c == '"') { 170 if (c == ':') 171 return ":"+s.toString(); 172 search.unread(next); 173 if (s.toString().equals("OR")) 174 return "|"; 175 return " "+s.toString(); 176 } 177 } 172 178 } 173 179 } catch (IOException e) { … … 175 181 } 176 182 } 177 178 183 184 179 185 private boolean notKey = false; 180 186 private boolean notValue = false; … … 185 191 String value = token.substring(1); 186 192 if (key == null) { 187 Match c = new Any(value); 193 Match c = null; 194 if (value.equals("modified")) 195 c = new Modified(); 196 else 197 c = new Any(value); 188 198 if (notValue) 189 199 return new Not(c); … … 207 217 return c; 208 218 } 209 219 210 220 private Match parse(PushbackReader search) { 211 221 Match result = null; … … 231 241 else 232 242 result = or ? new Or(result, current) : new And(result, current); 233 key = null;234 notKey = false;235 notValue = false;236 or = false;243 key = null; 244 notKey = false; 245 notValue = false; 246 or = false; 237 247 } 238 248 }
Note:
See TracChangeset
for help on using the changeset viewer.