[GRASS-SVN] r72325 - in grass/branches/releasebranch_7_4: lib/vector/Vlib vector/v.out.ogr
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Mar 5 07:05:33 PST 2018
Author: mmetz
Date: 2018-03-05 07:05:32 -0800 (Mon, 05 Mar 2018)
New Revision: 72325
Modified:
grass/branches/releasebranch_7_4/lib/vector/Vlib/write_ogr.c
grass/branches/releasebranch_7_4/vector/v.out.ogr/main.c
Log:
v.external.out/v.out.ogr: add CRS EPSG code if available (backport trunk r72160)
Modified: grass/branches/releasebranch_7_4/lib/vector/Vlib/write_ogr.c
===================================================================
--- grass/branches/releasebranch_7_4/lib/vector/Vlib/write_ogr.c 2018-03-05 14:57:59 UTC (rev 72324)
+++ grass/branches/releasebranch_7_4/lib/vector/Vlib/write_ogr.c 2018-03-05 15:05:32 UTC (rev 72325)
@@ -136,9 +136,10 @@
}
if (OGR_L_DeleteFeature(ogr_info->layer,
- ogr_info->offset.array[offset]) != OGRERR_NONE)
+ ogr_info->offset.array[offset]) != OGRERR_NONE) {
G_warning(_("Unable to delete feature"));
return -1;
+ }
return 0;
#else
@@ -269,7 +270,7 @@
OGRSpatialReferenceH Ogr_spatial_ref;
struct field_info *Fi;
- struct Key_Value *projinfo, *projunits;
+ struct Key_Value *projinfo, *projunits, *projepsg;
struct Format_info_ogr *ogr_info;
OGRwkbGeometryType Ogr_geom_type;
@@ -285,7 +286,8 @@
/* get spatial reference */
projinfo = G_get_projinfo();
projunits = G_get_projunits();
- Ogr_spatial_ref = GPJ_grass_to_osr(projinfo, projunits);
+ projepsg = G_get_projepsg();
+ Ogr_spatial_ref = GPJ_grass_to_osr2(projinfo, projunits, projepsg);
G_free_key_value(projinfo);
G_free_key_value(projunits);
Modified: grass/branches/releasebranch_7_4/vector/v.out.ogr/main.c
===================================================================
--- grass/branches/releasebranch_7_4/vector/v.out.ogr/main.c 2018-03-05 14:57:59 UTC (rev 72324)
+++ grass/branches/releasebranch_7_4/vector/v.out.ogr/main.c 2018-03-05 15:05:32 UTC (rev 72325)
@@ -27,7 +27,7 @@
#include "local_proto.h"
-#include "ogr_srs_api.h"
+#include <ogr_srs_api.h>
int main(int argc, char *argv[])
{
@@ -260,23 +260,16 @@
G_get_default_window(&cellhd);
Ogr_projection = NULL;
if (cellhd.proj != PROJECTION_XY) {
- const char *epsg;
+ struct Key_Value *projinfo, *projunits, *projepsg;
- Ogr_projection = NULL;
- /* try EPSG code first */
- epsg = G_database_epsg_code();
- if (!epsg) {
- struct Key_Value *projinfo, *projunits;
-
- projinfo = G_get_projinfo();
- projunits = G_get_projunits();
- Ogr_projection = GPJ_grass_to_osr(projinfo, projunits);
- }
- else {
- Ogr_projection = OSRNewSpatialReference(NULL);
- if (OSRImportFromEPSG(Ogr_projection, atoi(epsg)) != OGRERR_NONE)
- G_fatal_error(_("Unknown EPSG code %s"), epsg);
- }
+ projinfo = G_get_projinfo();
+ projunits = G_get_projunits();
+ projepsg = G_get_projepsg();
+ Ogr_projection = GPJ_grass_to_osr2(projinfo, projunits, projepsg);
+
+ if (Ogr_projection == NULL)
+ G_fatal_error(_("Unable to create OGR spatial reference"));
+
if (flags.esristyle->answer &&
(strcmp(options.format->answer, "ESRI_Shapefile") == 0))
OSRMorphToESRI(Ogr_projection);
More information about the grass-commit
mailing list