Beispiel #1
0
/******************************************************************************
	Constructor: This is a constructor for the "Entry" object.  A linked list
	of these "Entry" objects is underlying structure of the main object.

	NOTE: the specific of handling different file types are handled here.
*/
struct csAts77ToCsrsEntry_* CSnewAts77ToCsrsEntry (struct csDatumCatalogEntry_* catPtr)
{
	struct csAts77ToCsrsEntry_* __This;

	/* Prepare for an error. */
	__This = NULL;

	/* Allocate some storage. */
	__This = (struct csAts77ToCsrsEntry_*) CS_malc (sizeof (struct csAts77ToCsrsEntry_));
	if (__This == NULL)
	{
		CS_erpt (cs_NO_MEM);
		goto error;
	}
	__This->next = NULL;
	__This->type = dtAts77ToCsrsNoneYet;
	__This->pointers.c2DatumPtr = NULL;

	/* Set up the file; construct a Canadian National Transformation,
	   Version 2 object.  It's smart enough to deal with the differences
	   between the Canadian format and the Australian variation. */
	__This->pointers.c2DatumPtr = CSnewDatumShiftCa2 (dtcTypeAustralian,catPtr->pathName,catPtr->bufferSize,catPtr->flags,catPtr->density);
	if (__This->pointers.c2DatumPtr == NULL)
	{
		goto error;
	}
	__This->type = dtAts77ToCsrsC2;
	return __This;

error:
	CSdeleteAts77ToCsrsEntry (__This);
	return NULL;
}
Beispiel #2
0
/******************************************************************************
	Constructor: This is a constructor for the "Entry" object.  A linked list
	of these "Entry" objects is underlying structure of the main object.

	NOTE: the specific of handling different file types is handled here.
*/
struct csRgf93ToNtfEntry_* CSnewRgf93ToNtfEntry (struct csDatumCatalogEntry_* catPtr)
{
	extern char cs_DirsepC;
	extern char cs_ExtsepC;
	extern char csErrnam [];

	char *cp;
	struct csRgf93ToNtfEntry_* __This;

	/* Prepare for an error. */
	__This = NULL;

	/* Allocate some storage. */
	__This = (struct csRgf93ToNtfEntry_*) CS_malc (sizeof (struct csRgf93ToNtfEntry_));
	if (__This == NULL)
	{
		CS_erpt (cs_NO_MEM);
		goto error;
	}
	__This->next = NULL;
	__This->type = dtRgf93ToNtfNone;
	__This->pointers.txtDatumPtr = NULL;
	__This->pointers.c2DatumPtr = NULL;         /* Yes, redundant! */

	/* Issue an error if information in the catalog file is
	   inconsistent.  That is, if the extension is not one of the
	   two supported. */
	cp = strrchr (catPtr->pathName,cs_DirsepC);
	if (cp == NULL)
	{
		/* Can't find a path specification in the path name. */
		CS_stncp (csErrnam,catPtr->pathName,MAXPATH);
		CS_erpt (cs_DTC_PATH);
		goto error;
	}
	cp = strchr (cp,cs_ExtsepC);
	if (cp == NULL || strlen (cp) != 4)
	{
		/* Can't find an extension in the file name. */
		CS_stncp (csErrnam,catPtr->pathName,MAXPATH);
		CS_erpt (cs_DTC_PATH);
		goto error;
	}
	

	/* Process the entry according to the extension on the file name. */
	cp += 1;                                /* bump past the separator*/
	if (!CS_stricmp (cp,"TXT"))
	{
		/* Construct a text file object.  In the past 10 years, there has only
		   one.  But with htis new implementation (Nov 2008) we supported
		   multiple .txt files as well as multiple .gsb files. */
		__This->pointers.txtDatumPtr = CSnewRgf93ToNtfTxt (catPtr->pathName,catPtr->bufferSize,catPtr->flags,catPtr->density);
		__This->type = dtRgf93ToNtfTxt;
	}
	else if (!CS_stricmp (cp,"GSB"))
	{
		/* Construct a Canadian National Transformation Version 2 object. */
		__This->pointers.c2DatumPtr = CSnewDatumShiftCa2 (dtcTypeCanadian2,catPtr->pathName,catPtr->bufferSize,catPtr->flags,catPtr->density);
		if (__This->pointers.c2DatumPtr == NULL)
		{
			goto error;
		}
		__This->type = dtRgf93ToNtfC2;
	}
	else
	{
		CS_stncp (csErrnam,catPtr->pathName,MAXPATH);
		CS_erpt (cs_NAD_EXT);
		goto error;
	}

