Skip to content

Commit

Permalink
Small changes in support of merge with dev
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarkramer committed Nov 1, 2018
1 parent b057b8c commit 11eec09
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 107 deletions.
137 changes: 59 additions & 78 deletions src/imaging/ossimImageData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,14 @@
RTTI_DEF1(ossimImageData, "ossimImageData", ossimRectilinearDataObject)

ossimImageData::ossimImageData()
: ossimRectilinearDataObject(2, // 2d
0, // owner
1, // bands
OSSIM_UINT8), // scalar
m_nullPixelValue(0),
m_minPixelValue(0),
m_maxPixelValue(0),
m_alpha(0),
m_origin(0, 0),
m_indexedFlag(false),
m_histogram(NULL)
: ossimRectilinearDataObject(2, 0, 1, OSSIM_UINT8), // scalar
m_nullPixelValue(0),
m_minPixelValue(0),
m_maxPixelValue(0),
m_alpha(0),
m_origin(0, 0),
m_indexedFlag(false),
m_histogram(NULL)
{
ossimIpt tileSize;
ossim::defaultTileSize(tileSize);
Expand All @@ -56,17 +53,14 @@ ossimImageData::ossimImageData()
ossimImageData::ossimImageData(ossimSource* owner,
ossimScalarType scalar,
ossim_uint32 bands)
: ossimRectilinearDataObject(2,
owner,
bands,
scalar),
m_nullPixelValue(0),
m_minPixelValue(0),
m_maxPixelValue(0),
m_alpha(0),
m_origin(0, 0),
m_indexedFlag(false),
m_histogram(NULL)
: ossimRectilinearDataObject(2, owner, bands, scalar),
m_nullPixelValue(0),
m_minPixelValue(0),
m_maxPixelValue(0),
m_alpha(0),
m_origin(0, 0),
m_indexedFlag(false),
m_histogram(NULL)
{
ossimIpt tileSize;
ossim::defaultTileSize(tileSize);
Expand All @@ -80,34 +74,30 @@ ossimImageData::ossimImageData(ossimSource* owner,
ossim_uint32 bands,
ossim_uint32 width,
ossim_uint32 height)
: ossimRectilinearDataObject(owner,
bands,
width, // 2-D array
height,
scalar),
m_nullPixelValue(0),
m_minPixelValue(0),
m_maxPixelValue(0),
m_alpha(0),
m_origin(0, 0),
m_indexedFlag(false),
m_histogram(NULL),
m_percentFull(0)
: ossimRectilinearDataObject(owner, bands, width, height, scalar),
m_nullPixelValue(0),
m_minPixelValue(0),
m_maxPixelValue(0),
m_alpha(0),
m_origin(0, 0),
m_indexedFlag(false),
m_histogram(NULL),
m_percentFull(0)
{
m_spatialExtents[0] = width;
m_spatialExtents[1] = height;
initializeDefaults();
}

ossimImageData::ossimImageData(const ossimImageData &rhs)
: ossimRectilinearDataObject(rhs),
m_nullPixelValue(rhs.m_nullPixelValue),
m_minPixelValue(rhs.m_minPixelValue),
m_maxPixelValue(rhs.m_maxPixelValue),
m_alpha(rhs.m_alpha),
m_origin(rhs.m_origin),
m_indexedFlag(rhs.m_indexedFlag),
m_percentFull(0)
: ossimRectilinearDataObject(rhs),
m_nullPixelValue(rhs.m_nullPixelValue),
m_minPixelValue(rhs.m_minPixelValue),
m_maxPixelValue(rhs.m_maxPixelValue),
m_alpha(rhs.m_alpha),
m_origin(rhs.m_origin),
m_indexedFlag(rhs.m_indexedFlag),
m_percentFull(0)
{
}

Expand Down Expand Up @@ -229,12 +219,12 @@ const ossim_uint8* ossimImageData::getUcharBuf() const

const ossim_uint16* ossimImageData::getUshortBuf() const
{
if (m_scalarType == OSSIM_UINT16 ||
if ( m_scalarType == OSSIM_UINT16 ||
m_scalarType == OSSIM_USHORT11 ||
m_scalarType == OSSIM_USHORT12 ||
m_scalarType == OSSIM_USHORT13 ||
m_scalarType == OSSIM_USHORT14 ||
m_scalarType == OSSIM_USHORT15)
m_scalarType == OSSIM_USHORT12 ||
m_scalarType == OSSIM_USHORT13 ||
m_scalarType == OSSIM_USHORT14 ||
m_scalarType == OSSIM_USHORT15)
{
return static_cast<const ossim_uint16*>(getBuf());
}
Expand Down Expand Up @@ -281,12 +271,12 @@ ossim_uint8* ossimImageData::getUcharBuf()

ossim_uint16* ossimImageData::getUshortBuf()
{
if (m_scalarType == OSSIM_UINT16 ||
if ( m_scalarType == OSSIM_UINT16 ||
m_scalarType == OSSIM_USHORT11 ||
m_scalarType == OSSIM_USHORT12 ||
m_scalarType == OSSIM_USHORT13 ||
m_scalarType == OSSIM_USHORT14 ||
m_scalarType == OSSIM_USHORT15)
m_scalarType == OSSIM_USHORT12 ||
m_scalarType == OSSIM_USHORT13 ||
m_scalarType == OSSIM_USHORT14 ||
m_scalarType == OSSIM_USHORT15)
{
return static_cast<ossim_uint16*>(getBuf());
}
Expand Down Expand Up @@ -333,12 +323,12 @@ const ossim_uint8* ossimImageData::getUcharBuf(ossim_uint32 band) const

const ossim_uint16* ossimImageData::getUshortBuf(ossim_uint32 band) const
{
if (m_scalarType == OSSIM_UINT16 ||
if ( m_scalarType == OSSIM_UINT16 ||
m_scalarType == OSSIM_USHORT11 ||
m_scalarType == OSSIM_USHORT12 ||
m_scalarType == OSSIM_USHORT13 ||
m_scalarType == OSSIM_USHORT14 ||
m_scalarType == OSSIM_USHORT15)
m_scalarType == OSSIM_USHORT12 ||
m_scalarType == OSSIM_USHORT13 ||
m_scalarType == OSSIM_USHORT14 ||
m_scalarType == OSSIM_USHORT15)
{
return static_cast<const ossim_uint16*>(getBuf(band));
}
Expand Down Expand Up @@ -385,12 +375,12 @@ ossim_uint8* ossimImageData::getUcharBuf(ossim_uint32 band)

ossim_uint16* ossimImageData::getUshortBuf(ossim_uint32 band)
{
if (m_scalarType == OSSIM_UINT16 ||
if ( m_scalarType == OSSIM_UINT16 ||
m_scalarType == OSSIM_USHORT11 ||
m_scalarType == OSSIM_USHORT12 ||
m_scalarType == OSSIM_USHORT13 ||
m_scalarType == OSSIM_USHORT14 ||
m_scalarType == OSSIM_USHORT15)
m_scalarType == OSSIM_USHORT12 ||
m_scalarType == OSSIM_USHORT13 ||
m_scalarType == OSSIM_USHORT14 ||
m_scalarType == OSSIM_USHORT15)
{
return static_cast<ossim_uint16*>(getBuf(band));
}
Expand Down Expand Up @@ -1442,8 +1432,7 @@ void ossimImageData::setValue(ossim_int32 x, ossim_int32 y, ossim_float64 color)
{
for(band = 0; band < m_numberOfDataComponents; band++)
{
unsigned char* buf = static_cast<unsigned char*>(getBuf(band))+
offset;
unsigned char* buf = static_cast<unsigned char*>(getBuf(band))+offset;
*buf = (unsigned char)color;
}
break;
Expand All @@ -1452,8 +1441,7 @@ void ossimImageData::setValue(ossim_int32 x, ossim_int32 y, ossim_float64 color)
{
for(band = 0; band < m_numberOfDataComponents; band++)
{
ossim_sint8* buf = static_cast<ossim_sint8*>(getBuf(band))+
offset;
ossim_sint8* buf = static_cast<ossim_sint8*>(getBuf(band))+offset;
*buf = (ossim_sint8)color;
}
break;
Expand All @@ -1467,8 +1455,7 @@ void ossimImageData::setValue(ossim_int32 x, ossim_int32 y, ossim_float64 color)
{
for(band = 0; band < m_numberOfDataComponents; band++)
{
ossim_uint16* buf = static_cast<ossim_uint16*>(getBuf(band))+
offset;
ossim_uint16* buf = static_cast<ossim_uint16*>(getBuf(band))+offset;
*buf = (ossim_uint16)color;
}
break;
Expand All @@ -1477,8 +1464,7 @@ void ossimImageData::setValue(ossim_int32 x, ossim_int32 y, ossim_float64 color)
{
for(band = 0; band < m_numberOfDataComponents; band++)
{
signed short* buf = static_cast<signed short*>(getBuf(band))+
offset;
signed short* buf = static_cast<signed short*>(getBuf(band))+offset;
*buf = (signed short)color;
}
break;
Expand All @@ -1487,8 +1473,7 @@ void ossimImageData::setValue(ossim_int32 x, ossim_int32 y, ossim_float64 color)
{
for(band = 0; band < m_numberOfDataComponents; band++)
{
ossim_uint32* buf = static_cast<ossim_uint32*>(getBuf(band))+
offset;
ossim_uint32* buf = static_cast<ossim_uint32*>(getBuf(band))+offset;
*buf = (ossim_uint32)color;
}
break;
Expand All @@ -1497,8 +1482,7 @@ void ossimImageData::setValue(ossim_int32 x, ossim_int32 y, ossim_float64 color)
{
for(band = 0; band < m_numberOfDataComponents; band++)
{
ossim_sint32* buf = static_cast<ossim_sint32*>(getBuf(band))+
offset;
ossim_sint32* buf = static_cast<ossim_sint32*>(getBuf(band))+offset;
*buf = (ossim_sint32)color;
}
break;
Expand Down Expand Up @@ -1530,9 +1514,7 @@ void ossimImageData::setValue(ossim_int32 x, ossim_int32 y, ossim_float64 color)
ossimNotify(ossimNotifyLevel_WARN)
<< "ossimImageData::setValue Unsupported scalar type!"
<< std::endl;

}

} // End of: switch (getScalarType())
}
}
Expand Down Expand Up @@ -1613,7 +1595,6 @@ void ossimImageData::setValue(ossim_int32 x, ossim_int32 y,
ossimNotify(ossimNotifyLevel_WARN)
<< "ossimImageData::setValue Unsupported scalar type!"
<< std::endl;

}
} // End of: switch (getScalarType())
}
Expand Down
2 changes: 1 addition & 1 deletion src/projection/ossimEquDistCylProjection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ void ossimEquDistCylProjection::setOrigin(const ossimGpt& origin)
ossimDpt gsd = getMetersPerPixel();
gsd.x = gsd.y; // reset X (longitude) direction GSD
setMetersPerPixel(gsd);
update();
}

void ossimEquDistCylProjection::setFalseEasting(double falseEasting)
Expand Down Expand Up @@ -147,6 +146,7 @@ void ossimEquDistCylProjection::setDefaults()

#if 0
// The base class ossimMapProjection can handle this. No need for special implementation

void ossimEquDistCylProjection::lineSampleHeightToWorld(const ossimDpt &lineSample,
const double& hgtEllipsoid,
ossimGpt& gpt)const
Expand Down
9 changes: 4 additions & 5 deletions src/projection/ossimLlxyProjection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,14 @@ ossimLlxyProjection::ossimLlxyProjection(const ossimGpt& origin,
updateTransform();
}

ossimLlxyProjection::ossimLlxyProjection(const ossimEllipsoid& ellipsoid,
const ossimGpt& origin)
:ossimMapProjection(ellipsoid, origin)
ossimLlxyProjection::ossimLlxyProjection(const ossimEllipsoid& ellipsoid, const ossimGpt& origin)
: ossimMapProjection(ellipsoid, origin)
{
theProjectionUnits = OSSIM_DEGREES;
theDegreesPerPixel.y = 1.0;
theDegreesPerPixel.x = 1.0;
theUlEastingNorthing.y = ossim::nan();
theUlEastingNorthing.x = ossim::nan();
theUlEastingNorthing.y = 0.0;
theUlEastingNorthing.x = 0.0;
computeMetersPerPixel(theOrigin, theDegreesPerPixel.y, theDegreesPerPixel.x, theMetersPerPixel);
updateTransform();
}
Expand Down
4 changes: 2 additions & 2 deletions src/projection/ossimMapProjection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ void ossimMapProjection::lineSampleToEastingNorthing(const ossimDpt& lineSample,
eastingNorthing.y = m[1][0]*lineSample.x + m[1][1]*lineSample.y + m[1][3];
#else
/** Performs image to model coordinate transformation. This implementation bypasses
* theModelTransform. Probably should eventually switch to use equivalent imageToModel()
* theModelTransform. Probably should eventually switch to use theModelTransform
* because this cannot handle map rotation. */

// make sure that the passed in lineSample is good and
Expand Down Expand Up @@ -476,7 +476,7 @@ void ossimMapProjection::eastingNorthingToLineSample(const ossimDpt& eastingNort
lineSample.y = m[1][0]*eastingNorthing.x + m[1][1]*eastingNorthing.y + m[1][3];
#else
/** Performs model to image coordinate transformation. This implementation bypasses
* theModelTransform. Probably should eventually switch to use equivalent modelToImage()
* theModelTransform. Probably should eventually switch to use equivalent theModelTransform
* because this cannot handle map rotation. */

if(eastingNorthing.hasNans())
Expand Down
26 changes: 12 additions & 14 deletions src/support_data/ossimGeoTiff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ bool ossimGeoTiff::writeTags(TIFF *tifPtr,
if (mapProj->isRotated())
{
double transform[16];
auto m = mapProj->getModelTransform().getData();
const NEWMAT::Matrix& m = mapProj->getModelTransform().getData();
for (int i=0; i<16; ++i)
transform[i] = m[i/4][i%4];

Expand Down Expand Up @@ -1666,7 +1666,7 @@ bool ossimGeoTiff::addImageGeometry(ossimKeywordlist &kwl, const char *prefix) c
else if (usingModelTransform())
{
ostringstream s;
for (auto m : theModelTransformation)
for (const double& m : theModelTransformation)
s << std::setprecision(20) << m << " ";

kwl.add(prefix, ossimKeywordNames::IMAGE_MODEL_TRANSFORM_MATRIX_KW, s.str().c_str());
Expand Down Expand Up @@ -2298,17 +2298,19 @@ std::ostream &ossimGeoTiff::print(std::ostream &out) const
out << "theTiePoint is empty..." << endl;
}

if (theModelTransformation.size())
if (usingModelTransform())
{
std::vector<double>::const_iterator i = theModelTransformation.begin();
ossim_uint32 index = 0;
while (i < theModelTransformation.end())
ossim_uint32 i = 0;
out << "theModelTransformation: "<<endl;
for (ossim_uint32 rows=0; rows<4; ++rows)
{
out << "theModelTransformation[" << index << "]: "
<< (*i) << std::endl;
++index;
++i;
for (ossim_uint32 cols=0; cols<4; ++cols)
{
out << " " << theModelTransformation[i++];
}
out<<"\n";
}
out<<endl;
}
else
{
Expand All @@ -2323,10 +2325,6 @@ std::ostream &ossimGeoTiff::print(std::ostream &out) const

bool ossimGeoTiff::usingModelTransform() const
{
// The model transform is a 4x4 matrix but currently only scale, rotation, and offset are
// represented as a 3x2 transform of image point to projection model point. This tag should never
// appear if a scale or tiepoints are specified. Give priority to the latter:
//---
return (theModelTransformation.size()==16);
}

Expand Down
12 changes: 5 additions & 7 deletions src/support_data/ossimTiffInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1252,23 +1252,21 @@ bool ossimTiffInfo::getImageGeometry(const ossimKeywordlist &gtiffKwl,
ossimDpt scale;
bool hasScale = false;

// Get the model transform.
// Get the model transform if provided.
std::vector<ossim_float64> xfrm;
getModelTransform(gtiffPrefix, gtiffKwl, xfrm);
if (xfrm.size() == 16)
{
std::ostringstream out;
out << std::setprecision(15); // To avoid truncating.
ossim_uint32 idx = 0;
for (idx = 0; idx < 16; ++idx)
{
out << xfrm[idx] << " ";
}
for (const double& m : xfrm)
out << m << " ";

geomKwl.add(geomPrefix.c_str(),
ossimKeywordNames::IMAGE_MODEL_TRANSFORM_MATRIX_KW,
out.str().c_str(), true);
geomKwl.add(geomPrefix.c_str(),
ossimKeywordNames::IMAGE_MODEL_TRANSFORM_UNIT_KW,
ossimKeywordNames::ORIGINAL_MAP_UNITS_KW,
units.c_str(), true);
}
else // Use tie points and scale.
Expand Down

0 comments on commit 11eec09

Please sign in to comment.