Ejemplo n.º 1
0
/* ---------------------------------------------------------------------------------- */
void print_header(LASHeaderH header, int bSkipVLR) {

    char *pszSignature = NULL;
    char *pszProjectId = NULL;
    char *pszSystemId = NULL;
    char *pszSoftwareId = NULL;
    /*char *pszProj4 = NULL;*/
    
    char *pszVLRUser = NULL;
    char *pszVLRDescription = NULL;
    uint16_t nVLRLength = 0;
    uint16_t nVLRRecordId = 0;
    
    LASVLRH pVLR = NULL;
    LASSRSH pSRS = NULL;
    uint32_t nVLR = 0;
    int i = 0;

#ifdef HAVE_GEOTIFF
    const GTIF* pGTIF = NULL;
#else
    const void* pGTIF = NULL;
#endif    

    pszSignature = LASHeader_GetFileSignature(header);
    pszProjectId = LASHeader_GetProjectId(header);
    pszSystemId = LASHeader_GetSystemId(header);
    pszSoftwareId = LASHeader_GetSoftwareId(header);
    
    pSRS = LASHeader_GetSRS(header);
    /*pszProj4 = LASSRS_GetProj4(pSRS);*/
    pGTIF = LASSRS_GetGTIF(pSRS);
    
    nVLR = LASHeader_GetRecordsCount(header);
 
    mexPrintf("\n---------------------------------------------------------\n");
    mexPrintf("  Header Summary\n");
    mexPrintf("---------------------------------------------------------\n");

    if (strcmp(pszSignature,"LASF") !=0) {
        LASError_Print("File signature is not 'LASF'... aborting");
        return;
    }
    mexPrintf("  Version:                    %d.%d\n", 
                    LASHeader_GetVersionMajor(header), LASHeader_GetVersionMinor(header));

    mexPrintf("  Source ID:                  %d\n", LASHeader_GetFileSourceId(header) ) ;
    mexPrintf("  Reserved:                   %d\n", LASHeader_GetReserved(header) );
    mexPrintf("  Project ID/GUID:           '%s'\n", pszProjectId);
    mexPrintf("  System Identifier:         '%s'\n", pszSystemId);
    mexPrintf("  Generating Software:       '%s'\n", pszSoftwareId);
    mexPrintf("  File Creation Day/Year:    %d/%d\n", 
                    LASHeader_GetCreationDOY(header), LASHeader_GetCreationYear(header));

    mexPrintf("  Header Size                %d\n", LASHeader_GetHeaderSize(header));
    mexPrintf("  Offset to Point Data       %d\n", LASHeader_GetDataOffset(header));
    mexPrintf("  Number Var. Length Records %d\n", LASHeader_GetRecordsCount(header));
    mexPrintf("  Point Data Format          %d\n", LASHeader_GetDataFormatId(header));
    mexPrintf("  Point Data Record Length   %d\n", LASHeader_GetDataRecordLength(header));
    mexPrintf("  Number of Point Records    %d\n", LASHeader_GetPointRecordsCount(header));
    mexPrintf("  Number of Points by Return %d %d %d %d %d\n", 
                    LASHeader_GetPointRecordsByReturnCount(header, 0), 
                    LASHeader_GetPointRecordsByReturnCount(header, 1), 
                    LASHeader_GetPointRecordsByReturnCount(header, 2), 
                    LASHeader_GetPointRecordsByReturnCount(header, 3), 
                    LASHeader_GetPointRecordsByReturnCount(header, 4));

    mexPrintf("  Scale Factor X Y Z         %.6g %.6g %.6g\n", 
                    LASHeader_GetScaleX(header), 
                    LASHeader_GetScaleY(header),
                    LASHeader_GetScaleZ(header));

    mexPrintf("  Offset X Y Z               %.6f %.6f %.6f\n", 
                    LASHeader_GetOffsetX(header), 
                    LASHeader_GetOffsetY(header), 
                    LASHeader_GetOffsetZ(header));

    mexPrintf("  Min X Y Z                  %.6f %.6f %.6f\n",
                    LASHeader_GetMinX(header), 
                    LASHeader_GetMinY(header), 
                    LASHeader_GetMinZ(header));

    mexPrintf("  Max X Y Z                  %.6f %.6f %.6f\n", 
                    LASHeader_GetMaxX(header), 
                    LASHeader_GetMaxY(header), 
                    LASHeader_GetMaxZ(header));
    
    /*mexPrintf(" Spatial Reference           %s\n", pszProj4);*/
#ifdef HAVE_LIBGEOTIFF
    if (pGTIF) GTIFPrint((GTIF*)pGTIF, 0, 0);
#endif
    if (nVLR && !bSkipVLR) {
        
    mexPrintf("\n---------------------------------------------------------\n");
    mexPrintf("  VLR Summary\n");
    mexPrintf("---------------------------------------------------------\n");

        for (i = 0; i < (int)nVLR; i++) {
            pVLR = LASHeader_GetVLR(header, i);

            if (LASError_GetLastErrorNum()) {
                LASError_Print("Unable to fetch VLR");
                return;
            }
            
            pszVLRUser = LASVLR_GetUserId(pVLR);
            pszVLRDescription = LASVLR_GetDescription(pVLR);
            nVLRLength = LASVLR_GetRecordLength(pVLR);
            nVLRRecordId = LASVLR_GetRecordId(pVLR);
            
            mexPrintf("   User: '******' - Description: '%s'\n", pszVLRUser, pszVLRDescription);
            mexPrintf("   ID: %d Length: %d\n\n", nVLRRecordId, nVLRLength);
            
            LASVLR_Destroy(pVLR);
            pVLR = NULL;
            
            LASString_Free(pszVLRUser);
            LASString_Free(pszVLRDescription);
        }
        
    }
    LASString_Free(pszSignature);
    LASString_Free(pszProjectId);
    LASString_Free(pszSystemId);
    LASString_Free(pszSoftwareId);
    /*LASString_Free(pszProj4);*/
}
Ejemplo n.º 2
0
int main(int argc, char *argv[])
{
    char	*fname = NULL;
    TIFF 	*tif=(TIFF*)0;  /* TIFF-level descriptor */
    GTIF	*gtif=(GTIF*)0; /* GeoKey-level descriptor */
    int		i, norm_print_flag = 1, proj4_print_flag = 0;
    int		tfw_flag = 0, inv_flag = 0, dec_flag = 0;

    /*
     * Handle command line options.
     */
    for( i = 1; i < argc; i++ )
    {
        if( strcmp(argv[i],"-no_norm") == 0 )
            norm_print_flag = 0;
        else if( strcmp(argv[i],"-t") == 0 )
        {
            CSVDirName = argv[++i];
            SetCSVFilenameHook( CSVFileOverride );
        }
        else if( strcmp(argv[i],"-tfw") == 0 )
            tfw_flag = 1;
        else if( strcmp(argv[i],"-proj4") == 0 )
            proj4_print_flag = 1;
        else if( strcmp(argv[i],"-i") == 0 )
            inv_flag = 1;
        else if( strcmp(argv[i],"-d") == 0 )
            dec_flag = 1;
        else if( fname == NULL && argv[i][0] != '-' )
            fname = argv[i];
        else
        {
            Usage();
        }
    }

    if( fname == NULL )
        Usage();

    /*
     * Open the file, read the GeoTIFF information, and print to stdout. 
     */

    tif=XTIFFOpen(fname,"r");
    if (!tif) goto failure;
	
    gtif = GTIFNew(tif);
    if (!gtif)
    {
        fprintf(stderr,"failed in GTIFNew\n");
        goto failure;
    }

    if( tfw_flag )
    {
        WriteTFWFile( gtif, fname );

        goto Success;
    }
	
    /* dump the GeoTIFF metadata to std out */

    GTIFPrint(gtif,0,0);

    /*
     * Capture, and report normalized information if requested.
     */

    if( norm_print_flag )
    {
        GTIFDefn	defn;
        
        if( GTIFGetDefn( gtif, &defn ) )
        {
            int		xsize, ysize;
            
            printf( "\n" );
            GTIFPrintDefn( &defn, stdout );

            if( proj4_print_flag )
            {
                printf( "\n" );
                printf( "PROJ.4 Definition: %s\n", GTIFGetProj4Defn(&defn));
            }
            
            TIFFGetField( tif, TIFFTAG_IMAGEWIDTH, &xsize );
            TIFFGetField( tif, TIFFTAG_IMAGELENGTH, &ysize );
            GTIFPrintCorners( gtif, &defn, stdout, xsize, ysize, inv_flag, dec_flag );
        }

    }

  Success:
    GTIFFree(gtif);
    XTIFFClose(tif);
    return 0;
		
  failure:
    fprintf(stderr,"failure in listgeo\n");
    if (tif) XTIFFClose(tif);
    if (gtif) GTIFFree(gtif);
    return 1;
}
Ejemplo n.º 3
0
bool DEM::readDem(char* fname) 
{

    demFilename = fname;
    TIFF 	*tif=(TIFF*)0;  /* TIFF-level descriptor */
    GTIF	*gtif=(GTIF*)0; /* GeoKey-level descriptor */
    int	proj4_print_flag = 0;
    int	inv_flag = 0, dec_flag = 1;
    int      st_test_flag = 0;
    GTIFDefn	defn;

    /*
     * Open the file, read the GeoTIFF information, and print some info to stdout. 
     */
	
    tif=XTIFFOpen(fname,"r");
    if (!tif) goto failure;
    
    gtif = GTIFNew(tif);
    if (!gtif)
	{
		fprintf(stderr,"failed in GTIFNew\n");
		goto failure;
	}
	
    /* dump the GeoTIFF metadata to std out */
	
    GTIFPrint(gtif,0,0);
	
    if( GTIFGetDefn( gtif, &defn ) )
	{
		printf( "\n" );
		GTIFPrintDefn( &defn, stdout );
		
		if( proj4_print_flag )
		{
			printf( "\n" );
			printf( "PROJ.4 Definition: %s\n", GTIFGetProj4Defn(&defn));
		}
		int count, orient;
		double* data;
		TIFFGetField( tif, TIFFTAG_IMAGEWIDTH, &xsize );
		TIFFGetField( tif, TIFFTAG_IMAGELENGTH, &ysize );
		TIFFGetField( tif, TIFFTAG_GEOPIXELSCALE, &count, &data);
		TIFFGetField( tif, TIFFTAG_ORIENTATION, &orient );
		printf("Orientation:%d\n",orient);
		
		GTIFPrintCorners( gtif, &defn, stdout, xsize, ysize, inv_flag, dec_flag );
		double originx = 0.0;
		double originy = ysize;
		GTIFImageToPCS( gtif, &originx, &originy);
		refLat = originy;
		refLon = originx;
		npixels = xsize * ysize;
		int16* buf;
		tsample_t sample;
		int nbytes;
		nbytes = TIFFScanlineSize(tif);
		buf = (int16*) _TIFFmalloc(nbytes);
		elevations = (int16*) _TIFFmalloc(npixels * sizeof (int16));
		if (elevations != NULL) {
			for(unsigned int y = 0; y < ysize; y++ )
			{
				uint32 row = ysize - 1 - y;
				TIFFReadScanline(tif, buf, row, sample);
				for(unsigned int x = 0; x < xsize; x++ ) 
				{
					elevations[y*xsize + x] = buf[x];
				}
			}	    
			_TIFFfree(buf);
		}
		_TIFFfree(elevations);
		
	}
    

    GTIFFree(gtif);
    if( st_test_flag )
        ST_Destroy( (ST_TIFF *) tif );
    else
        XTIFFClose(tif);
    GTIFDeaccessCSV();
    return true;
	
failure:
    fprintf(stderr,"failure in listgeo\n");
    if (tif) XTIFFClose(tif);
    if (gtif) GTIFFree(gtif);
    GTIFDeaccessCSV();
    return false;
}
Ejemplo n.º 4
0
int main(int argc, char *argv[])
{
    char	*fname = NULL;
    char        *outfile = NULL;
    TIFF 	*tif=(TIFF*)0;  /* TIFF-level descriptor */
    GTIF	*gtif=(GTIF*)0; /* GeoKey-level descriptor */
    int		i, j, norm_print_flag = 0, proj4_print_flag = 0;
    int		tfw_flag = 0, inv_flag = 0, dec_flag = 1;
    int         st_test_flag = 0;
    size_t npixels;
    int16* elevations;
    int x, y, skip;
    GTIFDefn	defn;
    FILE* out;

    /*
     * Handle command line options.
     */
    for( i = 1; i < argc; i++ )
    {
        if( fname == NULL && argv[i][0] != '-' )
            fname = argv[i];
        else
        {
            Usage();
        }
    }
    if( fname == NULL)
        Usage();

    skip = 5;

    /*
     * Open the file, read the GeoTIFF information, and print to stdout. 
     */
    int flength = strlen(fname);
    outfile = (char *) malloc(flength);
    strncpy(outfile,fname,flength-4);
    strcat(outfile, ".asc\0");
    out = fopen(outfile, "w");
    printf("Writing to %s\n\n",outfile);
    free(outfile);

    tif=XTIFFOpen(fname,"r");
    if (!tif) goto failure;
    
    gtif = GTIFNew(tif);
    if (!gtif)
      {
	fprintf(stderr,"failed in GTIFNew\n");
	goto failure;
      }
	
    /* dump the GeoTIFF metadata to std out */

    GTIFPrint(gtif,0,0);

    if( GTIFGetDefn( gtif, &defn ) )
      {
	uint32		xsize, ysize;
        
	printf( "\n" );
	GTIFPrintDefn( &defn, stdout );
	
	if( proj4_print_flag )
	  {
	    printf( "\n" );
	    printf( "PROJ.4 Definition: %s\n", GTIFGetProj4Defn(&defn));
	  }
	int count, orient;
	double* data;
	TIFFGetField( tif, TIFFTAG_IMAGEWIDTH, &xsize );
	TIFFGetField( tif, TIFFTAG_IMAGELENGTH, &ysize );
	TIFFGetField( tif, TIFFTAG_GEOPIXELSCALE, &count, &data);
	TIFFGetField( tif, TIFFTAG_ORIENTATION, &orient );
	printf("Orientation:%d\n",orient);

	GTIFPrintCorners( gtif, &defn, stdout, xsize, ysize, inv_flag, dec_flag );
	const char* project = "ASTERGDEM";
	const char* yymmdd = "090629";
	double originx, originy;
	GTIFImageToPCS( gtif, &originx, &originy);
	int lat = (int)originy*1000;
	int lon = (int)originx*1000;
	int xmin = 0;
	int ymin = 0;
	int nx = xsize/skip + 1;
	int ny = ysize/skip + 1;
	int dx = 30 * skip;
	int dy = 30 * skip;
	int16 elev = 0;
	fprintf(out, "%12s%12s%7d%7d%7d%7d%7d%7d%7d%7d\n",
	       project, yymmdd, lat, lon, xmin, ymin, nx, ny, dx,dy);
	npixels = xsize * ysize;
	int16* buf;
	tsample_t sample;
	int nbytes;
	nbytes = TIFFScanlineSize(tif);
	buf = (int16*) _TIFFmalloc(nbytes);
	elevations = (int16*) _TIFFmalloc(npixels * sizeof (int16));
	if (elevations != NULL) {
	    for( y = 0; y < ysize; y++ )
	      {
		uint32 row = ysize - 1 - y;
		TIFFReadScanline(tif, buf, row, sample);
		for( x = 0; x < xsize; x++ ) 
		  {
		    elevations[y*xsize + x] = buf[x];
		  }
	      }	    
	  _TIFFfree(buf);
	}
	for( y = 0; y < ysize; y+=skip ) {
	  for( x = 0; x < xsize; x+=skip ) {
	    fprintf(out, "%6d", elevations[y*xsize + x]);
	  }
	  fprintf(out, "\n");
	}
	_TIFFfree(elevations);

      }
    
  Success:
    GTIFFree(gtif);
    if( st_test_flag )
        ST_Destroy( (ST_TIFF *) tif );
    else
        XTIFFClose(tif);
    GTIFDeaccessCSV();
    return 0;
		
  failure:
    fprintf(stderr,"failure in listgeo\n");
    if (tif) XTIFFClose(tif);
    if (gtif) GTIFFree(gtif);
    GTIFDeaccessCSV();
    return 1;
}
void CGeoImageView::EngineSetup(void)
{
	Ogre::Root *Root = ((CGeoImageApp*)AfxGetApp())->m_Engine->GetRoot();

	Ogre::SceneManager *SceneManager = NULL;

	SceneManager = Root->createSceneManager(Ogre::ST_GENERIC, "MFCOgre");

    //
    // Create a render window
    // This window should be the current ChildView window using the externalWindowHandle
    // value pair option.
    //

    Ogre::NameValuePairList parms;
    parms["externalWindowHandle"] = Ogre::StringConverter::toString((long)m_hWnd);
    parms["vsync"] = "true";

	CRect   rect;
    GetClientRect(&rect);

	Ogre::RenderTarget *RenderWindow = Root->getRenderTarget("Ogre in MFC");

	if (RenderWindow == NULL)
	{
	try
	{
		m_RenderWindow = Root->createRenderWindow("Ogre in MFC", rect.Width(), rect.Height(), false, &parms);
	}
    catch(...)
	{
		MessageBox("Cannot initialize\nCheck that graphic-card driver is up-to-date", "Initialize Render System", MB_OK | MB_ICONSTOP);
		exit(EXIT_SUCCESS);
	}
	}
// Load resources
	Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

    // Create the camera
    m_Camera = SceneManager->createCamera("Camera");
    m_Camera->setNearClipDistance(0.5);
	m_Camera->setFarClipDistance(5000); 
	m_Camera->setCastShadows(false);
	m_Camera->setUseRenderingDistance(true);
//	m_Camera->setPosition(Ogre::Vector3(320.0, 240.0, 500.0));
	Ogre::SceneNode *CameraNode = NULL;
	CameraNode = SceneManager->getRootSceneNode()->createChildSceneNode("CameraNode");

	Ogre::Viewport* Viewport = NULL;
	
	if (0 == m_RenderWindow->getNumViewports())
	{
		Viewport = m_RenderWindow->addViewport(m_Camera);
		Viewport->setBackgroundColour(Ogre::ColourValue(0.8f, 1.0f, 0.8f));
	}

    // Alter the camera aspect ratio to match the viewport
    m_Camera->setAspectRatio(Ogre::Real(rect.Width()) / Ogre::Real(rect.Height()));
		

	TIFF 	*Tif = (TIFF*)0;  /* TIFF-level descriptor */
  	GTIF	*GTif = (GTIF*)0; /* GeoKey-level descriptor */

	CString SourcePath = "C:\\Users\\Ilya\\Documents\\Visual Studio 2010\\Projects\\Recipes\\media\\materials\\textures\\o41078a1.tif";
 int ImageWidth;
 int ImageHeight;

 double LowerLeftX;
 double LowerLeftY;

 double UpperRightX;
 double UpperRightY;

 int Xpos;
 int Ypos;

	Tif = XTIFFOpen((LPCSTR)SourcePath, "r");
	GTif = GTIFNew(Tif);
 
	GTIFDefn Definition;
	GTIFGetDefn(GTif, &Definition);
 
	GTIFPrint(GTif, 0, 0);

	TIFFGetField( Tif, TIFFTAG_IMAGEWIDTH, &ImageWidth);
 	TIFFGetField( Tif, TIFFTAG_IMAGELENGTH, &ImageHeight);

int res = 0;

 double LowerRightX = ImageWidth;
 double LowerRightY = ImageHeight;

 res = GTIFImageToPCS(GTif, &LowerRightX, &LowerRightY);
  //Lower Left
 LowerLeftX = 0.0;
 LowerLeftY = ImageHeight;

 res = GTIFImageToPCS(GTif, &LowerLeftX, &LowerLeftY);

 //Upper Right
 UpperRightX = ImageWidth;
 UpperRightY = 0.0;

 res = GTIFImageToPCS(GTif, &UpperRightX, &UpperRightY);

 double UpperLeftX = 0.0;
 double UpperLeftY = 0.0;

 res = GTIFImageToPCS(GTif, &UpperLeftX, &UpperLeftY);

  	Ogre::ManualObject *Terrain = SceneManager->createManualObject("Terrain");
	Terrain->setDynamic(false);
	Terrain->begin("Terrain", Ogre::RenderOperation::OT_TRIANGLE_FAN);

#define MIN(x,y)     (((x) < (y)) ? (x) : (y))
#define MAX(x,y)     (((x) > (y)) ? (x) : (y))

#define SW     0
#define NW     1
#define NE     2
#define SE     3

FILE *File = NULL;
char            Dummy[160];
char inText[24];
 char *Dest;
	int             base[2048];         /* array of base elevations */
char            mapLabel[145];
int             DEMlevel, elevationPattern, groundSystem, groundZone;
double          projectParams[15];
int             planeUnitOfMeasure, elevUnitOfMeasure, polygonSizes;
double          groundCoords[4][2], elevBounds[2], localRotation;
int             accuracyCode;
double          spatialResolution[3];
int             profileDimension[2];
int             firstRow, lastRow;
int             wcount = 0;

double          verticalScale = 1.0;      /* to stretch or shrink elevations */
double          deltaY;
char *junk;

double eastMost;
double westMost;
double southMost;
double northMost;

int  eastMostSample;
int  westMostSample;
int southMostSample;
int northMostSample;

int        rowCount, columnCount, r, c;
int	rowStr = 1;
int rowEnd;
int colStr = 1;
int colEnd;
int colInt = 1;
int rowInt = 1;
int outType = 0;
 int k,l ;
 double comp = 0.0;

     int 	   mod ;
    int             tempInt, lastProfile = 0;

    float           noValue = 0.0f;
    int             profileID[2], profileSize[2];
    double          planCoords[2], localElevation, elevExtremea[2];


 File = fopen("C:\\Users\\Ilya\\Documents\\Visual Studio 2010\\Projects\\Recipes\\media\\geotiff\\karthaus_pa.dem", "r");

 fscanf(File, "%144c%6d%6d%6d%6d",
	     mapLabel,              /* 1 */
	     &DEMlevel,             /* 2 */
	     &elevationPattern,     /* 3 */
             &groundSystem,         /* 4 */
             &groundZone );         /* 5 */


    for (k=0; k<15 ; k++) 
	{
     fscanf(File,"%24c", inText);    /* 6 */
      Dest = strchr(inText,'D');  *Dest = 'E';
      projectParams[k]  = strtod(inText,&junk);
    }

    fscanf(File,"%6d%6d%6d",
             &planeUnitOfMeasure,   /* 7 */
             &elevUnitOfMeasure,    /* 8 */
             &polygonSizes);        /* 9 */

    for (k=0; k < 4 ; k++)
       for (l=0; l < 2 ; l++)
	   { 
        fscanf(File,"%24c", inText);    /* 6 */
        Dest = strchr(inText,'D');  *Dest = 'E';
        groundCoords[k][l]  = strtod(inText,&junk);
	   }

    fscanf(File,"%24c", inText);
    Dest = strchr(inText,'D');  *Dest = 'E';
    elevBounds[0] = strtod(inText,&junk);       /* 10 */
    fscanf(File,"%24c", inText);
    
	Dest = strchr(inText,'D');  *Dest = 'E';
    elevBounds[1] = strtod(inText,&junk);      /* 11 */
    fscanf(File,"%24c", inText);
    Dest = strchr(inText,'D');  *Dest = 'E';
    localRotation  = strtod(inText,&junk);      /* 12 */

   fscanf(File,"%1d%12le%12le%12le%6d%6d",
             &accuracyCode,             /* 13 */
	     &spatialResolution[0],     /* 14 */
             &spatialResolution[1],     /* 14 */
             &spatialResolution[2],     /* 14 */
             &profileDimension[0],      /* 15 */
             &profileDimension[1]);     /* 15 */

   fscanf(File, "%160c", Dummy);

    if (spatialResolution[0] == 3.0) 
	{
	 comp   = spatialResolution[0] - 1.0 ;
	 deltaY = spatialResolution[1] / 3600.  ;
    }
    else
	{
	 comp   = 0.;
	 deltaY = spatialResolution[1] ;
    }

    eastMost  = MAX(groundCoords[NE][0], groundCoords[SE][0]);
    westMost  = MIN(groundCoords[NW][0], groundCoords[SW][0]);
    northMost = MAX(groundCoords[NE][1], groundCoords[NW][1]);
    southMost = MIN(groundCoords[SW][1], groundCoords[SE][1]);
    eastMostSample =  ((int) (eastMost / spatialResolution[0]))
		     * (int) spatialResolution[0];
    westMostSample =  ((int) ((westMost + comp) / spatialResolution[0]))
		     * (int) spatialResolution[0] ;
    northMostSample = ((int) (northMost / spatialResolution[1]))
		     * (int) spatialResolution[1] ;
    southMostSample = ((int) ((southMost + comp) / spatialResolution[1]))
		     * (int) spatialResolution[1] ;
    
	columnCount = (eastMostSample  - westMostSample)
		  / (int) spatialResolution[0] + 1;
    rowCount    = (northMostSample - southMostSample)
		  / (int) spatialResolution[1] + 1;

    if (columnCount != profileDimension[1])
	  columnCount =MIN( profileDimension[1], columnCount);

for (c = 1; c <= columnCount; c++) 
 {
  fscanf(File, "%d%d%d%d",
		 &profileID[0],        /* 1 */
		 &profileID[1],        /* 1 */
		 &profileSize[0],      /* 2 */
		 &profileSize[1]);     /* 2 */

       fscanf(File,"%24c", inText);
       Dest = strchr(inText,'D');  *Dest = 'E';
       planCoords[0]   = strtod(inText,&junk);     /* 3 */
	  fscanf(File,"%24c", inText);
       Dest = strchr(inText,'D');  *Dest = 'E';
       planCoords[1]   = strtod(inText,&junk);     /* 3 */
	   fscanf(File,"%24c", inText);
       Dest = strchr(inText,'D');  *Dest = 'E';
       localElevation  = strtod(inText,&junk);     /* 4 */
	 fscanf(File,"%24c", inText);
       Dest = strchr(inText,'D');  *Dest = 'E';
       elevExtremea[0] = strtod(inText,&junk);     /* 5 */
	   fscanf(File,"%24c", inText);
       Dest = strchr(inText,'D');  *Dest = 'E';
       elevExtremea[1] = strtod(inText,&junk);     /* 5 */

       lastProfile =  profileID[1];

       firstRow = abs(((int) (planCoords[1] - southMostSample))
		 / (int) spatialResolution[1]);
       lastRow = firstRow + profileSize[0] - 1;

       for ( r = 0 ; r < firstRow  ; r++ ) 
		   base[r] = 0;

/*     read in all the data for this column */
       for (r = firstRow; r <= lastRow; r++ )
       {
	  fscanf(File, "%6d",	&tempInt);
	   base[r] = tempInt;
       }

    double          tempFloat;

   for (r = firstRow; r <= lastRow; r += rowInt) 
   {
    tempFloat = (float) base[r]  * verticalScale;
 	Terrain->position(planCoords[0], tempFloat, planCoords[1]);

	Ogre::Real u = 0.0;
	Ogre::Real v = 0.0;

	if (planCoords[0] > LowerLeftX && planCoords[0] < UpperRightX)
	{
		u = (planCoords[0] - LowerLeftX) / (UpperRightX - LowerLeftX);
	}

	if (planCoords[1] > LowerLeftY && planCoords[1] < UpperRightY)
	{
		v = (planCoords[1] - LowerLeftY) / (UpperRightY - LowerLeftY);
	}

	Terrain->textureCoord(u, v); 
	planCoords[1] += deltaY;
   }
 }

 Terrain->end();
 fclose(File);

	Ogre::SceneNode* node = SceneManager->getRootSceneNode()->createChildSceneNode();
	node->setPosition(0, 0, 0);
	node->attachObject(Terrain);

	Ogre::AxisAlignedBox Box = Terrain->getBoundingBox();
	Ogre::Vector3 Center = Box.getCenter();

	Ogre::Vector3 Target = Center;
	Ogre::Vector3 Position = Center;

	Position[1] += 5000.0;
	m_Camera->setPosition(Position);
	m_Camera->lookAt(Target);
}