Changeset 2599 in josm for trunk/src/org/openstreetmap/josm/io
- Timestamp:
- 2009-12-09T21:25:40+01:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/io
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/Capabilities.java
r2512 r2599 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.io; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 3 5 4 6 import java.util.HashMap; … … 71 73 } 72 74 75 /** 76 * Replies the max number of objects in a changeset. -1 if either the capabilities 77 * don't include this parameter or if the parameter value is illegal (not a number, 78 * a negative number) 79 * 80 * @return the max number of objects in a changeset 81 */ 82 public int getMaxChangsetSize() { 83 String v = get("changesets", "maximum_elements"); 84 if (v == null) return -1; 85 try { 86 int n = Integer.parseInt(v); 87 if (n <= 0) { 88 System.err.println(tr("Warning: illegal value of attribute '{0}'' of element ''{1}'' in server capabilities. Got ''{2}", "changesets", "maximum_elements", n )); 89 return -1; 90 } 91 return n; 92 } catch(NumberFormatException e) { 93 System.err.println(tr("Warning: illegal value of attribute '{0}'' of element ''{1}'' in server capabilities. Got ''{2}", "changesets", "maximum_elements", v )); 94 return -1; 95 } 96 } 73 97 } -
trunk/src/org/openstreetmap/josm/io/ChangesetClosedException.java
r2569 r2599 31 31 final static public String ERROR_HEADER_PATTERN = "The changeset (\\d+) was closed at (.*)"; 32 32 33 static enum Source {33 public static enum Source { 34 34 /** 35 35 * The exception was thrown when a changeset was updated. This most likely means … … 114 114 115 115 /** 116 * Creates the exception 117 * 118 * @param changesetId the id if the closed changeset 119 * @param closedOn the date the changeset was closed on 120 * @param source the source for the exception 121 */ 122 public ChangesetClosedException(long changesetId, Date closedOn, Source source) { 123 super(""); 124 this.source = source == null ? Source.UNSPECIFIED : source; 125 this.changesetId = changesetId; 126 this.closedOn = closedOn; 127 } 128 129 /** 116 130 * Replies the id of the changeset which was closed 117 131 * … … 139 153 return source; 140 154 } 155 156 public void setSource(Source source) { 157 this.source = source == null ? Source.UNSPECIFIED : source; 158 } 141 159 } -
trunk/src/org/openstreetmap/josm/io/MultiFetchServerObjectReader.java
r2578 r2599 19 19 import org.openstreetmap.josm.data.osm.OsmPrimitive; 20 20 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 21 import org.openstreetmap.josm.data.osm.PrimitiveId; 21 22 import org.openstreetmap.josm.data.osm.Relation; 22 23 import org.openstreetmap.josm.data.osm.RelationMember; … … 76 77 77 78 /** 78 * remembers an {@see OsmPrimitive}'s id and its type. The id will79 * Remembers an {@see OsmPrimitive}'s id. The id will 79 80 * later be fetched as part of a Multi Get request. 80 81 * 81 * Ignore the id if it id <= 0.82 * Ignore the id if it represents a new primitives. 82 83 * 83 84 * @param id the id 84 * @param type the type 85 */ 86 protected void remember(long id, OsmPrimitiveType type) { 87 if (id <= 0) return; 88 if (type.equals(OsmPrimitiveType.NODE)) { 89 nodes.add(id); 90 } else if (type.equals(OsmPrimitiveType.WAY)) { 91 ways.add(id); 92 } if (type.equals(OsmPrimitiveType.RELATION)) { 93 relations.add(id); 85 */ 86 protected void remember(PrimitiveId id) { 87 if (id.isNew()) return; 88 switch(id.getType()) { 89 case NODE: nodes.add(id.getUniqueId()); break; 90 case WAY: ways.add(id.getUniqueId()); break; 91 case RELATION: relations.add(id.getUniqueId()); break; 94 92 } 95 93 } … … 115 113 if (primitive == null) 116 114 throw new NoSuchElementException(tr("No primitive with id {0} in local dataset. Can't infer primitive type.", id)); 117 remember( id, OsmPrimitiveType.from(primitive));115 remember(primitive.getPrimitiveId()); 118 116 return; 119 117 } … … 153 151 public MultiFetchServerObjectReader append(Node node) { 154 152 if (node == null) return this; 155 if (node.isNew()) return this; 156 remember(node.getId(), OsmPrimitiveType.NODE); 153 remember(node.getPrimitiveId()); 157 154 return this; 158 155 } … … 170 167 for (Node node: way.getNodes()) { 171 168 if (!node.isNew()) { 172 remember(node.get Id(), OsmPrimitiveType.NODE);173 } 174 } 175 remember(way.get Id(), OsmPrimitiveType.WAY);169 remember(node.getPrimitiveId()); 170 } 171 } 172 remember(way.getPrimitiveId()); 176 173 return this; 177 174 } … … 187 184 if (relation == null) return this; 188 185 if (relation.isNew()) return this; 189 remember(relation.get Id(), OsmPrimitiveType.RELATION);186 remember(relation.getPrimitiveId()); 190 187 for (RelationMember member : relation.getMembers()) { 191 188 if (OsmPrimitiveType.from(member.getMember()).equals(OsmPrimitiveType.RELATION)) { -
trunk/src/org/openstreetmap/josm/io/OsmApi.java
r2569 r2599 80 80 String serverUrl = Main.pref.get("osm-server.url", "http://api.openstreetmap.org/api"); 81 81 if (serverUrl == null) 82 throw new IllegalStateException(tr("Preference ''{0}'' missing. Can' t initialize OsmApi.", "osm-server.url"));82 throw new IllegalStateException(tr("Preference ''{0}'' missing. Can''t initialize OsmApi.", "osm-server.url")); 83 83 return getOsmApi(serverUrl); 84 84 } … … 342 342 monitor 343 343 ); 344 } catch(ChangesetClosedException e) { 345 e.setSource(ChangesetClosedException.Source.UPDATE_CHANGESET); 346 throw e; 344 347 } catch(OsmApiException e) { 345 348 if (e.getResponseCode() == HttpURLConnection.HTTP_CONFLICT && ChangesetClosedException.errorHeaderMatchesPattern(e.getErrorHeader())) -
trunk/src/org/openstreetmap/josm/io/OsmServerWriter.java
r2569 r2599 149 149 while(it.hasNext()) { 150 150 i++; 151 progressMonitor.setCustomText(tr("({0}/{1}) Uploading {2} objects...", i,numChunks,chunkSize));152 151 if (canceled) return; 153 152 int j = 0; … … 158 157 chunk.add(it.next()); 159 158 } 159 progressMonitor.setCustomText(tr("({0}/{1}) Uploading {2} objects...", i,numChunks,chunk.size())); 160 160 processed.addAll(api.uploadDiff(chunk, progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false))); 161 161 }
Note:
See TracChangeset
for help on using the changeset viewer.