コード例 #1
0
ファイル: CS_dtEd50ToEtrf89.c プロジェクト: auranet/csmap
/******************************************************************************
	Calculate datum shift, the main man.
	Returns  0 for expected result
	        -1 for hard/fatal failure
			+1 for no data coverage, unshifted result returned
			+2 for no data coverage, fallback used successfully
*/
int CScalcEd50ToEtrf89 (struct csEd50ToEtrf89_* __This,double* ll89,Const double *ll50)
{
	int status;
	struct csEd50ToEtrf89Entry_* dtEntryPtr;

	status = 0;

	/* First see if using the cache works.  This works more often than not. */
	if (__This->cachePtr != NULL)
	{
		status = CScalcLLGridCellCache (__This->cachePtr,ll89,ll50);
		if (status == 0)
		{
			return status;
		}
	}

	/* I guess we'll have to do it the hard way. */
	dtEntryPtr = CSselectEd50ToEtrf89 (__This,ll50);
	if (dtEntryPtr != NULL)
	{
		status = CScalcEd50ToEtrf89Entry (dtEntryPtr,ll89,ll50,__This->cachePtr);
	}
	else if (__This->fallback != NULL)
	{
		/* We didn't find any coverage.  A positive value is used to indicate
		   that we're using the fallback to do this calculation. */
		status = CScalcFallbackForward (__This->fallback,ll89,ll50);
	}
	else
	{
		status = 1;
	}
	return status;
}
コード例 #2
0
ファイル: CSnad27ToCsrs.c プロジェクト: auranet/csmap
/******************************************************************************
	Calculate datum shift, the main man.
	Returns  0 for expected result
	        -1 for hard/fatal failure
			+1 for no data coverage, unshifted result returned
			+2 for no data coverage, fallback used successfully
*/
int CScalcNad27ToCsrs (struct csNad27ToCsrs_* __This,double* ll_csrs,Const double *ll_nad27)
{
	int status;
	struct csNad27ToCsrsEntry_* dtEntryPtr;

	status = 0;

	/* First see if using the cache works.  This works more often than not. */
	if (__This->cachePtr != NULL)
	{
		status = CScalcLLGridCellCache (__This->cachePtr,ll_csrs,ll_nad27);
		if (status == 0)
		{
			return status;
		}
	}

	/* I guess we'll have to do it the hard way. */
	dtEntryPtr = CSselectNad27ToCsrs (__This,ll_nad27);
	if (dtEntryPtr != NULL)
	{
		status = CScalcNad27ToCsrsEntry (dtEntryPtr,ll_csrs,ll_nad27,__This->cachePtr);
	}
	else if (__This->fallback != NULL)
	{
		status = CScalcFallbackForward (__This->fallback,ll_csrs,ll_nad27);
	}
	else
	{
		/* We didn't find any coverage.  A positive value is used to indicate
		   an error, but not internally within this code. */
		status = 1;
	}
	return status;
}
コード例 #3
0
ファイル: CS_dtRgf93ToNtf.c プロジェクト: asir6/Colt
/******************************************************************************
	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;
}