Skip to content

Commit

Permalink
Merge pull request #12 from rad-lanl/master
Browse files Browse the repository at this point in the history
Update GeoTess to v2.7, expose new methods
  • Loading branch information
jkmacc-LANL authored May 23, 2024
2 parents 244a7de + d4bd52b commit a0778ba
Show file tree
Hide file tree
Showing 72 changed files with 5,802 additions and 3,233 deletions.
45 changes: 41 additions & 4 deletions geotess/src/CPPUtils.cc
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ string CPPUtils::itos(int i, const string& frmt)
{
char s[300];

sprintf(s, frmt.c_str(), i);
snprintf(s, 300, frmt.c_str(), i);
return s;
}

Expand Down Expand Up @@ -163,7 +163,7 @@ string CPPUtils::ltos(LONG_INT l, const string& frmt)
{
char s[300];

sprintf(s, frmt.c_str(), l);
snprintf(s, 300, frmt.c_str(), l);
return s;
}

Expand Down Expand Up @@ -192,7 +192,7 @@ string CPPUtils::ftos(float f, const string& frmt)
{
char s[300];

sprintf(s, frmt.c_str(), f);
snprintf(s, 300, frmt.c_str(), f);
return s;
}

Expand Down Expand Up @@ -221,7 +221,7 @@ string CPPUtils::dtos(double d, const string& frmt)
{
char s[300];

sprintf(s, frmt.c_str(), d);
snprintf(s, 300, frmt.c_str(), d);
return s;
}

Expand Down Expand Up @@ -505,4 +505,41 @@ void CPPUtils::tokenizeString(const string& str, const string& delim,
}
}

void CPPUtils::split(const string& s, const string& delim, vector<string>& tokens)
{
tokens.clear();
if (s.size() > 0)
{
if (delim.size() == 0)
{
tokens.push_back(s);
return;
}
string newString = s;
size_t pos = newString.find(delim);
while (pos != string::npos)
{
tokens.push_back(newString.substr(0, pos));
newString = newString.substr(pos+delim.size());
pos = newString.find(delim);
}
tokens.push_back(newString);
}
}

string CPPUtils::replace(const string& s, const string& r, const string& n)
{
string newString = s;
if (s.size() > 0 && r.size() > 0)
{
size_t pos = newString.find(r);
if (pos != string::npos)
{
newString = newString.replace(pos, r.size(), n);
pos = newString.find(r);
}
}
return newString;
}

} // end namespace geotess
19 changes: 19 additions & 0 deletions geotess/src/CPPUtils.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,25 @@ class GEOTESS_EXP_IMP CPPUtils
static string stringReplaceAll(const string& sf, const string& sr,
const string& s);

/**
* Modify a copy of string s by replacing the first occurrence of string r with string n
* and return the copy. This method functions much like the similarly named method in Java.
* @param s the string to be modified
* @param r the substring in s that is to be replaced
* @param n the new substring that is to replace substring r in s.
* @return a new string that is a copy of s with substring r replaced with substring n
*/
static string replace(const string& s, const string& r, const string& n);

/**
* Split string s into substrings using string delim as the delimiter.
* This method functions much like the similarly named method in Java.
* @param s the string to be split
* @param delim the delimiter
* @param tokens the vector of substrings.
*/
static void split(const string& s, const string& delim, vector<string>& tokens);

/**
* Removes '/r', '/n', or '/r/n' from the end of the input string if it exists.
*/
Expand Down
Empty file modified geotess/src/CpuTimer.cc
100755 → 100644
Empty file.
Empty file modified geotess/src/CpuTimer.h
100755 → 100644
Empty file.
Empty file modified geotess/src/DataType.cc
100755 → 100644
Empty file.
10 changes: 5 additions & 5 deletions geotess/src/EarthShape.cc
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
//- ****************************************************************************
//-
//-
//- Copyright 2009 Sandia Corporation. Under the terms of Contract
//- DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
//- retains certain rights in this software.
//-
//-
//- BSD Open Source License.
//- All rights reserved.
//-
//-
//- Redistribution and use in source and binary forms, with or without
//- modification, are permitted provided that the following conditions are met:
//-
//-
//- * Redistributions of source code must retain the above copyright notice,
//- this list of conditions and the following disclaimer.
//- * Redistributions in binary form must reproduce the above copyright
Expand All @@ -18,7 +18,7 @@
//- * Neither the name of Sandia National Laboratories nor the names of its
//- contributors may be used to endorse or promote products derived from
//- this software without specific prior written permission.
//-
//-
//- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
//- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
//- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Expand Down
13 changes: 7 additions & 6 deletions geotess/src/EarthShape.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
//- ****************************************************************************
//-
//-
//- Copyright 2009 Sandia Corporation. Under the terms of Contract
//- DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
//- retains certain rights in this software.
//-
//-
//- BSD Open Source License.
//- All rights reserved.
//-
//-
//- Redistribution and use in source and binary forms, with or without
//- modification, are permitted provided that the following conditions are met:
//-
//-
//- * Redistributions of source code must retain the above copyright notice,
//- this list of conditions and the following disclaimer.
//- * Redistributions in binary form must reproduce the above copyright
Expand All @@ -18,7 +18,7 @@
//- * Neither the name of Sandia National Laboratories nor the names of its
//- contributors may be used to endorse or promote products derived from
//- this software without specific prior written permission.
//-
//-
//- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
//- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
//- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Expand All @@ -40,6 +40,7 @@

