Changeset 32972 in osm for applications/editors
- Timestamp:
- 2016-09-11T13:47:23+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImage.java
r32574 r32972 16 16 */ 17 17 public class MapillaryImage extends MapillaryAbstractImage { 18 /** Unique identifier of the object. */ 18 /** 19 * Unique identifier of the object. 20 */ 19 21 private final String key; 20 /** The user that made the image. */ 22 /** 23 * The user that made the image. 24 */ 21 25 private String user; 22 /** Set of traffic signs in the image. */ 23 private final List<String> signs = new ArrayList<>(); 24 /** Where the picture was taken. */ 26 /** 27 * Set of traffic signs in the image. 28 */ 29 private final List<MapillarySign> signs = new ArrayList<>(); 30 /** 31 * Where the picture was taken. 32 */ 25 33 private String location; 26 34 … … 28 36 * Main constructor of the class MapillaryImage 29 37 * 30 * @param key The unique identifier of the image.38 * @param key The unique identifier of the image. 31 39 * @param latLon The latitude and longitude where it is positioned. 32 * @param ca The direction of the images in degrees, meaning 0 north.40 * @param ca The direction of the images in degrees, meaning 0 north. 33 41 */ 34 42 public MapillaryImage(final String key, final LatLon latLon, final double ca) { … … 70 78 * @param sign A {@code String} that identifies the type of sign. 71 79 */ 72 public void addSign(String sign) { 73 this.signs.add(sign); 80 public void addSign(MapillarySign sign) { 81 if (sign != null) { 82 this.signs.add(sign); 83 } 74 84 } 75 85 … … 79 89 * @return A {@link List} object containing the signs assigned to this image. 80 90 */ 81 public List< String> getSigns() {91 public List<MapillarySign> getSigns() { 82 92 return this.signs; 83 93 } … … 104 114 public String toString() { 105 115 return String.format( 106 "Image[key=%s,lat=%f,lon=%f,ca=%f,location=%s,user=%s,capturedAt=%d]",107 key, latLon.lat(), latLon.lon(), ca, location, user, capturedAt116 "Image[key=%s,lat=%f,lon=%f,ca=%f,location=%s,user=%s,capturedAt=%d]", 117 key, latLon.lat(), latLon.lon(), ca, location, user, capturedAt 108 118 ); 109 119 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryFilterDialog.java
r32653 r32972 11 11 import java.util.Arrays; 12 12 import java.util.Calendar; 13 import java.util.regex.Pattern; 13 14 14 15 import javax.swing.AbstractAction; … … 32 33 import org.openstreetmap.josm.plugins.mapillary.MapillaryImportedImage; 33 34 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer; 35 import org.openstreetmap.josm.plugins.mapillary.MapillarySign; 34 36 import org.openstreetmap.josm.tools.ImageProvider; 35 37 import org.openstreetmap.josm.tools.Shortcut; … … 69 71 * The list of sign names 70 72 */ 71 private static final String[] SIGN_TAGS = {"prohibitory_speed_limit", 72 "priority_stop", "other_give_way", "mandatory_roundabout", 73 "other_no_entry", "prohibitory_no_traffic_both_ways", 74 "danger_intersection", "mandatory_go", "mandatory_keep", 75 "danger_priority_next_intersection", "danger_uneven_road", 76 "prohibitory_no_parking", "prohibitory_on_overtaking", 77 "danger_pedestrian_crossing", "prohibitory_no_u_turn", 78 "prohibitory_noturn"}; 73 private static final String[] SIGN_TAGS = {"prohibitory--maximum-speed-limit", 74 "regulatory|priority--stop", "regulatory|priority--give_way|yield", "warning|mandatory--roundabout", 75 "prohibitory|regulatory--no-entry|no-traffic-both-ways", 76 "crossroads|junction", "mandatory--turn|straight", "uneven|slippery", 77 "no-parking", "no_overtaking", 78 "danger_pedestrian_crossing", "no_*_turn"}; 79 79 /** 80 80 * The {@link JCheckBox} where the respective tag should be searched … … 82 82 private final JCheckBox[] SIGN_CHECKBOXES = {this.signFilter.maxSpeed, 83 83 this.signFilter.stop, this.signFilter.giveWay, 84 this.signFilter.roundabout, this.signFilter.access, 85 this.signFilter.access, this.signFilter.intersection, 86 this.signFilter.direction, this.signFilter.direction, 87 this.signFilter.intersection, this.signFilter.uneven, 84 this.signFilter.roundabout, this.signFilter.access, this.signFilter.intersection, 85 this.signFilter.direction, this.signFilter.uneven, 88 86 this.signFilter.noParking, this.signFilter.noOvertaking, 89 this.signFilter.crossing, this.signFilter.noTurn , this.signFilter.noTurn};87 this.signFilter.crossing, this.signFilter.noTurn}; 90 88 91 89 private MapillaryFilterDialog() { … … 242 240 } 243 241 244 private static boolean checkSign(MapillaryImage img, JCheckBox signCheckBox, String si ngString) {242 private static boolean checkSign(MapillaryImage img, JCheckBox signCheckBox, String signTag) { 245 243 boolean contains = false; 246 for (String sign : img.getSigns()) { 247 if (sign.contains(singString)) 244 for (MapillarySign sign : img.getSigns()) { 245 String[] parts = signTag.split("--"); 246 if (Pattern.compile(parts[0]).matcher(sign.getCategory()).find() && 247 Pattern.compile(parts[1]).matcher(sign.getType()).find()) { 248 248 contains = true; 249 } 249 250 } 250 251 return contains == signCheckBox.isSelected() && contains; -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillaryImageInfoDownloadThread.java
r32341 r32972 67 67 ((MapillaryImage) image).setUser(data.getString("user")); 68 68 ((MapillaryImage) image).setCapturedAt(data.getJsonNumber("captured_at").longValue()); 69 ((MapillaryImage) image).setLocation(data.getString("location")); 69 70 } 70 71 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillaryTrafficSignDownloadThread.java
r32069 r32972 17 17 import org.openstreetmap.josm.plugins.mapillary.MapillaryImage; 18 18 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer; 19 import org.openstreetmap.josm.plugins.mapillary.MapillarySign; 19 20 import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryURL; 20 21 import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryURL.IMAGE_SELECTOR; … … 24 25 * 25 26 * @author nokutu 26 *27 27 */ 28 28 public class MapillaryTrafficSignDownloadThread extends Thread { … … 34 34 * Main constructor. 35 35 * 36 * @param ex {@link ExecutorService} object that is executing this thread.36 * @param ex {@link ExecutorService} object that is executing this thread. 37 37 * @param bounds the bounds in which the traffic signs should be downloaded 38 * @param page the pagenumber of the results page that should be retrieved38 * @param page the pagenumber of the results page that should be retrieved 39 39 */ 40 40 public MapillaryTrafficSignDownloadThread(ExecutorService ex, Bounds bounds, int page) { … … 46 46 @Override 47 47 public void run() { 48 49 48 try ( 50 BufferedReader br = new BufferedReader(new InputStreamReader(51 MapillaryURL.searchImageInfoURL(bounds, page, IMAGE_SELECTOR.OBJ_REC_ONLY).openStream(), "UTF-8"52 ));49 BufferedReader br = new BufferedReader(new InputStreamReader( 50 MapillaryURL.searchImageInfoURL(bounds, page, IMAGE_SELECTOR.OBJ_REC_ONLY).openStream(), "UTF-8" 51 )); 53 52 ) { 54 53 JsonObject jsonobj = Json.createReader(br).readObject(); … … 60 59 JsonArray rects = jsonarr.getJsonObject(i).getJsonArray("rects"); 61 60 JsonArray rectversions = jsonarr.getJsonObject(i).getJsonArray( 62 "rectversions");61 "rectversions"); 63 62 String key = jsonarr.getJsonObject(i).getString("key"); 64 63 if (rectversions != null) { … … 68 67 JsonObject data = rects.getJsonObject(k); 69 68 for (MapillaryAbstractImage image : MapillaryLayer.getInstance().getData().getImages()) { 70 if (image instanceof MapillaryImage && ((MapillaryImage) image).getKey().equals(key)) 71 ((MapillaryImage) image).addSign(data.getString("type")); 69 if (image instanceof MapillaryImage && ((MapillaryImage) image).getKey().equals(key)) { 70 ((MapillaryImage) image).addSign(MapillarySign.getSign(data.getString("type"), rectversions.getJsonObject(j).getString("package").split("_")[1])); 71 } 72 72 } 73 73 } … … 81 81 for (MapillaryAbstractImage image : MapillaryLayer.getInstance().getData().getImages()) { 82 82 if (image instanceof MapillaryImage && ((MapillaryImage) image).getKey().equals(key)) { 83 ((MapillaryImage) image).addSign( data.getString("type"));83 ((MapillaryImage) image).addSign(MapillarySign.getSign(data.getString("type"), data.getString("package").split("_")[1])); 84 84 } 85 85 } … … 87 87 } 88 88 } 89 } catch (MalformedURLException e) {90 Main.error(e);91 89 } catch (IOException e) { 92 90 Main.error(e);
Note:
See TracChangeset
for help on using the changeset viewer.