[Chameleon] ExtentHistory compareEntries()

McGraw, Joanne mcgrawj at AGR.GC.CA
Thu Nov 24 13:38:50 EST 2005


Paul, 
I just went with these changes in compareEntries() (actually in the widget I'm extending ExtentHistory with so I don't lose this in future):

        //text minx
        $d = abs($e1[0] - $e2[0]);
        if (abs($d - ($w1 * $pw)) > $tolerance)
            return false;

        //text miny
        $d = abs($e1[1] - $e2[1]);
        if (abs($d - ($h1 * $ph)) > $tolerance)
            return false;

        //text maxx
        $d = abs($e1[2] - $e2[2]);
        if (abs($d - ($w1 * $pw)) > $tolerance)
            return false;

        //text maxy
        $d = abs($e1[3] - $e2[3]);
        if (abs($d - ($h1 * $ph)) > $tolerance)
            return false;

Whether it's reasonable or not, others can determine. It certainly took care of my particular problem where the same extents were being evaluated to be unequal.

Cheers,
jtm

-----Original Message-----
From: Paul Spencer [mailto:pspencer at dmsolutions.ca] 
Sent: Thursday, November 24, 2005 1:29 PM
To: McGraw, Joanne
Cc: chameleon at lists.maptools.org
Subject: Re: [Chameleon] ExtentHistory compareEntries()

Joanne,

if you can come up with a way to use the tolerance in the evaluation  
in a reasonable way, please file a bug and we'll put your code in.

Cheers

Paul

On 23-Nov-05, at 11:34 AM, McGraw, Joanne wrote:

> Hello all,
>
> In ExtentHistory's compareEntries(), the tolerance 0.005 is being  
> used to evaluate whether or not there is a difference in the width  
> and height but is not being used to limit differences between the  
> various min/max extents. Should it be?
>
> In a scenario I can duplicate, compareEntries() is comparing the  
> two extents shown at the bottom of this email, considering them  
> unequal and, therefore, adding another extents entry to the stack.  
> Another extents entry that is the exact same as the one before it,  
> but the code considers them different because it is evaluating the  
> difference between the minx of $e1 and $e2 as:
>
> 0.00000000488944351673 - 0.00000000325962901115 =  
> 0.00000000162981450558
>
> That value is really just the result of rounding errors in the math  
> to get those two values. A more complete showing of the numbers  
> that got me to them is below.
>
> So, should the tolerance be used to evaluate the differences  
> between the coordinates, as well as for the width and height? I  
> assume yes, simply because comparisons of real numbers are usually  
> limited by a tolerance of some kind, even if it's just 0.001  
> (depending on your numbers' precision). If this should be entered  
> as a bug or if anyone is aware of why no tolerance is being used in  
> the evaluation, let me know.
>
> Cheers,
> jtm
>
>
> These first four are showing the values held in the identified  
> element for the $e1 and then the $e2 extent arrays:
>
> [23-Nov-2005 10:45:08] 0 1177671.43072 = 1177671.43072
> [23-Nov-2005 10:45:08] 1 6299760.16495 = 6299760.16495
> [23-Nov-2005 10:45:08] 2 1364643.55198 = 1364643.55198
> [23-Nov-2005 10:45:08] 3 6392540.6704 = 6392540.6704
>
> These are basically showing the results of the math to get to the  
> point where the minx is being evaluated as different:
>
> [23-Nov-2005 10:45:08] w1 = 186972.121257; w2 = 186972.121257; abs 
> (w1 - w2) = 3.25962901115E-009; abs(w1 - w2)/w2 =  
> 1.74337702821E-014; pw = 1.74337702821E-014; tolerance = 0.005
> [23-Nov-2005 10:45:08] h1 = 92780.5054541; h2 = 92780.5054541; abs 
> (h1 - h2) = 1.86264514923E-009; abs(h1 - h2)/h2 =  
> 2.00758245508E-014; ph = 2.00758245508E-014; tolerance = 0.005
> [23-Nov-2005 10:45:08] e1[0] = 1177671.43072; e2[0] =  
> 1177671.43072; abs(e1[0] - e2[0]) = 4.88944351673E-009; w1 * pw =  
> 3.25962901115E-009
> [23-Nov-2005 10:45:08] minx = 4.88944351673E-009 > 3.25962901115E-009
> [23-Nov-2005 10:45:08] returning false
>
>
> Joanne T. McGraw
> GIS Data Analyst / Analyste des données du SIG
> Agriculture and Agri-Food Canada / Agriculture et Agroalimentaire  
> Canada
> Telephone/Téléphone: (613) 759-6103
> Facsimile/Télécopieur: (613) 759-1937
> 960 Carling Ave, #1136
> Ottawa, Ontario
> K1A 0C6
>
> mcgrawj at agr.gc.ca
>
>
>
> _______________________________________________
> Chameleon mailing list
> Chameleon at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/chameleon

+-----------------------------------------------------------------+
|Paul Spencer                           pspencer at dmsolutions.ca   |
+-----------------------------------------------------------------+
|Applications & Software Development                              |
|DM Solutions Group Inc                 http://www.dmsolutions.ca/|
+-----------------------------------------------------------------+







More information about the Chameleon mailing list