Changeset 52 in josm
- Timestamp:
- 2006-02-14T00:52:11+01:00 (19 years ago)
- Files:
-
- 1 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/actions/SaveAction.java
r51 r52 73 73 } 74 74 fileWriter.close(); 75 Main.main.getMapFrame().mapView.editLayer().cleanData( false, false);75 Main.main.getMapFrame().mapView.editLayer().cleanData(null, false); 76 76 } catch (IOException e) { 77 77 e.printStackTrace(); -
src/org/openstreetmap/josm/actions/UploadAction.java
r51 r52 84 84 JOptionPane.showMessageDialog(Main.main, x.getMessage()); 85 85 } 86 Main.main.getMapFrame().mapView.editLayer().cleanData( true, !add.isEmpty());86 Main.main.getMapFrame().mapView.editLayer().cleanData(server.processed, !add.isEmpty()); 87 87 } 88 88 }).start(); -
src/org/openstreetmap/josm/data/GeoPoint.java
r41 r52 80 80 81 81 /** 82 * @return <code>true</code>, if the other GeoPoint has almost the same lat/lon 83 * values, only differ by no more than 1/Projection.MAX_SERVER_PRECISION. 84 */ 85 public boolean equalsLatLonEpsilon(GeoPoint other) { 86 final double p = 1/Projection.MAX_SERVER_PRECISION; 87 return Math.abs(lat-other.lat) <= p && Math.abs(lon-other.lon) <= p && 88 !Double.isNaN(lat) && !Double.isNaN(lon); 89 } 90 91 /** 82 92 * @return <code>true</code>, if the coordinate is outside the world, compared 83 93 * by using lat/lon. -
src/org/openstreetmap/josm/data/osm/visitor/MergeVisitor.java
r50 r52 42 42 if (myNode.modified && !otherNode.modified) 43 43 return; 44 if (!myNode.coor.equalsLatLon(otherNode.coor)) { 44 if (!myNode.coor.equalsLatLonEpsilon(otherNode.coor)) { 45 45 myNode.coor = otherNode.coor; 46 46 myNode.modified = otherNode.modified; … … 51 51 /** 52 52 * Merge the line segment if id matches or if both nodes are the same (and the 53 * id is zero of either segment). Nodes are equalwhen they @see match53 * id is zero of either segment). Nodes are the "same" when they @see match 54 54 */ 55 55 public void visit(LineSegment otherLs) { … … 120 120 private boolean match(Node n1, Node n2) { 121 121 if (n1.id == 0 || n2.id == 0) 122 return n1.coor.equalsLatLon(n2.coor); 122 return n1.coor.equalsLatLonEpsilon(n2.coor); 123 123 return n1.id == n2.id; 124 124 } … … 153 153 */ 154 154 private void mergeCommon(OsmPrimitive myOsm, OsmPrimitive otherOsm) { 155 if (otherOsm.modified)156 myOsm.modified = true;157 155 if (otherOsm.isDeleted()) 158 156 myOsm.setDeleted(true); 159 157 if (!myOsm.modified || otherOsm.modified) { 160 if (otherOsm.id ! = 0 && myOsm.id == 0)158 if (myOsm.id == 0 && otherOsm.id != 0) 161 159 myOsm.id = otherOsm.id; // means not ncessary the object is now modified 160 else if (myOsm.id != 0 && otherOsm.id != 0 && otherOsm.modified) 161 myOsm.modified = true; 162 162 } 163 163 if (myOsm.modifiedProperties && !otherOsm.modifiedProperties) 164 164 return; 165 if (myOsm.keys != null && !myOsm.keys.equals(otherOsm.keys)) { 166 if (myOsm.keys == null) 167 myOsm.keys = otherOsm.keys; 168 else if (otherOsm.keys != null) 169 myOsm.keys.putAll(otherOsm.keys); 170 myOsm.modifiedProperties = true; 171 } 165 if (otherOsm.keys == null) 166 return; 167 if (myOsm.keys != null && myOsm.keys.entrySet().containsAll(otherOsm.keys.entrySet())) 168 return; 169 if (myOsm.keys == null) 170 myOsm.keys = otherOsm.keys; 171 else 172 myOsm.keys.putAll(otherOsm.keys); 173 myOsm.modifiedProperties = true; 172 174 } 173 175 } -
src/org/openstreetmap/josm/data/projection/Epsg4263.java
r51 r52 16 16 17 17 public void xy2latlon(GeoPoint p) { 18 p.lat = Math.round(p.y*MAX_SERVER_PRECISION)/MAX_SERVER_PRECISION;19 p.lon = Math.round(p.x*MAX_SERVER_PRECISION)/MAX_SERVER_PRECISION;18 p.lat = p.y; 19 p.lon = p.x; 20 20 } 21 21 -
src/org/openstreetmap/josm/data/projection/Mercator.java
r51 r52 22 22 p.lon = p.x*180/Math.PI; 23 23 p.lat = Math.atan(Math.sinh(p.y))*180/Math.PI; 24 // round values to maximum server precision25 p.lon = Math.round(p.lon*MAX_SERVER_PRECISION)/MAX_SERVER_PRECISION;26 p.lat = Math.round(p.lat*MAX_SERVER_PRECISION)/MAX_SERVER_PRECISION;27 24 } 28 25 -
src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r51 r52 5 5 import java.beans.PropertyChangeListener; 6 6 import java.util.Collection; 7 import java.util.HashSet; 7 8 import java.util.Iterator; 8 9 import java.util.LinkedList; 10 import java.util.Set; 9 11 import java.util.Stack; 10 12 … … 218 220 * really deleting all deleted objects and reset the modified flags. This is done 219 221 * after a successfull upload. 222 * 220 223 * @param uploaded <code>true</code>, if the data was uploaded, false if saved to disk 221 * @param dataAdded <code>true</code>, if data was added during the upload process. 222 */ 223 public void cleanData(boolean uploaded, boolean dataAdded) { 224 * @param processed A list of all objects, that were actually uploaded. 225 * May be <code>null</code>, which means nothing has been uploaded but 226 * saved to disk instead. 227 */ 228 public void cleanData(Collection<OsmPrimitive> processed, boolean dataAdded) { 224 229 redoCommands.clear(); 225 230 commands.clear(); 226 231 227 232 // if uploaded, clean the modified flags as well 228 if (uploaded) { 233 if (processed != null) { 234 Set<OsmPrimitive> processedSet = new HashSet<OsmPrimitive>(processed); 229 235 for (Iterator<Node> it = data.nodes.iterator(); it.hasNext();) 230 clean ModifiedFlag(it);236 cleanIterator(it, processedSet); 231 237 for (Iterator<LineSegment> it = data.lineSegments.iterator(); it.hasNext();) 232 clean ModifiedFlag(it);238 cleanIterator(it, processedSet); 233 239 for (Iterator<Track> it = data.tracks.iterator(); it.hasNext();) 234 clean ModifiedFlag(it);240 cleanIterator(it, processedSet); 235 241 } 236 242 237 243 // update the modified flag 238 244 239 if (fromDisk && uploaded&& !dataAdded)245 if (fromDisk && processed != null && !dataAdded) 240 246 return; // do nothing when uploading non-harmful changes. 241 247 242 248 // modified if server changed the data (esp. the id). 243 uploadedModified = fromDisk && uploaded&& dataAdded;249 uploadedModified = fromDisk && processed != null && dataAdded; 244 250 setModified(uploadedModified); 245 251 //TODO: Replace with listener scheme … … 248 254 } 249 255 250 private void cleanModifiedFlag(Iterator<? extends OsmPrimitive> it) { 256 /** 257 * Clean the modified flag for the given iterator over a collection if it is in the 258 * list of processed entries. 259 * 260 * @param it The iterator to change the modified and remove the items if deleted. 261 * @param processed A list of all objects that have been successfully progressed. 262 * If the object in the iterator is not in the list, nothing will be changed on it. 263 */ 264 private void cleanIterator(Iterator<? extends OsmPrimitive> it, Collection<OsmPrimitive> processed) { 251 265 OsmPrimitive osm = it.next(); 266 if (!processed.remove(osm)) 267 return; 252 268 osm.modified = false; 253 269 osm.modifiedProperties = false; -
src/org/openstreetmap/josm/io/OsmServerWriter.java
r43 r52 11 11 import java.util.Collection; 12 12 import java.util.HashMap; 13 import java.util.LinkedList; 13 14 14 15 import org.jdom.Document; … … 41 42 42 43 /** 44 * This list contain all sucessfull processed objects. The caller of 45 * upload* has to check this after the call and update its dataset. 46 * 47 * If a server connection error occours, this may contain fewer entries 48 * than where passed in the list to upload*. 49 */ 50 public Collection<OsmPrimitive> processed; 51 52 /** 43 53 * Send the dataset to the server. Ask the user first and does nothing if he 44 54 * does not want to send the data. 45 55 */ 46 56 public void uploadOsm(Collection<OsmPrimitive> list) throws JDOMException { 57 processed = new LinkedList<OsmPrimitive>(); 47 58 initAuthentication(); 48 59 … … 67 78 sendRequest("PUT", "node/" + n.id, n, true); 68 79 } 80 processed.add(n); 69 81 } 70 82 … … 81 93 sendRequest("PUT", "segment/" + ls.id, ls, true); 82 94 } 95 processed.add(ls); 83 96 } 84 97 … … 103 116 104 117 /** 105 * Read a nlong from the input stream and return it.118 * Read a long from the input stream and return it. 106 119 */ 107 120 private long readId(InputStream inputStream) throws IOException { … … 118 131 } 119 132 133 /** 134 * Send the request. The objects id will be replaced if it was 0 before 135 * (on add requests). 136 * 137 * @param requestMethod The http method used when talking with the server. 138 * @param urlSuffix The suffix to add at the server url. 139 * @param osm The primitive to encode to the server. 140 * @param addBody <code>true</code>, if the whole primitive body should be added. 141 * <code>false</code>, if only the id is encoded. 142 */ 120 143 @SuppressWarnings("unchecked") 121 144 private void sendRequest(String requestMethod, String urlSuffix, -
test/org/openstreetmap/josm/test/framework/DataSetTestCaseHelper.java
r49 r52 43 43 * Create a line segment with out of the given nodes. 44 44 */ 45 p rivatestatic LineSegment createLineSegment(DataSet ds, Node n1, Node n2) {45 public static LineSegment createLineSegment(DataSet ds, Node n1, Node n2) { 46 46 LineSegment ls = new LineSegment(n1, n2); 47 47 ds.lineSegments.add(ls); … … 52 52 * Add a random node. 53 53 */ 54 p rivatestatic Node createNode(DataSet ds) {54 public static Node createNode(DataSet ds) { 55 55 Node node = new Node(); 56 56 node.coor = new GeoPoint(Math.random(), Math.random());
Note:
See TracChangeset
for help on using the changeset viewer.