Changeset 7509 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2014-09-07T16:33:52+02:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/tools
- Files:
-
- 9 edited
-
Base64.java (modified) (1 diff)
-
GeoPropertyIndex.java (modified) (11 diffs)
-
Geometry.java (modified) (1 diff)
-
InputMapUtils.java (modified) (1 diff)
-
LanguageInfo.java (modified) (2 diffs)
-
Pair.java (modified) (2 diffs)
-
Predicate.java (modified) (1 diff)
-
Property.java (modified) (2 diffs)
-
RightAndLefthandTraffic.java (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/Base64.java
r7060 r7509 17 17 // Hide default constructor for utils classes 18 18 } 19 19 20 20 /** "base64": RFC 2045 default encoding */ 21 21 private static String encDefault = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -
trunk/src/org/openstreetmap/josm/tools/GeoPropertyIndex.java
r7353 r7509 7 7 /** 8 8 * Fast index to look up properties of the earth surface. 9 * 9 * 10 10 * It is expected that there is a relatively slow method to look up the property 11 11 * for a certain coordinate and that there are larger areas with a uniform 12 12 * property. 13 * 13 * 14 14 * This index tries to find rectangles with uniform property and caches them. 15 15 * Rectangles are subdivided, if there are different properties within. 16 16 * (Up to a maximum level, when the slow method is used again.) 17 * 17 * 18 18 * @param <T> the property (like land/water or nation) 19 19 */ 20 20 public class GeoPropertyIndex<T> { 21 21 22 22 /** 23 23 * A method to look up a property of the earth surface. … … 45 45 private final GPLevel<T> root; 46 46 private GPLevel<T> lastLevelUsed; 47 47 48 48 private static final boolean DEBUG = false; 49 49 … … 51 51 * Create new GeoPropertyIndex. 52 52 * @param geoProp the input property that should be made faster by this index 53 * @param maxLevel 53 * @param maxLevel 54 54 */ 55 55 public GeoPropertyIndex(GeoProperty<T> geoProp, int maxLevel) { … … 59 59 this.lastLevelUsed = root; 60 60 } 61 61 62 62 /** 63 63 * Look up the property for a certain point. … … 70 70 return lastLevelUsed.get(ll); 71 71 } 72 72 73 73 public static int index(LatLon ll, int level) { 74 74 long noParts = 1 << level; … … 102 102 return parent.get(ll); 103 103 } 104 104 105 105 private T getBounded(LatLon ll) { 106 106 if (DEBUG) System.err.print("GPLevel["+level+"]"+bbox+" "); … … 117 117 return owner.geoProp.get(ll); 118 118 } 119 119 120 120 if (children == null) { 121 121 @SuppressWarnings("unchecked") … … 123 123 this.children = tmp; 124 124 } 125 125 126 126 int idx = index(ll, level+1); 127 127 if (children[idx] == null) { 128 128 double lon1, lat1; 129 129 switch (idx) { 130 case 0: 130 case 0: 131 131 lon1 = bbox.getTopLeftLon(); 132 132 lat1 = bbox.getBottomRightLat(); … … 136 136 lat1 = bbox.getTopLeftLat(); 137 137 break; 138 case 2: 138 case 2: 139 139 lon1 = bbox.getBottomRightLon(); 140 140 lat1 = bbox.getBottomRightLat(); 141 141 break; 142 case 3: 142 case 3: 143 143 lon1 = bbox.getBottomRightLon(); 144 144 lat1 = bbox.getTopLeftLat(); … … 154 154 return children[idx].getBounded(ll); 155 155 } 156 156 157 157 /** 158 158 * Checks, if a point is inside this tile. … … 163 163 */ 164 164 boolean isInside(LatLon ll) { 165 return bbox.getTopLeftLon() <= ll.lon() && 166 (ll.lon() < bbox.getBottomRightLon() || (ll.lon() == 180.0 && bbox.getBottomRightLon() == 180.0)) && 167 bbox.getBottomRightLat() <= ll.lat() && 165 return bbox.getTopLeftLon() <= ll.lon() && 166 (ll.lon() < bbox.getBottomRightLon() || (ll.lon() == 180.0 && bbox.getBottomRightLon() == 180.0)) && 167 bbox.getBottomRightLat() <= ll.lat() && 168 168 (ll.lat() < bbox.getTopLeftLat() || (ll.lat() == 90.0 && bbox.getTopLeftLat() == 90.0)); 169 169 } -
trunk/src/org/openstreetmap/josm/tools/Geometry.java
r7392 r7509 469 469 return new Area(path); 470 470 } 471 471 472 472 /** 473 473 * Returns the Area of a polygon, from its list of nodes. -
trunk/src/org/openstreetmap/josm/tools/InputMapUtils.java
r6557 r7509 17 17 */ 18 18 public final class InputMapUtils { 19 19 20 20 private InputMapUtils() { 21 21 // Hide default constructor for utils classes 22 22 } 23 23 24 24 /** 25 25 * Unassign Ctrl-Shift/Alt-Shift Up/Down from the given component -
trunk/src/org/openstreetmap/josm/tools/LanguageInfo.java
r7012 r7509 5 5 6 6 public final class LanguageInfo { 7 7 8 8 private LanguageInfo() { 9 9 // Hide default constructor for utils classes 10 10 } 11 11 12 12 /** 13 13 * Type of the locale to use … … 126 126 return getJOSMLocaleCode()+"."; 127 127 } 128 128 129 129 public static String getLanguageCodeManifest() { 130 130 return getJOSMLocaleCode()+"_"; -
trunk/src/org/openstreetmap/josm/tools/Pair.java
r7005 r7509 10 10 */ 11 11 public final class Pair<A,B> { 12 12 13 13 /** 14 14 * The first item 15 15 */ 16 16 public A a; 17 17 18 18 /** 19 19 * The second item … … 65 65 66 66 /** 67 * Convenient constructor method 67 * Convenient constructor method 68 68 * @param u The first item 69 69 * @param v The second item -
trunk/src/org/openstreetmap/josm/tools/Predicate.java
r6452 r7509 9 9 */ 10 10 public interface Predicate<T> { 11 11 12 12 /** 13 13 * Determines whether the object passes the test or not -
trunk/src/org/openstreetmap/josm/tools/Property.java
r6223 r7509 8 8 */ 9 9 public interface Property<O, P> { 10 10 11 11 /** 12 12 * Get the value of the property. … … 15 15 */ 16 16 public P get(O obj); 17 17 18 18 /** 19 19 * Set the value of the property for the object. -
trunk/src/org/openstreetmap/josm/tools/RightAndLefthandTraffic.java
r7248 r7509 21 21 */ 22 22 public class RightAndLefthandTraffic { 23 23 24 24 private static class RLTrafficGeoProperty implements GeoProperty<Boolean> { 25 25 … … 46 46 } 47 47 } 48 48 49 49 private static Collection<Area> leftHandTrafficPolygons; 50 50 private static GeoPropertyIndex<Boolean> rlCache; … … 52 52 /** 53 53 * Check if there is right-hand traffic at a certain location. 54 * 54 * 55 55 * TODO: Synchronization can be refined inside the {@link GeoPropertyIndex} 56 * as most look-ups are read-only. 56 * as most look-ups are read-only. 57 57 * @param ll the coordinates of the point 58 58 * @return true if there is right-hand traffic, false if there is left-hand traffic … … 77 77 rlCache = new GeoPropertyIndex<Boolean>(new RLTrafficGeoProperty(), 24); 78 78 } 79 79 80 80 }
Note:
See TracChangeset
for help on using the changeset viewer.
