/// <summary> /// Displays a single projection string /// </summary> /// <param name="item">Listview item</param> /// <param name="projection">String to display</param> private void UpdateDialectString(ListViewItem item, string projection) { MapWinGIS.GeoProjection projTest = new GeoProjection(); string projType = projTest.ImportFromProj4(projection) ? "proj4" : "WKT"; projTest = null; item.SubItems.Add(projType); item.SubItems.Add(projection); }
private void CheckNewMethods() { axMap1.DeserializeLayer(1, "Test"); var projection = new GeoProjection(); projection.ImportFromProj4("g"); var t = tkSavingMode.modeXMLOverwrite; axMap1.SaveMapState("r", true, true); axMap1.set_LayerSkipOnSaving(1, true); var sf = new Shapefile(); var reprojectedCount = 0; sf.Reproject(projection, ref reprojectedCount); var geoProjection = sf.GeoProjection; var sfSimple = sf.SimplifyLines(10, false); var gridHeader = new GridHeader(); var gridHeaderGeoProjection = gridHeader.GeoProjection; var ext = axMap1.MaxExtents; var utils = new Utils(); utils.ClipGridWithPolygon("test", sfSimple.Shape[0], "new", false); utils.Polygonize(string.Empty, string.Empty, 1, false, string.Empty, "ESRI Shapefile", string.Empty); utils.GDALInfo(string.Empty, string.Empty); utils.TranslateRaster(string.Empty, string.Empty, string.Empty); utils.OGRInfo(string.Empty, string.Empty); utils.OGR2OGR(string.Empty, string.Empty, string.Empty); utils.GDALAddOverviews(string.Empty, string.Empty, string.Empty); utils.GDALBuildVrt(string.Empty, string.Empty); utils.GDALRasterize(string.Empty, string.Empty, string.Empty); utils.GDALWarp(string.Empty, string.Empty, string.Empty); var ds = new GdalDataset(); var subDatasetCount = ds.SubDatasetCount; }
// <summary> // Some operaions with GeoProjection object // </summary> public void GeoProjection(AxMap axMap1) { GeoProjection proj = new GeoProjection(); // EPSG code proj.ImportFromEPSG(4326); // WGS84 // proj 4 string proj.ImportFromProj4("+proj=longlat +datum=WGS84 +no_defs"); // WGS84 // autodetect the format string unknown_format = "4326"; proj.ImportFromAutoDetect(unknown_format); // from file string filename = "some_name"; proj.ReadFromFile(filename); // show the name of the loaded projection Debug.Print("Projection loaded: " + proj.Name); // show proj 4 representation Debug.Print("Proj4 representation: " + proj.ExportToProj4()); // let's show the properties of the geographic projection string s = ""; double[] arr = new double[5]; for (int i = 0; i < 5; i++) { // extract the parameter in element of val arr proj.get_GeogCSParam((tkGeogCSParameter)i, ref arr[i]); // append the name of parameter and the value to the string s += (tkGeogCSParameter)i + ": " + arr[i] + Environment.NewLine; } MessageBox.Show("Parameters of geographic coordinate system: " + Environment.NewLine + s); }
public bool ImportFromProj4(string proj) { return(_projection.ImportFromProj4(proj)); }