[cig-commits] r7346 - in cs/spatialdata-0.1/trunk/libsrc: . geocoords spatialdb utils

brad at geodynamics.org brad at geodynamics.org
Thu Jun 21 11:53:24 PDT 2007


Author: brad
Date: 2007-06-21 11:53:23 -0700 (Thu, 21 Jun 2007)
New Revision: 7346

Modified:
   cs/spatialdata-0.1/trunk/libsrc/Makefile.am
   cs/spatialdata-0.1/trunk/libsrc/geocoords/CSCart.cc
   cs/spatialdata-0.1/trunk/libsrc/geocoords/CSGeo.cc
   cs/spatialdata-0.1/trunk/libsrc/geocoords/CSGeoLocalCart.cc
   cs/spatialdata-0.1/trunk/libsrc/geocoords/CSGeoProj.cc
   cs/spatialdata-0.1/trunk/libsrc/geocoords/Projector.cc
   cs/spatialdata-0.1/trunk/libsrc/spatialdb/SimpleIOAscii.cc
   cs/spatialdata-0.1/trunk/libsrc/utils/Makefile.am
Log:
Added ability to include C++ style comments in spatialdatabase files.

Modified: cs/spatialdata-0.1/trunk/libsrc/Makefile.am
===================================================================
--- cs/spatialdata-0.1/trunk/libsrc/Makefile.am	2007-06-21 17:44:20 UTC (rev 7345)
+++ cs/spatialdata-0.1/trunk/libsrc/Makefile.am	2007-06-21 18:53:23 UTC (rev 7346)
@@ -18,6 +18,7 @@
 lib_LTLIBRARIES = libspatialdata.la
 
 libspatialdata_la_SOURCES = \
+	utils/LineParser.cc \
 	utils/PointsStream.cc \
 	geocoords/Converter.cc \
 	geocoords/CoordSys.cc \

Modified: cs/spatialdata-0.1/trunk/libsrc/geocoords/CSCart.cc
===================================================================
--- cs/spatialdata-0.1/trunk/libsrc/geocoords/CSCart.cc	2007-06-21 17:44:20 UTC (rev 7345)
+++ cs/spatialdata-0.1/trunk/libsrc/geocoords/CSCart.cc	2007-06-21 18:53:23 UTC (rev 7346)
@@ -14,6 +14,8 @@
 
 #include "CSCart.hh" // implementation of class methods
 
+#include "spatialdata/utils/LineParser.hh" // USES LineParser
+
 #include <iostream> // USES std::istream, std::ostream
 
 #include <sstream> // USES std::ostringstream
