Changeset 34428 in osm for applications


Ignore:
Timestamp:
2018-07-18T12:02:17+02:00 (6 years ago)
Author:
renerr18
Message:

Improvements and refactoring (logging, ImageInfo, CubemapBuilder) post release.

Location:
applications/editors/josm/plugins/MicrosoftStreetside
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/MicrosoftStreetside

    • Property svn:ignore
      •  

        old new  
        88.gitignore
        99.gradle
         10.settings
        1011checkstyle-josm-MicrosoftStreetside.xml
        1112spotbugs-josm-MicrosoftStreetside.xml
  • applications/editors/josm/plugins/MicrosoftStreetside/.classpath

    r34399 r34428  
    11<?xml version="1.0" encoding="UTF-8"?>
    22<classpath>
    3         <classpathentry including="data/**|images/**|LICENSE|LICENSE_*" kind="src" output="bin/main" path="">
     3        <classpathentry excluding="config/" including="data/**|images/**|LICENSE|LICENSE_*" kind="src" output="bin/main" path="">
    44                <attributes>
    55                        <attribute name="gradle_scope" value="main"/>
     
    77                </attributes>
    88        </classpathentry>
     9        <classpathentry kind="src" path="config"/>
    910        <classpathentry kind="src" output="bin/test" path="test/unit">
    1011                <attributes>
  • applications/editors/josm/plugins/MicrosoftStreetside/.gitignore

    r34416 r34428  
    1616.gradle/
    1717.travis.yml
     18.settings
    1819
    1920# OS X metadata
  • applications/editors/josm/plugins/MicrosoftStreetside/README.md

    r34328 r34428  
    1313
    1414## Building from source
    15 Checkout the JOSM source, compile it and checkout the plugin source:
     15Checkout the JOSM source, compile it and checkout the plugin source (the last gradle command is optional, but contains code checking and unit test functionality - requires a Gradle installation):
    1616
    1717    svn co http://svn.openstreetmap.org/applications/editors/josm josm
    1818    cd josm/core
    19     ant clean dist
     19    ant
    2020    cd ../plugins
    2121    rm -rf MicrosoftStreetside
    2222    git clone https://github.com/JOSM/MicrosoftStreetside.git MicrosoftStreetside
    2323    cd MicrosoftStreetside
    24     ant clean install
     24    ant clean
     25    ant dist
     26    gradle build
    2527   
    2628Now Restart JOSM and activate the MicrosoftStreeside plugin in your preferences.
  • applications/editors/josm/plugins/MicrosoftStreetside/build.xml

    r34348 r34428  
    3939                <include name="apache-commons.jar"/>
    4040                <include name="apache-http.jar"/>
     41                <include name="utilsplugin2.jar"/>
    4142        </fileset>
    4243
  • applications/editors/josm/plugins/MicrosoftStreetside/gradle.properties

    r34349 r34428  
    1414# If not, choose the next higher number that is available, or the gradle build will break.
    1515plugin.compile.version=13860
    16 plugin.requires=apache-commons;apache-http
     16plugin.requires=apache-commons;apache-http;utilsplugin2
    1717
    1818# Character encoding of Gradle files
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/StreetsideAbstractImage.java

    r34385 r34428  
    1212/**
    1313 * Abstract superclass for all image objects. At the moment there are 3,
    14  * {@link StreetsideImportedImage}, {@link StreetsideImage}, & {@link StreetsideCubemap}.
     14 * {@link StreetsideImportedImage}, {@link StreetsideImage}, {@link StreetsideCubemap}.
    1515 *
    1616 * @author nokutu
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/cubemap/CubemapBox.java

    r34416 r34428  
    88
    99import java.awt.image.BufferedImage;
     10
     11import org.openstreetmap.josm.plugins.streetside.utils.GraphicsUtils;
    1012
    1113import javafx.animation.AnimationTimer;
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/cubemap/CubemapBuilder.java

    r34419 r34428  
    55import java.text.MessageFormat;
    66import java.util.ArrayList;
     7import java.util.EnumSet;
    78import java.util.HashMap;
    89import java.util.List;
     
    2021import org.openstreetmap.josm.plugins.streetside.gui.StreetsideViewerDialog;
    2122import org.openstreetmap.josm.plugins.streetside.gui.imageinfo.StreetsideViewerPanel;
     23import org.openstreetmap.josm.plugins.streetside.utils.GraphicsUtils;
    2224import org.openstreetmap.josm.plugins.streetside.utils.StreetsideProperties;
    2325
     
    3537        protected boolean cancelled;
    3638        private long startTime;
    37   private Map<String, BufferedImage> tileImages = new ConcurrentHashMap();//new HashMap<>();
     39
     40        private Map<String, BufferedImage> tileImages = new ConcurrentHashMap<>();
     41
     42        private int currentTileCount = 0;
    3843
    3944  /**
     
    5560        }
    5661
    57         @Override
     62        /**
     63   * Fired when any image is added to the database.
     64   */
     65  @Override
    5866        public void imagesAdded() {
    59                 // Do nothing
    60         }
    61 
    62         @Override
    63         public void selectedImageChanged(StreetsideAbstractImage oldImage, StreetsideAbstractImage newImage) {
    64                 startTime = System.currentTimeMillis();
     67                // Not implemented by the CubemapBuilder
     68        }
     69
     70        /**
     71   * Fired when the selected image is changed by something different from
     72   * manually clicking on the icon.
     73   *
     74   * @param oldImage
     75   *          Old selected {@link StreetsideAbstractImage}
     76   * @param newImage
     77   *          New selected {@link StreetsideAbstractImage}
     78   *
     79   * @see StreetsideDataListener
     80   */
     81  @Override
     82  public void selectedImageChanged(StreetsideAbstractImage oldImage, StreetsideAbstractImage newImage) {
     83    startTime = System.currentTimeMillis();
    6584
    6685                if (newImage != null) {
     
    90109        public void downloadCubemapImages(String imageId) {
    91110
    92                 final int maxCols = StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get() ? 4 : 2;
    93                 final int maxRows = StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get() ? 4 : 2;
    94                 final int maxThreadCount = 6 * maxCols * maxRows;
     111          final int maxThreadCount = StreetsideProperties.DOWNLOAD_CUBEFACE_TILES_TOGETHER.get()?6:6 * CubemapUtils.getMaxCols() * CubemapUtils.getMaxRows();
    95112
    96113                int fails = 0;
    97114
    98                 int min = 0;   int max = (StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get()?96:24)*2;
    99 
    100                 String[] message = new String[2];
     115    // TODO: message for progress bar
     116    String[] message = new String[2];
    101117    message[0] = MessageFormat.format("Downloading Streetside imagery for {0}", imageId);
    102118    message[1] = "Wait for completion…….";
    103119
    104                 long startTime = System.currentTimeMillis();
    105 
    106                 try {
    107 
    108                         ExecutorService pool = Executors.newFixedThreadPool(maxThreadCount);
    109                         List<Callable<String>> tasks = new ArrayList<>(maxThreadCount);
    110 
    111                         // launch 4-tiled (low-res) downloading tasks . . .
    112                         if (!StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get()) {
    113                                 for (int i = 0; i < CubemapUtils.NUM_SIDES; i++) {
    114                                         int tileNr = 0;
    115                                         for (int j = 0; j < maxCols; j++) {
    116                                                 for (int k = 0; k < maxRows; k++) {
    117 
    118                                                         String tileId = String.valueOf(imageId + CubemapUtils.getFaceNumberForCount(i)
    119                                                                         + Integer.valueOf(tileNr++).toString());
    120                                                         tasks.add(new TileDownloadingTask(tileId));
    121                                                 }
    122                                         }
    123                                 }
    124 
    125                                 List<Future<String>> results = pool.invokeAll(tasks);
    126                                 for (Future<String> ff : results) {
    127 
    128                                         if(StreetsideProperties.DEBUGING_ENABLED.get()) {
    129                                           logger.debug(MessageFormat.format("Completed tile downloading task {0} in {1} seconds.", ff.get(), (startTime - System.currentTimeMillis())/ 1000));
    130                                         }
    131                                 }
    132 
    133                                 // launch 16-tiled (high-res) downloading tasks
    134                         } else if (StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get()) {
    135                                 for (int i = 0; i < CubemapUtils.NUM_SIDES; i++) {
    136                                         for (int j = 0; j < maxCols; j++) {
    137                                                 for (int k = 0; k < maxRows; k++) {
    138 
    139                                                         String tileId = String.valueOf(imageId + CubemapUtils.getFaceNumberForCount(i)
    140                                                                         + String.valueOf(Integer.valueOf(j).toString() + Integer.valueOf(k).toString()));
    141                                                         tasks.add(new TileDownloadingTask(tileId));
    142                                                 }
    143                                         }
    144                                 }
    145 
    146                                 List<Future<String>> results = pool.invokeAll(tasks);
    147                                 for (Future<String> ff : results) {
    148                                         if(StreetsideProperties.DEBUGING_ENABLED.get()) {
    149                                           logger.debug(MessageFormat.format("Completed tile downloading task {0} in {1} seconds.",ff.get(),
    150                                                         (System.currentTimeMillis())/ 1000 - startTime));
    151                                         }
    152                                 }
    153                         }
    154                 } catch (Exception ee) {
    155                         fails++;
    156                         logger.error("Error loading tile for image " + imageId);
    157                         ee.printStackTrace();
    158                 }
    159 
    160                 long stopTime = System.currentTimeMillis();
    161                 long runTime = stopTime - startTime;
    162 
    163                 if (StreetsideProperties.DEBUGING_ENABLED.get()) {
    164       logger.debug(MessageFormat.format("Tile imagery downloading tasks completed in {0} seconds.",  runTime/1000));
    165                 }
    166 
    167                 if (fails > 0) {
    168                         logger.error(Integer.valueOf(fails) + " downloading tasks failed!");
    169                 }
    170 
    171         }
    172 
    173         @Override
    174         public void tileAdded(String tileId) {
    175                 // determine whether all tiles have been set for each of the
    176                 // six cubemap faces. If so, build the images for the faces
    177                 // and set the views in the cubemap box.
    178 
    179                 int tileCount = 0;
    180 
    181                 tileCount = CubemapBuilder.getInstance().getTileImages().keySet().size();
    182 
    183                 int maxCols = StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get() ? 4 : 2;
    184                 int maxRows = StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get() ? 4 : 2;
    185 
    186                 if (tileCount == (CubemapUtils.NUM_SIDES * maxCols * maxRows)) {
    187                   if (StreetsideProperties.DEBUGING_ENABLED.get()) {
    188         logger.debug(MessageFormat.format("{0} tile images ready for building cumbemap faces for cubemap {1}.", tileCount,
    189                                         CubemapBuilder.getInstance().getCubemap().getId()));
    190                   }
    191 
    192                         buildCubemapFaces();
    193                 }
    194         }
    195 
    196         @Override
    197   public void tilesAdded(String[] tileIds) {
    198     // determine whether all tiles have been set for each of the
     120    long startTime = System.currentTimeMillis();
     121
     122    try {
     123
     124      ExecutorService pool = Executors.newFixedThreadPool(maxThreadCount);
     125      List<Callable<List<String>>> tasks = new ArrayList<>(maxThreadCount);
     126
     127      if (StreetsideProperties.DOWNLOAD_CUBEFACE_TILES_TOGETHER.get()) {
     128        EnumSet.allOf(CubemapUtils.CubemapFaces.class).forEach(face -> {
     129          String tileId = String.valueOf(imageId + face.getValue());
     130          tasks.add(new TileDownloadingTask(tileId));
     131        });
     132      } else {
     133
     134        // launch 4-tiled (low-res) downloading tasks . . .
     135        if (!StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get()) {
     136          // download all imagery for each cubeface at once
     137
     138          for (int i = 0; i < CubemapUtils.NUM_SIDES; i++) {
     139            int tileNr = 0;
     140            for (int j = 0; j < CubemapUtils.getMaxCols(); j++) {
     141              for (int k = 0; k < CubemapUtils.getMaxRows(); k++) {
     142
     143                String tileId = String
     144                  .valueOf(imageId + CubemapUtils.getFaceNumberForCount(i) + Integer.valueOf(tileNr++).toString());
     145                tasks.add(new TileDownloadingTask(tileId));
     146              }
     147            }
     148          }
     149
     150          List<Future<List<String>>> results = pool.invokeAll(tasks);
     151          /*for (Future<List<String>> ff : results) {
     152
     153            if (StreetsideProperties.DEBUGING_ENABLED.get()) {
     154              logger.debug(
     155                MessageFormat.format(
     156                  "Completed tile downloading task {0} in {1} seconds.", ff.get().toString(),
     157                  (System.currentTimeMillis()) / 1000 - startTime)
     158                );
     159            }
     160          }*/
     161
     162          // launch 16-tiled (high-res) downloading tasks
     163        } else if (StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get()) {
     164
     165          for (int i = 0; i < CubemapUtils.NUM_SIDES; i++) {
     166            for (int j = 0; j < CubemapUtils.getMaxCols(); j++) {
     167              for (int k = 0; k < CubemapUtils.getMaxRows(); k++) {
     168
     169                String tileId = String
     170                  .valueOf(imageId + CubemapUtils.getFaceNumberForCount(i) + String.valueOf(Integer.valueOf(j).toString() + Integer.valueOf(k).toString()));
     171                tasks.add(new TileDownloadingTask(tileId));
     172              }
     173            }
     174          }
     175        }
     176      } // finish preparing tasks for invocation
     177
     178      List<Future<List<String>>> results = pool.invokeAll(tasks);
     179      for (Future<List<String>> ff : results) {
     180        if (StreetsideProperties.DEBUGING_ENABLED.get()) {
     181          logger.debug(
     182            MessageFormat.format(
     183              "Completed tile downloading task {0} in {1} seconds.", ff.get().toString(),
     184              ((System.currentTimeMillis()) - startTime)/1000)
     185            );
     186        }
     187      }
     188    } catch (Exception ee) {
     189      fails++;
     190      logger.error("Error loading tile for image " + imageId);
     191      ee.printStackTrace();
     192    }
     193
     194    long stopTime = System.currentTimeMillis();
     195    long runTime = stopTime - startTime;
     196
     197    if (StreetsideProperties.DEBUGING_ENABLED.get()) {
     198      logger.debug(MessageFormat.format("Tile imagery downloading tasks completed in {0} seconds.", runTime / 1000));
     199    }
     200
     201    if (fails > 0) {
     202      logger.error(Integer.valueOf(fails) + " downloading tasks failed!");
     203    }
     204  }
     205
     206  /**
     207   * Fired when a TileDownloadingTask has completed downloading an image tile. When all of the tiles for the Cubemap
     208   * have been downloaded, the CubemapBuilder assembles the cubemap.
     209   *
     210   * @param tileId
     211   *          the complete quadKey of the imagery tile, including cubeface and row/column in quaternary.
     212   * @see TileDownloadingTask
     213   */
     214  @Override
     215  public void tileAdded(String tileId) {
     216    // determine whether four tiles have been set for each of the
    199217    // six cubemap faces. If so, build the images for the faces
    200218    // and set the views in the cubemap box.
    201219
    202     int tileCount = 0;
    203 
    204     tileCount = CubemapBuilder.getInstance().getTileImages().keySet().size();
    205 
    206     int maxCols = StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get() ? 4 : 2;
    207     int maxRows = StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get() ? 4 : 2;
    208 
    209     if (tileCount == (CubemapUtils.NUM_SIDES * maxCols * maxRows)) {
     220    if(currentTileCount>96) {
     221      int x = 0;
     222    }
     223
     224    currentTileCount++;
     225
     226    if (currentTileCount == (CubemapUtils.NUM_SIDES * CubemapUtils.getMaxCols() * CubemapUtils.getMaxRows())) {
    210227      if (StreetsideProperties.DEBUGING_ENABLED.get()) {
    211         logger.debug(MessageFormat.format("{0} tile images ready for building cumbemap faces for cubemap {1}.", tileCount,
    212           CubemapBuilder.getInstance().getCubemap().getId()));
     228        long endTime = System.currentTimeMillis();
     229        long runTime = (endTime - startTime) / 1000;
     230        logger.debug(
     231          MessageFormat.format(
     232            "{0} tile images ready for building cumbemap faces for cubemap {1} in {2} seconds.", currentTileCount,
     233            CubemapBuilder.getInstance().getCubemap().getId(), Long.toString(runTime))
     234          );
    213235      }
    214236
     
    217239  }
    218240
    219         private void buildCubemapFaces() {
    220 
    221           if (StreetsideProperties.DEBUGING_ENABLED.get()) {
    222       logger.debug("Assembling cubemap tile images");
    223           }
    224 
    225           CubemapBox cmb = StreetsideViewerDialog.getInstance().getStreetsideViewerPanel().getCubemapBox();
     241  /**
     242   * Assembles the cubemap once all of the tiles have been downloaded.
     243   * <p>
     244   * The tiles for each cubemap face are cropped and stitched together
     245   * then the ImageViews of the cubemap are set with the new imagery.
     246   *
     247   * @see         StreetsideCubemap
     248   */
     249   private void buildCubemapFaces() {
     250                CubemapBox cmb = StreetsideViewerDialog.getInstance().getStreetsideViewerPanel().getCubemapBox();
    226251                ImageView[] views = cmb.getViews();
    227 
    228                 final int maxCols = StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get() ? 4 : 2;
    229                 final int maxRows = StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get() ? 4 : 2;
    230252
    231253                Image finalImages[] = new Image[CubemapUtils.NUM_SIDES];
     
    235257                        for (int i = 0; i < CubemapUtils.NUM_SIDES; i++) {
    236258
    237                                 BufferedImage[] faceTileImages = new BufferedImage[maxCols * maxRows];
    238 
    239                                 for (int j = 0; j < (maxCols * maxRows); j++) {
     259                                BufferedImage[] faceTileImages = new BufferedImage[CubemapUtils.getMaxCols() * CubemapUtils.getMaxRows()];
     260
     261                                for (int j = 0; j < (CubemapUtils.getMaxCols() * CubemapUtils.getMaxRows()); j++) {
    240262                                        String tileId = String.valueOf(getCubemap().getId() + CubemapUtils.getFaceNumberForCount(i)
    241263                                                        + Integer.valueOf(j).toString());
     
    262284                                                .get() ? 16 : 4];
    263285
    264                                 for (int j = 0; j < maxCols; j++) {
    265                                         for (int k = 0; k < maxRows; k++) {
     286                                for (int j = 0; j < CubemapUtils.getMaxCols(); j++) {
     287                                        for (int k = 0; k < CubemapUtils.getMaxRows(); k++) {
    266288                                                String tileId = String.valueOf(getCubemap().getId() + CubemapUtils.getFaceNumberForCount(i)
    267289                                                                + CubemapUtils.convertDoubleCountNrto16TileNr(
     
    303325    }
    304326
    305     CubemapBuilder.getInstance().resetTileImages();
     327    // reset count and image map after assembly
     328    resetTileImages();
     329    currentTileCount = 0;
    306330        }
    307331
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/cubemap/CubemapUtils.java

    r34399 r34428  
    1414  final static Logger logger = Logger.getLogger(CubemapUtils.class);
    1515
     16  private CubemapUtils() {
     17    // Private constructor to avoid instantiation
     18  }
    1619
    1720        public enum CubefaceType {
     
    7174        public static final String IMPORTED_ID = "00000000";
    7275        public static final int NUM_SIDES = 6;
    73 
    7476        public static Map<String,String> rowCol2StreetsideCellAddressMap = null;
    7577
     
    9698        }
    9799
     100        public static int getMaxCols() {
     101          return StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get()?4:2;
     102        }
     103
     104        public static int getMaxRows() {
     105          return getMaxCols();
     106        }
     107
    98108        public static String convertDecimal2Quaternary(long inputNum) {
    99109                String res = null;
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/cubemap/ITileDownloadingTaskListener.java

    r34416 r34428  
    1616 void tileAdded(String imageId);
    1717
    18  /**
    19   * Fired when multiple cubemap tile images are downloaded by a download worker.
    20   * @param imageId image id
    21   */
    22   void tilesAdded(String[] imageId);
    2318}
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/cubemap/TileDownloadingTask.java

    r34419 r34428  
    33
    44import java.awt.image.BufferedImage;
     5import java.io.IOException;
    56import java.text.MessageFormat;
     7import java.util.ArrayList;
    68import java.util.List;
    79import java.util.Objects;
     
    1820import us.monoid.web.Resty;
    1921
    20 public class TileDownloadingTask implements Callable<String> {
     22public class TileDownloadingTask implements Callable<List<String>> {
    2123
    2224  final static Logger logger = Logger.getLogger(TileDownloadingTask.class);
    2325
    2426        private String tileId;
    25         private final long startTime = System.currentTimeMillis();
    2627        private StreetsideCache cache;
    2728        protected CubemapBuilder cb;
     
    9899        }
    99100
    100         @Override
    101         public String call() throws Exception {
     101  @Override
     102  public List<String> call() throws Exception {
    102103
    103           BufferedImage img = ImageIO.read(new Resty().bytes(
    104                                 StreetsideURL.VirtualEarth.streetsideTile(tileId, false).toExternalForm())
    105                                 .stream());
     104    List<String> res = new ArrayList<>();
    106105
    107                 if (img == null) {
    108                         logger.error("Download of BufferedImage " + tileId + " is null!");
    109                 }
     106    if (StreetsideProperties.DOWNLOAD_CUBEFACE_TILES_TOGETHER.get()) {
     107      // download all imagery for each cubeface at once
     108      if (!StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get()) {
     109        // download low-res imagery
     110        int tileNr = 0;
     111        for (int j = 0; j < CubemapUtils.getMaxCols(); j++) {
     112          for (int k = 0; k < CubemapUtils.getMaxRows(); k++) {
     113            String quadKey = String.valueOf(tileId + Integer.valueOf(tileNr++).toString());
     114            res.add(downloadTile(quadKey));
     115          }
     116        }
     117        // download high-res imagery
     118      } else {
     119        for (int j = 0; j < CubemapUtils.getMaxCols(); j++) {
     120          for (int k = 0; k < CubemapUtils.getMaxRows(); k++) {
     121            String quadKey = String
     122              .valueOf(tileId + String.valueOf(Integer.valueOf(j).toString() + Integer.valueOf(k).toString()));
     123            res.add(downloadTile(quadKey));
     124          }
     125        }
     126      }
     127    // task downloads just one tile
     128    } else {
     129      res.add(downloadTile(tileId));
     130    }
     131    return res;
     132  }
    110133
    111                 CubemapBuilder.getInstance().getTileImages().put(tileId, img);
     134  private String downloadTile(String tileId) {
     135    BufferedImage img;
    112136
    113                 fireTileAdded(tileId);
     137    long startTime = System.currentTimeMillis();
    114138
    115                 if (StreetsideProperties.DEBUGING_ENABLED.get()) {
    116                   long endTime = System.currentTimeMillis();
    117             long runTime = (endTime-startTime)/1000;
    118             logger.debug(MessageFormat.format("Loaded image for {0} in {1} seconds.", tileId, runTime));
    119                 }
     139    try {
     140      img = ImageIO
     141        .read(new Resty().bytes(StreetsideURL.VirtualEarth.streetsideTile(tileId, false).toExternalForm()).stream());
    120142
    121                 return tileId;
    122         }
     143      if (img == null) {
     144        logger.error("Download of BufferedImage " + tileId + " is null!");
     145      }
     146
     147      CubemapBuilder.getInstance().getTileImages().put(tileId, img);
     148
     149      fireTileAdded(tileId);
     150
     151      if (StreetsideProperties.DEBUGING_ENABLED.get()) {
     152        long endTime = System.currentTimeMillis();
     153        long runTime = (endTime - startTime) / 1000;
     154        logger.debug(MessageFormat.format("Loaded image for {0} in {1} seconds.", tileId, runTime));
     155      }
     156    } catch (IOException e) {
     157      logger.error(MessageFormat.format("Error downloading image for tileId {0}", tileId));
     158      return null;
     159    }
     160    return tileId;
     161  }
    123162
    124163        private void fireTileAdded(String id) {
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/gui/StreetsideMainDialog.java

    r34416 r34428  
    5757        private volatile StreetsideAbstractImage image;
    5858
    59         /*public final SideButton nextButton = new SideButton(new NextPictureAction());
    60         public final SideButton previousButton = new SideButton(new PreviousPictureAction());
    61         *//**
    62          * Button used to jump to the image following the red line
    63          *//*
    64         public final SideButton redButton = new SideButton(new RedAction());
    65         *//**
    66          * Button used to jump to the image following the blue line
    67          *//*
    68         public final SideButton blueButton = new SideButton(new BlueAction());
    69 
    70         private final SideButton playButton = new SideButton(new PlayAction());
    71         private final SideButton pauseButton = new SideButton(new PauseAction());
    72         private final SideButton stopButton = new SideButton(new StopAction());*/
    73 
    7459        private ImageInfoHelpPopup imageInfoHelp;
    7560
     
    10792                streetsideImageDisplay = new StreetsideImageDisplay();
    10893
    109                 /*blueButton.setForeground(Color.BLUE);
    110                 redButton.setForeground(Color.RED);*/
    111 
    11294                setMode(MODE.NORMAL);
    11395        }
     
    11799         */
    118100        private void addShortcuts() {
    119                 /*nextButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
    120                                 KeyStroke.getKeyStroke("PAGE_DOWN"), "next");
    121                 nextButton.getActionMap().put("next", new NextPictureAction());
    122                 previousButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
    123                                 KeyStroke.getKeyStroke("PAGE_UP"), "previous");
    124                 previousButton.getActionMap().put("previous",
    125                                 new PreviousPictureAction());
    126                 blueButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
    127                                 KeyStroke.getKeyStroke("control PAGE_UP"), "blue");
    128                 blueButton.getActionMap().put("blue", new BlueAction());
    129                 redButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
    130                                 KeyStroke.getKeyStroke("control PAGE_DOWN"), "red");
    131                 redButton.getActionMap().put("red", new RedAction());*/
     101                // next, previous, blueAction and redAction from Mapillary removed
    132102        }
    133103
     
    176146                        createLayout(
    177147                                streetsideImageDisplay,
    178                                 null//Arrays.asList(playButton, pauseButton, stopButton)
     148                                null
     149                                // TODO: Walk Action for Streetside - re-add buttons here
    179150                        );
    180151                case NORMAL:
     
    182153                        createLayout(
    183154                        streetsideImageDisplay,
    184                         null//Arrays.asList(blueButton, previousButton, nextButton, redButton)
     155                        null
    185156                    );
    186157                }
    187                 //disableAllButtons();
     158
    188159                if (MODE.NORMAL.equals(mode)) {
    189160                        updateImage();
     
    222193                                streetsideImageDisplay.setImage(null, null);
    223194                                setTitle(I18n.tr(StreetsideMainDialog.BASE_TITLE));
    224                                 //disableAllButtons();
    225195                                return;
    226196                        }
    227197
    228                         // TODO: help for cubemaps? @rrh
    229198                        if (imageInfoHelp != null && StreetsideProperties.IMAGEINFO_HELP_COUNTDOWN.get() > 0 && imageInfoHelp.showPopup()) {
    230199                                // Count down the number of times the popup will be displayed
     
    232201                        }
    233202
    234                         // Enables/disables next/previous buttons
    235                         /*nextButton.setEnabled(false);
    236                         previousButton.setEnabled(false);*/
    237203                        if (image.getSequence() != null) {
    238204                                StreetsideAbstractImage tempImage = image;
     
    250216                                        tempImage = tempImage.previous();
    251217                                        if (tempImage.isVisible()) {
    252                                                 //previousButton.setEnabled(true);
    253218                                                break;
    254219                                        }
     
    290255
    291256        /**
    292          * Disables all the buttons in the dialog
    293          */
    294         /*public private void disableAllButtons() {
    295                 nextButton.setEnabled(false);
    296                 previousButton.setEnabled(false);
    297                 blueButton.setEnabled(false);
    298                 redButton.setEnabled(false);
    299         }*/
    300 
    301         /**
    302257         * Sets a new StreetsideImage to be shown.
    303258         *
     
    407362                }
    408363
    409                 // TODO: RedAction for cubemaps? @rrh
    410364                @Override
    411365                public void actionPerformed(ActionEvent e) {
     
    553507                                                || img.getHeight() > streetsideImageDisplay.getImage().getHeight()
    554508                                                ) {
    555                                         //final StreetsideAbstractImage mai = getImage();
    556509                                        streetsideImageDisplay.setImage(
    557510                                                        img,
    558                                                         //mai instanceof StreetsideImage ? ((StreetsideImage) getImage()).getDetections() : null
    559511                                                        null);
    560512                                }
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/gui/imageinfo/StreetsideViewerPanel.java

    r34416 r34428  
    1818import org.openstreetmap.josm.plugins.streetside.cubemap.CubemapBuilder;
    1919import org.openstreetmap.josm.plugins.streetside.cubemap.CubemapUtils;
    20 import org.openstreetmap.josm.plugins.streetside.cubemap.GraphicsUtils;
    2120import org.openstreetmap.josm.plugins.streetside.gui.boilerplate.StreetsideButton;
     21import org.openstreetmap.josm.plugins.streetside.utils.GraphicsUtils;
    2222import org.openstreetmap.josm.plugins.streetside.utils.StreetsideProperties;
    2323import org.openstreetmap.josm.plugins.streetside.utils.StreetsideURL;
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/io/download/BoundsDownloadRunnable.java

    r34399 r34428  
    5959
    6060  /**
    61    * Logs information about the given connection via {@link logger#info(String)}.
     61   * Logs information about the given connection via {@link Logger}.
    6262   * If it's a {@link HttpURLConnection}, the request method, the response code and the URL itself are logged.
    6363   * Otherwise only the URL is logged.
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/io/download/SequenceDownloadRunnable.java

    r34416 r34428  
    66import java.net.URL;
    77import java.net.URLConnection;
     8import java.text.MessageFormat;
    89import java.util.ArrayList;
    910import java.util.EnumSet;
     
    128129
    129130    } catch (JsonParseException e) {
    130       e.printStackTrace();
     131      logger.error(MessageFormat.format("JSON parsing error occured during Streetside sequence download {0}",e.getMessage()));
    131132    } catch (JsonMappingException e) {
    132       e.printStackTrace();
     133      logger.error(MessageFormat.format("JSON mapping error occured during Streetside sequence download {0}",e.getMessage()));
    133134    } catch (IOException e) {
    134       e.printStackTrace();
     135      logger.error(MessageFormat.format("Input/output error occured during Streetside sequence download {0}",e.getMessage()));
    135136    }
    136137
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/mode/package-info.java

    r34325 r34428  
    55 * Currently there are two of them:
    66 * <ul>
    7  *  <li><strong>{@link org.openstreetmap.josm.plugins.streetside.mode.JoinMode JoinMode}</strong> for joining pictures to make sequences</li>
    87 *  <li><strong>{@link org.openstreetmap.josm.plugins.streetside.mode.SelectMode SelectMode}</strong> for selecting pictures in the layer</li>
    98 * </ul>
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/utils/StreetsideProperties.java

    r34416 r34428  
    2424  public static final IntegerProperty TILE_DOWNLOAD_THREAD_PAUSE_LEN_SEC = new IntegerProperty("streetside.tile-download-thread-pause-len-sec", 60);
    2525  public static final BooleanProperty PREDOWNLOAD_CUBEMAPS = new BooleanProperty("streetside.predownload-cubemaps", false);
    26   public static final BooleanProperty DEBUGING_ENABLED = new BooleanProperty("streetside.debugging-enabled", false);
     26  public static final BooleanProperty DEBUGING_ENABLED = new BooleanProperty("streetside.debugging-enabled", true);
     27  public static final BooleanProperty DOWNLOAD_CUBEFACE_TILES_TOGETHER = new BooleanProperty("streetside.download-cubeface-tiles-together", false);
     28
    2729  /**
    2830   * If false, all sequences that cross the download bounds are put completely into the StreetsideData object.
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/utils/StreetsideSequenceIdGenerator.java

    r34317 r34428  
    55
    66/**
    7  *
     7 * Utility class to generated unique ids for Streetside "sequences".
     8 * Due to the functionality inherited from Mapillary the plugin is structured to
     9 * handle sequences of contiguous imagery, but Streetside only has implicit
     10 * sequences defined by the "pre" and "ne" attributes.
     11 * <p/>
     12 * @See StreetsideSequence
    813 */
    914public class StreetsideSequenceIdGenerator {
    10  
     15
     16  private StreetsideSequenceIdGenerator() {
     17    // private constructor to avoid instantiation
     18  }
    1119  public static String generateId() {
    12    
     20
    1321    return UUID.randomUUID().toString();
    14    
     22
    1523  }
    1624
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/utils/StreetsideURL.java

    r34417 r34428  
    324324        /**
    325325         * Converts a {@link String} into a {@link URL} without throwing a {@link MalformedURLException}.
    326          * Instead such an exception will lead to an {@link logger#error(Throwable)}.
     326         * Instead such an exception will lead to an {@link Logger}.
    327327         * So you should be very confident that your URL is well-formed when calling this method.
    328328         * @param strings the Strings describing the URL
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/utils/api/JsonDecoder.java

    r34399 r34428  
    9696   * @return the point in time as a {@link Long} value representing the UNIX epoch time, or <code>null</code> if the
    9797   *   parameter does not match the required format (this also triggers a warning via
    98    *   {@link logger#warn(Throwable)}), or the parameter is <code>null</code>.
     98   *   {@link Logger}, or the parameter is <code>null</code>).
    9999   */
    100100  static Long decodeTimestamp(final String timestamp) {
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/utils/api/JsonStreetsideDecoder.java

    r34365 r34428  
    9696   * @return the point in time as a {@link Long} value representing the UNIX epoch time, or <code>null</code> if the
    9797   *   parameter does not match the required format (this also triggers a warning via
    98    *   {@link logger#warn(Throwable)}), or the parameter is <code>null</code>.
     98   *   {@link Logger}, or the parameter is <code>null</code>).
    9999   */
    100100  static Long decodeTimestamp(final String timestamp) {
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/StreetsideAbstractImageTest.java

    r34416 r34428  
    1313public class StreetsideAbstractImageTest {
    1414
    15   @Rule
    16   public JOSMTestRules rules = new StreetsideTestRules().platform();
     15  /*@Rule
     16  public JOSMTestRules rules = new StreetsideTestRules().platform();*/
    1717
    1818  @Test
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/StreetsideDataTest.java

    r34386 r34428  
    2525public class StreetsideDataTest {
    2626
    27   @Rule
    28   public JOSMTestRules rules = new StreetsideTestRules().platform();
     27  /*@Rule
     28  public JOSMTestRules rules = new StreetsideTestRules().platform();*/
    2929
    3030  private StreetsideData data;
     
    9696   * Tests the selection of images.
    9797   */
    98   @Ignore
    9998  @Test
    10099  public void selectTest() {
     
    113112   * {@link StreetsideData#selectPrevious()} methods.
    114113   */
    115   @Ignore
    116114  @Test
    117115  public void nextAndPreviousTest() {
     
    128126  }
    129127
    130   @Ignore
    131128  @Test(expected=IllegalStateException.class)
    132129  public void nextOfNullImgTest() {
     
    135132  }
    136133
    137   @Ignore
    138134  @Test(expected=IllegalStateException.class)
    139135  public void previousOfNullImgTest() {
     
    146142   * multiselected List should reset.
    147143   */
    148   @Ignore
    149144  @Test
    150145  public void multiSelectTest() {
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/StreetsideLayerTest.java

    r34419 r34428  
    7373  }
    7474
    75   @Ignore
    7675  @Test
    7776  public void testClearInstance() {
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/cubemap/GraphicsUtilsTest.java

    r34386 r34428  
    4848
    4949  /**
    50    * Test method for {@link org.openstreetmap.josm.plugins.streetside.cubemap.GraphicsUtils#convertBufferedImage2JavaFXImage(java.awt.image.BufferedImage)}.
     50   * Test method for {@link org.openstreetmap.josm.plugins.streetside.utils.GraphicsUtils#convertBufferedImage2JavaFXImage(java.awt.image.BufferedImage)}.
    5151   */
    5252  @Ignore
     
    5757
    5858  /**
    59    * Test method for {@link org.openstreetmap.josm.plugins.streetside.cubemap.GraphicsUtils#buildMultiTiledCubemapFaceImage(java.awt.image.BufferedImage[])}.
     59   * Test method for {@link org.openstreetmap.josm.plugins.streetside.utils.GraphicsUtils#buildMultiTiledCubemapFaceImage(java.awt.image.BufferedImage[])}.
    6060   */
    6161  @Ignore
     
    6666
    6767  /**
    68    * Test method for {@link org.openstreetmap.josm.plugins.streetside.cubemap.GraphicsUtils#rotateImage(java.awt.image.BufferedImage)}.
     68   * Test method for {@link org.openstreetmap.josm.plugins.streetside.utils.GraphicsUtils#rotateImage(java.awt.image.BufferedImage)}.
    6969   */
    7070  @Ignore
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/cubemap/TileDownloadingTaskTest.java

    r34419 r34428  
    2121  public final void testCall() {
    2222    ExecutorService pool = Executors.newFixedThreadPool(1);
    23     List<Callable<String>> tasks = new ArrayList<>(1);
     23    List<Callable<List<String>>> tasks = new ArrayList<>(1);
    2424      tasks.add(new TileDownloadingTask("2202112030033001233"));
    2525      try {
    26         List<Future<String>> results = pool.invokeAll(tasks);
     26        List<Future<List<String>>> results = pool.invokeAll(tasks);
    2727        assertEquals(results.get(0),"2202112030033001233");
    2828      } catch (InterruptedException e) {
Note: See TracChangeset for help on using the changeset viewer.