/// <summary> /// Assignes selected projection and displays results /// </summary> public bool Assign(string filename, ISpatialReference proj) { var projWgs84 = new SpatialReference(); if (!projWgs84.ImportFromEpsg(4326)) { MessageService.Current.Warn("Failed to initialize WGS84 coordinate system."); return(false); } bool sameProj = proj.IsSame(projWgs84); int count = 0; bool success = false; int rowIndex = dgv.Rows.Add(); _shapefile = new FeatureSet(filename); Text = @"Assigning projection: " + Path.GetFileName(filename); lblProjection.Text = @"Projection: " + proj.Name; // it will be faster to assing new instance of class // as ImportFromEPSG() is slow according to GDAL documentation _shapefile.Projection.CopyFrom(proj); if (!sameProj) { // we can't show preview on map without reprojection if ((_shapefile.StartEditingShapes())) { if (_shapefile.ReprojectInPlace(projWgs84, ref count)) { success = true; } } } else { success = true; } if (success) { AddShapefile(_shapefile); return(true); } // no success in reprojection _shapefile.Close(); return(false); }