[mapguide-users] Tiled Map
Walt Welton-Lair
walt.welton-lair at autodesk.com
Thu Apr 6 17:36:48 EDT 2006
Thanks for pointing out the problem. I'll make sure this gets fixed.
Walt
-----Original Message-----
From: velen [mailto:vliang at thecarbonproject.com]
Sent: Thursday, April 06, 2006 5:33 PM
To: users at mapguide.osgeo.org
Subject: RE: [mapguide-users] Tiled Map
Jason,
Great tips! I just tried and it looks promising. I crashed the server
when
trying GETMAPIMAGE. It's my fault - SETDISPLAYHEIGHT was not populated.
I
was surprised that either "WebTier" or "Server" have not filter out bad
request. For now I'll do some error checking before submitting http
request.
Thanks,
Velen
-----Original Message-----
From: Jason Birch [mailto:Jason.Birch at nanaimo.ca]
Sent: Thursday, April 06, 2006 3:29 PM
To: users at mapguide.osgeo.org
Subject: RE: [mapguide-users] Tiled Map
You can figure out the calls to use via the API web interface:
http://localhost/mapguide/mapagent/index.html (might need to add the
port)
The first request that you would want to make would be to determine what
map definitions are available:
http://localhost/mapguide/mapagent/mapagent.fcgi?OPERATION=ENUMERATERESO
URCES&VERSION=1.0.0&LOCALE=en&RESOURCEID=Library://&TYPE=MapDefinition&D
EPTH=-1&FORMAT=text/xml
Then, for each of these, you would want to get the extents:
http://localhost/mapguide/mapagent/mapagent.fcgi?OPERATION=GETRESOURCECO
NTENT&VERSION=1.0.0&LOCALE=en&RESOURCEID=Library://Samples/Sheboygan/Map
s/Sheboygan.MapDefinition&FORMAT=text/xml
Then you would iterate through your tile pyramid:
http://localhost/mapguide/mapagent/mapagent.fcgi?OPERATION=GETMAPIMAGE&V
ERSION=1.0.0&LOCALE=en&MAPDEFINITION=Library%3A%2F%2FSamples%2FSheboygan
%2FMaps%2FSheboygan.MapDefinition&FORMAT=image/png&SETVIEWCENTERX=-87.73
&SETVIEWCENTERY=43.74&SETVIEWSCALE=5000&SETDISPLAYDPI=72&SETDISPLAYWIDTH
=200&SETDISPLAYHEIGHT=200
I tried playing around with the Data Extent parameters (which would be a
lot easier to work with for a tiling application) but it appears to be
disabled for a reason. I managed to crash the service several times by
manually specifying an envelope. I'll try again when 1.0.0 is released.
Jason
-----Original Message-----
From: velen [mailto:vliang at thecarbonproject.com]
Sent: Thursday, April 06, 2006 09:18
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
---------------------------------------------------------------------
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