001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.plugins.streetside.io.download;
003
004import java.io.IOException;
005import java.net.URL;
006import java.net.URLConnection;
007import java.util.function.Function;
008
009import org.openstreetmap.josm.data.Bounds;
010import org.openstreetmap.josm.plugins.streetside.StreetsideData;
011import org.openstreetmap.josm.plugins.streetside.utils.StreetsideURL.APIv3;
012
013
014public class ImageDetailsDownloadRunnable extends BoundsDownloadRunnable {
015  //private static final Function<Bounds, URL> URL_GEN = APIv3::searchImages;
016  private static final Function<Bounds, URL> URL_GEN = APIv3::searchStreetsideImages;
017
018  private final StreetsideData data;
019
020  public ImageDetailsDownloadRunnable(final StreetsideData data, final Bounds bounds) {
021    super(bounds);
022    this.data = data;
023  }
024
025  // TODO: image infos for 360 degree viewer? @rrh
026  @Override
027  public void run(final URLConnection con) throws IOException {
028     // TODO: modifiy decoder to handle Streetside image info. @rrh
029          /*try (JsonReader reader = Json.createReader(new BufferedInputStream(con.getInputStream()))) {
030      JsonImageDetailsDecoder.decodeImageInfos(reader.readObject(), data);
031      logConnectionInfo(con, null);
032      StreetsideMainDialog.getInstance().updateTitle();
033    } catch (JsonException | NumberFormatException e) {
034      throw new IOException(e);
035    }*/
036  }
037
038  @Override
039  protected Function<Bounds, URL> getUrlGenerator() {
040    return URL_GEN;
041  }
042
043}