Hi,
It seems NutiteqStreamedMap class be default inherits EPSG3785 projection class. I need to use EPSG4326 instead.
What changed do I need to do, to achieve that? Can you please share the code for that?
Thx!
Hi,
I changed the following source code of NutiteqStreamedMap to use 4326 projection (code pasted below). At the back-end, i wrote the script to convert to calculate BBOX for 4326 projection (code discussed at: http://www.nutiteq.com/content/server-side-script-nutiteqstreamedmap-api).
Now when I run my app, at the backend after conversion of BBOX, the generated tilecache url seems invalid (it tries to find some image eg. 370.png, at folder where no such file physically exist).
Please review my front-end and back-end code, if you can find some error -
FRONT-END CODE -
---------------
package com.nutiteq.maps;
import com.nutiteq.components.MapTile;
import com.nutiteq.maps.projections.EPSG4326;
//import com.nutiteq.maps.projections.EPSG3785;
/**
* Streamed maps based on Nutiteq map tiles streaming server.
*/
public class NutiteqStreamedMap extends EPSG4326 implements GeoMap, StreamedOnlineMap {
private final String baseUrl;
public NutiteqStreamedMap(final String baseUrl, final String copyright, final int tileSize,
final int minZoom, final int maxZoom) {
super(copyright, tileSize, minZoom, maxZoom);
this.baseUrl = baseUrl;
}
public String buildStreamedUrl(final MapTile[] tiles) {
final StringBuffer urlBuf = new StringBuffer(baseUrl);
final MapTile firstTile = tiles[0];
urlBuf.append("z=");
urlBuf.append(firstTile.getZoom());
urlBuf.append("&ver=2");
urlBuf.append("&t=");
urlBuf.append(firstTile.getX() / getTileSize());
urlBuf.append(',');
urlBuf.append(firstTile.getY() / getTileSize());
for (int i = 1; i < tiles.length; i++) {
final MapTile obj = tiles[i];
urlBuf.append(',');
urlBuf.append(obj.getX() / getTileSize());
urlBuf.append(',');
urlBuf.append(obj.getY() / getTileSize());
}
return urlBuf.toString();
}
}
--------------------------------------
BACK-END CODE :-
--------------
while(@xy){
$tileX = shift(@xy);
$tileY = shift(@xy);
$mapTopLeftX = $tileX*$resolution[$z]*$tileSizeInPixel-180;
$mapTopLeftY = 180-$tileY*$resolution[$z]*$tileSizeInPixel;
$mapBottomRightX=$mapTopLeftX + $resolution[$z]*$tileSizeInPixel;
$mapBottomRightY=$mapTopLeftY - $resolution[$z]*$tileSizeInPixel;
//tilecache URL http://server/cgi-bin/tilecache.cgi?LAYERS=LAYER_NAME&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&SRS=EPSG%3A4326&BBOX=$mapTopLeftX,$mapTopLeftY,$mapBottomRightX,$mapBottomRightY&WIDTH=64&HEIGHT=64\n";
}
-------------------------------------------------
Note: Reason, why i am using 4326 projection is, server side supports only 4326 (not 3785)
Please provide your traces: what were your requested map coordinates (e.g. initial map location lat,long and zoom), what tiles (URL) client requested, and what URL requests were made to the tilecache?
One possible mistake could be in $resolution[$z] values, otherwise code looks fine at the first glance.
Hi Jaak,
Thanks for the reply.
I will be off for few days and will be back to work from Monday. I'll send you the traces by then.
Thx!
Try this one. Have not tested it, but this is has only change in projection.
import com.nutiteq.components.MapTile;
import com.nutiteq.maps.GeoMap;
import com.nutiteq.maps.StreamedMap;
import com.nutiteq.maps.projections.EPSG4326;
import com.nutiteq.ui.Copyright;
import com.nutiteq.ui.StringCopyright;
import com.nutiteq.utils.Utils;
public class MyStreamedMap extends EPSG4326 implements GeoMap, StreamedMap {
private final String baseUrl;
public MyStreamedMap(final String baseUrl, final String copyright, final int tileSize,
final int minZoom, final int maxZoom) {
this(baseUrl, new StringCopyright(copyright), tileSize, minZoom, maxZoom);
}
public MyStreamedMap(final String baseUrl, final Copyright copyright, final int tileSize,
final int minZoom, final int maxZoom) {
super(copyright, tileSize, minZoom, maxZoom);
this.baseUrl = Utils.prepareForParameters(baseUrl);
}
public String buildStreamedPath(final MapTile[] tiles) {
final StringBuffer urlBuf = new StringBuffer(baseUrl);
final MapTile firstTile = tiles[0];
urlBuf.append("z=");
urlBuf.append(firstTile.getZoom());
urlBuf.append("&ver=2");
urlBuf.append("&t=");
urlBuf.append(firstTile.getX() / getTileSize());
urlBuf.append(',');
urlBuf.append(firstTile.getY() / getTileSize());
for (int i = 1; i < tiles.length; i++) {
final MapTile obj = tiles[i];
urlBuf.append(',');
urlBuf.append(obj.getX() / getTileSize());
urlBuf.append(',');
urlBuf.append(obj.getY() / getTileSize());
}
return urlBuf.toString();
}
}
/JaakL