public void TestProjMap() { string proj4Str = "proj +proj=stere +lon_0=0 +lat_0=-90 +lat_ts=-71 +ellps=WGS84 +datum=WGS84"; ISpatialReference srcSpatialRef = SpatialReferenceFactory.GetSpatialReferenceByPrjFile("WGS 1984.prj"); srcSpatialRef = SpatialReferenceFactory.GetSpatialReferenceByProj4String(proj4Str); Console.WriteLine(srcSpatialRef.ToString()); }
public void CreateEmptyLdfFile() { Assert.That(_newFileName != null); IGeoDataDriver driver = GeoDataDriver.GetDriverByName("LDF"); Assert.NotNull(driver); ILdfDriver drv = driver as ILdfDriver; Assert.NotNull(drv); int width = 2048; int height = 3390; int bandCount = 10; enumDataType dataType = enumDataType.UInt16; enumInterleave interleave = enumInterleave.BSQ; string version = "LDF"; //string proj4 = "+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378137 +b=6378137"; string mapInfo = "{1,1}:{110,35}:{0.01,0.01}"; bool withHdr = true; ILdfDataProvider prd = drv.Create(_newFileName, width, height, bandCount, dataType, "INTERLEAVE=" + interleave.ToString(), "VERSION=" + version, //"SPATIALREF=" + proj4, "MAPINFO=" + mapInfo, "WITHHDR=" + withHdr.ToString()) as ILdfDataProvider; Assert.NotNull(prd); Assert.That(prd.Width == width && prd.Height == height); Assert.That(prd.BandCount == bandCount); Assert.That(prd.DataType == dataType); ILdfHeader header = prd.Header; Assert.NotNull(header); HdrFile hdr = header.ToHdrFile(); PrintHdrInfo(hdr); Ldf1Header ldfheader = header as Ldf1Header; Assert.NotNull(ldfheader); Assert.That(ldfheader._width == width && ldfheader._height == height); Assert.That(ldfheader.DataType == dataType); Assert.NotNull(prd.SpatialRef); for (int i = 0; i < bandCount; i++) { IRasterBand band = prd.GetRasterBand(i + 1); Assert.NotNull(band); Assert.That(band.Width == width && band.Height == height); Assert.That(band.DataType == dataType); } prd.Dispose(); drv.Dispose(); Assert.True(File.Exists(_newFileName)); FileInfo fInfo = new FileInfo(_newFileName); Assert.True(width * height * bandCount * 2 + header.HeaderSize == fInfo.Length); ISpatialReference spatialRef = prd.SpatialRef; Assert.NotNull(spatialRef); Console.Out.WriteLine(spatialRef.ToString()); }
private void TryApplyPrj(PrjCoordinateDefine prjCoordinateDefine) { prjCoordinateDefine.ShowDialog(); if (prjCoordinateDefine.DialogResult == System.Windows.Forms.DialogResult.OK) { if (prjCoordinateDefine.SpatialReference != null) { _spatialReference = prjCoordinateDefine.SpatialReference; txtSpatialRefInfo.Text = _spatialReference.ToString(); } } }
private void TryApplyGeo(GeoCoordinateDefine geoCoordinateDefine) { geoCoordinateDefine.ShowDialog(); if (geoCoordinateDefine.DialogResult == System.Windows.Forms.DialogResult.OK) { if (geoCoordinateDefine.GeographicCoordSystem != null) { _geoCoordSystem = geoCoordinateDefine.GeographicCoordSystem; _spatialReference = new SpatialReference(_geoCoordSystem); txtSpatialRefInfo.Text = _spatialReference.ToString(); } } }
protected override void CollectValuesToEntity() { _entity.Name = txtName.Text; _entity.Description = txtDecription.Text; (_entity as SpatialFeatureDataset).Source = txtSource.Text; (_entity as SpatialFeatureDataset).MapScale = (int)txtMapScale.Value; ISpatialReference sref = ucSpatialRef1.SpatialReference; if (sref != null) { (_entity as SpatialFeatureDataset).SpatialRef = sref.ToString(); } }
private void lstCodes_SelectedIndexChanged(object sender, EventArgs e) { txtDescription.Text = String.Empty; if (lstCodes.SelectedItem == null) { return; } string sRefID = lstCodes.SelectedItem.ToString(); ISpatialReference sRef = SpatialReference.FromID(sRefID); if (sRef != null) { txtDescription.Text = sRef.Description + "\r\n" + sRef.ToString(); } }
public void ParseProj4() { string proj4 = "+proj=merc +lon_0=0 +k0=1 +x_0=0 +y_0=0 +a=6378137 +b=6378137"; Console.WriteLine("INPUT:"); Console.WriteLine(proj4); ISpatialReference spatialRef = SpatialReferenceFactory.GetSpatialReferenceByProj4String(proj4); Console.WriteLine("ESRI WKT:"); Console.WriteLine(spatialRef.ToString()); Console.WriteLine("PROJ.4:"); Console.WriteLine(spatialRef.ToProj4String()); Console.WriteLine("OGC WKT:"); Console.WriteLine(spatialRef.ToWKTString()); Console.WriteLine("ENVI Projection Info:"); Console.WriteLine(spatialRef.ToEnviProjectionInfoString()); }
private void ShowSpatialRefInfos(TreeNode node) { if (node.Level == 0) { node.Expand(); return; } if ((node.Tag as SpatialReferenceFile).IsPrjFile == false) { node.Expand(); return; } btnModify.Enabled = true; txtSpatialRefInfo.Clear(); string txtCoordinateInfo; _spatialReference = (node.Tag as SpatialReferenceFile).SpatialReference; txtCoordinateInfo = _spatialReference.ToString(); txtSpatialRefInfo.Text = txtCoordinateInfo; }