Changeset 31306 in osm for applications


Ignore:
Timestamp:
2015-06-24T22:29:34+02:00 (9 years ago)
Author:
nokutu
Message:

Solved cache infinite loop and added more signs to the filter

Location:
applications/editors/josm/plugins/mapillary
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImportedImage.java

    r31284 r31306  
    1919        super(lat, lon, ca);
    2020        this.file = file;
    21         System.out.println(datetimeOriginal);
    2221        this.datetimeOriginal = getEpoch(datetimeOriginal, "yyyy/MM/dd hh:mm:ss");
    2322    }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryMouseAdapter.java

    r31299 r31306  
    125125                        double dist = clickPoint.distanceSq(imagePoint);
    126126                        if (minDistance > dist
    127                                         && clickPoint.distance(imagePoint) < snapDistance) {
     127                                        && clickPoint.distance(imagePoint) < snapDistance && image.isVisible()) {
    128128                                minDistance = dist;
    129129                                closest = image;
     
    208208                        Main.map.mapMode.putValue("active", Boolean.FALSE);
    209209                        imageHighlighted = true;
    210                         System.out.println("1");
    211210
    212211                } else if (closestTemp == null
     
    215214                        nothingHighlighted = false;
    216215                        Main.map.mapMode.putValue("active", Boolean.TRUE);
    217                         System.out.println("2");
    218216
    219217                } else if (imageHighlighted && !nothingHighlighted
     
    221219                                && Main.map.mapView.getEditLayer().data != null
    222220                                && Main.map.mapView.getActiveLayer() instanceof OsmDataLayer) {
    223                         System.out.println("3");
    224221
    225222                        for (OsmPrimitive primivitive : Main.map.mapView.getEditLayer().data
     
    231228                }
    232229
    233                 // TODO check if it is possible to do this while the OSM data layer is
    234                 // selected.
    235230                if (MapillaryData.getInstance().getHoveredImage() != closestTemp
    236231                                && closestTemp != null) {
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/cache/MapillaryCache.java

    r31278 r31306  
    1111
    1212public class MapillaryCache extends
    13         JCSCachedTileLoaderJob<String, BufferedImageCacheEntry> {
     13                JCSCachedTileLoaderJob<String, BufferedImageCacheEntry> {
    1414
    15     private volatile URL url;
    16     private volatile String key;
     15        private volatile URL url;
     16        private volatile String key;
    1717
    18     public static enum Type {
    19         FULL_IMAGE, THUMBNAIL
    20     }
     18        public static enum Type {
     19                FULL_IMAGE, THUMBNAIL
     20        }
    2121
    22     public MapillaryCache(String key, Type type) {
    23         super(MapillaryPlugin.CACHE, 50000, 50000,
    24                 new HashMap<String, String>());
    25         this.key = key;
    26         try {
    27             if (type == Type.FULL_IMAGE) {
    28                 url = new URL("https://d1cuyjsrcm0gby.cloudfront.net/" + key
    29                         + "/thumb-2048.jpg");
    30                 this.key += ".FULL_IMAGE";
     22        public MapillaryCache(String key, Type type) {
     23                super(MapillaryPlugin.CACHE, 50000, 50000,
     24                                new HashMap<String, String>());
     25                this.key = key;
     26                try {
     27                        if (type == Type.FULL_IMAGE) {
     28                                url = new URL("https://d1cuyjsrcm0gby.cloudfront.net/" + key
     29                                                + "/thumb-2048.jpg");
     30                                this.key += ".FULL_IMAGE";
    3131
    32             } else if (type == Type.THUMBNAIL) {
    33                 url = new URL("https://d1cuyjsrcm0gby.cloudfront.net/" + key
    34                         + "/thumb-320.jpg");
    35                 this.key += ".THUMBNAIL";
    36             }
    37         } catch (MalformedURLException e) {
    38             Main.error(e);
    39         }
    40     }
     32                        } else if (type == Type.THUMBNAIL) {
     33                                url = new URL("https://d1cuyjsrcm0gby.cloudfront.net/" + key
     34                                                + "/thumb-320.jpg");
     35                                this.key += ".THUMBNAIL";
     36                        }
     37                } catch (MalformedURLException e) {
     38                        Main.error(e);
     39                }
     40        }
    4141
    42     @Override
    43     public String getCacheKey() {
    44         return key;
    45     }
     42        @Override
     43        public String getCacheKey() {
     44                return key;
     45        }
    4646
    47     @Override
    48     public URL getUrl() {
    49         return url;
    50     }
     47        @Override
     48        public URL getUrl() {
     49                return url;
     50        }
    5151
    52     @Override
    53     protected BufferedImageCacheEntry createCacheEntry(byte[] content) {
    54         return new BufferedImageCacheEntry(content);
    55     }
     52        @Override
     53        protected BufferedImageCacheEntry createCacheEntry(byte[] content) {
     54                return new BufferedImageCacheEntry(content);
     55        }
    5656
    57     @Override
    58     protected boolean isObjectLoadable() {
    59         if (cacheData == null)
    60             return false;
    61         byte[] content = cacheData.getContent();
    62         return content != null && content.length > 0;
    63     }
     57        @Override
     58        protected boolean isObjectLoadable() {
     59                if (cacheData == null)
     60                        return false;
     61                byte[] content = cacheData.getContent();
     62                return content != null && content.length > 0;
     63        }
    6464
    65     // @Override
    66     protected boolean handleNotFound() {
    67         return false;
    68     }
     65        // @Override
     66        protected boolean handleNotFound() {
     67                return false;
     68        }
    6969}
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryDownloader.java

    r31296 r31306  
    5050
    5151        try {
    52             Main.info("MapillaryPlugin GET " + url2);
     52            Main.info("GET " + url2 + " (Mapillary plugin)");
    5353            Main.worker.submit(new MapillarySquareDownloadManagerThread(url1,
    5454                    url2, url3));
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySquareDownloadManagerThread.java

    r31278 r31306  
    99import org.openstreetmap.josm.Main;
    1010import org.openstreetmap.josm.plugins.mapillary.MapillaryData;
     11import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryFilterDialog;
    1112
    1213/**
     
    4950            Main.map.statusLine.setHelpText(tr("No images found"));
    5051        MapillaryData.getInstance().dataUpdated();
     52        MapillaryFilterDialog.getInstance().refresh();
    5153    }
    5254
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryFilterChooseSigns.java

    r31300 r31306  
    2020    public final JCheckBox roundabout = new JCheckBox();
    2121    public final JCheckBox access = new JCheckBox();
     22    public final JCheckBox intersection = new JCheckBox();
     23    public final JCheckBox direction = new JCheckBox();
    2224
    2325    private static MapillaryFilterChooseSigns INSTANCE;
     
    2931        roundabout.setSelected(true);
    3032        access.setSelected(true);
     33        intersection.setSelected(true);
     34        direction.setSelected(true);
    3135
    3236       
     
    7377        JLabel noEntryLabel = new JLabel(tr("No entry"));
    7478        noEntryLabel.setIcon(new ImageProvider(
    75                 "styles/standard/vehicle/restriction/access.png").get());
     79                "no_entry.png").get());
    7680        noEntryPanel.add(noEntryLabel);
    7781        noEntryPanel.add(access);
    7882        this.add(noEntryPanel);
     83       
     84        // Danger intersection
     85        JPanel intersectionPanel = new JPanel();
     86        JLabel intersectionLabel = new JLabel(tr("Intersection danger"));
     87        intersectionLabel.setIcon(new ImageProvider(
     88                "intersection_danger.png").get());
     89        intersectionPanel.add(intersectionLabel);
     90        intersectionPanel.add(intersection);
     91        this.add(intersectionPanel);
     92       
     93        // Mandatory direction
     94        JPanel directionPanel = new JPanel();
     95        JLabel directionLabel = new JLabel(tr("Mandatory direction (any)"));
     96        directionLabel.setIcon(new ImageProvider(
     97                "/home/nokutu/josm/core/images/styles/standard/vehicle/restriction/turn_restrictions/only_straight_on.png").get());
     98        directionPanel.add(directionLabel);
     99        directionPanel.add(direction);
     100        this.add(directionPanel);
    79101    }
    80102
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryFilterDialog.java

    r31300 r31306  
    5151
    5252        private final JCheckBox imported = new JCheckBox("Imported images");
    53         private final JCheckBox downloaded = new JCheckBox(new downloadCheckBoxAction());
     53        private final JCheckBox downloaded = new JCheckBox(
     54                        new downloadCheckBoxAction());
    5455        private final JCheckBox onlySigns = new JCheckBox(new OnlySignsAction());
    5556        private final JComboBox<String> time;
     
    6263        public final MapillaryFilterChooseSigns signFilter = MapillaryFilterChooseSigns
    6364                        .getInstance();
     65
     66        private final String[] SIGN_TAGS = { "prohibitory_speed_limit",
     67                        "priority_stop", "other_give_way", "mandatory_roundabout",
     68                        "other_no_entry", "danger_intersection", "mandatory_go",
     69                        "mandatory_keep" };
     70        private final JCheckBox[] SIGN_CHECKBOXES = { signFilter.maxspeed,
     71                        signFilter.stop, signFilter.giveWay, signFilter.roundabout,
     72                        signFilter.access, signFilter.intersection, signFilter.direction,
     73                        signFilter.direction };
    6474
    6575        public MapillaryFilterDialog() {
     
    7080                                                Shortcut.NONE), 200);
    7181
    72  
    7382                signChooser.setEnabled(false);
    7483                JPanel signChooserPanel = new JPanel();
     
    188197
    189198        private boolean checkSigns(MapillaryImage img) {
    190                 // TODO move strings into an arraylist
    191                 if (checkSign(img, signFilter.maxspeed, "prohibitory_speed_limit"))
    192                         return true;
    193                
    194                 if (checkSign(img, signFilter.stop, "priority_stop"))
    195                         return true;
    196                
    197                 if (checkSign(img, signFilter.giveWay, "other_give_way"))
    198                         return true;
    199                
    200                 if (checkSign(img, signFilter.roundabout, "mandatory_roundabout"))
    201                         return true;
    202                
    203                 if (checkSign(img, signFilter.access, "other_no_entry"))
    204                         return true;
    205 
     199                for (int i = 0; i < SIGN_TAGS.length; i++) {
     200                        if (checkSign(img, SIGN_CHECKBOXES[i], SIGN_TAGS[i]))
     201                                return true;
     202                }
    206203                return false;
    207204        }
    208        
    209         private boolean checkSign(MapillaryImage img, JCheckBox signCheckBox, String singString) {
     205
     206        private boolean checkSign(MapillaryImage img, JCheckBox signCheckBox,
     207                        String singString) {
    210208                boolean contains = false;
    211209                for (String sign : img.getSigns()) {
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryToggleDialog.java

    r31300 r31306  
    298298         */
    299299        @Override
    300         public void loadingFinished(CacheEntry data,
    301                         CacheEntryAttributes attributes, LoadResult result) {
     300        public void loadingFinished(final CacheEntry data,
     301                        final CacheEntryAttributes attributes, final LoadResult result) {
    302302                if (!SwingUtilities.isEventDispatchThread()) {
    303303                        SwingUtilities.invokeLater(new Runnable() {
    304304                                @Override
    305305                                public void run() {
    306                                         updateImage();
     306                                        loadingFinished(data, attributes, result);
    307307                                }
    308308                        });
Note: See TracChangeset for help on using the changeset viewer.