[mapguide-users] Tiled Map
Traian Stanev
traian.stanev at autodesk.com
Thu Apr 6 14:06:26 EDT 2006
GETMAPIMAGE will return an image with all layers, not just base layers.
If the MapGuide server you are using accepts Anonymous users, you might
not even have to authenticate.
Traian
-----Original Message-----
From: velen [mailto:vliang at thecarbonproject.com]
Sent: Thursday, April 06, 2006 1:59 PM
To: users at mapguide.osgeo.org
Subject: RE: [mapguide-users] Tiled Map
Traian,
Yes - I am sending http request via fcgi. Sorry to confuse you. Let me
elaborate:
Since we're extending our API (CarbonTools), we thought that programmers
who
use the API may or may not have a server running locally. Further more,
the
API users may or may not be building a web browser type of application.
So
our plan of attack is to see if our API can do something like mapagent.
This
way the location of mapguide server is transparent to the API users.
My main focus now is to be able to get tile images. As you point out,
GETTILEIMAGE requires a base layer (as well as an established web
browser
session?), which a windows application (.net winform in particular) may
not
have.
Velen
-----Original Message-----
From: Traian Stanev [mailto:traian.stanev at autodesk.com]
Sent: Thursday, April 06, 2006 12:43 PM
To: users at mapguide.osgeo.org
Subject: RE: [mapguide-users] Tiled Map
What do you mean? Are you looking for an http request that will return a
map image? In that case you can probably use the exisitng GETMAPIMAGE
operation with a url like:
http://localhost/mapguide/mapagent/mapagent.fcgi?OPERATION=GETMAPIMAGE&V
ERSION=1.0.0&LOCALE=en&MAPDEFINITION=Library://Samples/Sheboygan/Maps/Sh
eboygan.MapDefinition&FORMAT=PNG
as discussed earlier in the "MapAgent parameters" thread. You can add
extra arguments to this to specify which piece of the map you want at
what scale. This call might require you to authenticate yourself to the
MapGuide server.
If you have a running Mapguide server, you can play with GETMAPIMAGE
requests using the test html form we provide. See attached screenshot
for which page to look for.
If you would like to use the API directly from code, then RenderMap is
public, so you can just call it directly from your code.
Traian
-----Original Message-----
From: velen [mailto:vliang at thecarbonproject.com]
Sent: Thursday, April 06, 2006 12:18 PM
To: users at mapguide.osgeo.org
Subject: RE: [mapguide-users] Tiled Map
Traian,
Thank you for the pointers. Good point on generating tiles without base
layer group - that's exactly what we need.
What are the steps to expose RenderMap(or Similar functionality) via
fcgi(MapAgent)? This will be nice because then our upcoming ASP.NET API
will
be able to use this service also.
Velen
-----Original Message-----
From: Traian Stanev [mailto:traian.stanev at autodesk.com]
Sent: Thursday, April 06, 2006 9:07 AM
To: users at mapguide.osgeo.org
Subject: RE: [mapguide-users] MapAgent parameters - Tiled Map
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
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe at mapguide.osgeo.org
For additional commands, e-mail: users-help at mapguide.osgeo.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe at mapguide.osgeo.org
For additional commands, e-mail: users-help at mapguide.osgeo.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe at mapguide.osgeo.org
For additional commands, e-mail: users-help at mapguide.osgeo.org
More information about the Mapguide-users
mailing list