#include <stdio.h>
#include <unistd.h>
#include <NCSECWClient.h>
#include <NCSErrors.h>

int main (void)
{
	NCSFileView *pNCSFileView;
	NCSFileViewFileInfo	*pNCSFileInfo;
	NCSError eError;

	NCSecwInit();
	chdir ("Folder1");
	eError = NCScbmOpenFileView("test.ecw", &pNCSFileView, NULL);
	if (eError != NCS_SUCCESS)
	{
		fprintf(stderr,"Could not open view for file\n");
		fprintf(stderr,"Error = %s\n", NCSGetErrorText(eError));
		NCScbmCloseFileView(pNCSFileView);
		exit (1);
	}
	NCScbmGetViewFileInfo(pNCSFileView, &pNCSFileInfo);
	printf ("Nb of bands : %d\n",pNCSFileInfo->nBands); 
	printf ("Input file datum : %s\n", pNCSFileInfo->szDatum);
	printf ("Input file projection : %s\n", pNCSFileInfo->szProjection);
	printf ("Origin X : %f\n", pNCSFileInfo->fOriginX);
	printf ("Origin Y : %f\n", pNCSFileInfo->fOriginY);
	printf ("Cell Increment X : %f\n", pNCSFileInfo->fCellIncrementX);
	printf ("Cell Increment Y : %f\n", pNCSFileInfo->fCellIncrementY);
	NCScbmCloseFileView(pNCSFileView);

	chdir ("../Folder2");
	eError = NCScbmOpenFileView("test.ecw", &pNCSFileView, NULL);
	if (eError != NCS_SUCCESS)
	{
		fprintf(stderr,"Could not open view for file\n");
		fprintf(stderr,"Error = %s\n", NCSGetErrorText(eError));
		NCScbmCloseFileView(pNCSFileView);
		exit (1);
	}
	NCScbmGetViewFileInfo(pNCSFileView, &pNCSFileInfo);
	printf ("Nb of bands : %d\n",pNCSFileInfo->nBands); 
	printf ("Input file datum : %s\n", pNCSFileInfo->szDatum);
	printf ("Input file projection : %s\n", pNCSFileInfo->szProjection);
	printf ("Origin X : %f\n", pNCSFileInfo->fOriginX);
	printf ("Origin Y : %f\n", pNCSFileInfo->fOriginY);
	printf ("Cell Increment X : %f\n", pNCSFileInfo->fCellIncrementX);
	printf ("Cell Increment Y : %f\n", pNCSFileInfo->fCellIncrementY);
	NCScbmCloseFileView(pNCSFileView);

	eError = NCScbmOpenFileView("test1.ecw", &pNCSFileView, NULL);
	if (eError != NCS_SUCCESS)
	{
		fprintf(stderr,"Could not open view for file\n");
		fprintf(stderr,"Error = %s\n", NCSGetErrorText(eError));
		NCScbmCloseFileView(pNCSFileView);
		exit (1);
	}
	NCScbmGetViewFileInfo(pNCSFileView, &pNCSFileInfo);
	printf ("Nb of bands : %d\n",pNCSFileInfo->nBands); 
	printf ("Input file datum : %s\n", pNCSFileInfo->szDatum);
	printf ("Input file projection : %s\n", pNCSFileInfo->szProjection);
	printf ("Origin X : %f\n", pNCSFileInfo->fOriginX);
	printf ("Origin Y : %f\n", pNCSFileInfo->fOriginY);
	printf ("Cell Increment X : %f\n", pNCSFileInfo->fCellIncrementX);
	printf ("Cell Increment Y : %f\n", pNCSFileInfo->fCellIncrementY);
	NCScbmCloseFileView(pNCSFileView);

}
