Index: trunk/psLib/src/astro/psCoord.c
===================================================================
--- trunk/psLib/src/astro/psCoord.c	(revision 41523)
+++ trunk/psLib/src/astro/psCoord.c	(revision 41531)
@@ -1000,5 +1000,5 @@
     const psPlaneTransform *in,
     psRegion region,
-    int nSamples)
+    int nSamples, int extraOrders)
 {
     PS_ASSERT_PTR_NON_NULL(in, NULL);
@@ -1026,8 +1026,13 @@
     PS_ASSERT_INT_LARGER_THAN_OR_EQUAL(nSamples, 1, NULL);
 
-    //
-    // Allocate a new psPlaneTransform if "out" is NULL, or has the wrong size.
-    //
-    psS32 order = in->x->nX;
+
+    // Allocate a new psPlaneTransform if "out" is NULL, or has the wrong size.  For a
+    // non-linear transformation, the inverted solution must have a higher order than the
+    // forward solution.  Since we are fitting a dense grid (generated below), it is not a
+    // problem (in terms of over-fitting) to use a higher order
+
+    // XXX : the extra orders supplied here needs to be something supplied by the user
+
+    psS32 order = in->x->nX + extraOrders;
     psPlaneTransform *myPT = NULL;
     if (out == NULL) {
@@ -1036,13 +1041,4 @@
       // the user has supplied a model with a specific order : fit that order
       myPT = psMemIncrRefCounter(out); // we need to return something which can be freed
-# if (0)
-        if ((out->x->nX == order) && (out->x->nY == order) &&
-	    (out->y->nX == order) && (out->y->nX == order)) {
-            myPT = out;
-        } else {
-            psFree(out);
-            myPT = psPlaneTransformAlloc(order, order);
-        }
-# endif
     }
 
Index: trunk/psLib/src/astro/psCoord.h
===================================================================
--- trunk/psLib/src/astro/psCoord.h	(revision 41523)
+++ trunk/psLib/src/astro/psCoord.h	(revision 41531)
@@ -348,5 +348,6 @@
     const psPlaneTransform *in,        ///< transform to invert
     psRegion region,                   ///< region to fit for non-linear transform inversion
-    int nSamples                       ///< number of samples in each axis for fit
+    int nSamples,                       ///< number of samples in each axis for fit
+    int extraOrders			///< increase the order of the output by the amount vs input, if input is non-linear
 );
 
