Hi,
I think i found a problem in the image getprojection function.
I am trying to load a geotiff images, no prj files associated.
If the BSTR variable is not set then the variable is not modified, with no error.
I think the problem is in the way looking for prj file. It doesn't test for the presence of the prj, and so the Proj' string is not set to "", and it doesn't check for projection using GDAL
from mapwingis 4.8 (svn)
STDMETHODIMP CImageClass::GetProjection(BSTR * Proj4)
{
USES_CONVERSION;
// If the .prj file exists, load it.
CString prjFilename = FileName.Left(FileName.GetLength() - 3) + "prj";
if (prjFilename != "")
{
char * prj4 = NULL;
ProjectionTools * p = new ProjectionTools();
p->GetProj4FromPRJFile(prjFilename.GetBuffer(), &prj4);
if (prj4 != NULL)
*Proj4 = A2BSTR(prj4);
CPLFree(prj4);
delete p; //added by Lailin Chen 12/30/2005
}
else
*Proj4 = A2BSTR("");
Regards
Comments: There is an error indeed. But instead of fixing it I added Image.GeoProjection property (projection will be read during image opening). Image.GetProjection is redirected to this new property (the same way it works for shapefiles).
I think i found a problem in the image getprojection function.
I am trying to load a geotiff images, no prj files associated.
If the BSTR variable is not set then the variable is not modified, with no error.
I think the problem is in the way looking for prj file. It doesn't test for the presence of the prj, and so the Proj' string is not set to "", and it doesn't check for projection using GDAL
from mapwingis 4.8 (svn)
STDMETHODIMP CImageClass::GetProjection(BSTR * Proj4)
{
USES_CONVERSION;
// If the .prj file exists, load it.
CString prjFilename = FileName.Left(FileName.GetLength() - 3) + "prj";
if (prjFilename != "")
{
char * prj4 = NULL;
ProjectionTools * p = new ProjectionTools();
p->GetProj4FromPRJFile(prjFilename.GetBuffer(), &prj4);
if (prj4 != NULL)
*Proj4 = A2BSTR(prj4);
CPLFree(prj4);
delete p; //added by Lailin Chen 12/30/2005
}
else
*Proj4 = A2BSTR("");
Regards
Comments: There is an error indeed. But instead of fixing it I added Image.GeoProjection property (projection will be read during image opening). Image.GetProjection is redirected to this new property (the same way it works for shapefiles).