Skip to content

Commit

Permalink
final cleanup of the last pointInitialization and wxStation code that…
Browse files Browse the repository at this point in the history
… I had been editing

something still looks quirky with the wxStation time and list stuff, but I think this is good enough for now
  • Loading branch information
latwood committed Dec 3, 2024
1 parent e5ef783 commit 85895ad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/ninja/pointInitialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ vector<pointInitialization::preInterpolate> pointInitialization::readDiskLine(st
OGR_L_ResetReading(hLayer);
int fCount=OGR_L_GetFeatureCount(hLayer,1);

CPLDebug("STATION_FETCH", "Reading csvName: %s", stationLoc.c_str());
CPLDebug("STATION_FETCH", "Reading csv file: %s", stationLoc.c_str());

poLayer->ResetReading();

Expand All @@ -765,7 +765,7 @@ vector<pointInitialization::preInterpolate> pointInitialization::readDiskLine(st
oStation.stationName=oStationName;
pszKey = poFeature->GetFieldAsString( 1 );

//LAT LON COORDINATES
//COORDINATES STUFF
if( EQUAL( pszKey, "geogcs" ) )
{
CPLDebug("STATION_FETCH","GEOGCS FOUND!");
Expand Down
18 changes: 7 additions & 11 deletions src/ninja/wxStation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ void wxStation::set_location_projected( double Xord, double Yord,
return;
}

//get llcorner to subtract
GDALDataset *poDS = (GDALDataset*) GDALOpen( demFile.c_str(), GA_ReadOnly );
if( poDS == NULL ){
xord = Xord;
Expand All @@ -322,6 +321,7 @@ void wxStation::set_location_projected( double Xord, double Yord,
return;
}

//get llcorner to subtract
double adfGeoTransform[6];

if( poDS->GetGeoTransform( adfGeoTransform ) != CE_None ) {
Expand All @@ -332,10 +332,8 @@ void wxStation::set_location_projected( double Xord, double Yord,
return;
}

double llx = 0.0;
double lly = 0.0;
llx = adfGeoTransform[0];
lly = adfGeoTransform[3] + ( adfGeoTransform[5] * poDS->GetRasterYSize() );
double llx = adfGeoTransform[0];
double lly = adfGeoTransform[3] + ( adfGeoTransform[5] * poDS->GetRasterYSize() );

xord = Xord - llx;
yord = Yord - lly;
Expand Down Expand Up @@ -390,8 +388,8 @@ void wxStation::set_location_LatLong( double Lat, double Lon,
yord = Lat;
return;
}
GDALDataset *poDS = (GDALDataset*)GDALOpen( demFile.c_str(), GA_ReadOnly );

GDALDataset *poDS = (GDALDataset*)GDALOpen( demFile.c_str(), GA_ReadOnly );
if( poDS == NULL ){
projXord = Lon;
projYord = Lat;
Expand All @@ -408,9 +406,7 @@ void wxStation::set_location_LatLong( double Lat, double Lon,
projXord = projX;
projYord = projY;

//still assume dem is projected.
double llx = 0.0;
double lly = 0.0;
//get llcorner to subtract
double adfGeoTransform[6];

if( poDS->GetGeoTransform( adfGeoTransform ) != CE_None ){
Expand All @@ -419,8 +415,8 @@ void wxStation::set_location_LatLong( double Lat, double Lon,
return;
}

llx = adfGeoTransform[0];
lly = adfGeoTransform[3] + ( adfGeoTransform[5] * poDS->GetRasterYSize() );
double llx = adfGeoTransform[0];
double lly = adfGeoTransform[3] + ( adfGeoTransform[5] * poDS->GetRasterYSize() );

xord = projXord - llx;
yord = projYord - lly;
Expand Down

0 comments on commit 85895ad

Please sign in to comment.