double EXP_LVL1 CS_scale (Const char *cs_nam,double ll [2]) { extern double cs_Mone; /* -1.0 */ struct cs_Csprm_ *cs_ptr; double kk; cs_ptr = CSbcclu (cs_nam); if (cs_ptr != NULL) kk = CS_csscl (cs_ptr,ll); else kk = cs_Mone; return (kk); }
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); }
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; }