Changeset 34348 in osm for applications/editors/josm


Ignore:
Timestamp:
2018-06-23T23:03:38+02:00 (6 years ago)
Author:
renerr18
Message:

Missing StreetsideChangesetDialog committed.

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

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/MicrosoftStreetside/build.xml

    r34329 r34348  
    1313        <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    1414        <property name="plugin.main.version" value="13860" />
     15        <property name="plugin.version" value="13860" />
    1516       
    1617  <property name="plugin.author" value="renerr18" />
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/StreetsideImage.java

    r34333 r34348  
    4848  private double pi;
    4949
    50   // Heading (equivalent to Mapillary cd attribute - not currently supported.
    51   private double he;
    52 
    5350  // Blurring instructions - not currently used by the plugin
    5451  private String bl;
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/actions/StreetsideDownloadAction.java

    r34317 r34348  
    4747  @Override
    4848  public void actionPerformed(ActionEvent ae) {
    49     if (!StreetsideLayer.hasInstance()) {
    50       // A new streetside layer is created, so the active layer is not changed
    51       StreetsideLayer.getInstance();
    52       return;
    53     } else if (!MainApplication.getLayerManager().containsLayer(StreetsideLayer.getInstance())) {
     49    if (!StreetsideLayer.hasInstance() || !MainApplication.getLayerManager().containsLayer(StreetsideLayer.getInstance())) {
    5450      MainApplication.getLayerManager().addLayer(StreetsideLayer.getInstance());
    5551      return;
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/actions/StreetsideDownloadViewAction.java

    r34317 r34348  
    2626
    2727  private static final long serialVersionUID = 6738276777802831669L;
    28 
    2928  private static final String DESCRIPTION = I18n.marktr("Download Streetside images in current view");
    3029
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/actions/StreetsideExportAction.java

    r34317 r34348  
    6363    cancel.addActionListener(e -> pane.setValue(JOptionPane.CANCEL_OPTION));
    6464
    65     dialog = new StreetsideExportDialog(ok);
    66     pane.setMessage(dialog);
     65    this.dialog = new StreetsideExportDialog(ok);
     66    pane.setMessage(this.dialog);
    6767    pane.setOptions(new JButton[] {ok, cancel});
    6868
     
    7474    if (pane.getValue() != null
    7575        && (int) pane.getValue() == JOptionPane.OK_OPTION
    76         && dialog.chooser != null) {
    77       if (dialog.group.isSelected(dialog.all.getModel())) {
     76        && this.dialog.chooser != null) {
     77      if (this.dialog.group.isSelected(this.dialog.all.getModel())) {
    7878        export(StreetsideLayer.getInstance().getData().getImages());
    79       } else if (dialog.group.isSelected(dialog.sequence.getModel())) {
     79      } else if (this.dialog.group.isSelected(this.dialog.sequence.getModel())) {
    8080        Set<StreetsideAbstractImage> images = new ConcurrentSkipListSet<>();
    8181        for (StreetsideAbstractImage image : StreetsideLayer.getInstance().getData().getMultiSelectedImages()) {
     
    8989        }
    9090        export(images);
    91       } else if (dialog.group.isSelected(dialog.selected.getModel())) {
     91      } else if (this.dialog.group.isSelected(dialog.selected.getModel())) {
    9292        export(StreetsideLayer.getInstance().getData().getMultiSelectedImages());
    9393      }
    9494      // This option ignores the selected directory.
    95     } else if (dialog.group.isSelected(dialog.rewrite.getModel())) {
     95    } else if (this.dialog.group.isSelected(dialog.rewrite.getModel())) {
    9696      ArrayList<StreetsideImportedImage> images = new ArrayList<>();
    9797      StreetsideLayer.getInstance().getData().getImages().stream().filter(img -> img instanceof StreetsideImportedImage).forEach(img -> images.add((StreetsideImportedImage) img));
     
    113113  public void export(Set<StreetsideAbstractImage> images) {
    114114    MainApplication.worker.execute(new StreetsideExportManager(images,
    115         dialog.chooser.getSelectedFile().toString()));
     115        this.dialog.chooser.getSelectedFile().toString()));
    116116  }
    117117
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/actions/StreetsideWalkAction.java

    r34317 r34348  
    5555    if (pane.getValue() != null
    5656        && (int) pane.getValue() == JOptionPane.OK_OPTION) {
    57       thread = new WalkThread((int) dialog.spin.getValue(),
     57      this.thread = new WalkThread((int) dialog.spin.getValue(),
    5858          dialog.waitForPicture.isSelected(),
    5959          dialog.followSelection.isSelected(), dialog.goForward.isSelected());
     
    7676   */
    7777  public void addListener(WalkListener lis) {
    78     listeners.add(lis);
     78    this.listeners.add(lis);
    7979  }
    8080
     
    8686   */
    8787  public void removeListener(WalkListener lis) {
    88     listeners.remove(lis);
     88    this.listeners.remove(lis);
    8989  }
    9090
    9191  private void fireWalkStarted() {
    92     if (listeners.isEmpty()) {
     92    if (this.listeners.isEmpty()) {
    9393      return;
    9494    }
    95     for (WalkListener lis : listeners) {
    96       lis.walkStarted(thread);
     95    for (WalkListener lis : this.listeners) {
     96      lis.walkStarted(this.thread);
    9797    }
    9898  }
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/actions/StreetsideZoomAction.java

    r34317 r34348  
    66import java.awt.event.ActionEvent;
    77
    8 import org.openstreetmap.josm.plugins.streetside.StreetsideLayer;
    9 
    108import org.openstreetmap.josm.actions.JosmAction;
    119import org.openstreetmap.josm.gui.MainApplication;
    1210import org.openstreetmap.josm.plugins.streetside.StreetsideAbstractImage;
    1311import org.openstreetmap.josm.plugins.streetside.StreetsideDataListener;
     12import org.openstreetmap.josm.plugins.streetside.StreetsideLayer;
    1413import org.openstreetmap.josm.plugins.streetside.StreetsidePlugin;
    1514import org.openstreetmap.josm.tools.ImageProvider;
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/cubemap/CubemapBuilder.java

    r34317 r34348  
    4444        }
    4545
    46         @Override
    47         public void selectedImageChanged(StreetsideAbstractImage oldImage, StreetsideAbstractImage newImage) {
    48                 startTime = System.currentTimeMillis();
    49 
    50                 if (newImage != null) {
    51 
    52                         cubemap = null;
    53                         cubemap = new StreetsideCubemap(newImage.getId(), newImage.getLatLon(), newImage.getHe());
    54                         cubemap.setCd(newImage.getCd());
    55 
    56                         // download cubemap images in different threads and then subsequently
    57                         // set the cubeface images in JavaFX
    58                         downloadCubemapImages(cubemap.getId());
    59                 }
    60         }
    61 
    62         public void reload(String imageId) {
    63                 if (cubemap != null && imageId.equals(cubemap.getId())) {
    64                         CubemapBuilder.getInstance().getCubemap().resetFaces2TileMap();
    65                         downloadCubemapImages(imageId);
    66                 }
    67         }
     46  @Override
     47  public void selectedImageChanged(StreetsideAbstractImage oldImage, StreetsideAbstractImage newImage) {
     48    startTime = System.nanoTime();
     49
     50    if (newImage != null) {
     51
     52      cubemap = null;
     53      cubemap = new StreetsideCubemap(newImage.getId(), newImage.getLatLon(), newImage.getHe());
     54      cubemap.setCd(newImage.getCd());
     55
     56      // download cubemap images in different threads and then subsequently
     57      // set the cubeface images in JavaFX
     58      downloadCubemapImages(cubemap.getId());
     59    }
     60  }
     61
     62  public void reload(String imageId) {
     63    if (cubemap != null && imageId.equals(cubemap.getId())) {
     64      CubemapBuilder.getInstance().getCubemap().resetFaces2TileMap();
     65      downloadCubemapImages(imageId);
     66    }
     67  }
    6868
    6969        public void downloadCubemapImages(String imageId) {
     
    7575                int fails = 0;
    7676
    77                 long startTime = System.currentTimeMillis();
     77                long startTime = System.nanoTime();
    7878
    7979                try {
     
    102102                                for (Future<String> ff : results) {
    103103
    104                                         Logging.debug(I18n.tr("Completed tile downloading task {0} in {1}", ff.get(),
    105                                                         CubemapUtils.msToString(startTime - System.currentTimeMillis())));
     104                                        Logging.info(I18n.tr("Completed tile downloading task {0} in {1}", ff.get(),
     105                                                        CubemapUtils.msToString(startTime - System.nanoTime())));
    106106                                }
    107107
     
    115115                                                                        + String.valueOf(Integer.valueOf(j).toString() + Integer.valueOf(k).toString()));
    116116                                                        tasks.add(new TileDownloadingTask(tileId));
    117                                                         Logging.debug(
     117                                                        Logging.info(
    118118                                                                        I18n.tr("Starting tile downloading task for imageId {0}, cubeface {1}, tileID {2}",
    119119                                                                                        imageId, CubemapUtils.getFaceNumberForCount(i), tileId));
     
    124124                                List<Future<String>> results = pool.invokeAll(tasks);
    125125                                for (Future<String> ff : results) {
    126                                         Logging.info(I18n.tr("Completed tile downloading task {0} in {1}", ff.get(),
    127                                                         CubemapUtils.msToString(startTime - System.currentTimeMillis())));
     126                                        Logging.debug(I18n.tr("Completed tile downloading task {0} in {1}", ff.get(),
     127                                                        CubemapUtils.msToString(startTime - System.nanoTime())));
    128128                                }
    129129                        }
     
    134134                }
    135135
    136                 long stopTime = System.currentTimeMillis();
     136                long stopTime = System.nanoTime();
    137137                long runTime = stopTime - startTime;
    138138
    139                 Logging.info(I18n.tr("Tile imagery downloading tasks completed in {0}", CubemapUtils.msToString(runTime)));
     139                Logging.info(I18n.tr("Imagery downloading tasks completed for all tiles in {0} seconds.", runTime % 1000));
    140140
    141141                if (fails > 0) {
     
    164164
    165165                if (tileCount == (CubemapUtils.NUM_SIDES * maxCols * maxRows)) {
    166                         Logging.info(I18n.tr("{0} tile images ready for building cumbemap faces for cubemap {0}", tileCount,
     166                        Logging.debug(I18n.tr("{0} tile images ready for building cumbemap faces for cubemap {0}", tileCount,
    167167                                        CubemapBuilder.getInstance().getCubemap().getId()));
    168168
    169169                        buildCubemapFaces();
    170170                } else {
    171                         Logging.info(I18n.tr("{0} tile images received for cubemap {1}", Integer.valueOf(tileCount).toString(),
     171                        Logging.debug(I18n.tr("{0} tile images received for cubemap {1}", Integer.valueOf(tileCount).toString(),
    172172                                        CubemapBuilder.getInstance().getCubemap().getId()));
    173173                }
     
    246246                StreetsideViewerPanel.getThreeSixtyDegreeViewerPanel().repaint();
    247247
    248                 long endTime = System.currentTimeMillis();
     248                long endTime = System.nanoTime();
    249249                long runTime = endTime - startTime;
    250250                Logging.info(I18n.tr("Completed downloading, assembling and setting cubemap imagery for cubemap {0} in {1}",
    251                                 cubemap.getId(), CubemapUtils.msToString(runTime)));
     251                                cubemap.getId(), runTime));
    252252        }
    253253
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/cubemap/GraphicsUtils.java

    r34317 r34348  
    4444                BufferedImage res = null;
    4545
    46                 int pixelBuffer = StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get()?2:1;
     46                int pixelBuffer = StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get() ? 2 : 1;
    4747
    4848                tiles = cropMultiTiledImages(tiles, pixelBuffer);
    4949
    50                 int rows = StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get()?4:2; //we assume the no. of rows and cols are known and each chunk has equal width and height
    51         int cols = StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get()?4:2;
     50                int rows = StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get() ? 4 : 2; // we assume the no. of rows and
     51                                                                                                                                                                                // cols are known and each chunk
     52                                                                                                                                                                                // has
     53                                                                                                                                                                                // equal width and height
     54                int cols = StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get() ? 4 : 2;
    5255
    53         int chunkWidth, chunkHeight;
     56                int chunkWidth, chunkHeight;
    5457
    55         chunkWidth = tiles[0].getWidth();
    56         chunkHeight = tiles[0].getHeight();
     58                chunkWidth = tiles[0].getWidth();
     59                chunkHeight = tiles[0].getHeight();
    5760
    58         //Initializing the final image
    59         BufferedImage img = new BufferedImage(chunkWidth*cols, chunkHeight*rows, BufferedImage.TYPE_INT_ARGB);
     61                // Initializing the final image
     62                BufferedImage img = new BufferedImage(chunkWidth * cols, chunkHeight * rows, BufferedImage.TYPE_INT_ARGB);
    6063
    61         int num = 0;
    62         for (int i = 0; i < rows; i++) {
    63             for (int j = 0; j < cols; j++) {
    64                 // TODO: this makes the image a mirror image. why!?!
    65                 img.createGraphics().drawImage(tiles[num], chunkWidth * j, chunkHeight * i, null);
     64                int num = 0;
     65                for (int i = 0; i < rows; i++) {
     66                        for (int j = 0; j < cols; j++) {
     67                                // TODO: mirror image
     68                                img.createGraphics().drawImage(tiles[num], chunkWidth * j, chunkHeight * i, null);
    6669
    67                 // TODO: remove file test!
    68                 /*try {
    69                                 ImageIO.write(img, "jpeg", new File("/Users/renerr18/Desktop/TileImagesTest/tile16b" + Long.valueOf(System.currentTimeMillis()).toString() + "createGraphicsAfter.jpeg"));
    70                                 //ImageIO.write(res[i], "jpeg", outputfileAfter);
    71                         } catch (IOException e) {
    72                                 // TODO Auto-generated catch block
    73                                 e.printStackTrace();
    74                         }*/
     70                                int width = StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get() ? 1014 : 510;
     71                                int height = StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get() ? 1014 : 510;
    7572
    76                 int width = StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get()?1014:510;
    77                 int height = StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get()?1014:510;
     73                                res = new BufferedImage(StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get() ? 1014 : 510,
     74                                                StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get() ? 1014 : 510,
     75                                                BufferedImage.TYPE_INT_ARGB);
    7876
    79                 // BufferedImage for mirror image
    80                 res = new BufferedImage(StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get()?1014:510, StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get()?1014:510,
    81                                                 BufferedImage.TYPE_INT_ARGB);
     77                                // Create mirror image pixel by pixel
     78                                for (int y = 0; y < height; y++) {
     79                                        for (int lx = 0, rx = width - 1; lx < width; lx++, rx--) {
     80                                                // lx starts from the left side of the image
     81                                                // rx starts from the right side of the image
     82                                                // lx is used since we are getting pixel from left side
     83                                                // rx is used to set from right side
     84                                                // get source pixel value
     85                                                int p = img.getRGB(lx, y);
    8286
    83                 // Create mirror image pixel by pixel
    84                 for (int y = 0; y < height; y++)
    85                 {
    86                     for (int lx = 0, rx = width - 1; lx < width; lx++, rx--)
    87                     {
    88                         // lx starts from the left side of the image
    89                         // rx starts from the right side of the image
    90                         // lx is used since we are getting pixel from left side
    91                         // rx is used to set from right side
    92                         // get source pixel value
    93                         int p = img.getRGB(lx, y);
     87                                                // set mirror image pixel value
     88                                                res.setRGB(rx, y, p);
     89                                        }
     90                                }
     91                                num++;
     92                        }
     93                }
    9494
    95                         // set mirror image pixel value
    96                         res.setRGB(rx, y, p);
    97                     }
    98                 }
    99                 num++;
    100             }
    101         }
     95                Logging.debug("Image concatenated.....");
    10296
    103         Logging.info("Image concatenated.....");
    104 
    105         return res;
     97                return res;
    10698        }
    10799
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/cubemap/TileDownloadingTask.java

    r34325 r34348  
    2222
    2323        private String tileId;
    24         private final long startTime = System.currentTimeMillis();
     24        private final long startTime = System.nanoTime();
    2525        private StreetsideCache cache;
    2626        protected CubemapBuilder cb;
     
    120120                fireTileAdded(tileId);
    121121
    122                 long endTime = System.currentTimeMillis();
    123                 long runTime = startTime - endTime;
    124                 Logging.debug("Loaded image for tile {0} in {1} seconds", tileId, CubemapUtils.msToString(runTime));
     122                long endTime = System.nanoTime();
     123                long runTime = endTime - startTime;
     124                Logging.info("Loaded image for tile {0} in {1} seconds", tileId, runTime);
    125125
    126126                return tileId;
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/gui/imageinfo/ImageInfoPanel.java

    r34325 r34348  
    1212
    1313import javax.swing.ImageIcon;
     14import javax.swing.JCheckBox;
    1415import javax.swing.JLabel;
    1516import javax.swing.JPanel;
     
    1819import org.apache.commons.logging.Log;
    1920import org.apache.commons.logging.LogFactory;
    20 import org.openstreetmap.josm.data.osm.DataSelectionListener;
     21
     22import org.openstreetmap.josm.data.SelectionChangedListener;
     23import org.openstreetmap.josm.data.osm.DataSet;
    2124import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2225import org.openstreetmap.josm.data.osm.Tag;
     
    3437import org.openstreetmap.josm.tools.I18n;
    3538
    36 public final class ImageInfoPanel extends ToggleDialog implements StreetsideDataListener, DataSelectionListener {
     39public final class ImageInfoPanel extends ToggleDialog implements StreetsideDataListener, SelectionChangedListener {
    3740  private static final long serialVersionUID = 4141847503072417190L;
    3841  private static final Log L = LogFactory.getLog(ImageInfoPanel.class);
     
    4043  private static final ImageIcon EMPTY_USER_AVATAR = new ImageIcon(new BufferedImage(32, 32, BufferedImage.TYPE_INT_ARGB));
    4144
    42   //private final JLabel numDetectionsLabel;
    43   //private final JCheckBox showDetectionsCheck;
     45  private final JLabel numDetectionsLabel;
     46  private final JCheckBox showDetectionsCheck;
    4447  private final JLabel usernameLabel;
    4548  private final JTextPane imgKeyValue;
     
    5962      150
    6063    );
    61     SelectionEventManager.getInstance().addSelectionListener(this);
    62 
    63     //numDetectionsLabel = new JLabel();
    64     //numDetectionsLabel.setFont(numDetectionsLabel.getFont().deriveFont(Font.PLAIN));
    65 
    66     //showDetectionsCheck = new JCheckBox(I18n.tr("Show detections on top of image"));
    67     //showDetectionsCheck.setSelected(StreetsideProperties.SHOW_DETECTED_SIGNS.get());
    68     /*showDetectionsCheck.addActionListener(
    69       action -> StreetsideProperties.SHOW_DETECTED_SIGNS.put(showDetectionsCheck.isSelected())
    70     );
    71     StreetsideProperties.SHOW_DETECTED_SIGNS.addListener(
    72       valueChange -> showDetectionsCheck.setSelected(StreetsideProperties.SHOW_DETECTED_SIGNS.get())
    73     );*/
     64    DataSet.addSelectionListener(this);
     65
     66    numDetectionsLabel = new JLabel();
     67    numDetectionsLabel.setFont(numDetectionsLabel.getFont().deriveFont(Font.PLAIN));
     68
     69    showDetectionsCheck = new JCheckBox(I18n.tr("Show detections on top of image"));
     70
     71    // no selections currently available for Streetside
     72    showDetectionsCheck.setSelected(false);
    7473
    7574    usernameLabel = new JLabel();
     
    120119    gbc.gridy = 0;
    121120    gbc.anchor = GridBagConstraints.LINE_START;
    122     //root.add(numDetectionsLabel, gbc);
    123     //gbc.gridy++;
    124     //root.add(showDetectionsCheck, gbc);
    125     //gbc.gridy++;
     121    root.add(numDetectionsLabel, gbc);
     122    gbc.gridy++;
     123    root.add(showDetectionsCheck, gbc);
     124    gbc.gridy++;
    126125    root.add(usernameLabel, gbc);
    127126    gbc.gridy++;
     
    172171
    173172  /* (non-Javadoc)
    174    * @see org.openstreetmap.josm.plugins.streetside.StreetsideDataListener#selectedImageChanged(org.openstreetmap.josm.plugins.streetside.StreetsideAbstractImage, org.openstreetmap.josm.plugins.streetside.StreetsideAbstractImage)
     173   * @see org.openstreetmap.josm.plugins.mapillary.MapillaryDataListener#selectedImageChanged(org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage, org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage)
    175174   */
    176175  @Override
     
    182181    ));
    183182
    184     //numDetectionsLabel.setText(I18n.tr("{0} detections", newImage instanceof StreetsideImage ? ((StreetsideImage) newImage).getDetections().size() : 0));
     183    numDetectionsLabel.setText(I18n.tr("{0} detections", newImage instanceof StreetsideImage ? ((StreetsideImage) newImage).getDetections().size() : 0));
    185184    imgKeyValue.setEnabled(newImage instanceof StreetsideImage);
    186185    final String newImageKey = newImage instanceof StreetsideImage ? ((StreetsideImage) newImage).getId(): null;
     
    209208    }
    210209
    211     final UserProfile user = newImage instanceof StreetsideImage ? ((StreetsideImage) newImage).getUser() : null;
     210    // Currently no user info supported in Streetside plugin
     211    final UserProfile user = null;
    212212    usernameLabel.setEnabled(user != null);
    213213    if (user != null) {
     
    232232   */
    233233  @Override
    234   public synchronized void selectionChanged(final SelectionChangeEvent event) {
    235     final Collection<? extends OsmPrimitive> sel = event.getSelection();
     234  public synchronized void selectionChanged(final Collection<? extends OsmPrimitive> sel) {
    236235    L.debug(String.format("Selection changed. %d primitives are selected.", sel == null ? 0 : sel.size()));
    237236    addStreetsideTagAction.setTarget(sel != null && sel.size() == 1 ? sel.iterator().next() : null);
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/io/download/SequenceDownloadRunnable.java

    r34333 r34348  
    4949
    5050    StreetsideSequence seq = new StreetsideSequence(null);
    51     // TODO: re-add sequenceID
    52     //StreetsideSequence seq = new StreetsideSequence(StreetsideSequenceIdGenerator.generateId());
    53 
    54     // TODO: how can LatLon and heading / camera angles (he attribute) be set for a sequence?
    55     // and does it make sense? @rrh
    5651
    5752    List<StreetsideImage> bubbleImages = new ArrayList<>();
    5853
    59     final long startTime = System.currentTimeMillis();
     54    final long startTime = System.nanoTime();
    6055
    6156    ObjectMapper mapper = new ObjectMapper();
     
    6964    try {
    7065
    71     JsonParser parser = mapper.getFactory().createParser(new BufferedInputStream(con.getInputStream()));
    72     if(parser.nextToken() != JsonToken.START_ARRAY) {
    73       parser.close();
    74       throw new IllegalStateException("Expected an array");
    75     }
     66      JsonParser parser = mapper.getFactory().createParser(new BufferedInputStream(con.getInputStream()));
     67      if (parser.nextToken() != JsonToken.START_ARRAY) {
     68        parser.close();
     69        throw new IllegalStateException("Expected an array");
     70      }
    7671
     72      StreetsideImage previous = null;
    7773
    78     StreetsideImage previous = null;
    79 
    80     while (parser.nextToken() == JsonToken.START_OBJECT) {
     74      while (parser.nextToken() == JsonToken.START_OBJECT) {
    8175        // read everything from this START_OBJECT to the matching END_OBJECT
    8276        // and return it as a tree model ObjectNode
     
    8579        if (node.get("id") != null && node.get("la") != null && node.get("lo") != null) {
    8680          StreetsideImage image = new StreetsideImage(CubemapUtils.convertDecimal2Quaternary(node.path("id").asLong()), node.path("la").asDouble(), node.get("lo").asDouble());
    87           if(previous!=null) {
    88                   // Analyze sequence behaviour
    89                   //previous.setNext(image.)
     81          if (previous != null) {
     82              previous.setNe(image.getNe());
    9083          }
    9184          image.setAd(node.path("ad").asInt());
     
    10093          image.setPi(node.path("pi").asDouble());
    10194          image.setPr(node.path("pr").asLong());
    102           // TODO: inner class @rrh
    103           // image.setRn(node.path("rn").asText());
    10495          image.setRo(node.path("ro").asDouble());
    10596
     
    10798          List<StreetsideImage> tiles = new ArrayList<StreetsideImage>();
    10899
    109         // TODO: set previous and next @rrh
     100          EnumSet.allOf(CubemapUtils.CubemapFaces.class).forEach(face -> {
    110101
    111                                         EnumSet.allOf(CubemapUtils.CubemapFaces.class).forEach(face -> {
     102            for (int i = 0; i < 4; i++) {
     103              // Initialize four-tiled cubemap faces (four images per cube side with 18-length
     104              // Quadkey)
     105              if (!StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get()) {
     106                StreetsideImage tile = new StreetsideImage(String.valueOf(image.getId() + Integer.valueOf(i)));
     107                tiles.add(tile);
     108              }
     109              // Initialize four-tiled cubemap faces (four images per cub eside with 20-length
     110              // Quadkey)
     111              if (StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get()) {
     112                for (int j = 0; j < 4; j++) {
     113                  StreetsideImage tile = new StreetsideImage(
     114                    String.valueOf(
     115                      image.getId() + face.getValue() + CubemapUtils.rowCol2StreetsideCellAddressMap
     116                        .get(String.valueOf(Integer.valueOf(i).toString() + Integer.valueOf(j).toString()))
     117                      ));
     118                  tiles.add(tile
     119              );
     120                }
     121              }
     122            }
     123          });
    112124
    113                                                         for (int i = 0; i < 4; i++) {
    114                                                                 // Initialize four-tiled cubemap faces (four images per cube side with 18-length
    115                                                                 // Quadkey)
    116                                                                 //if (StreetsideProperties.CUBEFACE_SIZE.get().intValue() == 4) {
    117                                                                 if (!StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get()) {
    118                                                                         StreetsideImage tile = new StreetsideImage(
    119                                                                                         String.valueOf(image.getId() + Integer.valueOf(i)));
    120                                                                         tiles.add(tile);
    121                                                                 }
    122                                                                 // Initialize four-tiled cubemap faces (four images per cub eside with 20-length
    123                                                                 // Quadkey)
    124                                                                 //if (StreetsideProperties.CUBEFACE_SIZE.get().intValue() == 16) {
    125                                                                 if (StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get()) {
    126                                                                         for (int j = 0; j < 4; j++) {
    127                                                                                 StreetsideImage tile = new StreetsideImage(String.valueOf(image.getId()
    128                                                                                                 + face.getValue() + CubemapUtils.rowCol2StreetsideCellAddressMap
    129                                                                                                                 .get(String.valueOf(Integer.valueOf(i).toString() + Integer.valueOf(j).toString()))));
    130                                                                                 tiles.add(tile);
    131                                                                         }
    132                                                                 }
    133                                                         }
    134                                         });
    135 
    136           bubbleImages.add(image);
    137           Logging.info("Added image with id <" + image.getId() + ">");
    138           // TODO: double check whether this pre-caches successfullly @rrh
    139           //StreetsideData.downloadSurroundingCubemaps(image);
     125          bubbleImages.add(image);
     126          Logging.debug("Added image with id <" + image.getId() + ">");
    140127
    141128        }
    142129      }
    143130
    144     parser.close();
    145 
    146     //StreetsideImage[] images;
    147 
    148       // First load all of the 'bubbles' from the request as Streetside Images
    149       /*List<StreetsideImage> images = mapper
    150         .readValue(new BufferedInputStream(con.getInputStream()), new TypeReference<List<StreetsideImage>>() {});
    151       */
    152 
    153 
    154       //images = mapper.readValue(new BufferedInputStream(con.getInputStream()), StreetsideImage[].class);
    155 
    156       /*for (StreetsideImage image : bubbleImages) {
    157         image = JsonStreetsideSequencesDecoder.decodeBubbleData(image);
    158         if(image != null) bubbleImages.add(image);
    159       }*/
     131      parser.close();
    160132
    161133    } catch (JsonParseException e) {
     
    192164    }
    193165
    194     final long endTime = System.currentTimeMillis();
     166    final long endTime = System.nanoTime();//currentTimeMillis();
    195167    Logging.info(I18n.tr("Sucessfully loaded {0} Microsoft Streetside images in {0} ",seq.getImages().size(),endTime-startTime%60));
    196168  }
  • applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/utils/StreetsideURL.java

    r34325 r34348  
    236236        }
    237237
    238         public static URL[] string2URLs(String baseUrlPrefix, String cubemapImageId, String baseUrlSuffix) {
    239                 List<URL> res = new ArrayList<>();
    240 
    241                 switch (StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get() ? 16 : 4) {
    242 
    243                 case 16:
    244 
    245                         EnumSet.allOf(CubemapUtils.CubemapFaces.class).forEach(face -> {
    246                                 for (int i = 0; i < 4; i++) {
    247                                         for (int j = 0; j < 4; j++) {
    248                                                 try {
    249                                                         final String urlStr = baseUrlPrefix + cubemapImageId
    250                                                                         + CubemapUtils.rowCol2StreetsideCellAddressMap
    251                                                                                         .get(String.valueOf(i) + String.valueOf(j))
    252                                                                         + baseUrlSuffix;
    253                                                         res.add(new URL(urlStr));
    254                                                 } catch (final MalformedURLException e) {
    255                                                         Logging.error(I18n.tr("Error creating URL String for cubemap {0}", cubemapImageId));
    256                                                         e.printStackTrace();
    257                                                 }
    258 
    259                                         }
    260                                 }
    261                         });
    262 
    263                 case 4:
    264                         EnumSet.allOf(CubemapUtils.CubemapFaces.class).forEach(face -> {
    265                                 for (int i = 0; i < 4; i++) {
    266 
    267                                         try {
    268                                                 final String urlStr = baseUrlPrefix + cubemapImageId
    269                                                                 + CubemapUtils.rowCol2StreetsideCellAddressMap.get(String.valueOf(i)) + baseUrlSuffix;
    270                                                 res.add(new URL(urlStr));
    271                                         } catch (final MalformedURLException e) {
    272                                                 Logging.error(I18n.tr("Error creating URL String for cubemap {0}", cubemapImageId));
    273                                                 e.printStackTrace();
    274                                         }
    275 
    276                                 }
    277                         });
    278                         break; // break is optional
    279                 default:
    280                         // Statements
    281                 }
    282                 return res.stream().toArray(URL[]::new);
    283         }
     238  public static URL[] string2URLs(String baseUrlPrefix, String cubemapImageId, String baseUrlSuffix) {
     239    List<URL> res = new ArrayList<>();
     240
     241    switch (StreetsideProperties.SHOW_HIGH_RES_STREETSIDE_IMAGERY.get() ? 16 : 4) {
     242
     243    case 16:
     244
     245      EnumSet.allOf(CubemapUtils.CubemapFaces.class).forEach(face -> {
     246        for (int i = 0; i < 4; i++) {
     247          for (int j = 0; j < 4; j++) {
     248            try {
     249              final String urlStr = baseUrlPrefix + cubemapImageId + CubemapUtils.rowCol2StreetsideCellAddressMap
     250                .get(String.valueOf(i) + String.valueOf(j)) + baseUrlSuffix;
     251              res.add(new URL(urlStr));
     252            } catch (final MalformedURLException e) {
     253              Logging.error(I18n.tr("Error creating URL String for cubemap {0}", cubemapImageId));
     254              e.printStackTrace();
     255            }
     256
     257          }
     258        }
     259      });
     260
     261      break;
     262
     263    case 4:
     264      EnumSet.allOf(CubemapUtils.CubemapFaces.class).forEach(face -> {
     265        for (int i = 0; i < 4; i++) {
     266
     267          try {
     268            final String urlStr = baseUrlPrefix + cubemapImageId
     269              + CubemapUtils.rowCol2StreetsideCellAddressMap.get(String.valueOf(i)) + baseUrlSuffix;
     270            res.add(new URL(urlStr));
     271          } catch (final MalformedURLException e) {
     272            Logging.error(I18n.tr("Error creating URL String for cubemap {0}", cubemapImageId));
     273            e.printStackTrace();
     274          }
     275
     276        }
     277      });
     278      break; // break is optional
     279    default:
     280      // Statements
     281    }
     282    return res.stream().toArray(URL[]::new);
     283  }
    284284
    285285        /**
Note: See TracChangeset for help on using the changeset viewer.