From 547302ad25c7840aa219ac60637d6981058b18fe Mon Sep 17 00:00:00 2001 From: Xun Li Date: Tue, 15 Oct 2019 15:09:48 -0700 Subject: [PATCH] fix an issue of specifying CRS when saveas When there is no projection information of current dataset (e.g. no .prj file, or create points from a csv table), specifying CRS when exporting to a vector data format doesn't generate a .prj file or related projection information. --- DialogTools/ExportDataDlg.cpp | 14 +++++++++----- version.h | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/DialogTools/ExportDataDlg.cpp b/DialogTools/ExportDataDlg.cpp index 85d4f330e..6d0f5c8b4 100644 --- a/DialogTools/ExportDataDlg.cpp +++ b/DialogTools/ExportDataDlg.cpp @@ -587,11 +587,15 @@ ExportDataDlg::CreateOGRLayer(wxString& ds_name, bool is_table, new_ref.importFromEPSG(4326); valid_input_crs = true; } - if (spatial_ref && (valid_input_crs && !spatial_ref->IsSame(&new_ref))) { - OGRCoordinateTransformation *poCT; - poCT = OGRCreateCoordinateTransformation(spatial_ref, &new_ref); - for (size_t i=0; i < ogr_geometries.size(); i++) { - ogr_geometries[i]->transform(poCT); + if (ogr_geometries.size() > 0 && valid_input_crs) { + if (spatial_ref && spatial_ref->IsSame(&new_ref) == false) { + // transform geometries from old CRS to new CRS + OGRCoordinateTransformation *poCT; + poCT = OGRCreateCoordinateTransformation(spatial_ref, &new_ref); + for (size_t i=0; i < ogr_geometries.size(); i++) { + ogr_geometries[i]->transform(poCT); + } + OGRCoordinateTransformation::DestroyCT(poCT); } spatial_ref = &new_ref; // use new CRS } diff --git a/version.h b/version.h index 2af793a7e..dc8e8d4b5 100644 --- a/version.h +++ b/version.h @@ -5,7 +5,7 @@ namespace Gda { const int version_subbuild = 2; const int version_year = 2019; const int version_month = 10; - const int version_day = 10; + const int version_day = 15; const int version_night = 0; const int version_type = 2; // 0: alpha, 1: beta, 2: release }