Ticket #1392 (closed enhancement: fixed)

Opened 6 years ago

Last modified 5 years ago

patch to add more informative error messages to gdal_crs.c

Reported by: schuyler@… Owned by: dreamil@…
Priority: highest Milestone:
Component: GDAL_Raster Version: unspecified
Severity: minor Keywords:
Cc: neteler

Description

The crs.c code actually has more informative error indications than was being thrown via CPLError(). This patch gives the developer slightly more clue as to where things went wrong.

diff -Naur gdal-1.3.2/alg/gdal_crs.c gdal-1.3.2-new/alg/gdal_crs.c
--- gdal-1.3.2/alg/gdal_crs.c   2004-12-26 11:12:21.000000000 -0500
+++ gdal-1.3.2-new/alg/gdal_crs.c       2006-12-12 16:23:38.000000000 -0500
@@ -101,6 +101,13 @@
 void *GDALDeserializeGCPTransformer( CPLXMLNode *psTree );
 CPL_C_END

+static char *CRS_error_message[] = {
+    "Failed to compute GCP transform: Not enough points available",
+    "Failed to compute GCP transform: Transform is not solvable",
+    "Failed to compute GCP transform: Not enough memory"
+    "Failed to compute GCP transform: Parameter error",
+    "Failed to compute GCP transform: Internal error"
+};
 /* crs.c */
 static int CRS_georef(double, double, double *, double *,
                               double [], double [], int);
@@ -217,14 +224,13 @@
 /* -------------------------------------------------------------------- */
 /*      Compute the forward and reverse polynomials.                    */
 /* -------------------------------------------------------------------- */
-    if( CRS_compute_georef_equations( &sPoints,
+    int nCRSresult = CRS_compute_georef_equations( &sPoints,
                                       psInfo->adfToGeoX, psInfo->adfToGeoY,
                                       psInfo->adfFromGeoX, psInfo->adfFromGeoY,
-                                      nReqOrder ) != 1 )
+                                      nReqOrder );
+    if (nCRSresult != 1 )
     {
-        CPLError( CE_Failure, CPLE_AppDefined,
-                  "Failed to compute polynomial equations of desired order\n"
-                  "for provided control points." );
+        CPLError( CE_Failure, CPLE_AppDefined, CRS_error_message[-nCRSresult] );
         goto CleanupAfterError;
     }

Change History

Changed 6 years ago by warmerdam

Swapnil,

Could you apply this patch, and find some way to test it?  I think the
easiest way would be to create an image with 3 colinear GCPs and then use
gdalwarp to warp it.  You should get the message about "Transform is not
solvable". 

GCPs can be added to an image with gdal_translate and the -gcp option. 


Changed 6 years ago by hobu

Swapnil,

I applied the patch, with some minor modification to make sure it works on windows.

Howard

Changed 5 years ago by rouault

  • status changed from new to closed
  • resolution set to fixed

Fixed since quite some time!

Note: See TracTickets for help on using tickets.