- Timestamp:
- 2014-09-12T01:57:41+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/upload/ApiPreconditionCheckerHook.java
r7434 r7529 32 32 // should be displayed. 33 33 api.initialize(NullProgressMonitor.INSTANCE); 34 long maxNodes = 0; 35 if (api.getCapabilities().isDefined("waynodes", "maximum")) { 36 maxNodes = api.getCapabilities().getLong("waynodes","maximum"); 37 } 34 long maxNodes = api.getCapabilities().getMaxWayNodes(); 38 35 if (maxNodes > 0) { 39 36 if( !checkMaxNodes(apiData.getPrimitivesToAdd(), maxNodes)) -
trunk/src/org/openstreetmap/josm/io/Capabilities.java
r7473 r7529 158 158 } 159 159 160 private static void warnIllegalValue(String attr, String elem, Object val) { 161 Main.warn(tr("Illegal value of attribute ''{0}'' of element ''{1}'' in server capabilities. Got ''{2}''", attr, elem, val)); 162 } 163 160 164 /** 161 165 * Returns the max number of objects in a changeset. -1 if either the capabilities … … 167 171 public int getMaxChangesetSize() { 168 172 String v = get("changesets", "maximum_elements"); 169 if (v == null) return -1; 170 try { 171 int n = Integer.parseInt(v); 172 if (n <= 0) { 173 Main.warn(tr("Illegal value of attribute ''{0}'' of element ''{1}'' in server capabilities. Got ''{2}''", "changesets", "maximum_elements", n )); 174 return -1; 175 } 176 return n; 177 } catch (NumberFormatException e) { 178 Main.warn(tr("Illegal value of attribute ''{0}'' of element ''{1}'' in server capabilities. Got ''{2}''", "changesets", "maximum_elements", v )); 179 return -1; 180 } 173 if (v != null) { 174 try { 175 int n = Integer.parseInt(v); 176 if (n <= 0) { 177 warnIllegalValue("changesets", "maximum_elements", n); 178 } else { 179 return n; 180 } 181 } catch (NumberFormatException e) { 182 warnIllegalValue("changesets", "maximum_elements", v); 183 } 184 } 185 return -1; 186 } 187 188 /** 189 * Returns the max number of nodes in a way. -1 if either the capabilities 190 * don't include this parameter or if the parameter value is illegal (not a number, 191 * a negative number) 192 * 193 * @return the max number of nodes in a way 194 */ 195 public long getMaxWayNodes() { 196 String v = get("waynodes", "maximum"); 197 if (v != null) { 198 try { 199 Long n = Long.parseLong(v); 200 if (n <= 0) { 201 warnIllegalValue("waynodes", "maximum", n); 202 } else { 203 return n; 204 } 205 } catch (NumberFormatException e) { 206 warnIllegalValue("waynodes", "maximum", v); 207 } 208 } 209 return -1; 181 210 } 182 211
Note:
See TracChangeset
for help on using the changeset viewer.