Move to new SGBucket API
This commit is contained in:
parent
f0895597b9
commit
143ea6efe6
11 changed files with 54 additions and 64 deletions
|
@ -317,7 +317,7 @@ void Airport::BuildBtg(const std::string& root, const string_list& elev_src )
|
|||
apt_lon = apt_lon / (double)num_samples;
|
||||
apt_lat = apt_lat / (double)num_samples;
|
||||
|
||||
SGBucket b( apt_lon, apt_lat );
|
||||
SGBucket b( SGGeod::fromDeg(apt_lon, apt_lat) );
|
||||
TG_LOG(SG_GENERAL, SG_DEBUG, b.gen_base_path() << "/" << b.gen_index_str());
|
||||
|
||||
// If we are cutting in the linear features, add them first
|
||||
|
|
|
@ -201,11 +201,9 @@ void TGConstruct::LoadSharedEdgeData( int stage )
|
|||
// we need to read just 4 buckets for stage 1 - 1 for each edge
|
||||
std::vector<SGGeod> north, south, east, west;
|
||||
SGBucket nb, sb, eb, wb;
|
||||
double clon = bucket.get_center_lon();
|
||||
double clat = bucket.get_center_lat();
|
||||
|
||||
// Read North tile and add its southern nodes
|
||||
nb = sgBucketOffset(clon, clat, 0, 1);
|
||||
nb = bucket.sibling(0, 1);
|
||||
LoadNeighboorEdgeDataStage1( nb, north, south, east, west );
|
||||
// Add southern nodes from northern tile
|
||||
for (unsigned int i=0; i<south.size(); i++) {
|
||||
|
@ -213,21 +211,21 @@ void TGConstruct::LoadSharedEdgeData( int stage )
|
|||
}
|
||||
|
||||
// Read South Tile and add its northern nodes
|
||||
sb = sgBucketOffset(clon, clat, 0, -1);
|
||||
sb = bucket.sibling(0, -1);
|
||||
LoadNeighboorEdgeDataStage1( sb, north, south, east, west );
|
||||
for (unsigned int i=0; i<north.size(); i++) {
|
||||
nodes.unique_add( north[i] );
|
||||
}
|
||||
|
||||
// Read East Tile and add its western nodes
|
||||
eb = sgBucketOffset(clon, clat, 1, 0);
|
||||
eb = bucket.sibling(1, 0);
|
||||
LoadNeighboorEdgeDataStage1( eb, north, south, east, west );
|
||||
for (unsigned int i=0; i<west.size(); i++) {
|
||||
nodes.unique_add( west[i] );
|
||||
}
|
||||
|
||||
// Read West Tile and add its eastern nodes
|
||||
wb = sgBucketOffset(clon, clat, -1, 0);
|
||||
wb = bucket.sibling(-1, 0);
|
||||
LoadNeighboorEdgeDataStage1( wb, north, south, east, west );
|
||||
for (unsigned int i=0; i<east.size(); i++) {
|
||||
nodes.unique_add( east[i] );
|
||||
|
@ -239,13 +237,11 @@ void TGConstruct::LoadSharedEdgeData( int stage )
|
|||
{
|
||||
string dir;
|
||||
string file;
|
||||
double clon = bucket.get_center_lon();
|
||||
double clat = bucket.get_center_lat();
|
||||
gzFile fp;
|
||||
SGBucket b;
|
||||
|
||||
// Read Northern tile and add its southern node faces
|
||||
b = sgBucketOffset(clon, clat, 0, 1);
|
||||
b = bucket.sibling(0, 1);
|
||||
dir = share_base + "/stage2/" + b.gen_base_path();
|
||||
file = dir + "/" + b.gen_index_str() + "_south_edge";
|
||||
fp = gzopen( file.c_str(), "rb" );
|
||||
|
@ -256,7 +252,7 @@ void TGConstruct::LoadSharedEdgeData( int stage )
|
|||
}
|
||||
|
||||
// Read Southern tile and add its northern node faces
|
||||
b = sgBucketOffset(clon, clat, 0, -1);
|
||||
b = bucket.sibling(0, -1);
|
||||
dir = share_base + "/stage2/" + b.gen_base_path();
|
||||
file = dir + "/" + b.gen_index_str() + "_north_edge";
|
||||
fp = gzopen( file.c_str(), "rb" );
|
||||
|
@ -267,7 +263,7 @@ void TGConstruct::LoadSharedEdgeData( int stage )
|
|||
}
|
||||
|
||||
// Read Eastern tile and add its western node faces
|
||||
b = sgBucketOffset(clon, clat, 1, 0);
|
||||
b = bucket.sibling(1, 0);
|
||||
dir = share_base + "/stage2/" + b.gen_base_path();
|
||||
file = dir + "/" + b.gen_index_str() + "_west_edge";
|
||||
fp = gzopen( file.c_str(), "rb" );
|
||||
|
@ -278,7 +274,7 @@ void TGConstruct::LoadSharedEdgeData( int stage )
|
|||
}
|
||||
|
||||
// Read Western tile and add its eastern node faces
|
||||
b = sgBucketOffset(clon, clat, -1, 0);
|
||||
b = bucket.sibling(-1, 0);
|
||||
dir = share_base + "/stage2/" + b.gen_base_path();
|
||||
file = dir + "/" + b.gen_index_str() + "_east_edge";
|
||||
fp = gzopen( file.c_str(), "rb" );
|
||||
|
@ -591,4 +587,4 @@ void TGConstruct::LoadFromIntermediateFiles( int stage )
|
|||
if ( !read_ok ) {
|
||||
isOcean = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -139,7 +139,7 @@ void init_tile_count( const string& chunk ) {
|
|||
lat = 100;
|
||||
|
||||
// determine tile height
|
||||
SGBucket tmp1( 0.0, 0.0 );
|
||||
SGBucket tmp1;
|
||||
dy = tmp1.get_height();
|
||||
|
||||
string lons = chunk.substr(0, 4);
|
||||
|
@ -185,7 +185,7 @@ long int get_next_tile() {
|
|||
// adjacent tiles)
|
||||
lat += 2.0 * dy;
|
||||
|
||||
SGBucket tmp( 0.0, lat );
|
||||
SGBucket tmp( SGGeod::fromDeg(0.0, lat) );
|
||||
double dx = tmp.get_width();
|
||||
lon = start_lon + (shift_over*dx) + (dx*0.5);
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ long int get_next_tile() {
|
|||
lat = start_lat + (shift_up*dy) + (dy*0.5);
|
||||
|
||||
// reset lon
|
||||
SGBucket tmp( 0.0, lat );
|
||||
SGBucket tmp( SGGeod::fromDeg(0.0, lat) );
|
||||
double dx = tmp.get_width();
|
||||
// lon = -82 + (shift_over*dx) + (dx*0.5);
|
||||
lon = start_lon + (shift_over*dx) + (dx*0.5);
|
||||
|
@ -229,10 +229,10 @@ long int get_next_tile() {
|
|||
// start_lon = false;
|
||||
// }
|
||||
|
||||
b = SGBucket( lon, lat );
|
||||
b = SGBucket( SGGeod::fromDeg(lon, lat) );
|
||||
|
||||
// increment to next tile
|
||||
SGBucket tmp( 0.0, lat );
|
||||
SGBucket tmp( SGGeod::fromDeg(0.0, lat) );
|
||||
double dx = tmp.get_width();
|
||||
|
||||
// skip every other column (to avoid two clients working on
|
||||
|
|
|
@ -72,7 +72,7 @@ int main( int argc, char **argv ) {
|
|||
exit(1);
|
||||
}
|
||||
|
||||
SGBucket b( lon, lat );
|
||||
SGBucket b( SGGeod::fromDeg(lon, lat) );
|
||||
cout << "input: lon=" << lon << ", lat=" << lat <<
|
||||
", gives Bucket = " << b << endl;
|
||||
|
||||
|
|
|
@ -52,13 +52,13 @@ void tgChopper::ClipRow( const tgPolygon& subject, const double& center_lat, con
|
|||
tgRectangle bb = subject.GetBoundingBox();
|
||||
SGBucket b_min( bb.getMin() );
|
||||
SGBucket b_max( bb.getMax() );
|
||||
double min_center_lon = b_min.get_center_lon();
|
||||
int dx, dy;
|
||||
|
||||
sgBucketDiff(b_min, b_max, &dx, &dy);
|
||||
SGBucket start = SGBucket(SGGeod::fromDeg( b_min.get_center_lon(), center_lat ));
|
||||
|
||||
for ( int i = 0; i <= dx; ++i ) {
|
||||
SGBucket b_cur = sgBucketOffset(min_center_lon, center_lat, i, 0);
|
||||
SGBucket b_cur = start.sibling(i, 0);
|
||||
Clip( subject, type, b_cur );
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +101,8 @@ void tgChopper::Add( const tgPolygon& subject, const std::string& type )
|
|||
for ( int row = 0; row <= dy; row++ )
|
||||
{
|
||||
// Generate a clip rectangle for the whole row
|
||||
SGBucket b_clip = sgBucketOffset( bb.getMin().getLongitudeDeg(), bb.getMin().getLatitudeDeg(), 0, row );
|
||||
|
||||
SGBucket b_clip = b_min.sibling(0, row);
|
||||
double clip_bottom = b_clip.get_center_lat() - SG_HALF_BUCKET_SPAN;
|
||||
double clip_top = b_clip.get_center_lat() + SG_HALF_BUCKET_SPAN;
|
||||
tgPolygon clip_row, clipped;
|
||||
|
@ -223,4 +224,4 @@ void tgChopper::Save( bool DebugShapefiles )
|
|||
|
||||
gzclose( fp );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,16 +63,13 @@ int main(int argc, char **argv) {
|
|||
dem.parse();
|
||||
dem.close();
|
||||
|
||||
SGVec2d min, max;
|
||||
min.x() = dem.get_originx() / 3600.0 + SG_HALF_BUCKET_SPAN;
|
||||
min.y() = dem.get_originy() / 3600.0 + SG_HALF_BUCKET_SPAN;
|
||||
SGBucket b_min( min.x(), min.y() );
|
||||
SGGeod min = SGGeod::fromDeg(dem.get_originx() / 3600.0 + SG_HALF_BUCKET_SPAN,
|
||||
dem.get_originy() / 3600.0 + SG_HALF_BUCKET_SPAN);
|
||||
|
||||
max.x() = (dem.get_originx() + dem.get_cols() * dem.get_col_step()) / 3600.0
|
||||
- SG_HALF_BUCKET_SPAN;
|
||||
max.y() = (dem.get_originy() + dem.get_rows() * dem.get_row_step()) / 3600.0
|
||||
- SG_HALF_BUCKET_SPAN;
|
||||
SGBucket b_max( max.x(), max.y() );
|
||||
SGGeod max = SGGeod::fromDeg( (dem.get_originx() + dem.get_cols() * dem.get_col_step()) / 3600.0 - SG_HALF_BUCKET_SPAN,
|
||||
(dem.get_originy() + dem.get_rows() * dem.get_row_step()) / 3600.0 - SG_HALF_BUCKET_SPAN );
|
||||
SGBucket b_min( min );
|
||||
SGBucket b_max( max );
|
||||
|
||||
if ( b_min == b_max ) {
|
||||
dem.write_area( work_dir, b_min );
|
||||
|
@ -91,7 +88,7 @@ int main(int argc, char **argv) {
|
|||
|
||||
for ( j = 0; j <= dy; j++ ) {
|
||||
for ( i = 0; i <= dx; i++ ) {
|
||||
b_cur = sgBucketOffset(min.x(), min.y(), i, j);
|
||||
b_cur = b_min.sibling(i, j);
|
||||
dem.write_area( work_dir, b_cur );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,14 +75,12 @@ int main(int argc, char **argv) {
|
|||
hgt.load();
|
||||
hgt.close();
|
||||
|
||||
SGVec2d min, max;
|
||||
min.x() = hgt.get_originx() / 3600.0 + SG_HALF_BUCKET_SPAN;
|
||||
min.y() = hgt.get_originy() / 3600.0 + SG_HALF_BUCKET_SPAN;
|
||||
SGBucket b_min( min.x(), min.y() );
|
||||
|
||||
max.x() = (hgt.get_originx() + hgt.get_cols() * hgt.get_col_step()) / 3600.0 - SG_HALF_BUCKET_SPAN;
|
||||
max.y() = (hgt.get_originy() + hgt.get_rows() * hgt.get_row_step()) / 3600.0 - SG_HALF_BUCKET_SPAN;
|
||||
SGBucket b_max( max.x(), max.y() );
|
||||
SGGeod min = SGGeod::fromDeg( hgt.get_originx() / 3600.0 + SG_HALF_BUCKET_SPAN,
|
||||
hgt.get_originy() / 3600.0 + SG_HALF_BUCKET_SPAN );
|
||||
SGGeod max = SGGeod::fromDeg( (hgt.get_originx() + hgt.get_cols() * hgt.get_col_step()) / 3600.0 - SG_HALF_BUCKET_SPAN,
|
||||
(hgt.get_originy() + hgt.get_rows() * hgt.get_row_step()) / 3600.0 - SG_HALF_BUCKET_SPAN );
|
||||
SGBucket b_min( min );
|
||||
SGBucket b_max( max );
|
||||
|
||||
if ( b_min == b_max ) {
|
||||
hgt.write_area( work_dir, b_min );
|
||||
|
@ -101,7 +99,7 @@ int main(int argc, char **argv) {
|
|||
|
||||
for ( j = 0; j <= dy; j++ ) {
|
||||
for ( i = 0; i <= dx; i++ ) {
|
||||
b_cur = sgBucketOffset(min.x(), min.y(), i, j);
|
||||
b_cur = b_min.sibling(i, j);
|
||||
hgt.write_area( work_dir, b_cur );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -349,14 +349,13 @@ int main(int argc, char **argv) {
|
|||
hgt.load();
|
||||
hgt.close();
|
||||
|
||||
SGVec2d min, max;
|
||||
min.x() = hgt.get_originx() / 3600.0 + SG_HALF_BUCKET_SPAN;
|
||||
min.y() = hgt.get_originy() / 3600.0 + SG_HALF_BUCKET_SPAN;
|
||||
SGBucket b_min( min.x(), min.y() );
|
||||
SGGeod min = SGGeod::fromDeg( hgt.get_originx() / 3600.0 + SG_HALF_BUCKET_SPAN,
|
||||
hgt.get_originy() / 3600.0 + SG_HALF_BUCKET_SPAN);
|
||||
SGGeod max = SGGeod::fromDeg( (hgt.get_originx() + hgt.get_cols() * hgt.get_col_step()) / 3600.0 - SG_HALF_BUCKET_SPAN,
|
||||
(hgt.get_originy() + hgt.get_rows() * hgt.get_row_step()) / 3600.0 - SG_HALF_BUCKET_SPAN);
|
||||
|
||||
max.x() = (hgt.get_originx() + hgt.get_cols() * hgt.get_col_step()) / 3600.0 - SG_HALF_BUCKET_SPAN;
|
||||
max.y() = (hgt.get_originy() + hgt.get_rows() * hgt.get_row_step()) / 3600.0 - SG_HALF_BUCKET_SPAN;
|
||||
SGBucket b_max( max.x(), max.y() );
|
||||
SGBucket b_min( min );
|
||||
SGBucket b_max( max );
|
||||
|
||||
if ( b_min == b_max ) {
|
||||
hgt.write_area( work_dir, b_min );
|
||||
|
@ -375,11 +374,11 @@ int main(int argc, char **argv) {
|
|||
|
||||
for ( j = 0; j <= dy; j++ ) {
|
||||
for ( i = 0; i <= dx; i++ ) {
|
||||
b_cur = sgBucketOffset(min.x(), min.y(), i, j);
|
||||
b_cur = b_min.sibling(i, j);
|
||||
hgt.write_area( work_dir, b_cur );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,14 +60,13 @@ int main(int argc, char **argv) {
|
|||
int lat_arcsec = (int)(lat_deg * 3600.0);
|
||||
int res = 1;
|
||||
|
||||
SGVec2d min, max;
|
||||
min.x() = lon_deg + SG_HALF_BUCKET_SPAN;
|
||||
min.y() = lat_deg + SG_HALF_BUCKET_SPAN;
|
||||
SGBucket b_min( min.x(), min.y() );
|
||||
SGGeod min = SGGeod::fromDeg( lon_deg + SG_HALF_BUCKET_SPAN,
|
||||
lat_deg + SG_HALF_BUCKET_SPAN );
|
||||
SGGeod max = SGGeod::fromDeg( lon_deg + 1 - SG_HALF_BUCKET_SPAN,
|
||||
lat_deg + 1 - SG_HALF_BUCKET_SPAN );
|
||||
|
||||
max.x() = lon_deg + 1 - SG_HALF_BUCKET_SPAN;
|
||||
max.y() = lat_deg + 1 - SG_HALF_BUCKET_SPAN;
|
||||
SGBucket b_max( max.x(), max.y() );
|
||||
SGBucket b_min( min );
|
||||
SGBucket b_max( max );
|
||||
|
||||
SGBucket b_cur;
|
||||
int dx, dy, i, j;
|
||||
|
@ -82,7 +81,7 @@ int main(int argc, char **argv) {
|
|||
|
||||
for ( j = 0; j <= dy; j++ ) {
|
||||
for ( i = 0; i <= dx; i++ ) {
|
||||
b_cur = sgBucketOffset(min.x(), min.y(), i, j);
|
||||
b_cur = b_min.sibling(i, j);
|
||||
string file = work_dir + "/";
|
||||
file += b_cur.gen_base_path() + "/";
|
||||
file += b_cur.gen_index_str();
|
||||
|
@ -124,4 +123,4 @@ int main(int argc, char **argv) {
|
|||
gzclose(fp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -503,7 +503,7 @@ int main(int argc, const char **argv)
|
|||
* specified datasets and check all the tiles contained in them.
|
||||
*/
|
||||
|
||||
SGBucket start(west, south), end(east, north);
|
||||
SGBucket start( SGGeod::fromDeg(west, south) ), end( SGGeod::fromDeg(east, north) );
|
||||
|
||||
int dx, dy;
|
||||
|
||||
|
@ -513,7 +513,7 @@ int main(int argc, const char **argv)
|
|||
|
||||
for (int x = 0; x <= dx; x++) {
|
||||
for (int y = 0; y <= dy; y++) {
|
||||
SGBucket bucket = sgBucketOffset(west, south, x, y);
|
||||
SGBucket bucket = start.sibling(x, y);
|
||||
|
||||
process_bucket(work_dir, bucket, images.get(), datasetcount);
|
||||
}
|
||||
|
|
|
@ -169,7 +169,7 @@ void fit_file(const SGPath& path) {
|
|||
unlink( outPath.c_str() );
|
||||
}
|
||||
|
||||
SGBucket bucket(0,0); // dummy bucket
|
||||
SGBucket bucket; // dummy bucket
|
||||
TGArray inarray(path.dir() + "/" + path.file_base());
|
||||
inarray.parse(bucket);
|
||||
inarray.close();
|
||||
|
|
Loading…
Add table
Reference in a new issue