= !MapGuide RFC 51 - Raster Re-projection = This page contains an change request (RFC) for the !MapGuide Open Source project. More !MapGuide RFCs can be found on the [wiki:MapGuideRfcs RFCs] page. == Status == ||RFC Template Version||(1.0)|| ||Submission Date|| July 14, 2008 || ||Last Modified|| Tony Fang [[Timestamp]]|| ||Author||Tony Fang|| ||RFC Status||draft|| ||Implementation Status||pending|| ||Proposed Milestone||2.1|| ||Assigned PSC guide(s)||(when determined)|| ||'''Voting History'''|| || ||+1|| || ||+0|| || ||-0|| || ||-1|| || ||no vote|| || == Overview == This is a proposal to add an efficient raster re-projection algorithm that is based on tessellating an image into smaller triangles and re-projecting the triangles. == Motivation == !MapGuide does not currently support any form of raster re-projection. If a user has a raster feature source, it can only be displayed in a !MapGuide map that uses the same coordinate system as the raster data. Previously, in order for application developers to use images in multiple coordinate systems, they needed to create copies of the images in each coordinate system. The re-projection capability that we are adding will allow developers to not have to have multiple versions of the same image (re-projected to different coordinate systems) at the cost of about 25% degradation in performance. == Proposed Solution == We will use a tessellation algorithm to re-project the raster data from one coordinate system (CS) to another. We must first determine how much of the original image is required by projecting the extents of the viewport (or map) into the image's CS. This is the clipped image. Then we project the extents of the clipped image into the viewport's CS, and then into device space. A mesh of uniform triangles is created in device space. Each point in the triangle mesh is transformed from device space, to the viewport's CS, to the image's CS, and then to device space. The image will then be rendered using a transform created from the two triangle meshes. Because the triangle mesh is in device space, choosing its size guarantees you a minimum level of accuracy: the error in the re-projected image will never be greater than the size of the individual triangles. ||[[Image(raster_reprojection_viewport.PNG)]]|| ||Figure 1. The blue mesh of triangles represents the extents of the projected image. The thick black lines represent the image. On the left we have the viewport. The blue On the right we have the image re-projected into the viewport's CS.|| The balance between performance and accuracy of the transformation is controlled by the number of triangles created for each raster. The configuration settings will control the size and number of triangles created. Configuration will be done through the serverconfig.ini. The category and setting names for this configuration are: {{{ [RenderingServiceProperties] # ***************************************************************************** # R E N D E R I N G S E R V I C E # # Property Name Description # ----------------------------------------------------------------------------- # RasterGridSize Size of raster re-projection grid in pixels # ***************************************************************************** RasterGridSize = 100 }}} Descriptive error messages will be logged to handle invalid configuration settings, invalid data, unsupported transformations etc. In keeping with !MapGuideā€™s current behavior, if the re-projection fails for any reason, the map will still be rendered and returned, using any other layers that it contains, and the failed layer(s) will be skipped. We will add an optimization if the re-projection is a simple datum shift. The image will simply be shifted, and the advanced algorithm will not be invoked. We will support re-projecting raster in drawing sources. == Implications == WMS is also a raster feature source and will be affected by this algorithm. The AGG and DWF Renderers will support raster re-projection. The GD Renderer is on hold pending RFC 52 - Remove GD Renderer. == Test Plan == Unit tests should cover: * The most common raster image formats (ECW, !MrSid, TIFF) * Re-projections between each of the main coordinate system types Unit tests should also validate that error conditions are handled gracefully. == Funding/Resources == Autodesk