Changeset 8568 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2015-07-04T22:52:23+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java
r8540 r8568 2 2 package org.openstreetmap.josm.data.cache; 3 3 4 import java.io.ByteArrayOutputStream;5 4 import java.io.FileNotFoundException; 6 5 import java.io.IOException; 7 import java.io.InputStream;8 6 import java.net.HttpURLConnection; 9 7 import java.net.URL; … … 30 28 import org.openstreetmap.josm.data.cache.ICachedLoaderListener.LoadResult; 31 29 import org.openstreetmap.josm.data.preferences.IntegerProperty; 30 import org.openstreetmap.josm.tools.Utils; 32 31 33 32 /** … … 350 349 351 350 attributes.setResponseCode(responseCode(urlConn)); 352 byte[] raw = read(urlConn);351 byte[] raw = Utils.readBytesFromStream(urlConn.getInputStream()); 353 352 354 353 if (isResponseLoadable(urlConn.getHeaderFields(), responseCode(urlConn), raw)) { … … 473 472 } 474 473 475 private static byte[] read(URLConnection urlConn) throws IOException {476 InputStream input = urlConn.getInputStream();477 try {478 ByteArrayOutputStream bout = new ByteArrayOutputStream(input.available());479 byte[] buffer = new byte[2048];480 boolean finished = false;481 do {482 int read = input.read(buffer);483 if (read >= 0) {484 bout.write(buffer, 0, read);485 } else {486 finished = true;487 }488 } while (!finished);489 if (bout.size() == 0)490 return null;491 return bout.toByteArray();492 } finally {493 input.close();494 }495 }496 497 474 /** 498 475 * TODO: move to JobFactory -
trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java
r8526 r8568 56 56 SCANEX("scanex"), 57 57 /** A WMS endpoint entry only stores the WMS server info, without layer, which are chosen later by the user. **/ 58 WMS_ENDPOINT("wms_endpoint"); 58 WMS_ENDPOINT("wms_endpoint"), 59 /** WMTS stores GetCapabilities URL. Does not store any information about the layer **/ 60 WMTS("wmts"); 59 61 60 62 -
trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java
r8533 r8568 8 8 import java.util.List; 9 9 import java.util.Map; 10 import java.util.concurrent.ConcurrentHashMap; 10 11 import java.util.regex.Matcher; 11 12 import java.util.regex.Pattern; … … 35 36 public class CustomProjection extends AbstractProjection { 36 37 38 private final static Map<String, Double> UNITS_TO_METERS = getUnitsToMeters(); 39 private final static double METER_PER_UNIT_DEGREE = 2 * Math.PI * 6370997 / 360; 40 37 41 /** 38 42 * pref String that defines the projection … … 45 49 protected String cacheDir; 46 50 protected Bounds bounds; 51 private double metersPerUnit = METER_PER_UNIT_DEGREE; // default to degrees 47 52 48 53 /** … … 89 94 wktext("wktext", false), // ignored 90 95 /** meters, US survey feet, etc. */ 91 units("units", true), // ignored96 units("units", true), 92 97 /** Don't use the /usr/share/proj/proj_def.dat defaults file */ 93 98 no_defs("no_defs", false), 94 99 init("init", true), 100 to_meter("to_meter", true), 95 101 // JOSM extensions, not present in PROJ.4 96 102 wmssrs("wmssrs", true), … … 103 109 104 110 /** Map of all parameters by key */ 105 static final Map<String, Param> paramsByKey = new HashMap<>(); 111 static final Map<String, Param> paramsByKey = new ConcurrentHashMap<>(); 106 112 static { 107 113 for (Param p : Param.values()) { … … 198 204 if (s != null) { 199 205 this.code = s; 206 } 207 s = parameters.get(Param.units.key); 208 if (s != null) { 209 this.metersPerUnit = UNITS_TO_METERS.get(s); 210 } 211 s = parameters.get(Param.to_meter.key); 212 if (s != null) { 213 this.metersPerUnit = parseDouble(s, Param.to_meter.key); 200 214 } 201 215 } … … 528 542 return name != null ? name : tr("Custom Projection"); 529 543 } 544 545 @Override 546 public double getMetersPerUnit() { 547 return metersPerUnit; 548 } 549 550 private static Map<String, Double> getUnitsToMeters() { 551 Map<String, Double> ret = new ConcurrentHashMap<>(); 552 ret.put("km", 1000d); 553 ret.put("m", 1d); 554 ret.put("dm", 1d/10); 555 ret.put("cm", 1d/100); 556 ret.put("mm", 1d/1000); 557 ret.put("kmi", 1852.0); 558 ret.put("in", 0.0254); 559 ret.put("ft", 0.3048); 560 ret.put("yd", 0.9144); 561 ret.put("mi", 1609.344); 562 ret.put("fathom", 1.8288); 563 ret.put("chain", 20.1168); 564 ret.put("link", 0.201168); 565 ret.put("us-in", 1d/39.37); 566 ret.put("us-ft", 0.304800609601219); 567 ret.put("us-yd", 0.914401828803658); 568 ret.put("us-ch", 20.11684023368047); 569 ret.put("us-mi", 1609.347218694437); 570 ret.put("ind-yd", 0.91439523); 571 ret.put("ind-ft", 0.30479841); 572 ret.put("ind-ch", 20.11669506); 573 ret.put("degree", METER_PER_UNIT_DEGREE); 574 return ret; 575 } 530 576 } -
trunk/src/org/openstreetmap/josm/data/projection/Projection.java
r6069 r8568 68 68 */ 69 69 Bounds getWorldBoundsLatLon(); 70 71 /** 72 * Get the number of meters per unit of this projection. This more 73 * defines the scale of the map, than real conversion of unit to meters 74 * as this value is more less correct only along great circles. 75 * 76 * Used by WMTS to properly scale tiles 77 * @return meters per unit of projection 78 * 79 */ 80 double getMetersPerUnit(); 70 81 } -
trunk/src/org/openstreetmap/josm/data/projection/proj/Proj.java
r7509 r8568 64 64 */ 65 65 double[] invproject(double east, double north); 66 67 66 }
Note:
See TracChangeset
for help on using the changeset viewer.