28 using namespace ossim;
30 static ossimTrace traceDebug(
"ossimRS1SarModel:debug");
32 static const double SEC_PER_DAY = 86400.0;
33 static const double NOMINAL_ORBIT_ELEVATION = 798000.0;
34 static const double DEG_PER_SEC = 0.004178074;
35 static const double INTRACK_OFFSET_SIGMA = 1000.0;
36 static const double CRTRACK_OFFSET_SIGMA = 300.0;
37 static const double RADIAL_OFFSET_SIGMA = 300.0;
38 static const double LINE_SCALE_SIGMA = 0.01;
39 static const double SKEW_SIGMA = 0.1;
40 static const double ORIENTATION_SIGMA = 0.2;
41 static const double EARTH_ANGULAR_VELOCITY = 7.2921151467e-05;
42 static const char* IMAGING_MODE_ID[] =
43 {
"UNKNOWN",
"SCN",
"SCW",
"SGC",
"SGF",
"SGX",
"SLC",
"SPG",
"SSG",
"RAW",
"ERS"};
50 theImagingMode (UNKNOWN_MODE)
62 theImagingMode (UNKNOWN_MODE)
64 static const char MODULE[] =
"Constructor ossimRS1SarModel(ossimFilename)";
65 if (traceDebug())
CLOG <<
"entering..." << endl;
91 if (traceDebug())
CLOG <<
"returning..." << endl;
130 const char* MODULE =
"ossimRS1SarModel::imagingRay()";
134 ossimDpt ip1 = image_point - offset;
153 NEWMAT::ColumnVector orpPos(3);
161 NEWMAT::ColumnVector arpEph(3);
170 (-ecfArpPos.
y()*EARTH_ANGULAR_VELOCITY, ecfArpPos.
x()*EARTH_ANGULAR_VELOCITY, 0.0);
171 ecfArpVel = ecfArpVel - earthVel;
183 double local_orp_range = rangeVector.
length();
186 double slant_range = local_orp_range;
210 double delta_g_i = ground_range;
211 for (
int i=1; i<6; i++)
214 delta_g_i *= ground_range;
221 slant_range = local_orp_range;
225 CLOG <<
"ERROR: Invalid imaging mode encountered." << endl;
236 const double& height_ellip,
239 static const char MODULE[] =
"ossimRS1SarModel::lineSampleHeightToWorld()";
240 if (traceDebug())
CLOG <<
"entering..." << endl;
249 if (traceDebug())
CLOG <<
"returning..." << endl;
258 static const char MODULE[] =
"ossimRS1SarModel::setImagingMode(modeStr)";
259 if (traceDebug())
CLOG <<
"entering..." << endl;
261 bool illegal_mode =
false;
263 if (strcmp(modeStr,
"SCN") == 0)
267 else if (strcmp(modeStr,
"SCW") == 0)
271 else if (strcmp(modeStr,
"SGC") == 0)
275 else if (strcmp(modeStr,
"SGF") == 0)
279 else if (strcmp(modeStr,
"SGX") == 0)
283 else if (strcmp(modeStr,
"SLC") == 0)
287 else if (strcmp(modeStr,
"SPG") == 0)
292 else if (strcmp(modeStr,
"SSG") == 0)
297 else if (strcmp(modeStr,
"RAW") == 0)
302 else if (strcmp(modeStr,
"ERS") == 0)
317 if (strcmp(buf,
"ERS") == 0)
320 illegal_mode =
false;
327 CLOG <<
"\n\t ERROR: The imaging mode <" 329 <<
"> is currently not supported. \n" << endl;
333 if (traceDebug())
CLOG <<
"returning..." << endl;
342 static const char MODULE[] =
"ossimRS1SarModel::initFromCeos()";
343 if (traceDebug())
CLOG <<
"entering..." << endl;
368 else if (dsr->
asc_des[0] ==
'D')
372 CLOG <<
"ERROR: Direction Flag: " << dsr->
asc_des <<
" not supported" 376 if (traceDebug())
CLOG <<
"returning with error..." << endl;
398 strncpy(buf, dsr->
pro_lat, 16);
417 double incidence = atof(buf);
424 char sensor_orientation[] =
"123456789";
426 if (strcmp(sensor_orientation,
"ANTARCTIC") == 0)
444 CLOG <<
" ERROR:\n\tCannot open CEOS image file: " 449 fseek(fptr, 0, SEEK_END);
450 long byte_count = ftell(fptr);
453 int lengthOfRec = atoi(buf);
466 int left_pixels = atoi(buf);
469 int data_pixels = atoi(buf);
472 int right_pixels = atoi(buf);
485 for (
int i=0; i<6; i++)
506 <<
"\n\t theORP = " <<
theORP 509 <<
"\n\t sensor_orientation = " << sensor_orientation
515 if (traceDebug())
CLOG <<
"returning..." << endl;
528 static const char* MODULE =
"ossimRS1SarModel::initAdjParms()";
529 if (traceDebug())
CLOG <<
"entering..." << endl;
557 strncpy (adj_desc[
INTRACK_OFFSET],
"intrack_offset", MAX_DESC_CHARS);
558 strncpy (adj_desc[
CRTRACK_OFFSET],
"crtrack_offset", MAX_DESC_CHARS);
559 strncpy (adj_desc[
RADIAL_OFFSET],
"radial_offset", MAX_DESC_CHARS);
561 strncpy (adj_desc[
LINE_SCALE],
"line_scale", MAX_DESC_CHARS);
562 strncpy (adj_desc[
SKEW],
"image_skew", MAX_DESC_CHARS);
563 strncpy (adj_desc[
ORIENTATION],
"image_orientation",MAX_DESC_CHARS);
566 for (
int i=0; i<num_adj_parm; i++)
569 if (traceDebug())
CLOG <<
"returning..." << endl;
581 static const char MODULE[] =
"ossimRS1SarModel::establishEphemeris()";
582 if (traceDebug())
CLOG <<
"entering..." << endl;
591 strncpy(gha_str, pdr->
hr_angle, 22);
596 strncpy(buf, pdr->
ndata, 4);
598 int numPoints = atoi(buf);
603 double sampling_period = atof(buf);
608 int first_day = atoi(buf);
609 double time_offset = (double) (first_day -
theFirstLineDay)*SEC_PER_DAY;
612 strncpy(buf, pdr->
gmt_sec, 22);
619 NEWMAT::ColumnVector eciArpPos(3);
620 NEWMAT::ColumnVector eciArpVel(3);
621 NEWMAT::ColumnVector ecfArpPos(3);
622 NEWMAT::ColumnVector ecfArpVel(3);
623 NEWMAT::ColumnVector earthVel(3);
624 NEWMAT::Matrix xform;
629 for (i=0; i<numPoints; i++)
634 eciArpPos[j] = atof(buf);
636 eciArpVel[j] = atof(buf)/1000.0;
641 ecfArpPos = xform*eciArpPos;
642 ecfArpVel = xform*eciArpVel;
646 earthVel[0] = -ecfArpPos[1]*EARTH_ANGULAR_VELOCITY;
647 earthVel[1] = ecfArpPos[0]*EARTH_ANGULAR_VELOCITY;
649 ecfArpVel = ecfArpVel - earthVel;
652 sample_time += sampling_period;
658 <<
"\n\t theGHA: " <<
theGHA 659 <<
"\n\t numPoints: " << numPoints
660 <<
"\n\t sampling_period: " << sampling_period
664 if (traceDebug())
CLOG <<
"returning..." << endl;
674 static const char MODULE[] =
"ossimRS1SarModel::eciToEcfXform(acq_time)";
675 if (traceDebug())
CLOG <<
"entering..." << endl;
681 double gha =
theGHA + delta_t*DEG_PER_SEC;
693 -sin_gha, cos_gha, 0.0,
698 <<
"\n\t acq_time = " << acq_time
699 <<
"\n\t delta_t = " << delta_t
700 <<
"\n\t gha = " << gha << endl;
703 if (traceDebug())
CLOG <<
"returning..." << endl;
729 static const char MODULE[] =
"ossimRS1SarModel::establishOrpInterp()";
730 if (traceDebug())
CLOG <<
"entering..." << endl;
733 CLOG <<
"DEBUG -- " << endl;
735 static const int NUM_DATA_POINTS = 11;
739 int sizeOfDescRec =
sizeof(descRec);
740 int sizeOfPrefRec =
sizeof(prefix);
741 int headerSize = sizeOfDescRec + sizeOfPrefRec;
742 char buf[] =
"123456";
744 std::vector<double> line_numbers_list;
745 std::vector<NEWMAT::ColumnVector> orpVectorList;
750 <<
"\nsizeOfDescRec: " << sizeOfDescRec
751 <<
"\nsizeOfPrefRec: " << sizeOfPrefRec << endl;
768 int delta_line = (
int)ceil(last_line/((
double)NUM_DATA_POINTS-1.0));
774 int record_size = atoi(buf);
779 for (index=0; index<NUM_DATA_POINTS; index++)
782 clog <<
"\t Processing ORP for line number " << line_number << endl;
785 fread(&descRec, sizeOfDescRec, 1, fptr);
786 fread(&prefix, sizeOfPrefRec, 1, fptr);
789 if ((prefix.
line_num-1) != line_number)
791 CLOG <<
"\n\tERROR: Synchronization error reading image file. " 792 <<
"Expected line number " << line_number+1
793 <<
" but read line number " << prefix.
line_num <<
"." << endl;
823 line_number += delta_line;
824 if (line_number > last_line)
826 delta_line -= line_number - last_line;
827 line_number = last_line;
831 fseek(fptr, (delta_line)*record_size-headerSize, SEEK_CUR);
837 lastLineTime -= SEC_PER_DAY;
839 lastLineTime += SEC_PER_DAY;
844 clog <<
"\n\t line_number (last) = " << line_number
845 <<
"\n\t last_line (in image) = " << last_line
847 <<
"\n\t lastLineTime = " << lastLineTime
852 if (traceDebug())
CLOG <<
"returning..." << endl;
861 static const char MODULE[] =
"ossimRS1SarModel::establishVehicleSpace()";
862 if (traceDebug())
CLOG <<
"entering..." << endl;
869 NEWMAT::ColumnVector arpPos(3);
871 NEWMAT::ColumnVector arpVel(3);
875 NEWMAT::Matrix xform;
882 ecfArpPos.
x()*EARTH_ANGULAR_VELOCITY,
884 ecfArpVel = ecfArpVel - earthVel;
897 if (traceDebug())
CLOG <<
"returning..." << endl;
906 static const char MODULE[] =
"ossimRS1SarModel::interpolatedScanORP(gDblPoint)";
907 if (traceDebug())
CLOG <<
"entering..." << endl;
916 if (traceDebug())
CLOG <<
"returning..." << endl;
930 static const char MODULE[] =
"ossimRS1SarModel::establishOrpGrid()";
931 if (traceDebug())
CLOG <<
"entering..." << endl;
935 CLOG <<
"DEBUG -- " << endl;
938 static const int NUM_GRID_POINTS_U = 11;
942 int sizeOfDescRec =
sizeof(descRec);
943 int sizeOfPrefRec =
sizeof(prefix);
944 int headerSize = sizeOfDescRec + sizeOfPrefRec;
945 char buf[] =
"123456";
946 ossimDpt gridSize ((
double) NUM_GRID_POINTS_U, 3.0);
970 int delta_line = (
int) cellSize.
u;
980 int record_size = atoi(buf);
981 int test_line = (int) gridSize.
u - 2;
984 for (
int u=0; u<(int)gridSize.
u; u++)
988 clog <<
"\t Processing grid line number " << u << endl;
992 fread(&descRec, sizeOfDescRec, 1, fptr);
993 fread(&prefix, sizeOfPrefRec, 1, fptr);
996 if ((prefix.
line_num-1) != line_number)
998 CLOG <<
"\n\tERROR: Synchronization error reading image file. " 999 <<
"Expected line number " << line_number+1
1000 <<
" but read line number " << prefix.
line_num <<
"." << endl;
1026 delta_line = last_line - line_number;
1027 line_number = last_line;
1031 line_number += delta_line;
1037 fseek(fptr, (delta_line)*record_size-headerSize, SEEK_CUR);
1044 lastLineTime -= SEC_PER_DAY;
1048 lastLineTime += SEC_PER_DAY;
1054 clog <<
"\n\t line_number (last) = " << line_number
1055 <<
"\n\t last_line (in image) = " << last_line
1057 <<
"\n\t lastLineTime = " << lastLineTime
1062 if (traceDebug())
CLOG <<
"returning..." << endl;
1074 static const char MODULE[] =
"ossimRS1SarModel::deallocateMemory()";
1075 if (traceDebug())
CLOG <<
"entering..." << endl;
1084 if (traceDebug())
CLOG <<
"returning..." << endl;
const ossimColumnVector3d & data() const
ossimRefPtr< ossimLagrangeInterpolator > theArpPosInterp
ossimRefPtr< ossimLagrangeInterpolator > theLocalOrpInterp
bool interpolate(const double &t, NEWMAT::ColumnVector &result) const
ossimColumnVector3d cross(const ossimColumnVector3d &rhs) const
RTTI_DEF1_INST(ossimGeneralRasterTileSource, "ossimGeneralRasterTileSource", ossimImageHandler) static ossimTrace traceDebug("ossimGeneralRasterTileSource for(ossim_uint32 i=0;i< aList.size();++i)
void establishOrpInterp()
ossimEcefPoint intersectAboveEarthEllipsoid(const double &heightAboveEllipsoid, const ossimDatum *aDatum=ossimDatumFactory::instance() ->wgs84()) const
Represents serializable keyword/value map.
struct pos_vect_rec pos_vect[64]
void addData(const double &t, const NEWMAT::ColumnVector &data)
static const ossimErrorCode OSSIM_OK
ossimEcefVector cross(const ossimEcefVector &) const
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=NULL) const
Fulfills ossimObject base-class pure virtuals.
This code was derived from https://gist.github.com/mshockwave.
const imop_desc_rec * imopDescRec() const
void interpolatedScanORP(const ossimDpt &orp, ossimEcefPoint &orp_ecf) const
void initialize(const ossimIpt &size, const ossimDpt &origin, const ossimDpt &spacing, double null_value=OSSIM_DEFAULT_NULL_PIX_DOUBLE)
ossim_float64 hgt
Height in meters above the ellipsiod.
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=NULL)
Fulfills ossimObject base-class pure virtuals.
struct srgr_coefset_rec srgr_coefset[20]
void establishVehicleSpace()
struct acq_date_rec acq_date
const ossimFilename & imageFile() const
DirectionFlag theDirectionFlag
OSSIM_DLL void toVector(std::vector< ossimDpt > &result, const ossimString &stringOfPoints)
Will take a string list separated by spaces and convert to a vector of ossimDpts. ...
virtual void clearErrorStatus() const
virtual void imagingRay(const ossimDpt &image_point, ossimEcefRay &image_ray) const
Given an image point, returns a ray originating at some arbitrarily high point (in this model at the ...
virtual ~ossimRS1SarModel()
ossimRefPtr< ossimLagrangeInterpolator > theArpVelInterp
ossimEcefVector thePosCorrection
const char * chars() const
For backward compatibility.
const text_rec * textRec() const
static NEWMAT::Matrix create()
ImagingMode theImagingMode
const pos_data_rec * posDataRec() const
double theEphFirstSampTime
void setImagingMode(char *modeStr)
virtual ossimErrorCode getErrorStatus() const
void eciToEcfXform(const double &julianDay, NEWMAT::Matrix &xform) const
const proc_parm_rec * procParmRec() const
virtual void setErrorStatus() const
virtual void lineSampleHeightToWorld(const ossimDpt &imagePt, const double &heightAboveEllipsoid, ossimGpt &worldPt) const
Establishes geographic 3D point given image line, sample and ellipsoid height.
ossimLsrSpace theVehicleSpace
const ossimColumnVector3d & data() const
const dataset_sum_rec * dataSetSumRec() const
void establishEphemeris()
ossimFilename path() const
void setNode(const ossimIpt &p, const double &value)
void initFromCeos(const ossimFilename &dataDir)
ossimRefPtr< ossimCeosData > theCeosData
const vol_desc_rec * volDescRec() const