MCPcopy Create free account
hub / github.com/MapServer/MapServer / msTileSetup

Function msTileSetup

maptile.c:236–324  ·  view source on GitHub ↗

* msTileSetup * * * * Called from mapserv.c, this is where the fun begins * * Set up projections and test the parameters for legality. * ************************************************************************/

Source from the content-addressed store, hash-verified

234 * Set up projections and test the parameters for legality. *
235 ************************************************************************/
236int msTileSetup(mapservObj* msObj) {
237#ifdef USE_TILE_API
238
239 char *outProjStr = NULL;
240 tileParams params;
241
242 /*
243 ** Load the metatiling information from the map file.
244 */
245 msTileGetParams(msObj->map, &params);
246
247 /*
248 ** Ensure all the LAYERs have a projection.
249 */
250 if( msTileSetProjections(msObj->map) != 0 ) {
251 return(MS_FAILURE);
252 }
253
254 /*
255 ** Set the projection string for this mode.
256 */
257 if( msObj->TileMode == TILE_GMAP || msObj->TileMode == TILE_VE ) {
258 outProjStr = SPHEREMERC_PROJ4;
259 } else {
260 return MS_FAILURE; /* Huh? No mode? */
261 }
262 if( msLoadProjectionString(&(msObj->map->projection), outProjStr) != 0 ) {
263 msSetError(MS_CGIERR, "Unable to load projection string.", "msTileSetup()");
264 return MS_FAILURE;
265 }
266
267 /*
268 ** Set up the output extents for this tilemode and tile coordinates
269 */
270 if( msObj->TileMode == TILE_GMAP ) {
271
272 int x, y, zoom;
273 double zoomfactor;
274
275 if( msObj->TileCoords ) {
276 if( msTileGetGMapCoords(msObj->TileCoords, &x, &y, &zoom) == MS_FAILURE )
277 return MS_FAILURE;
278 }
279 else {
280 msSetError(MS_WEBERR, "Tile parameter not set.", "msTileSetup()");
281 return MS_FAILURE;
282 }
283
284 if( params.metatile_level >= zoom ) {
285 msTileResetMetatileLevel(msObj->map);
286 }
287
288 zoomfactor = pow(2.0, (double)zoom);
289
290 /*
291 ** Check the input request for sanity.
292 */
293 if( x >= zoomfactor || y >= zoomfactor ) {

Callers 1

mainFunction · 0.85

Calls 6

msTileGetParamsFunction · 0.85
msTileSetProjectionsFunction · 0.85
msLoadProjectionStringFunction · 0.85
msSetErrorFunction · 0.85
msTileGetGMapCoordsFunction · 0.85
msTileResetMetatileLevelFunction · 0.85

Tested by

no test coverage detected