[GRASS-SVN] r72112 - in grass/trunk: include/defs lib/gis

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jan 22 06:56:43 PST 2018


Author: mmetz
Date: 2018-01-22 06:56:43 -0800 (Mon, 22 Jan 2018)
New Revision: 72112

Modified:
   grass/trunk/include/defs/gis.h
   grass/trunk/lib/gis/make_loc.c
Log:
libgis: +G_make_location_epsg()

Modified: grass/trunk/include/defs/gis.h
===================================================================
--- grass/trunk/include/defs/gis.h	2018-01-22 14:28:00 UTC (rev 72111)
+++ grass/trunk/include/defs/gis.h	2018-01-22 14:56:43 UTC (rev 72112)
@@ -504,6 +504,8 @@
 /* make_loc.c */
 int G_make_location(const char *, struct Cell_head *, const struct Key_Value *,
 		    const struct Key_Value *);
+int G_make_location_epsg(const char *, struct Cell_head *, const struct Key_Value *,
+			 const struct Key_Value *, const struct Key_Value *);
 int G_compare_projections(const struct Key_Value *, const struct Key_Value *,
 			  const struct Key_Value *, const struct Key_Value *);
 

Modified: grass/trunk/lib/gis/make_loc.c
===================================================================
--- grass/trunk/lib/gis/make_loc.c	2018-01-22 14:28:00 UTC (rev 72111)
+++ grass/trunk/lib/gis/make_loc.c	2018-01-22 14:56:43 UTC (rev 72112)
@@ -93,6 +93,59 @@
 }
 
 /*!
+ * \brief Create a new location
+ * 
+ * This function creates a new location in the current database,
+ * initializes the projection, default window and current window,
+ * and sets the EPSG code if present
+ *
+ * \param location_name Name of the new location. Should not include
+ *                      the full path, the location will be created within
+ *                      the current database.
+ * \param wind          default window setting for the new location.
+ *                      All fields should be set in this
+ *                      structure, and care should be taken to ensure that
+ *                      the proj/zone fields match the definition in the
+ *                      proj_info parameter(see G_set_cellhd_from_projinfo()).
+ *
+ * \param proj_info     projection definition suitable to write to the
+ *                      PROJ_INFO file, or NULL for PROJECTION_XY.
+ *
+ * \param proj_units    projection units suitable to write to the PROJ_UNITS
+ *                      file, or NULL.
+ * 
+ * \param proj_epsg     EPSG code suitable to write to the PROJ_EPSG
+ *                      file, or NULL.
+ *
+ * \return 0 on success
+ * \return -1 to indicate a system error (check errno).
+ * \return -2 failed to create projection file (currently not used)
+ * \return -3 illegal name 
+ */
+int G_make_location_epsg(const char *location_name,
+			 struct Cell_head *wind,
+			 const struct Key_Value *proj_info,
+			 const struct Key_Value *proj_units,
+			 const struct Key_Value *proj_epsg)
+{
+    int ret;
+    char path[GPATH_MAX];
+
+    ret = G_make_location(location_name, wind, proj_info, proj_units);
+
+    if (ret != 0)
+	return ret;
+
+    /* Write out the PROJ_EPSG if available. */
+    if (proj_epsg != NULL) {
+	G_file_name(path, "", "PROJ_EPSG", "PERMANENT");
+	G_write_key_value_file(path, proj_epsg);
+    }
+
+    return 0;
+}
+
+/*!
  * \brief Compare projections including units
  *
  *  \param proj_info1   projection info to compare



More information about the grass-commit mailing list