Skip to content

Commit

Permalink
Added constructor to support Hyrax demo.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelleerilee committed Jul 3, 2019
1 parent bce4c03 commit 9ce7b6a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
3 changes: 3 additions & 0 deletions include/STARE.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ typedef std::vector<STARE_ArrayIndexSpatialValue> STARE_ArrayIndexSpatialValues;
class STARE {
public:
STARE();
STARE( int search_level, int build_level );
STARE( int search_level, int build_level, SpatialRotation rotate_root_octahedron );
virtual ~STARE();

void defaultConfiguration();

uint32 sSearchLevel() const; /// Location precision level in the sIndex.

Expand Down
24 changes: 18 additions & 6 deletions src/STARE.C
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,44 @@ extern "C" const char *STARE_version() {
*
*/
STARE::STARE() {

SpatialVector axis = 0.5*xhat + 0.5*yhat; axis.normalize();
float64 theta = 0.25*gPi - 12.0e-9; // bump it over a 27-level triangle
rotate_root_octahedron = SpatialRotation(axis,theta);
defaultConfiguration();
sIndex = SpatialIndex(search_level, build_level, rotate_root_octahedron);
sIndexes.insert(std::make_pair(search_level,sIndex));
/*if( sIndexes.find(search_level) ) {
// The level was found...
}*/
}

STARE::STARE( int search_level, int build_level ) {
defaultConfiguration();
this->search_level = search_level;
this->build_level = build_level;
sIndex = SpatialIndex(this->search_level, this->build_level, this->rotate_root_octahedron);
sIndexes.insert(std::make_pair(search_level,sIndex));
}

STARE::STARE(
int search_level, int build_level, SpatialRotation rotate_root_octahedron ) {

this->search_level = search_level;
this->build_level = build_level;
this->rotate_root_octahedron = rotate_root_octahedron;

sIndex = SpatialIndex(search_level, build_level, this->rotate_root_octahedron);
sIndexes.insert(std::make_pair(search_level,sIndex));
sIndex = SpatialIndex(this->search_level, this->build_level, this->rotate_root_octahedron);
sIndexes.insert(std::make_pair(this->search_level,sIndex));
}

STARE::~STARE() {
// TODO Auto-generated destructor stub
}

void STARE::defaultConfiguration() {
SpatialVector axis = 0.5*xhat + 0.5*yhat; axis.normalize();
float64 theta = 0.25*gPi - 12.0e-9; // bump it over a 27-level triangle
rotate_root_octahedron = SpatialRotation(axis,theta);
}


uint32 STARE::sSearchLevel() const {
return sIndex.getMaxlevel();
}
Expand Down
7 changes: 6 additions & 1 deletion tests/CUTE/STARE_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ void STARE_test() {

STARE index;
STARE index1(index.getSearchLevel(),index.getBuildLevel(),index.getRotation());
STARE index2(index.getSearchLevel(),index.getBuildLevel());

// ASSERT_EQUAL(1,index.ValueFromLatLonDegrees(45.0, 45.0));

Expand All @@ -30,13 +31,15 @@ void STARE_test() {
cout << "aIndex: " << hex << aIndex << dec << endl;
*/
STARE_ArrayIndexSpatialValue aIndex1 = index1.ValueFromLatLonDegrees(latlon0.lat,latlon0.lon,8);
STARE_ArrayIndexSpatialValue aIndex2 = index2.ValueFromLatLonDegrees(latlon0.lat,latlon0.lon,8);
/*
cout << "aIndex1: " << hex << aIndex1 << dec << endl;
cout << "Resolution level tr0: " << index.ResolutionLevelFromValue(aIndex) << endl;
*/
ASSERT_EQUALM("Compare default and specified constructors",aIndex,aIndex1);

LatLonDegrees64 latlon1 = index.LatLonDegreesFromValue(aIndex);
LatLonDegrees64 latlon1 = index.LatLonDegreesFromValue(aIndex1);
LatLonDegrees64 latlon2 = index.LatLonDegreesFromValue(aIndex2);
// cout << "latlon1: " << latlon1.lat << " " << latlon1.lon << endl;

// float64 tol = 1.0e-14; /// What's our floating point error?
Expand All @@ -47,6 +50,8 @@ void STARE_test() {
// cout << "delta-lon: " << latlon1.lon - latlon0.lon << endl;
ASSERT_EQUAL_DELTAM("Round trip lat <-> sIndex",latlon0.lat,latlon1.lat,tol);
ASSERT_EQUAL_DELTAM("Round trip lon <-> sIndex",latlon0.lon,latlon1.lon,tol);
ASSERT_EQUAL_DELTAM("Round trip lat <-> sIndex",latlon0.lat,latlon2.lat,tol);
ASSERT_EQUAL_DELTAM("Round trip lon <-> sIndex",latlon0.lon,latlon2.lon,tol);

// int level = 27; // works-ish... fails due to rounding errors.
// int level = 26; // works-ish...
Expand Down

0 comments on commit 9ce7b6a

Please sign in to comment.