Author Topic: Geoportal.de MOBAC mapsource help needed  (Read 2775 times)

Offline Trullo Fetzer

  • More than Newbie
  • *
  • Posts: 16
    • View Profile
Geoportal.de MOBAC mapsource help needed
« on: November 12, 2013, 14:08:13 »
Hello to all Beanshell wizards.
I have the following problem. I try to access the German Geoportal with MOBAC, but that server is issuing 2 cookies. One for JSESSIONID and one for PHPSESSID. With the code below I only get the first cookie (JSESSIONID) successfully. I found some java code examples for storing cookies, but I don't know how to integrate this into the script. Any help would be appreciated. There are different approaches to get cookie values which I tried, but all of them only get the first cookie. Tahnks in advance.
Code: [Select]
name = "Geoportal DE";

tileType = "png"; // required; valid values: "jpg" "png" or "gif"

// Default size of each tile is 256x256 pixel
tileSize = 256; // optional
minZoom = 7;    // optional
maxZoom = 15;   // optional
//tileUpdate = TileUpdate.IfModifiedSince; // optional

//get authentication cookie

URL url = new URL("http://www.geoportal.de/DE/Geoportal/geoportal.html?lang=de");
httpConn = url.openConnection();
authHeader = httpConn.getHeaderField("Set-Cookie");
auth = authHeader.split(";")[0];

/**
 This method is called for each tile: input parameters for this script: "zoom", "x" and "y"
**/
String getTileUrl( int zoom, int x, int y ) {
return "http://www.geoportal.de/viewer/proxy/open?url=http://arcgis.lpz.web/arcgis/rest/services/webatlasde/MapServer/WMTS/tile/1.0.0/webatlasde/default/nativeTileMatrixSet/"+zoom+"/"+x+"/"+y+".png";
}

/**
 This method is called also for each tile (implementation optional)
 It allows to set HTTP headers like "Referer" or cookies the server
 wants to see.
**/
void addHeaders( java.net.HttpURLConnection conn) {
  conn.addRequestProperty("Cookie",auth);
  conn.addRequestProperty("Referer","http://www.geoportal.de/DE/Geoportal/geoportal.html?lang=de");
  conn.addRequestProperty("User-Agent","Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0) Gecko/20100101 Firefox/4.0 Opera 12.16");
}