@@ -79,18 +81,24 @@
 void 
 spatialdata::geocoords::CSCart::unpickle(std::istream& s)
 { // unpickle
+  utils::LineParser parser(s, "//");
+
   std::string token;
-  const int maxIgnore = 128;
+  std::istringstream buffer;
+  const int maxIgnore = 256;
 
-  s.ignore(maxIgnore, '{');
-  s >> token;
-  while (s.good() && token != "}") {
-    s.ignore(maxIgnore, '=');
+  parser.ignore('{');
+  parser.eatws();
+  buffer.str(parser.next());
+  buffer.clear();
+  buffer >> token;
+  while (buffer.good() && token != "}") {
+    buffer.ignore(maxIgnore, '=');
     if (0 == strcasecmp(token.c_str(), "to-meters")) {
-      s >> _toMeters;
+      buffer >> _toMeters;
     } else if (0 == strcasecmp(token.c_str(), "space-dim")) {
       int dim;
-      s >> dim;
+      buffer >> dim;
       setSpaceDim(dim);
     } else {
       std::ostringstream msg;
@@ -100,9 +108,12 @@
 	  << "  space-dim";
       throw std::runtime_error(msg.str().c_str());
     } // else
-    s >> token;
+    parser.eatws();
+    buffer.str(parser.next());
+    buffer.clear();
+    buffer >> token;
   } // while
-  if (!s.good())
+  if (token != "}")
     throw std::runtime_error("I/O error while parsing CSCart settings.");
 } // unpickle
 

Modified: cs/spatialdata-0.1/trunk/libsrc/geocoords/CSGeo.cc
===================================================================
--- cs/spatialdata-0.1/trunk/libsrc/geocoords/CSGeo.cc	2007-06-21 17:44:20 UTC (rev 7345)
+++ cs/spatialdata-0.1/trunk/libsrc/geocoords/CSGeo.cc	2007-06-21 18:53:23 UTC (rev 7346)
@@ -16,6 +16,8 @@
 
 #include "Geoid.hh" // USES Geoid
 
+#include "spatialdata/utils/LineParser.hh" // USES LineParser
+
 #include <math.h> // USES M_PI
 #include <sstream> // USES std::ostringsgream
 #include <iostream> // USES std::istream, std::ostream
@@ -210,32 +212,38 @@
 void 
 spatialdata::geocoords::CSGeo::unpickle(std::istream& s)
 { // unpickle
+  utils::LineParser parser(s, "//");
+
   std::string token;
-  const int maxIgnore = 128;
-  char buffer[maxIgnore];
+  std::istringstream buffer;
+  const int maxIgnore = 256;
+  char cbuffer[maxIgnore];
 
-  s.ignore(maxIgnore, '{');
-  s >> token;
-  while (s.good() && token != "}") {
-    s.ignore(maxIgnore, '=');
+  parser.ignore('{');
+  parser.eatws();
+  buffer.str(parser.next());
+  buffer.clear();
+  buffer >> token;
+  while (buffer.good() && token != "}") {
+    buffer.ignore(maxIgnore, '=');
     if (0 == strcasecmp(token.c_str(), "to-meters")) {
-      s >> _toMeters;
+      buffer >> _toMeters;
     } else if (0 == strcasecmp(token.c_str(), "space-dim")) {
       int ndims;
-      s >> ndims;
+      buffer >> ndims;
       setSpaceDim(ndims);
     } else if (0 == strcasecmp(token.c_str(), "ellipsoid")) {
-      s >> _ellipsoid;
+      buffer >> _ellipsoid;
     } else if (0 == strcasecmp(token.c_str(), "datum-horiz")) {
-      s >> std::ws;
-      s.get(buffer, maxIgnore, '\n');
-      _datumHoriz = buffer;
+      buffer >> std::ws;
+      buffer.get(cbuffer, maxIgnore, '\n');
+      _datumHoriz = cbuffer;
     } else if (0 == strcasecmp(token.c_str(), "datum-vert")) {
-      s >> std::ws;
-      s.get(buffer, maxIgnore, '\n');
-      _datumVert = buffer;
+      buffer >> std::ws;
+      buffer.get(cbuffer, maxIgnore, '\n');
+      _datumVert = cbuffer;
     } else if (0 == strcasecmp(token.c_str(), "is-geocentric")) {
-      s >> _isGeocentric;
+      buffer >> _isGeocentric;
     } else {
       std::ostringstream msg;
       msg << "Could not parse '" << token << "' into a CSGeo token.\n"
@@ -243,9 +251,12 @@
 	  << "  to-meters, ellipsoid, datum-horiz, datum-vert";
       throw std::runtime_error(msg.str().c_str());
     } // else
-    s >> token;
+    parser.eatws();
+    buffer.str(parser.next());
+    buffer.clear();
+    buffer >> token;
   } // while
-  if (!s.good())
+  if (token != "}")
     throw std::runtime_error("I/O error while parsing CSGeo settings.");
 } // unpickle
 

Modified: cs/spatialdata-0.1/trunk/libsrc/geocoords/CSGeoLocalCart.cc
===================================================================
--- cs/spatialdata-0.1/trunk/libsrc/geocoords/CSGeoLocalCart.cc	2007-06-21 17:44:20 UTC (rev 7345)
+++ cs/spatialdata-0.1/trunk/libsrc/geocoords/CSGeoLocalCart.cc	2007-06-21 18:53:23 UTC (rev 7346)
@@ -20,6 +20,8 @@
 
 #include "Geoid.hh" // USES Geoid
 
+#include "spatialdata/utils/LineParser.hh" // USES LineParser
+
 #include <math.h> // USES M_PI, sin(), cos()
 #include <iostream> // USES std::istream, std::ostream
 
@@ -398,37 +400,42 @@
 void 
 spatialdata::geocoords::CSGeoLocalCart::unpickle(std::istream& s)
 { // unpickle
+  utils::LineParser parser(s, "//");
+
   std::string token;
-  const int maxIgnore = 128;
-
-  char buffer[maxIgnore];
+  std::istringstream buffer;
+  const int maxIgnore = 256;
+  char cbuffer[maxIgnore];
   double val;
   std::string name;
 
-  s.ignore(maxIgnore, '{');
-  s >> token;
-  while (s.good() && token != "}") {
-    s.ignore(maxIgnore, '=');
+  parser.ignore('{');
+  parser.eatws();
+  buffer.str(parser.next());
+  buffer.clear();
+  buffer >> token;
+  while (buffer.good() && token != "}") {
+    buffer.ignore(maxIgnore, '=');
     if (0 == strcasecmp(token.c_str(), "to-meters")) {
-      s >> val;
+      buffer >> val;
       toMeters(val);
     } else if (0 == strcasecmp(token.c_str(), "ellipsoid")) {
-      s >> name;
+      buffer >> name;
       ellipsoid(name);
     } else if (0 == strcasecmp(token.c_str(), "datum-horiz")) {
-      s >> std::ws;
-      s.get(buffer, maxIgnore, '\n');
-      datumHoriz(buffer);
+      buffer >> std::ws;
+      buffer.get(cbuffer, maxIgnore, '\n');
+      datumHoriz(cbuffer);
     } else if (0 == strcasecmp(token.c_str(), "datum-vert")) {
-      s >> std::ws;
-      s.get(buffer, maxIgnore, '\n');
-      datumVert(buffer);
+      buffer >> std::ws;
+      buffer.get(cbuffer, maxIgnore, '\n');
+      datumVert(cbuffer);
     } else if (0 == strcasecmp(token.c_str(), "origin-lon")) {
-      s >> _originLon;
+      buffer >> _originLon;
     } else if (0 == strcasecmp(token.c_str(), "origin-lat")) {
-      s >> _originLat;
+      buffer >> _originLat;
     } else if (0 == strcasecmp(token.c_str(), "origin-elev")) {
-      s >> _originElev;
+      buffer >> _originElev;
     } else {
       std::ostringstream msg;
       msg << "Could not parse '" << token << "' into a CSGeoLocalCart token.\n"
@@ -437,9 +444,12 @@
 	  << "  origin-lon, origin-lat, origin-elev\n";
       throw std::runtime_error(msg.str().c_str());
     } // else
-    s >> token;
+    parser.eatws();
+    buffer.str(parser.next());
+    buffer.clear();
+    buffer >> token;
   } // while
-  if (!s.good())
+  if (token != "}")
     throw std::runtime_error("I/O error while parsing CSGeoLocalCart "
 			     "settings.");
 } // unpickle

Modified: cs/spatialdata-0.1/trunk/libsrc/geocoords/CSGeoProj.cc
===================================================================
--- cs/spatialdata-0.1/trunk/libsrc/geocoords/CSGeoProj.cc	2007-06-21 17:44:20 UTC (rev 7345)
+++ cs/spatialdata-0.1/trunk/libsrc/geocoords/CSGeoProj.cc	2007-06-21 18:53:23 UTC (rev 7346)
@@ -16,6 +16,8 @@
 
 #include "Projector.hh" // USES Projector
 
+#include "spatialdata/utils/LineParser.hh" // USES LineParser
+
 #include <iostream> // USES std::istream, std::ostream
 
 #include <stdexcept> // USES std::runtime_error, std::exception
@@ -147,33 +149,44 @@
 void 
 spatialdata::geocoords::CSGeoProj::unpickle(std::istream& s)
 { // unpickle
+  utils::LineParser parser(s, "//");
+
   std::string token;
-  const int maxIgnore = 128;
-
-  char buffer[maxIgnore];
+  std::istringstream buffer;
+  const int maxIgnore = 256;
+  char cbuffer[maxIgnore];
   double val;
   std::string name;
 
-  s.ignore(maxIgnore, '{');
-  s >> token;
-  while (s.good() && token != "}") {
-    s.ignore(maxIgnore, '=');
+  parser.ignore('{');
+  parser.eatws();
+  buffer.str(parser.next());
+  buffer.clear();
+  buffer >> token;
+  while (buffer.good() && token != "}") {
+    buffer.ignore(maxIgnore, '=');
     if (0 == strcasecmp(token.c_str(), "to-meters")) {
-      s >> val;
+      buffer >> val;
       toMeters(val);
     } else if (0 == strcasecmp(token.c_str(), "ellipsoid")) {
-      s >> name;
+      buffer >> name;
       ellipsoid(name);
     } else if (0 == strcasecmp(token.c_str(), "datum-horiz")) {
-      s >> std::ws;
-      s.get(buffer, maxIgnore, '\n');
-      datumHoriz(buffer);
+      buffer >> std::ws;
+      buffer.get(cbuffer, maxIgnore, '\n');
+      datumHoriz(cbuffer);
     } else if (0 == strcasecmp(token.c_str(), "datum-vert")) {
-      s >> std::ws;
-      s.get(buffer, maxIgnore, '\n');
-      datumVert(buffer);
+      buffer >> std::ws;
+      buffer.get(cbuffer, maxIgnore, '\n');
+      datumVert(cbuffer);
     } else if (0 == strcasecmp(token.c_str(), "projector")) {
-      s >> name;
+      std::string rbuffer(buffer.str());
+      int i = rbuffer.length()-1;
+      while (i >= 0) {
+	if ('=' == rbuffer[i])
+	  break;
+	s.putback(rbuffer[i--]);
+      } // while
       if (0 == _pProjector)
 	_pProjector = new Projector;
       _pProjector->unpickle(s);
@@ -184,9 +197,12 @@
 	  << "  to-meters, ellipsoid, datum-horiz, datum-vert, projector\n";
       throw std::runtime_error(msg.str().c_str());
     } // else
-    s >> token;
+    parser.eatws();
+    buffer.str(parser.next());
+    buffer.clear();
+    buffer >> token;
   } // while
-  if (!s.good())
+  if (token != "}")
     throw std::runtime_error("I/O error while parsing CSGeoProj "
 			     "settings.");
 } // unpickle

Modified: cs/spatialdata-0.1/trunk/libsrc/geocoords/Projector.cc
===================================================================
--- cs/spatialdata-0.1/trunk/libsrc/geocoords/Projector.cc	2007-06-21 17:44:20 UTC (rev 7345)
+++ cs/spatialdata-0.1/trunk/libsrc/geocoords/Projector.cc	2007-06-21 18:53:23 UTC (rev 7346)
@@ -21,6 +21,8 @@
 #include "proj_api.h" // USES PROJ4
 };
 
+#include "spatialdata/utils/LineParser.hh" // USES LineParser
+
 #include <iostream> // USES std::istream, std::ostream
 
 #include <stdexcept> // USES std::runtime_error, std::exception
@@ -169,23 +171,29 @@
 void 
 spatialdata::geocoords::Projector::unpickle(std::istream& s)
 { // unpickle
+  utils::LineParser parser(s, "//");
+
   std::string token;
-  const int maxIgnore = 128;
-  char buffer[maxIgnore];
+  std::istringstream buffer;
+  const int maxIgnore = 256;
+  char cbuffer[maxIgnore];
 
-  s.ignore(maxIgnore, '{');
-  s >> token;
-  while (s.good() && token != "}") {
-    s.ignore(maxIgnore, '=');
+  parser.ignore('{');
+  parser.eatws();
+  buffer.str(parser.next());
+  buffer.clear();
+  buffer >> token;
+  while (buffer.good() && token != "}") {
+    buffer.ignore(maxIgnore, '=');
     if (0 == strcasecmp(token.c_str(), "projection")) {
-      s >> _projection;
+      buffer >> _projection;
     } else if (0 == strcasecmp(token.c_str(), "units")) {
-      s >> _units;
+      buffer >> _units;
     } else if (0 == strcasecmp(token.c_str(), "proj-options")) {
-      s >> std::ws;
-      s.get(buffer, maxIgnore, '\n');
-      if (0 != strcasecmp("none", buffer))
-	_projOptions = buffer;
+      buffer >> std::ws;
+      buffer.get(cbuffer, maxIgnore, '\n');
+      if (0 != strcasecmp("none", cbuffer))
+	_projOptions = cbuffer;
     } else {
       std::ostringstream msg;
       msg << "Could not parse '" << token << "' into a Projector token.\n"
@@ -193,9 +201,12 @@
 	  << "  projection, units, proj-options";
       throw std::runtime_error(msg.str().c_str());
     } // else
-    s >> token;
+  parser.eatws();
+  buffer.str(parser.next());
+  buffer.clear();
+  buffer >> token;
   } // while
-  if (!s.good())
+  if (token != "}")
     throw std::runtime_error("I/O error while parsing Projector settings.");
 } // unpickle
 

Modified: cs/spatialdata-0.1/trunk/libsrc/spatialdb/SimpleIOAscii.cc
===================================================================
--- cs/spatialdata-0.1/trunk/libsrc/spatialdb/SimpleIOAscii.cc	2007-06-21 17:44:20 UTC (rev 7345)
+++ cs/spatialdata-0.1/trunk/libsrc/spatialdb/SimpleIOAscii.cc	2007-06-21 18:53:23 UTC (rev 7346)
@@ -23,6 +23,8 @@
 #include "spatialdata/geocoords/CSCart.hh" // USES CSCart
 #include "spatialdata/geocoords/CSPicklerAscii.hh" // USES CSPicklerAscii
 
+#include "spatialdata/utils/LineParser.hh" // USES LineParser
+
 #include <fstream> // USES std::ofstream, std::ifstream
 #include <iomanip> // USES setw(), setiosflags(), resetiosflags()
 
@@ -93,6 +95,7 @@
   } // try/catch
 } // read
 
+#include <iostream>
 // ----------------------------------------------------------------------
 // Read ascii database file.
 void
@@ -112,90 +115,116 @@
   pData->dataDim = 0;
   pData->spaceDim = 3;
 
-  std::string name;
+  utils::LineParser parser(filein, "//");
 
-  filein >> name;
-  if (0 == strcasecmp(name.c_str(), "SimpleDB")) {
-    int numVals = 0;
-    std::string token;
-    const int maxIgnore = 256;
-    filein.ignore(maxIgnore, '{');
-    filein >> token;
-    while (filein.good() && token != "}") {
-      if (0 == strcasecmp(token.c_str(), "num-values")) {
-	filein.ignore(maxIgnore, '=');
-	filein >> numVals;
-	pData->numVals = numVals;
-      } else if (0 == strcasecmp(token.c_str(), "num-locs")) {
-	filein.ignore(maxIgnore, '=');
-	filein >> pData->numLocs;
-      } else if (0 == strcasecmp(token.c_str(), "value-names")) {
-	if (numVals > 0)
-	  pData->valNames = new std::string[numVals];
-	else
-	  throw std::runtime_error("Number of values must be specified BEFORE "
-				   "names of values in SimpleDB file.");
-	filein.ignore(maxIgnore, '=');
-	for (int iVal=0; iVal < numVals; ++iVal)
-	  filein >> pData->valNames[iVal];
-      } else if (0 == strcasecmp(token.c_str(), "value-units")) {
-	if (numVals > 0)
-	  pData->valUnits = new std::string[numVals];
-	else
-	  throw std::runtime_error("Number of values must be specified BEFORE "
-				   "units of values in SimpleDB file.");
-	filein.ignore(maxIgnore, '=');
-	for (int iVal=0; iVal < numVals; ++iVal)
-	  filein >> pData->valUnits[iVal];
-      } else if (0 == strcasecmp(token.c_str(), "data-dim")) {
-	filein.ignore(maxIgnore, '=');
-	filein >> pData->dataDim;
-      } else if (0 == strcasecmp(token.c_str(), "space-dim")) {
-	filein.ignore(maxIgnore, '=');
-	filein >> pData->spaceDim;
-      } else if (0 == strcasecmp(token.c_str(), "cs-data")) {
-	spatialdata::geocoords::CSPicklerAscii::unpickle(filein, ppCS);
-      } else {
-	std::ostringstream msg;
-	msg << "Could not parse '" << token << "' into a SimpleDB setting.";
-	throw std::runtime_error(msg.str());
-      } // else
-      filein >> token;
-    } // while
-    if (!filein.good())
-      throw std::runtime_error("I/O error while parsing SimpleDB settings.");
+  std::string token;
+  std::istringstream buffer;
+  const int maxIgnore = 256;
 
-    bool ok = true;
+  parser.eatws();
+  buffer.str(parser.next());
+  buffer.clear();
+  buffer >> token;
+  if (0 != strcasecmp(token.c_str(), "SimpleDB")) {
     std::ostringstream msg;
-    if (0 == pData->numVals) {
-      ok = false;
-      msg << "SimpleDB settings must include 'num-values'.\n";
-    } // if
-    if (0 == pData->numLocs) {
-      ok = false;
-      msg << "SimpleDB settings must include 'num-locs'.\n";
-    } // if
-    if (0 == pData->valNames) {
-      ok = false;
-      msg << "SimpleDB settings must include 'value-names'.\n";
-    } // if
-    if (0 == pData->valUnits) {
-      ok = false;
-      msg << "SimpleDB settings must include 'value-units'.\n";
-    } // if
-    if (!ok)
-      throw std::runtime_error(msg.str());
-  } else {
-    std::ostringstream msg;
-    msg << "Could not parse '" << name << "' into 'SimpleDB'.\n";
+    msg << "Could not parse '" << token << "' into 'SimpleDB'.\n";
     throw std::runtime_error(msg.str());
   } // else
 
-  const int dataSize = pData->numLocs * (pData->spaceDim + pData->numVals);
+  int numVals = 0;
+  parser.eatws();
+  buffer.str(parser.next());
+  buffer.clear();
+  buffer >> token;
+  while (buffer.good() && token != "}") {
+    if (0 == strcasecmp(token.c_str(), "num-values")) {
+      buffer.ignore(maxIgnore, '=');
+      buffer >> numVals;
+      pData->numVals = numVals;
+    } else if (0 == strcasecmp(token.c_str(), "num-locs")) {
+      buffer.ignore(maxIgnore, '=');
+      buffer >> pData->numLocs;
+    } else if (0 == strcasecmp(token.c_str(), "value-names")) {
+      if (numVals > 0)
+	pData->valNames = new std::string[numVals];
+      else
+	throw std::runtime_error("Number of values must be specified BEFORE "
+				 "names of values in SimpleDB file.");
+      buffer.ignore(maxIgnore, '=');
+      for (int iVal=0; iVal < numVals; ++iVal)
+	buffer >> pData->valNames[iVal];
+    } else if (0 == strcasecmp(token.c_str(), "value-units")) {
+      if (numVals > 0)
+	pData->valUnits = new std::string[numVals];
+      else
+	throw std::runtime_error("Number of values must be specified BEFORE "
+				 "units of values in SimpleDB file.");
+      buffer.ignore(maxIgnore, '=');
+      for (int iVal=0; iVal < numVals; ++iVal)
+	buffer >> pData->valUnits[iVal];
+    } else if (0 == strcasecmp(token.c_str(), "data-dim")) {
+      buffer.ignore(maxIgnore, '=');
+      buffer >> pData->dataDim;
+    } else if (0 == strcasecmp(token.c_str(), "space-dim")) {
+      buffer.ignore(maxIgnore, '=');
+      buffer >> pData->spaceDim;
+    } else if (0 == strcasecmp(token.c_str(), "cs-data")) {
+      buffer.ignore(maxIgnore, '=');
+      std::string rbuffer(buffer.str());
+      int i = rbuffer.length();
+      while (i >= 0) {
+	filein.putback(rbuffer[i]);
+	if ('=' == rbuffer[i--])
+	  break;
+      } // while
+      spatialdata::geocoords::CSPicklerAscii::unpickle(filein, ppCS);
+    } else {
+      std::ostringstream msg;
+      msg << "Could not parse '" << token << "' into a SimpleDB setting.";
+      throw std::runtime_error(msg.str());
+    } // else
+
+    parser.eatws();
+    buffer.str(parser.next());
+    buffer.clear();
+    buffer >> token;
+  } // while
+  if (token != "}")
+    throw std::runtime_error("I/O error while parsing SimpleDB settings.");
+
+  bool ok = true;
+  std::ostringstream msg;
+  if (0 == pData->numVals) {
+    ok = false;
+    msg << "SimpleDB settings must include 'num-values'.\n";
+  } // if
+  if (0 == pData->numLocs) {
+    ok = false;
+    msg << "SimpleDB settings must include 'num-locs'.\n";
+  } // if
+  if (0 == pData->valNames) {
+    ok = false;
+      msg << "SimpleDB settings must include 'value-names'.\n";
+  } // if
+  if (0 == pData->valUnits) {
+    ok = false;
+    msg << "SimpleDB settings must include 'value-units'.\n";
+  } // if
+  if (!ok)
+    throw std::runtime_error(msg.str());
+  
+  
+  const int dataLocSize = pData->spaceDim + pData->numVals;
+  const int dataTotalSize = pData->numLocs * dataLocSize;
   delete[] pData->data; 
-  pData->data = (dataSize > 0) ? new double[dataSize] : 0;
-  for (int i=0; i < dataSize; ++i)
-    filein >> pData->data[i];
+  pData->data = (dataTotalSize > 0) ? new double[dataTotalSize] : 0;
+  for (int iLoc=0, i=0; iLoc < pData->numLocs; ++iLoc) {
+    parser.eatws();
+    buffer.str(parser.next());
+    buffer.clear();
+    for (int iVal=0; iVal < dataLocSize; ++iVal)
+      buffer >> pData->data[i++];
+  } // for
   if (!filein.good())
     throw std::runtime_error("I/O error while reading SimpleDB data.");
   

Modified: cs/spatialdata-0.1/trunk/libsrc/utils/Makefile.am
===================================================================
--- cs/spatialdata-0.1/trunk/libsrc/utils/Makefile.am	2007-06-21 17:44:20 UTC (rev 7345)
+++ cs/spatialdata-0.1/trunk/libsrc/utils/Makefile.am	2007-06-21 18:53:23 UTC (rev 7346)
@@ -14,6 +14,7 @@
 include $(top_srcdir)/subpackage.am
 
 subpkginclude_HEADERS = \
+	LineParser.hh \
 	PointsStream.hh \
 	PointsStream.icc
 



More information about the cig-commits mailing list