void CelSelect::ShowDetails () { double flat; struct cs_Eldef_ *elPtr; elPtr = CS_eldef (m_KeyName); if (elPtr == NULL) { char errMesg [256]; CS_errmsg (errMesg,sizeof (errMesg)); AfxMessageBox (errMesg); return; } flat = 0.0; if (fabs (elPtr->flat) > 1.0E-10) flat = 1.0 / elPtr->flat; m_Description = elPtr->name; m_Source = elPtr->source; m_Numbers.Format ("%12.3f, %12.3f, %10.5f, %10.8f", elPtr->e_rad, elPtr->p_rad, flat, elPtr->ecent * elPtr->ecent); CS_free (elPtr); UpdateData (FALSE); return; }
///////////////////////////////////////////////////////////////////////////// // CnewKeyName message handlers void CnewKeyName::OnOK() { char keyName [32]; if (!UpdateData (TRUE)) return; // Verify that the new meets other requirements. strncpy (keyName,(LPCTSTR)m_NewKeyName,sizeof (keyName)); keyName [sizeof (keyName) - 1] = '\0'; if (CS_nampp (keyName) != 0) { // Show dialog box error and return. // By not calling CDialog::OnOK, the dialog box remains active. char errMesg [256]; CS_errmsg (errMesg,sizeof (errMesg)); AfxMessageBox (errMesg); return; } // Note, CS_nampp doesn't know that this is a new name, but we do. So we // enforce the cs_Unique restriction if active. if (cs_Unique != '\0' && strchr (keyName,cs_Unique) == NULL && m_Type != NonDict) { char errMsg [256]; sprintf (errMsg,"Keynames of user definitions must contain the '%c' character to avoid name collisions with\nupdate distributions. Please adjust name appropriately.",cs_Unique); AfxMessageBox (errMsg,MB_OK | MB_ICONEXCLAMATION); return; } // Verify that the new name does not already exist. switch (m_Type) { case CoordSys: if (CS_csIsValid (keyName)) { AfxMessageBox ("Coordinate system with this name already exists.\nPlease choose another name.",MB_OK | MB_ICONEXCLAMATION); return; } break; case Datum: if (CS_dtIsValid (keyName)) { AfxMessageBox ("Datum with this key name already exists.\nPlease choose another name.",MB_OK | MB_ICONEXCLAMATION); return; } break; case Ellipsoid: if (CS_elIsValid (keyName)) { AfxMessageBox ("Ellipsoid with this key name already exists.\nPlease choose another name.",MB_OK | MB_ICONEXCLAMATION); return; } break; case NonDict: default: break; } // If we're still here, we have a valid name. CDialog::OnOK(); }
void CcsTest::OnCststReverse() { CWnd* errorPtr; CString tmpSystem; double tmpXY [3]; // Capture status of the check boxes before we proceed. if (!UpdateData (TRUE)) return; tmpSystem = m_SrcKeyName; m_SrcKeyName = m_TrgKeyName; m_TrgKeyName = tmpSystem; SetLabels (false); SetLabels (true); tmpXY [0] = m_SourceXY [0]; tmpXY [1] = m_SourceXY [1]; tmpXY [2] = m_SourceXY [2]; m_SourceXY [0] = m_TargetXY [0]; m_SourceXY [1] = m_TargetXY [1]; m_SourceXY [2] = m_TargetXY [2]; m_TargetXY [0] = tmpXY [0]; m_TargetXY [1] = tmpXY [1]; m_TargetXY [2] = tmpXY [2]; UpdateSource (); FetchSource (); errorPtr = Calculate (); if (errorPtr == NULL) { UpdateTarget (); errorPtr = GetDlgItem (IDC_CSTST_SRCXLAT); } else { char ctemp [256]; CS_errmsg (ctemp,sizeof (ctemp)); AfxMessageBox (ctemp); } GotoDlgCtrl (errorPtr); UpdateData (FALSE); return; }
///////////////////////////////////////////////////////////////////////////// // CcsTest message handlers void CcsTest::OnCststCalculate() { CWnd* errorPtr; CWnd* rvPtr; char ctemp [256]; if (!UpdateData (TRUE)) return; errorPtr = Calculate (); if (errorPtr != NULL) { CS_errmsg (ctemp,sizeof (ctemp)); AfxMessageBox (ctemp); } else { errorPtr = GetDlgItem (IDC_CSTST_SRCXLAT); } GotoDlgCtrl (errorPtr); rvPtr = GetDlgItem (ID_CSTST_REVERSE); if (rvPtr != NULL) rvPtr->EnableWindow (TRUE); UpdateData (FALSE); }
void CdtSelect::ShowDetails () { int ii, ident; struct cs_Dtdef_ *dtPtr; struct cs_Eldef_ *elPtr; char description [64]; dtPtr = CS_dtdef (m_KeyName); if (dtPtr == NULL) { char errMesg [256]; CS_errmsg (errMesg,sizeof (errMesg)); AfxMessageBox (errMesg); return; } m_Description = dtPtr->name; m_Source = dtPtr->source; elPtr = CS_eldef (dtPtr->ell_knm); if (elPtr == NULL) m_Ellipsoid = "???"; else { m_Ellipsoid = elPtr->name; CS_free (elPtr); } m_Technique = "???"; for (ii = 0; CS_viaEnum (ii,description,sizeof (description),&ident) > 0; ii += 1) { if (dtPtr->to84_via == ident) { m_Technique = description; break; } } CS_free (dtPtr); UpdateData (FALSE); return; }
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; }
int main (int argc,char *argv []) { extern char cs_Dir []; extern char* cs_DirP; extern char cs_Csname []; extern char cs_Dtname []; extern char cs_Elname []; int cmpVal, iTmp; int csDiffCnt, dtDiffCnt, elDiffCnt; int dummy; int nlFlag; csFILE *wasStrm, *isStrm; char wasDir [MAXPATH]; char isDir [MAXPATH]; char errorText [260]; struct cs_Csdef_ wasCsDef, isCsDef; struct cs_Dtdef_ wasDtDef, isDtDef; struct cs_Eldef_ wasElDef, isElDef; csDiffCnt = 0; dtDiffCnt = 0; elDiffCnt = 0; if (argc != 3) Usage (); strncpy (wasDir,argv [1],sizeof (wasDir)); wasDir [sizeof (wasDir) - 1] = '\0'; strncpy (isDir,argv [2],sizeof (isDir)); isDir [sizeof (isDir) - 1] = '\0'; if (CS_altdr (wasDir) != 0) { printf ("%s file not found in %s directory.\n",cs_Csname,wasDir); Usage (); } CS_stcpy (cs_DirP,cs_Dtname); if (CS_access (cs_Dir,4) != 0) { printf ("%s file not found in %s directory.\n",cs_Dtname,wasDir); Usage (); } CS_stcpy (cs_DirP,cs_Elname); if (CS_access (cs_Dir,4) != 0) { printf ("%s file not found in %s directory.\n",cs_Elname,wasDir); Usage (); } if (CS_altdr (isDir) != 0) { printf ("%s file not found in %s directory.\n",cs_Csname,isDir); Usage (); } CS_stcpy (cs_DirP,cs_Dtname); if (CS_access (cs_Dir,4) != 0) { printf ("%s file not found in %s directory.\n",cs_Dtname,isDir); Usage (); } CS_stcpy (cs_DirP,cs_Elname); if (CS_access (cs_Dir,4) != 0) { printf ("%s file not found in %s directory.\n",cs_Elname,isDir); Usage (); } /* Ok, we're ready to do our thing. Do coordinate systems first. */ CS_altdr (wasDir); /*lint !e534 */ wasStrm = CS_csopn (_STRM_BINRD); if (wasStrm == NULL) { printf ("Open of %s in the 'WAS' directory failed.\n",cs_Csname); Usage (); } CS_altdr (isDir); /*lint !e534 */ isStrm = CS_csopn (_STRM_BINRD); if (isStrm == NULL) { printf ("Open of %s in the 'IS' directory failed.\n",cs_Csname); Usage (); } /* Now, we loop through the dictionaries. In this module, we simply compare key names, looking for new definitions, or deleted definitions. When we have definitions with the same name, we call CS_csDiff to report any differences. First, we prime the pump. */ iTmp = CS_csrd (wasStrm,&wasCsDef,&dummy); if (iTmp < 0) { CS_errmsg (errorText,sizeof (errorText)); printf ("%s\n",errorText); Usage (); } if (iTmp == 0) { printf ("'WAS' coordinate system dictionary is empty.\n"); Usage (); } iTmp = CS_csrd (isStrm,&isCsDef,&dummy); if (iTmp < 0) { CS_errmsg (errorText,sizeof (errorText)); printf ("%s\n",errorText); Usage (); } if (iTmp == 0) { printf ("'IS' coordinate system dictionary is empty.\n"); Usage (); } nlFlag = FALSE; while (TRUE) { cmpVal = CS_stricmp (wasCsDef.key_nm,isCsDef.key_nm); if (cmpVal < 0) { if (nlFlag) { printf ("\n"); nlFlag = FALSE; } printf ("%s deleted from coordinate system dictionary!!!\n",wasCsDef.key_nm); csDiffCnt += 1; } else if (cmpVal > 0) { if (nlFlag) { printf ("\n"); nlFlag = FALSE; } printf ("%s added to coordinate system dictionary!!!\n",isCsDef.key_nm); csDiffCnt += 1; } else { /* Normal case, we have two definitions with the same name, */ iTmp = CS_csDiff (stdout,&wasCsDef,&isCsDef); if (iTmp != 0) { csDiffCnt += 1; nlFlag = TRUE; } } if (cmpVal >= 0) { iTmp = CS_csrd (isStrm,&isCsDef,&dummy); if (iTmp < 0) { CS_errmsg (errorText,sizeof (errorText)); printf ("%s\n",errorText); Usage (); } if (iTmp == 0) { CS_fclose (isStrm); isStrm = NULL; break; } } if (cmpVal <= 0) { iTmp = CS_csrd (wasStrm,&wasCsDef,&dummy); if (iTmp < 0) { CS_errmsg (errorText,sizeof (errorText)); printf ("%s\n",errorText); Usage (); } if (iTmp == 0) { CS_fclose (wasStrm); wasStrm = NULL; break; } } } /* Finish up properly. */ nlFlag = TRUE; while (wasStrm != NULL) { iTmp = CS_csrd (wasStrm,&wasCsDef,&dummy); if (iTmp > 0) { if (nlFlag) { printf ("\n"); nlFlag = FALSE; } printf ("%s deleted from coordinate system dictionary!!!\n",wasCsDef.key_nm); csDiffCnt += 1; } else if (iTmp == 0) { CS_fclose (wasStrm); wasStrm = NULL; } else { CS_errmsg (errorText,sizeof (errorText)); printf ("%s\n",errorText); Usage (); } } while (isStrm != NULL) { iTmp = CS_csrd (isStrm,&wasCsDef,&dummy); if (iTmp > 0) { if (nlFlag) { printf ("\n"); nlFlag = FALSE; } printf ("%s added to coordinate system dictionary!!!\n",isCsDef.key_nm); csDiffCnt += 1; } else if (iTmp == 0) { CS_fclose (isStrm); isStrm = NULL; } else { CS_errmsg (errorText,sizeof (errorText)); printf ("%s\n",errorText); Usage (); } } if (csDiffCnt == 0) { printf ("\nCoordinate system dictionaries are the same.\n\n"); } else { printf ("\n%d coordinate systems are different.\n\n",csDiffCnt); } /* Done with the coordinate system dictionary. Same as above, but with the Datum Dictionary this time. */ CS_altdr (wasDir); /*lint !e534 */ wasStrm = CS_dtopn (_STRM_BINRD); if (wasStrm == NULL) { printf ("Open of %s in the 'WAS' directory failed.\n",cs_Dtname); Usage (); } CS_altdr (isDir); /*lint !e534 */ isStrm = CS_dtopn (_STRM_BINRD); if (isStrm == NULL) { printf ("Open of %s in the 'IS' directory failed.\n",cs_Dtname); Usage (); } iTmp = CS_dtrd (wasStrm,&wasDtDef,&dummy); if (iTmp < 0) { CS_errmsg (errorText,sizeof (errorText)); printf ("%s\n",errorText); Usage (); } if (iTmp == 0) { printf ("'WAS' datum dictionary is empty.\n"); Usage (); } iTmp = CS_dtrd (isStrm,&isDtDef,&dummy); if (iTmp < 0) { CS_errmsg (errorText,sizeof (errorText)); printf ("%s\n",errorText); Usage (); } if (iTmp == 0) { printf ("'IS' datum dictionary is empty.\n"); Usage (); } nlFlag = FALSE; while (TRUE) { cmpVal = CS_stricmp (wasDtDef.key_nm,isDtDef.key_nm); if (cmpVal < 0) { if (nlFlag) { printf ("\n"); nlFlag = FALSE; } printf ("%s deleted from datum dictionary!!!\n",wasDtDef.key_nm); dtDiffCnt += 1; } else if (cmpVal > 0) { if (nlFlag) { printf ("\n"); nlFlag = FALSE; } printf ("%s added to datum dictionary!!!\n",isDtDef.key_nm); dtDiffCnt += 1; } else { /* Normal case, we have two definitions with the same name, */ iTmp = CS_dtDiff (stdout,&wasDtDef,&isDtDef); if (iTmp != 0) { dtDiffCnt += 1; nlFlag = TRUE; } } if (cmpVal >= 0) { iTmp = CS_dtrd (isStrm,&isDtDef,&dummy); if (iTmp < 0) { CS_errmsg (errorText,sizeof (errorText)); printf ("%s\n",errorText); Usage (); } if (iTmp == 0) { CS_fclose (isStrm); isStrm = NULL; break; } } if (cmpVal <= 0) { iTmp = CS_dtrd (wasStrm,&wasDtDef,&dummy); if (iTmp < 0) { CS_errmsg (errorText,sizeof (errorText)); printf ("%s\n",errorText); Usage (); } if (iTmp == 0) { CS_fclose (wasStrm); wasStrm = NULL; break; } } } nlFlag = TRUE; while (wasStrm != NULL) { iTmp = CS_dtrd (wasStrm,&wasDtDef,&dummy); if (iTmp > 0) { if (nlFlag) { printf ("\n"); nlFlag = FALSE; } printf ("%s deleted from datum dictionary!!!\n",wasDtDef.key_nm); dtDiffCnt += 1; } else if (iTmp == 0) { CS_fclose (wasStrm); wasStrm = NULL; } else { CS_errmsg (errorText,sizeof (errorText)); printf ("%s\n",errorText); Usage (); } } while (isStrm != NULL) { iTmp = CS_dtrd (isStrm,&wasDtDef,&dummy); if (iTmp > 0) { if (nlFlag) { printf ("\n"); nlFlag = FALSE; } printf ("%s added to datum dictionary!!!\n",isDtDef.key_nm); dtDiffCnt += 1; } else if (iTmp == 0) { CS_fclose (isStrm); isStrm = NULL; } else { CS_errmsg (errorText,sizeof (errorText)); printf ("%s\n",errorText); Usage (); } } if (dtDiffCnt == 0) { printf ("\nDatum dictionaries are the same.\n\n"); } else { printf ("\n%d datum definitions are different.\n\n",dtDiffCnt); } /* Ellipsoid Dictionary */ CS_altdr (wasDir); /*lint !e534 */ wasStrm = CS_elopn (_STRM_BINRD); if (wasStrm == NULL) { printf ("Open of %s in the 'WAS' directory failed.\n",cs_Elname); Usage (); } CS_altdr (isDir); /*lint !e534 */ isStrm = CS_elopn (_STRM_BINRD); if (isStrm == NULL) { printf ("Open of %s in the 'IS' directory failed.\n",cs_Elname); Usage (); } iTmp = CS_elrd (wasStrm,&wasElDef,&dummy); if (iTmp < 0) { CS_errmsg (errorText,sizeof (errorText)); printf ("%s\n",errorText); Usage (); } if (iTmp == 0) { printf ("'WAS' ellipsoid dictionary is empty.\n"); Usage (); } iTmp = CS_elrd (isStrm,&isElDef,&dummy); if (iTmp < 0) { CS_errmsg (errorText,sizeof (errorText)); printf ("%s\n",errorText); Usage (); } if (iTmp == 0) { printf ("'IS' ellipsoid dictionary is empty.\n"); Usage (); } nlFlag = FALSE; while (TRUE) { cmpVal = CS_stricmp (wasElDef.key_nm,isElDef.key_nm); if (cmpVal < 0) { if (nlFlag) { printf ("\n"); nlFlag = FALSE; } printf ("%s deleted from ellipsoid dictionary!!!\n",wasElDef.key_nm); elDiffCnt += 1; } else if (cmpVal > 0) { if (nlFlag) { printf ("\n"); nlFlag = FALSE; } printf ("%s added to ellipsoid dictionary!!!\n",isElDef.key_nm); elDiffCnt += 1; } else { /* Normal case, we have two definitions with the same name, */ iTmp = CS_elDiff (stdout,&wasElDef,&isElDef); if (iTmp != 0) { elDiffCnt += 1; nlFlag = TRUE; } } if (cmpVal >= 0) { iTmp = CS_elrd (isStrm,&isElDef,&dummy); if (iTmp < 0) { CS_errmsg (errorText,sizeof (errorText)); printf ("%s\n",errorText); Usage (); } if (iTmp == 0) { CS_fclose (isStrm); isStrm = NULL; break; } } if (cmpVal <= 0) { iTmp = CS_elrd (wasStrm,&wasElDef,&dummy); if (iTmp < 0) { CS_errmsg (errorText,sizeof (errorText)); printf ("%s\n",errorText); Usage (); } if (iTmp == 0) { CS_fclose (wasStrm); wasStrm = NULL; break; } } } nlFlag = TRUE; while (wasStrm != NULL) { iTmp = CS_elrd (wasStrm,&wasElDef,&dummy); if (iTmp > 0) { if (nlFlag) { printf ("\n"); nlFlag = FALSE; } printf ("%s deleted from ellipsoid dictionary!!!\n",wasElDef.key_nm); elDiffCnt += 1; } else if (iTmp == 0) { CS_fclose (wasStrm); wasStrm = NULL; } else { CS_errmsg (errorText,sizeof (errorText)); printf ("%s\n",errorText); Usage (); } } while (isStrm != NULL) { iTmp = CS_elrd (isStrm,&wasElDef,&dummy); if (iTmp > 0) { if (nlFlag) { printf ("\n"); nlFlag = FALSE; } printf ("%s added to ellipsoid dictionary!!!\n",isElDef.key_nm); dtDiffCnt += 1; } else if (iTmp == 0) { CS_fclose (isStrm); isStrm = NULL; } else { CS_errmsg (errorText,sizeof (errorText)); printf ("%s\n",errorText); Usage (); } } if (elDiffCnt == 0) { printf ("\nEllipsoid dictionaries are the same.\n\n"); } else { printf ("\n%d ellipsoid definitions are different.\n\n",elDiffCnt); } return 0; }