I am using MapSuite Web Edition, specifically MapSuiteCore 8.0.0.125
We have a web service that uses MapSuite to render vector and raster data to Bitmap tiles that get overlaid on Bing/Google maps
We had been using the Proj4 parameter string
+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs
to specify the external projection-- and this seemed to be working fine.
However, I discovered that the rendered data was actually being plotted offset south (in the northern hemisphere) or north (in the southern hemisphere) of where it was supposed to be with respect to the underlying map-- I read up on this issue and discovered that this was because Google and Bing maps don’t use WGS84 ellipsoid on output rendering. I found out about a parameter for Proj4 that makes the projection match that used by Google/Bing, +nadsgrid=null
I added that to the Proj4 parameter string we are using, to get:
+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +nadgrids=null
and sure enough, with these parameters all our data is being plotted correctly with respect to the maps.
The problem is that our web service now crashes intermittently. The crashes bring down the IIS 7 App Pool but leave no other log or trace. The only difference between the working and crashing web service is the additional parameter in the Proj4 parameter string. The crash appears to happen when we are trying to render a source .png with a 4326 projection into one of our tiles. The relevant source code appears below:
(The .png file’s source projection proj4 parameter is
+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs)
So to summarize:
Use
+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs
everything “works” but projection is off
Use
+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +nadgrids=null
projection is accurate but crashes IIS pretty often when rendering a tile with a re-projected .PNG file.
Does anyone know of a fix or workaround for this issue? I understand that the +nadgrids=null is a relatively recent update to the underlying Proj4 library-- perhaps there is a fix for this in a more recent version.
Relevant source:
var rs = new RectangleShape(pngWestExtent, pngNorthExtent, pngEastExtent, pngSouthExtent);
GdiPlusRasterLayer worldImageLayer = new GdiPlusRasterLayer(null, rs) {
InterpolationMode = interpolationMode.HiQualityBilinear
};
((GdiPlusRasterSource)(worldImageLayer.ImageSource)).StreamLoading += LoadFromStream;
if (sourceEpsg != targetEpsg)
{
ManagedProj4Projection proj4 = new ManagedProj4Projection("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs",
"+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +nadgrids=null"
);
proj4.Open();
worldImageLayer.ImageSource.Projection = proj4;
}