[cig-commits] r19859 - in cs/spatialdata/trunk: . libsrc/geocoords
brad at geodynamics.org
brad at geodynamics.org
Fri Mar 23 14:13:49 PDT 2012
Author: brad
Date: 2012-03-23 14:13:48 -0700 (Fri, 23 Mar 2012)
New Revision: 19859
Modified:
cs/spatialdata/trunk/CHANGES
cs/spatialdata/trunk/libsrc/geocoords/CSGeo.cc
cs/spatialdata/trunk/libsrc/geocoords/Projector.cc
Log:
Added ability to use empty datums and ellipsoid for use with +init projection options. Useful for Google Earth projections.
Modified: cs/spatialdata/trunk/CHANGES
===================================================================
--- cs/spatialdata/trunk/CHANGES 2012-03-23 14:14:01 UTC (rev 19858)
+++ cs/spatialdata/trunk/CHANGES 2012-03-23 21:13:48 UTC (rev 19859)
@@ -1,3 +1,8 @@
+2012/03/23
+
+ Added ability to use empty ellipsoid and datum in order to use +init option
+ for Google Earth projections.
+
2012/01/27 (version 1.8.1)
Fixed parsing of non-derived units (e.g., degree and radian) in for
Modified: cs/spatialdata/trunk/libsrc/geocoords/CSGeo.cc
===================================================================
--- cs/spatialdata/trunk/libsrc/geocoords/CSGeo.cc 2012-03-23 14:14:01 UTC (rev 19858)
+++ cs/spatialdata/trunk/libsrc/geocoords/CSGeo.cc 2012-03-23 21:13:48 UTC (rev 19859)
@@ -237,11 +237,15 @@
std::ostringstream args;
const char* proj = (_isGeocentric) ? "geocent" : "latlong";
- args
- << "+proj=" << proj
- << " +ellps=" << _ellipsoid
- << " +datum=" << _datumHoriz
- << " +units=m";
+ args << "+proj=" << proj;
+ if (_ellipsoid.length() > 0) {
+ args << " +ellps=" << _ellipsoid;
+ } // if
+ if (_datumHoriz.length() > 0) {
+ args << " +datum=" << _datumHoriz;
+ } // if
+ args << " +units=m";
+
return std::string(args.str());
} // _projCSString
@@ -273,6 +277,13 @@
const int maxIgnore = 256;
char cbuffer[maxIgnore];
+ // Set parameters to empty values.
+ _toMeters = 1.0;
+ setSpaceDim(2);
+ _ellipsoid = "";
+ _datumHoriz = "";
+ _datumVert = "ellipsoid";
+
parser.ignore('{');
buffer.str(parser.next());
buffer.clear();
Modified: cs/spatialdata/trunk/libsrc/geocoords/Projector.cc
===================================================================
--- cs/spatialdata/trunk/libsrc/geocoords/Projector.cc 2012-03-23 14:14:01 UTC (rev 19858)
+++ cs/spatialdata/trunk/libsrc/geocoords/Projector.cc 2012-03-23 21:13:48 UTC (rev 19859)
@@ -32,6 +32,7 @@
#include <stdexcept> // USES std::runtime_error, std::exception
#include <sstream> // USES std::ostringstream
#include <strings.h> // USES strcasecmp()
+#include <string.h> // USES strlen()
#include <assert.h> // USES assert()
// ----------------------------------------------------------------------
@@ -70,12 +71,17 @@
const char* datumHoriz = csGeo.datumHoriz();
std::ostringstream args;
- args
- << "+proj=" << _projection
- << " +ellps=" << ellipsoid
- << " +datum=" << datumHoriz
- << " +units=" << _units
- << " " << _projOptions;
+ args << "+proj=" << _projection;
+ if (strlen(ellipsoid) > 0) {
+ args << " +ellps=" << ellipsoid;
+ } // if
+ if (strlen(datumHoriz) > 0) {
+ args << " +datum=" << datumHoriz;
+ } // if
+ if (_units.length() > 0) {
+ args << " +units=" << _units;
+ } // if
+ args << " " << _projOptions;
pj_free(_pProj);
_pProj = pj_init_plus(args.str().c_str());
More information about the CIG-COMMITS
mailing list