Unfolding maps - bad image data fix?

edited August 2015 in Library Questions

Hey everyone,

I'm trying to create an interactive map for my company with locations of customer sites around the world. I was looking into using Unfolding for this with Processing as it seems to be the go-to. I can't seem to get even a simple map on the screen with the following code:

import de.fhpotsdam.unfolding.mapdisplay.*;
 import de.fhpotsdam.unfolding.utils.*;
 import de.fhpotsdam.unfolding.marker.*;
 import de.fhpotsdam.unfolding.tiles.*;
 import de.fhpotsdam.unfolding.interactions.*;
 import de.fhpotsdam.unfolding.ui.*;
 import de.fhpotsdam.unfolding.*;
 import de.fhpotsdam.unfolding.core.*;
 import de.fhpotsdam.unfolding.mapdisplay.shaders.*;
 import de.fhpotsdam.unfolding.data.*;
import de.fhpotsdam.unfolding.geo.*;
 import de.fhpotsdam.unfolding.texture.*;
 import de.fhpotsdam.unfolding.events.*;
 import de.fhpotsdam.utils.*;
 import de.fhpotsdam.unfolding.providers.*;

 UnfoldingMap map;

 void setup() {
         size(800, 600, P2D);
         map = new UnfoldingMap(this);
         MapUtils.createDefaultEventDispatcher(this, map);
}

 void draw() {
  map.draw();
 }

I get a blank canvas when I run it and errors of this type in the console:

"The file http://a.www.toolserver.org/tiles/bw-mapnik/2/2/3.png contains bad image data, or may not be an image."

Any ideas? Maybe I need to use a different source for the map images? Any help would be great! Thanks.

Answers

  • where are you even referencing that image?

    image looks fine in my browser.

  • Same problem here. The image also looks fine in my browser. The problem is inside Processing...

  • fetching those tiles manually i get

    wget http://a.www.toolserver.org/tiles/bw-mapnik/5/14/17.png
    --2015-08-12 21:48:02--  http://a.www.toolserver.org/tiles/bw-mapnik/5/14/17.png
    Resolving a.www.toolserver.org (a.www.toolserver.org)... 208.80.155.197
    Connecting to a.www.toolserver.org (a.www.toolserver.org)|208.80.155.197|:80... connected.
    HTTP request sent, awaiting response... 
    
    302 Found
    Location: https://www.toolserver.org/tiles/bw-mapnik/5/14/17.png [following]
    --2015-08-12 21:49:19--  https://www.toolserver.org/tiles/bw-mapnik/5/14/17.png
    Resolving www.toolserver.org (www.toolserver.org)... 208.80.155.197
    Connecting to www.toolserver.org (www.toolserver.org)|208.80.155.197|:443... connected.
    HTTP request sent, awaiting response... 
    
    301 Moved Permanently
    Location: http://a.tiles.wmflabs.org/bw-mapnik/5/14/17.png [following]
    --2015-08-12 21:49:23--  http://a.tiles.wmflabs.org/bw-mapnik/5/14/17.png
    Resolving a.tiles.wmflabs.org (a.tiles.wmflabs.org)... 208.80.155.156
    Connecting to a.tiles.wmflabs.org (a.tiles.wmflabs.org)|208.80.155.156|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 103 [image/png]
    Saving to: `17.png.1'
    
    2015-08-12 21:49:23 (7.48 MB/s) - `17.png.1' saved [103/103]
    

    the final image looks ok but the 302 and the 301 and the time take to negotiate those is probably causing the problem.

    using that final hostname, a.tiles.wmflabs.org might be an idea, however you do that...

  • ok, add

    import de.fhpotsdam.unfolding.providers.OpenStreetMap.*;
    

    and change the constructor to

    map = new UnfoldingMap(this, new OpenStreetMapProvider());
    
  • edited August 2015

    you can use any of the alternatives listed here:

    /libraries/Unfolding/reference/de/fhpotsdam/unfolding/providers/AbstractMapTileUrlProvider.html

    (above path is relative to your sketchbook directory)

    but i had trouble with the first couple i tried (google)

Sign In or Register to comment.