[Nasa-exp-checkins] SF.net SVN: nasa-exp: [3720] trunk/WorldWind/DstilePlugin
Brought to you by:
baker99-bull,
vigilant
From: <ti...@us...> - 2007-03-23 12:04:37
|
Revision: 3720 http://svn.sourceforge.net/nasa-exp/?rev=3720&view=rev Author: tish_mp Date: 2007-03-23 05:04:36 -0700 (Fri, 23 Mar 2007) Log Message: ----------- ADD-79: Replace GDAL Info Exec with GDAL API calls. Modified Paths: -------------- trunk/WorldWind/DstilePlugin/DstileFE.cs trunk/WorldWind/DstilePlugin/DstileGUI.csproj Modified: trunk/WorldWind/DstilePlugin/DstileFE.cs =================================================================== --- trunk/WorldWind/DstilePlugin/DstileFE.cs 2007-03-23 00:15:46 UTC (rev 3719) +++ trunk/WorldWind/DstilePlugin/DstileFE.cs 2007-03-23 12:04:36 UTC (rev 3720) @@ -26,6 +26,7 @@ //Import GDAL Utilities using GDAL; +using OSR; namespace DstileGUI { @@ -496,9 +497,10 @@ inputFileTextBox.Text = fileName; if (File.Exists(fileName)) currentStatusLabel.Text = "Data located"; + string strfileName = Path.GetFullPath(fileName); fileName = "\"" + fileName + "\""; Console.WriteLine("** File input: " + fileName); - + /* // only while testing - need to know/read in relative location Process process = new Process(); ProcessStartInfo psi = new ProcessStartInfo(Path.Combine(fwlocText.Text,"bin//gdalinfo.exe")); @@ -552,24 +554,52 @@ process.WaitForExit(); process.Close(); process.Dispose(); + */ - /* gdal.AllRegister(); - GDAL.Dataset dataset = gdal.Open(fileName, 0); - string proj = dataset.GetGCPProjection(); - */ + Console.WriteLine("GDAL Drivers:"+gdal.GetDriverCount()); + GDAL.Dataset dataset = gdal.Open(strfileName, 0); + string proj = dataset.GetProjection(); + if (proj != null) + { + SpatialReference srs = new SpatialReference(proj); + string proj4def; + srs.ExportToProj4(out proj4def); + srcProjTextBox.Text = proj4def; + SpatialReference llsrs = srs.CloneGeogCS(); + CoordinateTransformation coordtrans = new CoordinateTransformation(srs, llsrs); + double[] transform = new double[6]; + dataset.GetGeoTransform(transform); + int xsize = dataset.RasterXSize; + int ysize = dataset.RasterYSize; + double topleftx = transform[0]; + double toplefty = transform[3]; + double bottomrightx = transform[0] + xsize * transform[1]; + double bottomrighty = transform[3] + ysize * transform[5]; - if (srcProjNeeded) + double[] topleft = { topleftx, toplefty }; + double[] bottomright = { bottomrightx, bottomrighty }; + + coordtrans.TransformPoint(topleft); + coordtrans.TransformPoint(bottomright); + + northlab.Text = Convert.ToString(Math.Round(topleft[1], 2)); + westlab.Text = Convert.ToString(Math.Round(topleft[0], 2)); + southlab.Text = Convert.ToString(Math.Round(bottomright[1], 2)); + eastlab.Text = Convert.ToString(Math.Round(bottomright[0], 2)); + } + else { srcProjTextBox.ReadOnly = false; srcProjTextBox.Text = ""; } - + /* //TODO: Use proj.4 to reproject non-lat-lon coordinates to epsg:4326 if (srcProjTextBox.Text.ToLower() != "epsg:4326") { MessageBox.Show("Reprojection of the extents is needed"); } + */ } /// <summary> Modified: trunk/WorldWind/DstilePlugin/DstileGUI.csproj =================================================================== --- trunk/WorldWind/DstilePlugin/DstileGUI.csproj 2007-03-23 00:15:46 UTC (rev 3719) +++ trunk/WorldWind/DstilePlugin/DstileGUI.csproj 2007-03-23 12:04:36 UTC (rev 3720) @@ -82,6 +82,10 @@ <SpecificVersion>False</SpecificVersion> <HintPath>..\bin\Debug\gdal_csharp.dll</HintPath> </Reference> + <Reference Include="osr_csharp, Version=0.0.0.0, Culture=neutral"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\bin\Debug\osr_csharp.dll</HintPath> + </Reference> <Reference Include="System"> <Name>System</Name> </Reference> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |