double EXP_LVL1 CS_cnvrg (Const char *cs_nam,Const double ll [2]) { struct cs_Csprm_ *cs_ptr; double alpha; /* Perform the calculation. */ cs_ptr = CSbcclu (cs_nam); if (cs_ptr != NULL) alpha = CS_cscnv (cs_ptr,ll); else alpha = -360.0; return (alpha); }
int CStest8 (int verbose,int crypt) { extern char cs_MeKynm [128]; extern char cs_MeFunc [128]; extern double cs_Coords [3]; extern struct cs_Grptbl_ cs_CsGrptbl []; extern int cs_Error; int err_cnt; struct cs_Grptbl_ *tp; struct cs_Csgrplst_ *gp; struct cs_Csgrplst_ *grp_list; struct cs_Csprm_ *csprm; double xy [3]; double ll [3]; printf ("Exercising each coordinate system definition at least once.\n"); /* Loop through the group table and fetch a linked list for each group. Count the number in the group and add to the total in the group. */ err_cnt = 0; for (tp = cs_CsGrptbl;tp->group [0] != 0;tp += 1) { if (!CS_stricmp (tp->group,"LEGACY")) { continue; } CS_csgrp (tp->group,&grp_list); for (gp = grp_list;gp != NULL;gp = gp->next) { /* Activate this coordinate system. This ensures that every coordinate system is "set up" at least once in all of this. */ if (verbose) { printf ("Exercising coordinate system named %s.\n", gp->key_nm); } csprm = CS_csloc (gp->key_nm); if (csprm == NULL) { printf ("Couldn't setup coordinate system named %s.\n",gp->key_nm); err_cnt += 1; } else { /* Set information in case there is a floating point exception. */ CS_stncp (cs_MeKynm,gp->key_nm,sizeof (cs_MeKynm)); cs_Coords [0] = csprm->csdef.x_off; cs_Coords [1] = csprm->csdef.y_off; cs_Coords [2] = 0.0; /* Convert a coordinate, the false origin should be a safe one. */ xy [0] = csprm->csdef.x_off; xy [1] = csprm->csdef.y_off; xy [2] = 0.0; cs_Error = 0; CS_stncp (cs_MeFunc,"CS_cs2ll",sizeof (cs_MeFunc)); CS_cs2ll (csprm,ll,xy); CS_stncp (cs_MeFunc,"CS_ll2cs",sizeof (cs_MeFunc)); CS_ll2cs (csprm,xy,ll); CS_stncp (cs_MeFunc,"CS_csscl",sizeof (cs_MeFunc)); CS_csscl (csprm,ll); CS_stncp (cs_MeFunc,"CS_cscnv",sizeof (cs_MeFunc)); CS_cscnv (csprm,ll); if (cs_Error != 0) { printf ("Exercise of coordinate system %s failed.\n", csprm->csdef.key_nm); err_cnt += 1; } CS_free (csprm); } } CS_csgrpf (grp_list); } cs_MeKynm [0] = '\0'; cs_MeFunc [0] = '\0'; cs_Coords [0] = 0.0; cs_Coords [1] = 0.0; cs_Coords [2] = 0.0; return (err_cnt); }
int CStestC (bool verbose,long32_t duration) { int err_cnt; unsigned sequencer; struct cs_Grptbl_ *tp; struct cs_Csgrplst_ *gp; struct cs_Csgrplst_ *grp_list; struct cs_Csprm_ *csprm; double ll [3]; double xy [3]; double falseOrg [2]; double llAry [1][3]; double xyAry [1][3]; duration *= 10L; printf ("Trying very hard to produce a floating point exception.\n"); /* Loop through the group table and fetch a linked list for each group. Count the number in the group and add to the total in the group. */ err_cnt = 0; csprm = NULL; for (tp = cs_CsGrptbl;tp->group [0] != 0;tp += 1) { if (csprm != NULL) { CS_free (csprm); csprm = NULL; } if (!CS_stricmp (tp->group,"LEGACY")) { continue; } CS_csgrp (tp->group,&grp_list); for (gp = grp_list;gp != NULL;gp = gp->next) { if (csprm != NULL) { CS_free (csprm); csprm = NULL; } if (verbose) { printf ("Trying to cause a floating exception using %s.\n", gp->key_nm); } else { printf ("%s \r",gp->key_nm); } csprm = CS_csloc (gp->key_nm); if (csprm == NULL) { printf ("Couldn't setup coordinate system named %s.\n",gp->key_nm); err_cnt += 1; strcpy (cs_MeKynm,"???"); continue; } cs_MeFlag = 0; strcpy (cs_MeKynm,csprm->csdef.key_nm); sequencer = 0; while (CStestLLH (ll,csprm->cent_mer,&sequencer) == 0) { cs_Coords [LNG] = ll [0]; cs_Coords [LAT] = ll [1]; cs_Coords [HGT] = ll [2]; strcpy (cs_MeFunc,"CS_cssck"); CS_cssck (csprm,ll); if (cs_MeFlag) break; strcpy (cs_MeFunc,"CS_cssch"); CS_cssch (csprm,ll); if (cs_MeFlag) break; strcpy (cs_MeFunc,"CS_cscnv"); CS_cscnv (csprm,ll); if (cs_MeFlag) break; strcpy (cs_MeFunc,"CS_ll2cs"); CS_ll2cs (csprm,xy,ll); if (cs_MeFlag) break; llAry [0][0] = ll [0]; /* keep gcc compiler happy */ llAry [0][1] = ll [1]; llAry [0][2] = ll [2]; strcpy (cs_MeFunc,"CS_llchk"); CS_llchk (csprm,1,llAry); if (cs_MeFlag) break; } if (cs_MeFlag) { if (verbose) { printf ("\tLNG = %g, LAT = %g, HGT = %g \n",ll [0],ll [1],ll [2]); } err_cnt += 1; continue; } sequencer = 0; falseOrg [0] = csprm->csdef.x_off; falseOrg [1] = csprm->csdef.y_off; while (CStestXYZ (xy,falseOrg,&sequencer) == 0) { cs_Coords [XX] = xy [XX]; cs_Coords [YY] = xy [YY]; cs_Coords [ZZ] = xy [ZZ]; strcpy (cs_MeFunc,"CS_cs2ll"); CS_cs2ll (csprm,ll,xy); if (cs_MeFlag) break; strcpy (cs_MeFunc,"CS_llchk"); xyAry [0][0] = xy [0]; /* keep gcc compiler happy */ xyAry [0][1] = xy [1]; xyAry [0][2] = xy [2]; CS_xychk (csprm,1,xyAry); if (cs_MeFlag) break; } if (cs_MeFlag) { if (verbose) { printf ("\tXX = %g, YY = %g, ZZ = %g \n",xy [XX],xy [YY],xy [ZZ]); } err_cnt += 1; continue; } if (verbose) { printf (" \r"); } CS_free (csprm); csprm = NULL; } CS_csgrpf (grp_list); } printf (" \r"); return (err_cnt); }
CWnd* CcsTest::Calculate () { int status; CWnd* errorPtr; struct cs_Csprm_ *srcPtr; struct cs_Csprm_ *trgPtr; struct cs_Dtcprm_ *dtcPtr; double xy [3], ll [3]; char ctemp [512]; errorPtr = FetchSource (); if (errorPtr != NULL) goto error; xy [0] = m_SourceXY [0]; xy [1] = m_SourceXY [1]; if (m_ThreeDCalc) xy [2] = m_SourceXY [2]; else xy [2] = 0.0; // Set up the conversion. srcPtr = CSbcclu (m_SrcKeyName); if (srcPtr == NULL) { errorPtr = GetDlgItem (IDC_CSTST_SRCKEYNM); goto error; } trgPtr = CSbcclu (m_TrgKeyName); if (trgPtr == NULL) { errorPtr = GetDlgItem (IDC_CSTST_TRGKEYNM); goto error; } dtcPtr = CSbdclu (srcPtr,trgPtr,cs_DTCFLG_DAT_W,cs_DTCFLG_BLK_10); if (dtcPtr == NULL) { errorPtr = GetDlgItem (IDC_CSTST_SRCKEYNM); goto error; } // Do the conversion if (m_ThreeDCalc) { status = CS_cs3ll (srcPtr,ll,xy); } else { status = CS_cs2ll (srcPtr,ll,xy); } if (status == cs_CNVRT_OK) { m_SrcStatus = "OK"; } else if (status == cs_CNVRT_USFL) { m_SrcStatus = "Range"; } else if (status == cs_CNVRT_DOMN) { m_SrcStatus = "Domain"; } else if (status = cs_CNVRT_DEMO) { m_SrcStatus = "Demo"; } else { m_SrcStatus = "???"; } // Source Grid Scale and Convergence. m_SourceScale = CS_csscl (srcPtr,ll); m_SourceConvergence = CS_cscnv (srcPtr,ll); UpdateSource (); // Do the datum shift. if (m_ThreeDCalc) { status = CS_dtcvt3D (dtcPtr,ll,ll); } else { status = CS_dtcvt (dtcPtr,ll,ll); } if (status == 0) { m_TrgStatus.Empty (); } else if (status < 0) { m_TrgStatus = "DtErr"; errorPtr = GetDlgItem (IDC_CSTST_SRCKEYNM); goto error; } else { m_TrgStatus = "DtRng"; CS_errmsg (ctemp,sizeof (ctemp)); AfxMessageBox (ctemp); } // Target conversion if (m_ThreeDCalc) { status = CS_ll3cs (trgPtr,xy,ll); } else { status = CS_ll2cs (trgPtr,xy,ll); } if (m_TrgStatus.IsEmpty ()) { if (status == cs_CNVRT_OK) { m_TrgStatus = "OK"; } else if (status == cs_CNVRT_USFL) { m_TrgStatus = "Range"; } else if (status == cs_CNVRT_DOMN) { m_TrgStatus = "Domain"; } else if (status = cs_CNVRT_DEMO) { m_TrgStatus = "Demo"; } else { m_TrgStatus = "???"; } } m_TargetXY [0] = xy [0]; m_TargetXY [1] = xy [1]; if (m_ThreeDCalc) m_TargetXY [2] = xy [2]; else m_TargetXY [2] = 0.0; // Target Grid Scale and Convergence. m_TargetScale = CS_csscl (trgPtr,ll); m_TargetConvergence = CS_cscnv (trgPtr,ll); // Update the display UpdateTarget (); UpdateData (FALSE); return NULL; error: m_TrgStatus = "Error"; m_TargetXY [0] = 0.0; m_TargetXY [1] = 0.0; m_TargetXY [2] = 0.0; UpdateTarget (); UpdateData (FALSE); return errorPtr; }