~ubuntu-branches/ubuntu/breezy/proj/breezy

« back to all changes in this revision

Viewing changes to src/nad_cvt.c

  • Committer: Bazaar Package Importer
  • Author(s): Peter S Galbraith
  • Date: 2004-11-06 19:44:53 UTC
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20041106194453-axnsmkh1zplal8mz
Tags: upstream-4.4.9
ImportĀ upstreamĀ versionĀ 4.4.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
        tb = in;
16
16
        tb.lam -= ct->ll.lam;
17
17
        tb.phi -= ct->ll.phi;
18
 
        tb.lam = adjlon(tb.lam);
 
18
        tb.lam = adjlon(tb.lam - PI) + PI;
19
19
        t = nad_intr(tb, ct);
20
20
        if (inverse) {
21
21
                LP del, dif;
27
27
 
28
28
                do {
29
29
                        del = nad_intr(t, ct);
30
 
                        if (del.lam == HUGE_VAL) return del;
 
30
 
 
31
                        /* This case used to return failure, but I have
 
32
                           changed it to return the first order approximation
 
33
                           of the inverse shift.  This avoids cases where the
 
34
                           grid shift *into* this grid came from another grid.
 
35
                           While we aren't returning optimally correct results
 
36
                           I feel a close result in this case is better than
 
37
                           no result.  NFW
 
38
                           To demonstrate use -112.5839956 49.4914451 against
 
39
                           the NTv2 grid shift file from Canada. */
 
40
                        if (del.lam == HUGE_VAL) 
 
41
                        {
 
42
                            if( getenv( "PROJ_DEBUG" ) != NULL )
 
43
                                fprintf( stderr, 
 
44
                                         "Inverse grid shift iteration failed, presumably at grid edge.\n"
 
45
                                         "Using first approximation.\n" );
 
46
                            /* return del */;
 
47
                            break;
 
48
                        }
 
49
 
31
50
                        t.lam -= dif.lam = t.lam - del.lam - tb.lam;
32
51
                        t.phi -= dif.phi = t.phi + del.phi - tb.phi;
33
52
                } while (i-- && fabs(dif.lam) > TOL && fabs(dif.phi) > TOL);
34
53
                if (i < 0) {
35
 
                        t.lam = t.phi = HUGE_VAL;
36
 
                        return t;
 
54
                    if( getenv( "PROJ_DEBUG" ) != NULL )
 
55
                        fprintf( stderr, 
 
56
                                 "Inverse grid shift iterator failed to converge.\n" );
 
57
                    t.lam = t.phi = HUGE_VAL;
 
58
                    return t;
37
59
                }
38
60
                in.lam = adjlon(t.lam + ct->ll.lam);
39
61
                in.phi = t.phi + ct->ll.phi;