MCPcopy Index your code
hub / github.com/MapServer/MapServer / msMapComputeGeotransform

Function msMapComputeGeotransform

mapobject.c:386–433  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

384extern int InvGeoTransform( double *gt_in, double *gt_out );
385
386int msMapComputeGeotransform( mapObj * map )
387
388{
389 double rot_angle;
390 double geo_width, geo_height, center_x, center_y;
391
392 map->saved_extent = map->extent;
393
394 /* Do we have all required parameters? */
395 if( map->extent.minx == map->extent.maxx
396 || map->width == 0 || map->height == 0 )
397 return MS_FAILURE;
398
399 rot_angle = map->gt.rotation_angle * MS_PI / 180.0;
400
401 geo_width = map->extent.maxx - map->extent.minx;
402 geo_height = map->extent.maxy - map->extent.miny;
403
404 center_x = map->extent.minx + geo_width*0.5;
405 center_y = map->extent.miny + geo_height*0.5;
406
407 /*
408 ** Per bug 1916 we have to adjust for the fact that map extents
409 ** are based on the center of the edge pixels, not the outer
410 ** edges as is expected in a geotransform.
411 */
412 map->gt.geotransform[1] =
413 cos(rot_angle) * geo_width / (map->width-1);
414 map->gt.geotransform[2] =
415 sin(rot_angle) * geo_height / (map->height-1);
416 map->gt.geotransform[0] = center_x
417 - (map->width * 0.5) * map->gt.geotransform[1]
418 - (map->height * 0.5) * map->gt.geotransform[2];
419
420 map->gt.geotransform[4] =
421 sin(rot_angle) * geo_width / (map->width-1);
422 map->gt.geotransform[5] =
423 - cos(rot_angle) * geo_height / (map->height-1);
424 map->gt.geotransform[3] = center_y
425 - (map->width * 0.5) * map->gt.geotransform[4]
426 - (map->height * 0.5) * map->gt.geotransform[5];
427
428 if( InvGeoTransform( map->gt.geotransform,
429 map->gt.invgeotransform ) )
430 return MS_SUCCESS;
431 else
432 return MS_FAILURE;
433}
434
435/************************************************************************/
436/* msMapPixelToGeoref() */

Callers 8

msPrepareImageFunction · 0.85
msWCSGetCoverageFunction · 0.85
msWCSGetCoverage20Function · 0.85
loadMapInternalFunction · 0.85
msUpdateMapFromURLFunction · 0.85
msMapSetExtentFunction · 0.85
msMapSetRotationFunction · 0.85
msMapSetSizeFunction · 0.85

Calls 1

InvGeoTransformFunction · 0.85

Tested by

no test coverage detected