	/* Return a pointer to t2he 'constructed' entry object. */
	return __This;
error:
	CSdeleteRgf93ToNtfEntry (__This);
	return NULL;
}
Beispiel #3
0
/******************************************************************************
	Constructor: This is a constructor for the "Entry" object.  A linked list
	of these "Entry" objects is underlying structure of the main object.

	NOTE: the specific of handling different file types are handled here.
*/
struct csNad27ToCsrsEntry_* CSnewNad27ToCsrsEntry (struct csDatumCatalogEntry_* catPtr)
{
	extern char cs_DirsepC;
	extern struct csNad27ToAts77_* csNad27ToAts77;
	extern struct csAts77ToCsrs_* csAts77ToCsrs;

	int st;
	char *cp;
	struct csNad27ToCsrsEntry_* __This;

	/* Prepare for an error. */
	__This = NULL;

	/* Allocate some storage. */
	__This = (struct csNad27ToCsrsEntry_*) CS_malc (sizeof (struct csNad27ToCsrsEntry_));
	if (__This == NULL)
	{
		CS_erpt (cs_NO_MEM);
		goto error;
	}
	__This->next = NULL;
	__This->type = dtNad27ToCsrsNoneYet;
	__This->density = catPtr->density;
	__This->pointers.c2DatumPtr = NULL;

	/* See if this is the special case where conversion required is through the
	   ATS77 facility. */
	cp = strrchr (catPtr->pathName,cs_DirsepC);
	if (cp != NULL) cp += 1;
	else cp = catPtr->pathName;
	if (!CS_strnicmp (cp,"Ats77ToCsrs",11))
	{
		/* Here if we have a Maritime Province reference. */
		__This->pointers.nad27ToCsrsViaXfrm = (struct csNad27ToCsrsXfrm_ *)CS_malc (sizeof (struct csNad27ToCsrsXfrm_));
		if (__This->pointers.nad27ToCsrsViaXfrm == NULL)
		{
			CS_erpt (cs_NO_MEM);
			goto error;
		}
		__This->pointers.nad27ToCsrsViaXfrm->nad27ToAts77 = NULL;
		__This->pointers.nad27ToCsrsViaXfrm->ats77ToCsrs = NULL;
		__This->type = dtNad27ToCsrsXfrm;
		st = CSn27a77Init ();
		if (st == 0)
		{
			__This->pointers.nad27ToCsrsViaXfrm->nad27ToAts77 = csNad27ToAts77;
			if (__This->density == 0.0)
			{
				__This->density = 0.100000;
			}
		}
		else
		{
			 goto error;
		}
		st = CSats77Init ();
		if (st == 0)
		{
			__This->pointers.nad27ToCsrsViaXfrm->ats77ToCsrs = csAts77ToCsrs;
			if (__This->density < 0.00833333333)
			{
				__This->density = 0.098333333333;
			}
		}
		else
		{
			goto error;
		}
	}
	else
	{
		/* Set up the file; construct a Canadian National Transformation,
		   Version 2 object.  It's smart enough to deal with the differences
		   between the Canadian format and the Australian variation. */
		__This->pointers.c2DatumPtr = CSnewDatumShiftCa2 (dtcTypeAustralian,catPtr->pathName,catPtr->bufferSize,catPtr->flags,catPtr->density);
		if (__This->pointers.c2DatumPtr == NULL)
		{
			goto error;
		}
		__This->type = dtNad27ToCsrsC2;
	}
	return __This;

error:
	CSdeleteNad27ToCsrsEntry (__This);
	return NULL;
}