#include <iostream>
#include <string>
#include <stdio.h>

// use standard library objects
using namespace std;
Expand Down Expand Up @@ -429,7 +430,7 @@ class GEOTESS_EXP_IMP EarthShape
{
char s[300];
string frmt("%9.5f %10.5f");
sprintf(s, frmt.c_str(), getLatDegrees(v), getLonDegrees(v));
snprintf(s, 300, frmt.c_str(), getLatDegrees(v), getLonDegrees(v));
return s;
}

Expand Down
36 changes: 0 additions & 36 deletions geotess/src/EathShape.cc

This file was deleted.

Empty file modified geotess/src/EnumType.cc
100755 → 100644
Empty file.
Empty file modified geotess/src/GeoTessData.cc
100755 → 100644
Empty file.
Empty file modified geotess/src/GeoTessData.h
100755 → 100644
Empty file.
Empty file modified geotess/src/GeoTessDataArray.cc
100755 → 100644
Empty file.
15 changes: 7 additions & 8 deletions geotess/src/GeoTessDataArray.h
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
//- ****************************************************************************
//-
//-
//- Copyright 2009 Sandia Corporation. Under the terms of Contract
//- DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
//- retains certain rights in this software.
//-
//-
//- BSD Open Source License.
//- All rights reserved.
//-
//-
//- Redistribution and use in source and binary forms, with or without
//- modification, are permitted provided that the following conditions are met:
//-
//-
//- * Redistributions of source code must retain the above copyright notice,
//- this list of conditions and the following disclaimer.
//- * Redistributions in binary form must reproduce the above copyright
Expand All @@ -18,7 +18,7 @@
//- * Neither the name of Sandia National Laboratories nor the names of its
//- contributors may be used to endorse or promote products derived from
//- this software without specific prior written permission.
//-
//-
//- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
//- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
//- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Expand Down Expand Up @@ -432,7 +432,7 @@ class GEOTESS_EXP_IMP GeoTessDataArray : public GeoTessData
template<>
inline bool GeoTessDataArray<double>::isNaN(int attributeIndex) const
{
return (values[attributeIndex] == values [attributeIndex]);
return std::isnan(values[attributeIndex]);
}

/**
Expand All @@ -441,8 +441,7 @@ inline bool GeoTessDataArray<double>::isNaN(int attributeIndex) const
template<>
inline bool GeoTessDataArray<float>::isNaN(int attributeIndex) const
{
double v = (double) values[attributeIndex];
return (v == v);
return std::isnan(values[attributeIndex]);
}

/**
Expand Down
Empty file modified geotess/src/GeoTessDataType.h
100755 → 100644
Empty file.
Empty file modified geotess/src/GeoTessDataValue.cc
100755 → 100644
Empty file.
3 changes: 1 addition & 2 deletions geotess/src/GeoTessDataValue.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,7 @@ inline bool GeoTessDataValue<double>::isNaN(int attributeIndex) const
template<>
inline bool GeoTessDataValue<float>::isNaN(int attributeIndex) const
{
double v = (double) value;
return (std::isnan(v));
return (std::isnan(value));
}

/**
Expand Down
Empty file modified geotess/src/GeoTessEnumType.h
100755 → 100644
Empty file.
Empty file modified geotess/src/GeoTessException.cc
100755 → 100644
Empty file.
Empty file modified geotess/src/GeoTessException.h
100755 → 100644
Empty file.
Loading

0 comments on commit a0778ba

Please sign in to comment.