示例#1
0
/******************************************************************************
	Calculation function.  Calculates the conversion from Ats77 to NAD83.
*/
int CScalcNad27ToCsrsEntry (struct csNad27ToCsrsEntry_* __This,double* ll_nad27,Const double *ll_csrs,struct csLLGridCellCache_ *cachePtr)
{
	extern char csErrnam [];

	int status;
	double ll_ats77 [3];

	switch (__This->type) {
	case dtNad27ToCsrsC2:
		status = CScalcDatumShiftCa2 (__This->pointers.c2DatumPtr,ll_nad27,ll_csrs,cachePtr);
		break;
	case dtNad27ToCsrsXfrm:
		status = CScalcNad27ToAts77 (__This->pointers.nad27ToCsrsViaXfrm->nad27ToAts77,ll_ats77,ll_csrs);
		if (status == 0)
		{
			status = CScalcAts77ToCsrs (__This->pointers.nad27ToCsrsViaXfrm->ats77ToCsrs,ll_nad27,ll_ats77);
		}
		break;
	case dtNad27ToCsrsNoneYet:
	default:
		/* Minus one indicates a fatal error.  In this case, it is an internal
		   software error. */
		CS_stncp (csErrnam,"CS_dtNad27ToCsrs:1",MAXPATH);
		CS_erpt (cs_ISER);
		status = -1;
		break;
	}
	return status;
}
示例#2
0
/******************************************************************************
	Calculation function.  Calculates the conversion from AGD66 to GDA94.
*/
int CScalcEd50ToEtrf89Entry (struct csEd50ToEtrf89Entry_* __This,double* ll89,Const double *ll50,struct csLLGridCellCache_ *cachePtr)
{
	extern char csErrnam [];

	int status;

	switch (__This->type){
	case dtEd50ToEtrf89C2:
		status = CScalcDatumShiftCa2 (__This->pointers.c2DatumPtr,ll89,ll50,cachePtr);
		break;
	case dtEd50ToEtrf89NoneYet:
	default:
		/* Minus one indicates a fatal error.  In this case, it is an internal
		   software error. */
		CS_stncp (csErrnam,"CS_dtEd50ToEtrf89:1",MAXPATH);
		CS_erpt (cs_ISER);
		status = -1;
		break;
	}
	return status;
}
示例#3
0
/******************************************************************************
	Calculation function.  Calculates the conversion from RGF93 to NTF.
*/
int CScalcRgf93ToNtfEntry (struct csRgf93ToNtfEntry_* __This,double* llNtf,Const double *llRgf93,struct csLLGridCellCache_ *cachePtr)
{
	extern char csErrnam [];

	int status;

	switch (__This->type){
	case dtRgf93ToNtfTxt:
		status = CScalcRgf93ToNtfTxt (__This->pointers.txtDatumPtr,llNtf,llRgf93);
		break;
	case dtRgf93ToNtfC2:
		status = CScalcDatumShiftCa2 (__This->pointers.c2DatumPtr,llNtf,llRgf93,cachePtr);
		break;
	case dtRgf93ToNtfNone:
	default:
		/* Minus one indicates a fatal error.  In this case, it is an internal
		   software error. */
		CS_stncp (csErrnam,"CS_dtRgf93ToNtf:1",MAXPATH);
		CS_erpt (cs_ISER);
		status = -1;
		break;
	}
	return status;
}
示例#4
0
/******************************************************************************
	Calculate inverse datum shift, the second main man.e levels.

	Returns  0 for expected result
	        -1 for hard/fatal failure
			+1 2for no data coverage, unshifted result returned
			+2 for no data coverage, fallback used successfully
*/
int CSinverseRgf93ToNtf (struct csRgf93ToNtf_* __This,double* llRgf93,Const double *llNtf)
{
	int status;
	struct csRgf93ToNtfEntry_* dtEntryPtr;
	struct csRgf93ToNtfTxt_ *txtDatumPtr;
	struct csDatumShiftCa2_* caNtv2Ptr;

	double tmpLL [3];

	/* Until we know different.*/
	status = 1;

	/* The local grids use the NTv2 transformation format.  This is a 2D
	   transformation and, therefore, it does not give us a height shift.
	   Since the previous implementation used the national text file which
	   is a 3D transformation, the height shift was always present.  Therefore,
	   in order to get the height shift, we will always do the national text
	   calculation.  Then, if there is a local grid present whose extents
	   include thie provoded point, we will update the horizontal with the
	   new values from the local grid file. */
	dtEntryPtr = CSselectRgf93ToNtf (__This,dtRgf93ToNtfTxt,llRgf93);
	if (dtEntryPtr != NULL)
	{
		/* Note that the following expects CSinverseRgf93ToNtfTxt to do
		   a reasonably good job at computing the height. */
		txtDatumPtr = dtEntryPtr->pointers.txtDatumPtr;
		status = CSinverseRgf93ToNtfTxt (txtDatumPtr,llRgf93,llNtf);
		if (status == 0)
		{
			/* If there are no local grids for this point, we're done. */
			dtEntryPtr = CSselectRgf93ToNtf (__This,dtRgf93ToNtfC2,llRgf93);
			if (dtEntryPtr != NULL)
			{
				/* There is a local grid.  We use the local grid to compute a
				   new horizontal position, leaving the height calculated above
				   as is.  Note that the horizontal position change here is on
				   the order of 10 centimeters.  Thus, the change in the height
				   due to this sloght horizontal shift is negligble. */
				caNtv2Ptr = dtEntryPtr->pointers.c2DatumPtr;
				status = CScalcDatumShiftCa2 (caNtv2Ptr,tmpLL,llNtf,NULL);
				if (status == 0)
				{
					llRgf93 [0] = tmpLL [0];
					llRgf93 [1] = tmpLL [1];
				}
			}
		}
	}
	else if (__This->fallback != NULL)
	{
		status = CScalcFallbackForward (__This->fallback,llRgf93,llNtf);
	}
	
	if (status == 1 || status < 0)
	{
		llRgf93 [LNG] = llNtf [LNG];
		llRgf93 [LAT] = llNtf [LAT];
		llRgf93 [HGT] = llNtf [HGT];
	}
	return status;
}