[mapguide-users] MapAgent parameters - Tiled Map
Traian Stanev
traian.stanev at autodesk.com
Thu Apr 6 09:07:23 EDT 2006
Hi Velen.
Tile column and row are related to map coordinates in the function
called MgServerRenderingService::RenderTile(), on line 78 of
ServerRenderingService.cpp.
Here is the relevant piece of code that computes the extents in mapping
space from given tile row/col:
/////////////////////////////////////////////////////////////
// ------------------------------------------------------
// the upper left corner of tile (0,0) corresponds to the
// upper left corner of the map extent
// ------------------------------------------------------
//get the overall extent of the map
Ptr<MgEnvelope> mapExtent = map->GetMapExtent();
Ptr<MgCoordinate> pt00 = mapExtent->GetLowerLeftCoordinate();
Ptr<MgCoordinate> pt11 = mapExtent->GetUpperRightCoordinate();
double mapMinX = min(pt00->GetX(), pt11->GetX());
double mapMaxX = max(pt00->GetX(), pt11->GetX());
double mapMinY = min(pt00->GetY(), pt11->GetY());
double mapMaxY = max(pt00->GetY(), pt11->GetY());
//compute needed pixel to mapping unit scale factors
double metersPerUnit = map->GetMetersPerUnit();
double metersPerPixel = 0.0254 / MgTileParameters::tileDPI;
double tileWidthMCS = (double)MgTileParameters::tileWidth *
metersPerPixel * scale / metersPerUnit;
double tileHeightMCS = (double)MgTileParameters::tileHeight *
metersPerPixel * scale / metersPerUnit;
//compute tile bounds in mapping space
double tileMinX = mapMinX + (double)(tileColumn ) * tileWidthMCS;
// left edge
double tileMaxX = mapMinX + (double)(tileColumn+1) * tileWidthMCS;
// right edge
double tileMinY = mapMaxY - (double)(tileRow +1) * tileHeightMCS;
// bottom edge
double tileMaxY = mapMaxY - (double)(tileRow ) * tileHeightMCS;
// top edge
// make the call to render the tile
ret = RenderTile(map, baseGroup, scaleIndex,
MgTileParameters::tileWidth, MgTileParameters::tileHeight, scale,
tileMinX, tileMaxX, tileMinY, tileMaxY, MgTileParameters::tileFormat);
//////////////////////////////////////////////////////////////////////
Note that it is possible that the map extent is smaller than the extent
of all the data on the map. In that case, there could be non-empty tiles
at negative row/column indices (i.e. to the left or above the origin).
In order to get a tile from the server, you can use the above-mentioned
RenderingService API call. Our tiled view implementation does not use
this call directly -- we have a TileService which caches tiles on the
server side and only renders tiles the first time they are requested. If
you want to have server side caching, you should be calling
MgTileService::GetTile, which takes the same arguments as
MgRenderingService::RenderTile.
Also keep in mind that in tiles we only render layers that are added as
"base layers" to the map, so if a MapGuide map does not use base layers,
you will get an empty tile. So if you are trying to write a generic
tiling app, you can't really use the tile APIs, since you can't rely on
all maps having "base layers" only. What you can do is use regular
rendering APIs to generate images for arbitrary pieces of the map --
where by "arbitrary piece" I mean the extent of the tile you want. The
relevant public API in this case would be:
MgByteReader* MgRenderingService::RenderMap(
MgMap* map,
MgSelection* selection,
MgEnvelope* extents,
INT32 width,
INT32 height,
MgColor* backgroundColor,
CREFSTRING format)
This is what our WMS serving component calls internally and I believe
there is someone else on this list who was trying to do tiling using WMS
calls to MapGuide. This would work, however, since it is not using the
tiling code path, you may see some discontinuities between things like
labels at adjacent tile boundaries. We will likely fix that soon,
though, and you should be able to get seamless looking tiles via this
API call (and therefore WMS also).
Let us know if you have more questions, I'm sure other people will also
want to chime in about tiling :-).
Traian
________________________________
From: velen [mailto:vliang at thecarbonproject.com]
Sent: Wednesday, April 05, 2006 6:26 PM
To: users at mapguide.osgeo.org
Subject: RE: [mapguide-users] MapAgent parameters - Tiled Map
Hi,
Is there a more detail information regarding tile map? Especially how
the column or row relates to coordinates?
What we trying to do is to extend the support of Carbon Tools
(http://www.thecarbonproject.com/ ) for retrieving maps from MGOS. So
far we are able to create session and grab title map from a .net windows
form. But in order to do tile caching locally, it will be good to know
how the tiling is done.
Thanks,
Velen
More information about the Mapguide_users
mailing list