[Git][debian-gis-team/ossim][upstream] New upstream version 2.5.0

Bas Couwenberg gitlab at salsa.debian.org
Fri Aug 24 09:39:54 BST 2018


Bas Couwenberg pushed to branch upstream at Debian GIS Project / ossim


Commits:
546bd5af by Bas Couwenberg at 2018-08-24T07:14:53Z
New upstream version 2.5.0
- - - - -


8 changed files:

- include/ossim/base/ossimGpt.h
- include/ossim/imaging/ossimImageGeometry.h
- include/ossim/imaging/ossimImageRenderer.h
- include/ossim/projection/ossimImageViewTransform.h
- src/imaging/ossimImageGeometry.cpp
- src/imaging/ossimImageRenderer.cpp
- src/projection/ossimImageViewTransform.cpp
- src/projection/ossimRsmModel.cpp


Changes:

=====================================
include/ossim/base/ossimGpt.h
=====================================
--- a/include/ossim/base/ossimGpt.h
+++ b/include/ossim/base/ossimGpt.h
@@ -26,128 +26,136 @@
 #include <ossim/base/ossimString.h>
 #include <iosfwd>
 
-class  ossimDatum;
+class ossimDatum;
 
 class OSSIM_DLL ossimGpt
 {
 public:
-   /**
+  /**
     * Constructor.  The values are assumed to be in DEGREES.
     */
-   ossimGpt(const double alat=0,  // degrees
-            const double alon=0,  // degrees
-            const double ahgt=0,
-            const ossimDatum* aDatum=ossimDatumFactory::instance()->wgs84())
+  ossimGpt(const double alat = 0, // degrees
+           const double alon = 0, // degrees
+           const double ahgt = 0,
+           const ossimDatum *aDatum = ossimDatumFactory::instance()->wgs84())
       : lat(alat),
         lon(alon),
-        hgt(ahgt),  // relative to the ellipsoid
-        theDatum(aDatum) {}//limitLonTo180();}
+        hgt(ahgt), // relative to the ellipsoid
+        theDatum(aDatum)
+  {
+  } //limitLonTo180();}
 
-   /**
+  /**
     * Copy Constructor:
     */
-   ossimGpt(const ossimGpt& src);
-   
-   /**
+  ossimGpt(const ossimGpt &src);
+
+  /**
     * Constructor.  Conversion from geocentric to ground.
     */
-   ossimGpt(const ossimEcefPoint &aPt,
-            const ossimDatum* aDatum=ossimDatumFactory::instance()->wgs84());
+  ossimGpt(const ossimEcefPoint &aPt,
+           const ossimDatum *aDatum = ossimDatumFactory::instance()->wgs84());
 
-   /**
+  /**
     * Argument aPt (x, y, z) is understood to represent (lon, lat, hgt) relative to WGS84 datum.
     */
-   ossimGpt(const ossimDpt3d &aPt) :
-      lat(aPt.y), lon(aPt.x), hgt(aPt.z), theDatum(ossimDatumFactory::instance()->wgs84()) {}
+  ossimGpt(const ossimDpt3d &aPt) : lat(aPt.y), lon(aPt.x), hgt(aPt.z), theDatum(ossimDatumFactory::instance()->wgs84()) {}
 
-   /**
+  /**
     * latr().  Returns the latitude in radian measure.  
     */
-   double latr()const{return lat*RAD_PER_DEG;}
+  double latr() const { return lat * RAD_PER_DEG; }
 
-   /**
+  /**
     * Returns the latitude in radian measure.  
     */
-   void latr(double radianValue){lat = radianValue*DEG_PER_RAD;}
+  void latr(double radianValue) { lat = radianValue * DEG_PER_RAD; }
 
-   /**
+  /**
     * Returns the longitude in radian measure.  
     */
-   double lonr()const{return lon*RAD_PER_DEG;}
+  double lonr() const { return lon * RAD_PER_DEG; }
 
-   /**
+  /**
     * Assumes the value being passed in is in radians.
     */
-   void lonr(double radianValue)
-      {lon = radianValue*DEG_PER_RAD; }//limitLonTo180();}
+  void lonr(double radianValue)
+  {
+    lon = radianValue * DEG_PER_RAD;
+  } //limitLonTo180();}
 
-   /**
+  /**
     * Will convert the radian measure to degrees.
     */
-   double latd()const{return lat;}
+  double latd() const { return lat; }
 
-   /**
+  /**
     * Assumes the passed in value is in degrees.
     */
-   void latd(double degreeValue){lat = degreeValue;}
+  void latd(double degreeValue) { lat = degreeValue; }
 
-   /**
+  /**
     * Will convert the radian measure to degrees.
     */
-   double lond()const{return lon;}
+  double lond() const { return lon; }
 
-   /**
+  /**
     *  Assumes the passed in value is in degrees.
     */
-   void lond(double degreeValue){lon = degreeValue; }//limitLonTo180();}
+  void lond(double degreeValue) { lon = degreeValue; } //limitLonTo180();}
 
-   /**
+  /**
     * @return Returns the height in meters above the ellipsoid.
     */
-   double height()const{return hgt;}
+  double height() const { return hgt; }
 
-   /**
+  /**
     * @return Returns the height in meters above mean sea level (msl).
     * 
     * @note This is the height above the ellipsoid minus any geoid offset.
     */
-   double heightMSL() const;
+  double heightMSL() const;
 
-   /**
+  /**
     * Sets the "hgt" data member to height.
     *
     * @param height Height above the ellipsoid in meters.
     */
-   void height(double height){hgt = height;}
+  void height(double height) { hgt = height; }
 
-   /**
+  /**
     * Sets the "hgt" data member to heightMsl adding any geiod offset.
     *
     * @param heightMSL Height in meters above msl.
     */
-   void heightMSL(double heightMSL);
-
-   void makeNan(){lat=ossim::nan(); lon=ossim::nan(); hgt=ossim::nan();}
-   bool isNan()const
-   {
-      return (ossim::isnan(lat)&&ossim::isnan(lon)&&ossim::isnan(hgt));
-   }
-   bool hasNans()const
-   {
-      return (ossim::isnan(lat)||ossim::isnan(lon)||ossim::isnan(hgt));
-   }
-   bool isLatNan()const{return ossim::isnan(lat);}
-   bool isLonNan()const{return ossim::isnan(lon);}
-   bool isLonLatNan()const{return (ossim::isnan(lat)||ossim::isnan(lon));}
-   bool isLatLonNan() const{return (ossim::isnan(lat)||ossim::isnan(lon));}
-   bool isHgtNan()const{return ossim::isnan(hgt);}
-
-   std::ostream& print(std::ostream& os, ossim_uint32 precision=15) const;
-
-   friend OSSIMDLLEXPORT std::ostream& operator<<(std::ostream& os,
-                                                  const ossimGpt& pt);
-   
-   /**
+  void heightMSL(double heightMSL);
+
+  void makeNan()
+  {
+    lat = ossim::nan();
+    lon = ossim::nan();
+    hgt = ossim::nan();
+  }
+  bool isNan() const
+  {
+    return (ossim::isnan(lat) && ossim::isnan(lon) && ossim::isnan(hgt));
+  }
+  bool hasNans() const
+  {
+    return (ossim::isnan(lat) || ossim::isnan(lon) || ossim::isnan(hgt));
+  }
+  bool isLatNan() const { return ossim::isnan(lat); }
+  bool isLonNan() const { return ossim::isnan(lon); }
+  bool isLonLatNan() const { return (ossim::isnan(lat) || ossim::isnan(lon)); }
+  bool isLatLonNan() const { return (ossim::isnan(lat) || ossim::isnan(lon)); }
+  bool isHgtNan() const { return ossim::isnan(hgt); }
+
+  std::ostream &print(std::ostream &os, ossim_uint32 precision = 15) const;
+
+  friend OSSIMDLLEXPORT std::ostream &operator<<(std::ostream &os,
+                                                 const ossimGpt &pt);
+
+  /**
     * @param precision Output floating point precision.
     * 
     * @return ossimString representing point.
@@ -156,9 +164,9 @@ public:
     * ( 30.00000000000000, -90.00000000000000, 0.00000000000000, WGE )
     *   -----latitude----  -----longitude----  ------height----  datum
     */
-   ossimString toString(ossim_uint32 precision=15) const;
+  ossimString toString(ossim_uint32 precision = 15) const;
 
-   /**
+  /**
     * Initializes this point from string.  This method opens an istream to
     * s and then calls operator>>.
     *
@@ -170,9 +178,9 @@ public:
     *
     * @see operator>>
     */
-   void toPoint(const std::string& s);
-   
-   /**
+  void toPoint(const std::string &s);
+
+  /**
     * Method to input the formatted string of the "operator<<".
     * 
     * This method starts by doing a "makeNan" on aPt.  So if anything goes
@@ -186,174 +194,188 @@ public:
     * ( 30.00000000000000, -90.00000000000000, 0.00000000000000, WGE )
     *  -----latitude----  -----longitude----  ------height----  datum
     */
-   friend OSSIMDLLEXPORT std::istream& operator>>(std::istream& is,
-                                                  ossimGpt& pt);
+  friend OSSIMDLLEXPORT std::istream &operator>>(std::istream &is,
+                                                 ossimGpt &pt);
 
-   /**
+  /**
     * datum().  returns the datum associated with this ground.
     *
     */
-   const ossimDatum* datum()const{return theDatum;}
+  const ossimDatum *datum() const { return theDatum; }
 
-   /**
+  /**
     * Note: this will not do a shift.  This just allows you to set the datum.
     *       If you want an automatic shift to occur then you must call the
     *       changeDatum method
     */
-   void datum(const ossimDatum* aDatum){theDatum = aDatum?aDatum:theDatum;}
+  void datum(const ossimDatum *aDatum) { theDatum = aDatum ? aDatum : theDatum; }
 
-   /**
+  /**
     * This will actually perform a shift.
     */
-   void changeDatum(const ossimDatum *datum);
+  void changeDatum(const ossimDatum *datum);
+
+  const ossimGpt &operator=(const ossimGpt &aPt);
+  bool operator==(const ossimGpt &gpt) const;
 
-   const ossimGpt& operator = (const ossimGpt &aPt);
-   bool operator ==(const ossimGpt& gpt)const;
+  bool operator!=(const ossimGpt &gpt) const { return !(*this == gpt); }
 
-   bool operator != (const ossimGpt& gpt) const { return !(*this == gpt); }
-   
-   /**
+  /**
     * METHOD: limitLonTo180()
     * Converts the lon data member to a value between -180 and +180:
     */
-   void  limitLonTo180()
-   { if (lon <= -180.0) lon += 360.0; else if (lon > 180.0) lon -= 360.0; }
-
-   /**
+  void limitLonTo180()
+  {
+    if (lon <= -180.0)
+      lon += 360.0;
+    else if (lon > 180.0)
+      lon -= 360.0;
+  }
+
+  /**
     * @brief Wrap method to maintain longitude between -180 and +180 and latitude between
     * -90 and +90.  Inlined below.
     */
-   void wrap();
-
-   void clampLon(double low, double high)
-      {
-         if(lon < low) lon = low;
-         if(lon > high) lon = high;
-      }
-
-   void clampLat(double low, double high)
-      {
-         if(lat < low) lat = low;
-         if(lat > high) lat = high;
-      }
-
-   void clampHgt(double low, double high)
-      {
-         if(hgt < low) hgt = low;
-         if(hgt > high) hgt = high;
-      }
-      
-   /**
+  void wrap();
+
+  void clampLon(double low, double high)
+  {
+    if (lon < low)
+      lon = low;
+    if (lon > high)
+      lon = high;
+  }
+
+  void clampLat(double low, double high)
+  {
+    if (lat < low)
+      lat = low;
+    if (lat > high)
+      lat = high;
+  }
+
+  void clampHgt(double low, double high)
+  {
+    if (hgt < low)
+      hgt = low;
+    if (hgt > high)
+      hgt = high;
+  }
+
+  /**
     * METHOD: distanceTo(ossimGpt)
     * Computes straight-line distance in meters between this and arg gpt:
     */
-   double distanceTo(const ossimGpt& arg_gpt) const;
+  double distanceTo(const ossimGpt &arg_gpt) const;
 
-   /**
+  /**
    * METHOD: azimuthTo(ossimGpt)
    * Computes the great-circle starting azimuth (i.e., at this gpt) to the argument gpt in degrees.
    * In other words, what direction we would need to start walking in to travel the shortest 
    * distance to arg_gpt (assumes spherical earth)
    */
-   double azimuthTo(const ossimGpt& arg_gpt) const;
+  double azimuthTo(const ossimGpt &arg_gpt) const;
+
+  ossimDpt metersPerDegree() const;
 
-   ossimDpt metersPerDegree() const;
-   
-   ossimString toDmsString()const;
+  ossimString toDmsString() const;
 
-   bool isEqualTo(const ossimGpt& rhs, ossimCompareType compareType=OSSIM_COMPARE_FULL)const;
-   ossim_float64 lat; //> latitude in degrees measure
-   ossim_float64 lon; //> longitude in degrees measure
+  bool isEqualTo(const ossimGpt &rhs, ossimCompareType compareType = OSSIM_COMPARE_FULL) const;
+  ossim_float64 lat; //> latitude in degrees measure
+  ossim_float64 lon; //> longitude in degrees measure
 
-   /**
+  /**
     * Height in meters above the ellipsiod.
     *
     * @note This is NOT the same as "height msl".  "Height msl" is above
     * the geoid or better know as mean sea level.
-    */ 
-   ossim_float64 hgt;
+    */
+  ossim_float64 hgt;
 
 private:
-   
-   /**
+  /**
     * Know reference location plus an implied ellipsoid.
     */
-   const ossimDatum* theDatum;
- 
+  const ossimDatum *theDatum;
 };
 
-inline const ossimGpt& ossimGpt::operator=(const ossimGpt& aPt)
+inline const ossimGpt &ossimGpt::operator=(const ossimGpt &aPt)
 {
-   if ( this != &aPt )
-   {
-      lat = aPt.lat;
-      lon = aPt.lon;
-      hgt = aPt.hgt;
-
-      if(aPt.datum())
-      {
-         theDatum = aPt.datum();
-      }
-      if(!theDatum)
-      {
-         theDatum = ossimDatumFactory::instance()->wgs84();
-      }
-   }
-   return *this;
+  if (this != &aPt)
+  {
+    lat = aPt.lat;
+    lon = aPt.lon;
+    hgt = aPt.hgt;
+
+    if (aPt.datum())
+    {
+      theDatum = aPt.datum();
+    }
+    if (!theDatum)
+    {
+      theDatum = ossimDatumFactory::instance()->wgs84();
+    }
+  }
+  return *this;
 }
 
 inline void ossimGpt::wrap()
 {
-   if ( lon > 180.0 )
-   {
+  // only wrap if values are not nan
+  // may want to change this to isbad because
+  // hey could be INF instead of NAN
+  if (ossim::isnan(lon) || ossim::isnan(lat))
+    return;
+  if (lon > 180.0)
+  {
+    do
+    {
+      lon = lon - 360.0;
+    } while (lon > 180.0);
+  }
+  else if (lon < -180.0)
+  {
+    do
+    {
+      lon = lon + 360.0;
+    } while (lon < -180.0);
+  }
+  if (lat > 90.0)
+  {
+    if (lat > 360.0) // Remove total wraps.
+    {
       do
       {
-         lon = lon - 360.0;
-      } while ( lon > 180.0 );
-   }
-   else if ( lon < -180.0  )
-   {
+        lat = lat - 360.0;
+      } while (lat > 360.0);
+    }
+    if (lat > 270.0) // Between 270 and 360.
+    {
+      lat = lat - 360.0;
+    }
+    else if (lat > 90) // Between 90 and 270.
+    {
+      lat = 180.0 - lat;
+    }
+  }
+  else if (lat < -90.0)
+  {
+    if (lat < -360.0) // Remove total wraps.
+    {
       do
       {
-         lon = lon + 360.0;
-      } while ( lon < -180.0 );
-   }
-   if ( lat > 90.0 )
-   {
-      if ( lat > 360.0 ) // Remove total wraps.
-      {
-         do
-         {
-            lat = lat - 360.0;
-         } while ( lat > 360.0);
-      }
-      if ( lat > 270.0 ) // Between 270 and 360.
-      {
-         lat = lat - 360.0;
-      }
-      else if ( lat > 90 ) // Between 90 and 270.
-      {
-         lat = 180.0 - lat;
-      }
-   }
-   else if ( lat < -90.0  )
-   {
-      if ( lat < -360.0 ) // Remove total wraps.
-      {
-         do
-         {
-            lat = lat + 360.0;
-         } while ( lat < -360.0);
-      }
-      if ( lat < -270.0 ) 
-      {
-         lat = 360.0 + lat; // Between -270 and -360;
-      }
-      else if ( lat < -90.0 )
-      {
-         lat = -180.0 - lat;
-      }
-   }
+        lat = lat + 360.0;
+      } while (lat < -360.0);
+    }
+    if (lat < -270.0)
+    {
+      lat = 360.0 + lat; // Between -270 and -360;
+    }
+    else if (lat < -90.0)
+    {
+      lat = -180.0 - lat;
+    }
+  }
 }
 
 #endif /* #ifndef ossimGpt_HEADER */


=====================================
include/ossim/imaging/ossimImageGeometry.h
=====================================
--- a/include/ossim/imaging/ossimImageGeometry.h
+++ b/include/ossim/imaging/ossimImageGeometry.h
@@ -166,6 +166,13 @@ public:
    ossimProjection*       getProjection()       { return m_projection.get(); }
 
    /**
+    * @brief Returns true if underlying projection is derived from
+    * ossimMapProjection.
+    * @return true if map projected; false, if not.
+    */
+   bool isMapProjected() const;
+   
+   /**
     * @return const ossimMapProjection* or NULL if projection not set or not
     * derived from ossimMapProjection.
     */


=====================================
include/ossim/imaging/ossimImageRenderer.h
=====================================
--- a/include/ossim/imaging/ossimImageRenderer.h
+++ b/include/ossim/imaging/ossimImageRenderer.h
@@ -214,7 +214,8 @@ private:
       ossimDpt computeRoundTripErrorViewPt(const ossimDpt& dpt)const;
       bool isViewAPoint()const;
       bool isIdentity()const;
-      bool canBilinearInterpolate(double error)const;
+      //bool canBilinearInterpolate(double error) const;
+      bool canBilinearInterpolate() const;
 
       ossimDpt getParametricCenter(const ossimDpt& ul, const ossimDpt& ur, 
 				    const ossimDpt& lr, const ossimDpt& ll)const;
@@ -321,7 +322,7 @@ private:
     * renderers together.  So if we have one
     * renderer doing a scale and they pass an r-level
     * down and we have another renderer within the
-    * chain he will be starting at a different r-level.
+    * chain we will be starting at a different r-level.
     * The default will be r-level 0 request coming
     * from the right.
     */
@@ -338,8 +339,11 @@ private:
 
    ossimPolyArea2d          m_viewArea;
    bool                     m_crossesDateline;
-   
-TYPE_DATA
+
+   double                   m_averageViewToImageScale;
+   double                   m_averageViewToImageRLevelScale;
+
+   TYPE_DATA
 };
 
 inline ossimImageRenderer::ossimRendererSubRectInfo::ossimRendererSubRectInfo(ossimImageViewTransform* transform)


=====================================
include/ossim/projection/ossimImageViewTransform.h
=====================================
--- a/include/ossim/projection/ossimImageViewTransform.h
+++ b/include/ossim/projection/ossimImageViewTransform.h
@@ -57,7 +57,7 @@ public:
    */
   virtual void getImageToViewScale(ossimDpt& resultScale,
 				   const ossimDpt& imagePoint,
-				   const ossimDpt& deltaImagePointXY)const;
+				   const ossimDpt& deltaImagePointXY=ossimDpt(1.0,1.0))const;
 
   /*!
    * If it needs to it will use the information passed in to get the
@@ -70,10 +70,10 @@ public:
    * of one.  We have to see how this works before we actually keep this
    * implementation.
    */
-  virtual void getViewToImageScale(ossimDpt& resultScale,
-				   const ossimDpt& imagePoint,
-				   const ossimDpt& deltaImagePointXY)const;
-  
+  virtual void getViewToImageScale(ossimDpt &resultScale,
+                                   const ossimDpt &imagePoint,
+                                   const ossimDpt &deltaImagePointXY = ossimDpt(1.0, 1.0)) const;
+
   virtual void imageToView(const ossimDpt& imagePoint,
                            ossimDpt&       viewPoint)const;
   
@@ -114,7 +114,7 @@ public:
   /** Computes the bounding rect in image space of the quad formed by the transformed view points
    * of the input rect corners. */
   virtual ossimDrect getViewToImageBounds(const ossimDrect& viewRect) const;
-  
+
   virtual bool loadState(const ossimKeywordlist& kwl,
                          const char* prefix =0);
   


=====================================
src/imaging/ossimImageGeometry.cpp
=====================================
--- a/src/imaging/ossimImageGeometry.cpp
+++ b/src/imaging/ossimImageGeometry.cpp
@@ -1079,6 +1079,10 @@ void ossimImageGeometry::getImageEdgePoints(std::vector<ossimDpt>& result, ossim
       // error out
       return;
    }
+
+   // Make edge to edge.
+   imageRect.expand( ossimDpt(0.5, 0.5) );
+   
    result.clear();
    // First get the image points we will be transforming
    if(partitions > 2)
@@ -1151,7 +1155,7 @@ void ossimImageGeometry::calculatePolyBounds(ossimPolyArea2d& result, ossim_uint
                         ossimDpt(180,90),
                         ossimDpt(180,-90));
    getBoundingRect(imageRect);
-   bool affectedByElevation = isAffectedByElevation();
+   // bool affectedByElevation = isAffectedByElevation();
    bool crossesDateline     = getCrossesDateline();
    result.clear();
    if(imageRect.hasNans())
@@ -1221,7 +1225,6 @@ void ossimImageGeometry::calculatePolyBounds(ossimPolyArea2d& result, ossim_uint
    }
    else
    {
-      ossim_uint32 idx=0;
       for(std::vector<ossimDpt>::const_iterator iter=points.begin(); 
           iter != points.end();++iter)
       {
@@ -1674,3 +1677,9 @@ ossim_float64 ossimImageGeometry::northUpAngle()const
    return result;
    
 } // End: ossimImageGeometry::northUpAngle()
+
+bool ossimImageGeometry::isMapProjected() const
+{
+   return dynamic_cast<const ossimMapProjection*>( m_projection.get() ) != 0;
+}
+


=====================================
src/imaging/ossimImageRenderer.cpp
=====================================
--- a/src/imaging/ossimImageRenderer.cpp
+++ b/src/imaging/ossimImageRenderer.cpp
@@ -380,7 +380,7 @@ bool ossimImageRenderer::ossimRendererSubRectInfo::tooBig()const
 
 ossim_uint16 ossimImageRenderer::ossimRendererSubRectInfo::getSplitFlags()const
 {
-  #if 0
+  #if 1
    ossim_uint16 result = SPLIT_NONE;
    ossimDrect vRect = getViewRect();
 
@@ -389,7 +389,7 @@ ossim_uint16 ossimImageRenderer::ossimRendererSubRectInfo::getSplitFlags()const
    // very small rectangles in canBilinearInterpolate(...) method.
    // DRB 05 Dec. 2017
    //---
-   if ( imageHasNans()||(vRect.width() < 8 && vRect.height() < 8) )
+   if ( imageIsNan()||(vRect.width() < 8 && vRect.height() < 8) )
    {
       return result;
    }
@@ -434,7 +434,10 @@ ossim_uint16 ossimImageRenderer::ossimRendererSubRectInfo::getSplitFlags()const
    if(result != SPLIT_ALL)
    {
       ossim_float64 bias = m_ImageToViewScale.length();
-      if(bias < 1.0) bias = 1.0/bias;
+      //ossim_float64 bias = (m_ImageToViewScale.x+m_ImageToViewScale.y)/2.0;
+      //std::cout << "SCALE BIAS = " << bias << "\n";
+      if (bias < 1.0)
+        bias = 1.0 / bias;
       bias = std::sqrt(bias);
 
       if(bias < 1) bias = 1.0;
@@ -459,11 +462,9 @@ ossim_uint16 ossimImageRenderer::ossimRendererSubRectInfo::getSplitFlags()const
       // if(m_llRoundTripError.length() > sensitivityScale) result |= LOWER_LEFT_SPLIT_FLAG;
       // std::cout << result << " == " << SPLIT_ALL << "\n";
 
-      if((result!=SPLIT_ALL)&&!canBilinearInterpolate(bias))
+      if(!canBilinearInterpolate())
       {
-         // std::cout << "TESTING BILINEAR!!!!\n";
          result = SPLIT_ALL;
-
       }
       else
       {
@@ -575,19 +576,24 @@ void ossimImageRenderer::ossimRendererSubRectInfo::transformViewToImage()
 //  m_llRoundTripError = m_transform->getRoundTripErrorView(m_Vll);
 
 #if 1
-   m_VulScale = computeViewToImageScale(m_Vul, ossimDpt( w, h));
-   m_VurScale = computeViewToImageScale(m_Vur, ossimDpt(-w, h));
-   m_VlrScale = computeViewToImageScale(m_Vlr, ossimDpt(-w,-h));
-   m_VllScale = computeViewToImageScale(m_Vll, ossimDpt( w,-h));
+   m_transform->getViewToImageScale(m_VulScale, m_Vul);
+   m_transform->getViewToImageScale(m_VurScale, m_Vur);
+   m_transform->getViewToImageScale(m_VlrScale, m_Vlr);
+   m_transform->getViewToImageScale(m_VllScale, m_Vll);
+
+   //  m_VulScale = computeViewToImageScale(m_Vul, ossimDpt( w, h));
+   //  m_VurScale = computeViewToImageScale(m_Vur, ossimDpt(-w, h));
+   //  m_VlrScale = computeViewToImageScale(m_Vlr, ossimDpt(-w,-h));
+   //  m_VllScale = computeViewToImageScale(m_Vll, ossimDpt( w,-h));
 
    ossim_int32 n = 0;
    m_ViewToImageScale.x = 0.0;
    m_ViewToImageScale.y = 0.0;
 
-   if(!m_VulScale.hasNans())
+   if (!m_VulScale.hasNans())
    {
-      m_ViewToImageScale += m_VulScale; 
-      ++n;
+     m_ViewToImageScale += m_VulScale;
+     ++n;
    }
    if(!m_VurScale.hasNans())
    {
@@ -757,16 +763,16 @@ bool ossimImageRenderer::ossimRendererSubRectInfo::isIdentity()const
             (illDelta <= FLT_EPSILON));
 }
 
-
-bool ossimImageRenderer::ossimRendererSubRectInfo::canBilinearInterpolate(double error)const
+bool ossimImageRenderer::ossimRendererSubRectInfo::canBilinearInterpolate() const
+//bool ossimImageRenderer::ossimRendererSubRectInfo::canBilinearInterpolate(double error) const
 {
   bool result = false;
 
   // now check point placement
   ossimDpt imageToViewScale = getAbsValueImageToViewScales();
 
-  double testScale = imageToViewScale.length();
-
+//  double testScale = imageToViewScale.length();
+    double testScale = ossim::max<ossim_float64>(imageToViewScale.x, imageToViewScale.y);
   //  ossimDpt errorUl = transform->getRoundTripErrorView(m_Vul);
   //  ossimDpt errorUr = transform->getRoundTripErrorView(m_Vur);
   //  ossimDpt errorLr = transform->getRoundTripErrorView(m_Vlr);
@@ -888,6 +894,67 @@ bool ossimImageRenderer::ossimRendererSubRectInfo::canBilinearInterpolate(double
     double errorCheck3 = (testRight - iRight).length();
     double errorCheck4 = (testBottom - iBottom).length();
     double errorCheck5 = (testLeft - iLeft).length();
+    double error = 1.0;
+    if (testScale >= 1)
+    {
+      //  std::cout <<"testScale MUL: " << testScale << "\n";
+      // std::cout << "errorCheck1: " << errorCheck1 << "\n";
+      // std::cout << "errorCheck2: " << errorCheck2 << "\n";
+      // std::cout << "errorCheck3: " << errorCheck3 << "\n";
+      // std::cout << "errorCheck4: " << errorCheck4 << "\n";
+      // std::cout << "errorCheck5: " << errorCheck5 << "\n";
+      // std::cout << "AFTER\n";
+      // errorCheck1 *= testScale;
+      // errorCheck2 *= testScale;
+      // errorCheck3 *= testScale;
+      // errorCheck4 *= testScale;
+      // errorCheck5 *= testScale;
+      // error*=testScale;
+      // std::cout << "errorCheck1: " << errorCheck1 << "\n";
+      // std::cout << "errorCheck2: " << errorCheck2 << "\n";
+      // std::cout << "errorCheck3: " << errorCheck3 << "\n";
+      // std::cout << "errorCheck4: " << errorCheck4 << "\n";
+      // std::cout << "errorCheck5: " << errorCheck5 << "\n";
+    }
+    else if (testScale >= FLT_EPSILON)
+    {
+      //  std::cout << "testScale DIV: " << testScale << "\n";
+      // std::cout << "errorCheck1: " << errorCheck1 << "\n";
+      // std::cout << "errorCheck2: " << errorCheck2 << "\n";
+      // std::cout << "errorCheck3: " << errorCheck3 << "\n";
+      // std::cout << "errorCheck4: " << errorCheck4 << "\n";
+      // std::cout << "errorCheck5: " << errorCheck5 << "\n";
+      // errorCheck1 /= testScale;
+      // errorCheck2 /= testScale;
+      // errorCheck3 /= testScale;
+      // errorCheck4 /= testScale;
+      // errorCheck5 /= testScale;
+      // std::cout << "AFTER\n";
+      // std::cout << "errorCheck1: " << errorCheck1 << "\n";
+      // std::cout << "errorCheck2: " << errorCheck2 << "\n";
+      // std::cout << "errorCheck3: " << errorCheck3 << "\n";
+      // std::cout << "errorCheck4: " << errorCheck4 << "\n";
+      // std::cout << "errorCheck5: " << errorCheck5 << "\n";
+      // error /= testScale;
+    }
+    else
+    {
+      errorCheck1 = 0.0;
+      errorCheck2 = 0.0;
+      errorCheck3 = 0.0;
+      errorCheck4 = 0.0;
+      errorCheck5 = 0.0;
+    }
+  
+    //std::cout << "errorCheck1:" << errorCheck1 << " ?????? " << error << "\n";
+    //std::cout << "DIV:" << (errorCheck1 / error) << " ?????? " << error << "\n";
+    //std::cout << "MULT:" << (errorCheck1 * error) << " ?????? " << error << "\n";
+    // result = ((errorCheck1 < error) &&
+    //           (errorCheck2 < error) &&
+    //           (errorCheck3 < error) &&
+    //           (errorCheck4 < error) &&
+    //           (errorCheck5 < error));
+    // std::cout << "error: " << error << "\n";
     result = ((errorCheck1 < error) &&
               (errorCheck2 < error) &&
               (errorCheck3 < error) &&
@@ -1037,43 +1104,47 @@ ossimDpt ossimImageRenderer::ossimRendererSubRectInfo::getParametricCenter(const
 }
 
 ossimImageRenderer::ossimImageRenderer()
-:
-ossimImageSourceFilter(),
-ossimViewInterface(0),
-m_Resampler(0),
-m_BlankTile(0),
-m_Tile(0),
-m_TemporaryBuffer(0),
-m_StartingResLevel(0),
-m_ImageViewTransform(0),
-m_inputR0Rect(),
-m_viewRect(),
-m_rectsDirty(true),
-m_MaxRecursionLevel(5),
-m_AutoUpdateInputTransform(true),
-m_MaxLevelsToCompute(999999) // something large so it will always compute
+    : ossimImageSourceFilter(),
+      ossimViewInterface(0),
+      m_Resampler(0),
+      m_BlankTile(0),
+      m_Tile(0),
+      m_TemporaryBuffer(0),
+      m_StartingResLevel(0),
+      m_ImageViewTransform(0),
+      m_inputR0Rect(),
+      m_viewRect(),
+      m_rectsDirty(true),
+      m_MaxRecursionLevel(5),
+      m_AutoUpdateInputTransform(true),
+      m_MaxLevelsToCompute(999999), // something large so it will always compute
+      m_averageViewToImageScale(1.0),
+      m_averageViewToImageRLevelScale(0.0)
 {
-   ossimViewInterface::theObject = this;
-   m_Resampler = new ossimFilterResampler();
-   m_ImageViewTransform = new ossimImageViewProjectionTransform;
+  ossimViewInterface::theObject = this;
+  m_Resampler = new ossimFilterResampler();
+  m_ImageViewTransform = new ossimImageViewProjectionTransform;
 }
 
-ossimImageRenderer::ossimImageRenderer(ossimImageSource* inputSource,
-                                       ossimImageViewTransform* imageViewTrans)
-   : ossimImageSourceFilter(inputSource),
-     ossimViewInterface(0),
-     m_Resampler(0),
-     m_BlankTile(0),
-     m_Tile(0),
-     m_TemporaryBuffer(0),
-     m_StartingResLevel(0),
-     m_ImageViewTransform(imageViewTrans),
-     m_inputR0Rect(),
-     m_viewRect(),
-     m_rectsDirty(true),
-     m_MaxRecursionLevel(5),
-     m_AutoUpdateInputTransform(true),
-     m_MaxLevelsToCompute(999999) // something large so it will always compute
+ossimImageRenderer::ossimImageRenderer(ossimImageSource *inputSource,
+                                       ossimImageViewTransform *imageViewTrans)
+    : ossimImageSourceFilter(inputSource),
+      ossimViewInterface(0),
+      m_Resampler(0),
+      m_BlankTile(0),
+      m_Tile(0),
+      m_TemporaryBuffer(0),
+      m_StartingResLevel(0),
+      m_ImageViewTransform(imageViewTrans),
+      m_inputR0Rect(),
+      m_viewRect(),
+      m_rectsDirty(true),
+      m_MaxRecursionLevel(5),
+      m_AutoUpdateInputTransform(true),
+      m_MaxLevelsToCompute(999999),
+      m_averageViewToImageScale(1.0),
+      m_averageViewToImageRLevelScale(0.0)
+// something large so it will always compute
 {
    ossimViewInterface::theObject = this;
    m_Resampler = new ossimFilterResampler();
@@ -1098,7 +1169,7 @@ ossimRefPtr<ossimImageData> ossimImageRenderer::getTile(
    const  ossimIrect& tileRect,
    ossim_uint32 resLevel)
 {
-   // std::cout << "_________________________\n";
+  // std::cout << "_________________________\n";
    static const char MODULE[] = "ossimImageRenderer::getTile";
    if(traceDebug())
    {
@@ -1191,19 +1262,59 @@ ossimRefPtr<ossimImageData> ossimImageRenderer::getTile(
   //  return m_BlankTile;
   //} 
 
-#if 0
+#if 1
+   ossimIrect tempRect = tileRect;
+   ossim_uint32 levels = theInputConnection->getNumberOfDecimationLevels();
+   ossim_float64 length = ossim::max<ossim_float64>(m_inputR0Rect.width(), m_inputR0Rect.height());
+   
+   // if we are zoomed out or we are completely within the requesting tile rect
+   bool canClip = (m_viewRect.completely_within(tileRect));
+
+   if(!canClip)
+   {
+     if(m_averageViewToImageScale > 1.0)
+     {
+       if ((length / m_averageViewToImageScale) <= 256)
+       {
+         // we are very small so we can clip
+         canClip = true;
+       }
+     }
+   }
+   // gpotts:  Until I can fix the entire resampling process we will add a sanity
+   // if we are zoomed out or the rect completely fits within the tile
+   // then we will clip to the view rect
+   if (canClip)
+   {
+     ossimPolyArea2d tileRectArea(tileRect);
+     if (!(m_viewArea.intersects(tileRectArea)))
+     {
+       return m_BlankTile;
+     }
+     else
+     {
+       ossimDrect rect;
+       tileRectArea &= m_viewArea;
+       tileRectArea.getBoundingRect(rect);
+       tempRect = rect;
+       
+     }
+   }
+//     tempRect = tileRect.clipToRect(m_viewRect);
    // expand a small patch just to alleviate errors in the size of the rect when resampling
      // ossimIrect viewRectClip = tileRect.clipToRect(ossimIrect(m_viewRect.ul() + ossimIpt(-8,-8),
      //                                                          m_viewRect.lr() + ossimIpt(8,8)));
-   ossimIrect viewRectClip = tileRect.clipToRect(m_viewRect);
-   std::cout << "_____________________" << std::endl;
-   std::cout << "viewRectClip = " <<  viewRectClip << std::endl;
-//   std::cout << "tileRect = " <<  tileRect << std::endl;
-//   std::cout << "m_viewRect = " <<  m_viewRect << std::endl;
-   ossimRendererSubRectInfo subRectInfo(viewRectClip.ul(),
-                                        viewRectClip.ur(),
-                                        viewRectClip.lr(),
-                                        viewRectClip.ll());
+   //ossimIrect viewRectClip = tileRect.clipToRect(m_viewRect);
+   
+       //   std::cout << "_____________________" << std::endl;
+       //   std::cout << "viewRectClip = " <<  viewRectClip << std::endl;
+       //   std::cout << "tileRect = " <<  tileRect << std::endl;
+       //   std::cout << "m_viewRect = " <<  m_viewRect << std::endl;
+   ossimRendererSubRectInfo subRectInfo(m_ImageViewTransform.get(),
+                                        tempRect.ul(),
+                                        tempRect.ur(),
+                                        tempRect.lr(),
+                                        tempRect.ll());
 #else
    ossimRendererSubRectInfo subRectInfo(m_ImageViewTransform.get(),
                                         tileRect.ul(),
@@ -1599,131 +1710,145 @@ void ossimImageRenderer::getBoundingRect(ossimIrect& rect, ossim_uint32 resLevel
 
 void ossimImageRenderer::initializeBoundingRects()
 {
-   m_rectsDirty      = true;
-   ossimImageViewProjectionTransform* ivpt = 
-                   dynamic_cast<ossimImageViewProjectionTransform*>(m_ImageViewTransform.get()); 
-   if(!theInputConnection||!m_ImageViewTransform.valid()) return;
-   m_inputR0Rect = theInputConnection->getBoundingRect(0);
-   if (!m_inputR0Rect.hasNans() )
-   {
-     if(ivpt&&ivpt->getImageGeometry()&&ivpt->getViewGeometry())
-     {
-         // Little complicated but instead of always setting the edge walk
-         // to a high number like 50 points per edge
-         // we will look at the image to view scale change
-         // and use that as a factor.  So as the image zooms out we
-         // need fewer points to estimate the edge.
-         //
-         // ossim_uint32 idx;
-         std::vector<ossimDrect> boundList;
-         ossimImageGeometry* igeom = ivpt->getImageGeometry(); // look at projected meters
-         ossimImageGeometry* vgeom = ivpt->getViewGeometry(); // look at projected meters
-         ossimDrect testRect;
-         igeom->getBoundingRect(testRect);
-         ossimDpt mpp = igeom->getMetersPerPixel();
-         ossimDpt vmpp = vgeom->getMetersPerPixel();
-         ossim_float64 scale = 1.0;
-         ossim_uint32 maxLen = ossim::max(testRect.width(), testRect.height());
-
-         // (GP March 2, 2017) determine goodMatch : test if we have either enough samples to closely match the post spacing 
-         //  or if we have at least half the number of pixels along the edge of an image
-         //
-         // This is hopefully to help avoid when using the polygon for intersection to not have
-         // bad intersection tests when zooming.  We might have to rethink it and implement
-         // this as a windowed edge walker.  So when zooming we create a polygon that 
-         // is denser for only what the view can see and not the entire image.  Basically interatively
-         // tesselate the input image model based on bounding volumes and then create a dense edge walker
-         // for what lies in the view at the given scale.  Too much to implement right now so we will cheet
-         // and take an easy way out for now.
-         // 
-
-         if(!mpp.hasNans()&&!vmpp.hasNans())
-         {
-            scale = mpp.y/vmpp.y;
-            if(scale > 1.0) scale = 1.0; 
-         }  
-         ossim_float64 mppTest = mpp.y;
-         ossim_float64 divisor = mppTest; // default to 30 meter elevation
-         if(mppTest < 500 )
-         {
-            if(mppTest >= 45 )
-            {
-               divisor = 90; // 90 meters
-            }
-         }
-         else
-         {
-            divisor = 1000; // 1 kilometer
-         }
-         if(divisor < 30) divisor = 30.0;
-
-
-         // now test to see if our edge walk is close to matching enough
-         // points for a good match.
-         //
-         ossim_uint32 maxEdgeSample = ossim::min(static_cast<ossim_uint32>(50), maxLen); 
-         if(maxEdgeSample < 1) maxEdgeSample = 1;
-         ossim_uint32 testEdgeSample = ossim::round<ossim_uint32>((maxLen*scale*mpp.y)/divisor);
-
-         bool goodMatch = (testEdgeSample<=maxEdgeSample)||(testEdgeSample>=(maxLen>>1));
-         ossim_float64 steps = ossim::min(testEdgeSample, maxEdgeSample); 
+  m_averageViewToImageScale = 1.0;
+  m_rectsDirty = true;
+  ossimImageViewProjectionTransform *ivpt =
+      dynamic_cast<ossimImageViewProjectionTransform *>(m_ImageViewTransform.get());
+  if (!theInputConnection || !m_ImageViewTransform.valid())
+    return;
+  m_inputR0Rect = theInputConnection->getBoundingRect(0);
+  if (!m_inputR0Rect.hasNans())
+  {
+    if (ivpt && ivpt->getImageGeometry() && ivpt->getViewGeometry())
+    {
+      // Little complicated but instead of always setting the edge walk
+      // to a high number like 50 points per edge
+      // we will look at the image to view scale change
+      // and use that as a factor.  So as the image zooms out we
+      // need fewer points to estimate the edge.
+      //
+      // ossim_uint32 idx;
+      std::vector<ossimDrect> boundList;
+      ossimImageGeometry *igeom = ivpt->getImageGeometry(); // look at projected meters
+      ossimImageGeometry *vgeom = ivpt->getViewGeometry();  // look at projected meters
+      ossimDrect testRect;
+      igeom->getBoundingRect(testRect);
+      ossimDpt mpp = igeom->getMetersPerPixel();
+      ossimDpt vmpp = vgeom->getMetersPerPixel();
+      ossim_float64 scale = 1.0;
+      ossim_uint32 maxLen = ossim::max(testRect.width(), testRect.height());
+
+      // (GP March 2, 2017) determine goodMatch : test if we have either enough samples to closely match the post spacing
+      //  or if we have at least half the number of pixels along the edge of an image
+      //
+      // This is hopefully to help avoid when using the polygon for intersection to not have
+      // bad intersection tests when zooming.  We might have to rethink it and implement
+      // this as a windowed edge walker.  So when zooming we create a polygon that
+      // is denser for only what the view can see and not the entire image.  Basically interatively
+      // tesselate the input image model based on bounding volumes and then create a dense edge walker
+      // for what lies in the view at the given scale.  Too much to implement right now so we will cheet
+      // and take an easy way out for now.
+      //
 
-         ossim_uint32 finalSteps = ossim::round<ossim_uint32>(steps);
-         if(finalSteps<1) finalSteps=1;
-         if(igeom->getCrossesDateline())
-         {
-            if(finalSteps < maxEdgeSample) finalSteps = maxEdgeSample;
-         }
+      if (!mpp.hasNans() && !vmpp.hasNans())
+      {
+        scale = mpp.y / vmpp.y;
+        if (scale > 1.0)
+          scale = 1.0;
+      }
+      ossim_float64 mppTest = mpp.y;
+      ossim_float64 divisor = mppTest; // default to 30 meter elevation
+      if (mppTest < 500)
+      {
+        if (mppTest >= 45)
+        {
+          divisor = 90; // 90 meters
+        }
+      }
+      else
+      {
+        divisor = 1000; // 1 kilometer
+      }
+      if (divisor < 30)
+        divisor = 30.0;
 
-         ivpt->getViewSegments(boundList, m_viewArea, finalSteps);
-         if(boundList.size())
-         {
-            m_viewRect   = boundList[0];
-            ossim_uint32 idx = 0;
+      // now test to see if our edge walk is close to matching enough
+      // points for a good match.
+      //
+      ossim_uint32 maxEdgeSample = ossim::min(static_cast<ossim_uint32>(50), maxLen);
+      if (maxEdgeSample < 1)
+        maxEdgeSample = 1;
+      ossim_uint32 testEdgeSample = ossim::round<ossim_uint32>((maxLen * scale * mpp.y) / divisor);
+
+      bool goodMatch = (testEdgeSample <= maxEdgeSample) || (testEdgeSample >= (maxLen >> 1));
+      ossim_float64 steps = ossim::min(testEdgeSample, maxEdgeSample);
+
+      ossim_uint32 finalSteps = ossim::round<ossim_uint32>(steps);
+      if (finalSteps < 1)
+        finalSteps = 1;
+      if (igeom->getCrossesDateline())
+      {
+        if (finalSteps < maxEdgeSample)
+          finalSteps = maxEdgeSample;
+      }
 
-            if(goodMatch)
-            {
-               m_viewArea = boundList[idx];
-            }
-            else
-            {
-               m_viewArea = m_viewRect;
-            }
-            for(idx=1;idx<boundList.size();++idx)
-            {
-               ossimIrect rectBounds = ossimIrect(boundList[idx]);
-               m_viewRect = m_viewRect.combine(rectBounds);
-               if(goodMatch)
-               {
-                  m_viewArea.add(ossimPolygon(boundList[idx]));
-               }
-               else
-               {
-                  m_viewArea.add(rectBounds);
-               }
-            } //
-            if(!m_viewRect.hasNans())
-            {
-               m_rectsDirty = false;
-            } 
-        } //END if boundList.size()
-     }
-     else if(m_ImageViewTransform.valid())
-     {
-       m_viewRect = m_ImageViewTransform->getImageToViewBounds(m_inputR0Rect);
+      ivpt->getViewSegments(boundList, m_viewArea, finalSteps);
+      if (boundList.size())
+      {
+        m_viewRect = boundList[0];
+        ossim_uint32 idx = 0;
 
-       if(!m_viewRect.hasNans())
-       {
+        if (goodMatch)
+        {
+          m_viewArea = boundList[idx];
+        }
+        else
+        {
+          m_viewArea = m_viewRect;
+        }
+        for (idx = 1; idx < boundList.size(); ++idx)
+        {
+          ossimIrect rectBounds = ossimIrect(boundList[idx]);
+          m_viewRect = m_viewRect.combine(rectBounds);
+          if (goodMatch)
+          {
+            m_viewArea.add(ossimPolygon(boundList[idx]));
+          }
+          else
+          {
+            m_viewArea.add(rectBounds);
+          }
+        } //
+        if (!m_viewRect.hasNans())
+        {
           m_rectsDirty = false;
-       } 
+        }
+      } //END if boundList.size()
+    }
+    else if (m_ImageViewTransform.valid())
+    {
+      m_viewRect = m_ImageViewTransform->getImageToViewBounds(m_inputR0Rect);
 
-       m_viewArea = m_viewRect;
-     }
+      if (!m_viewRect.hasNans())
+      {
+        m_rectsDirty = false;
+      }
+
+      m_viewArea = m_viewRect;
+    }
+   }
+   if(!m_viewRect.hasNans()&&m_ImageViewTransform)
+   {
+     ossimDpt result;
+     m_ImageViewTransform->getViewToImageScale(result, m_viewRect.midPoint());
+     m_averageViewToImageScale = (result.x+result.y)/2.0;
+     m_averageViewToImageRLevelScale = log(m_averageViewToImageScale) / log(2);
    }
    if ( m_rectsDirty )
    {
       m_viewRect.makeNan();
    }
+   
 #if 0 /* Please leave for debug. */
    ossimNotify(ossimNotifyLevel_DEBUG)
       << "ossimImageRenderer::initializeBoundingRects() debug:\n"


=====================================
src/projection/ossimImageViewTransform.cpp
=====================================
--- a/src/projection/ossimImageViewTransform.cpp
+++ b/src/projection/ossimImageViewTransform.cpp
@@ -211,55 +211,47 @@ void ossimImageViewTransform::getScaleChangeViewToImage(ossimDpt& result,
    }
 }
 
-void ossimImageViewTransform::getImageToViewScale(ossimDpt& resultScale,
-						  const ossimDpt& imagePoint,
-						  const ossimDpt& deltaImagePointXY)const
+
+ossimDrect ossimImageViewTransform::getImageToViewBounds(const ossimDrect& imageRect)const
 {
-  ossimDpt p1 = imagePoint;
-  ossimDpt p2(imagePoint.x + deltaImagePointXY.x,
-	      imagePoint.y);
-  ossimDpt p3(imagePoint.x,
-	      imagePoint.y + deltaImagePointXY.y);
-  
-  ossimDpt transformedP1;
-  ossimDpt transformedP2;
-  ossimDpt transformedP3;
+   ossimDpt p1;
+   ossimDpt p2;
+   ossimDpt p3;
+   ossimDpt p4;
 
-  imageToView(p1, transformedP1);
-  imageToView(p2, transformedP2);
-  imageToView(p3, transformedP3);
+   imageToView(imageRect.ul(), p1);
+   imageToView(imageRect.ur(), p2);
+   imageToView(imageRect.lr(), p3);
+   imageToView(imageRect.ll(), p4);
 
-  ossimDpt deltaP1P2 = transformedP1 - transformedP2;
-  ossimDpt deltaP1P3 = transformedP1 - transformedP3;
- 
-  // now compute the distances.
-  double sumSquaredSqrtP1P2 = sqrt((deltaP1P2.x*deltaP1P2.x) +
-			       (deltaP1P2.y*deltaP1P2.y));
-  double sumSquaredSqrtP1P3 = sqrt((deltaP1P3.x*deltaP1P3.x) +
-			       (deltaP1P3.y*deltaP1P3.y));
+   return ossimDrect(p1, p2, p3, p4);
+}
 
-  resultScale.x = 0;
-  resultScale.y = 0;
+ossimDrect ossimImageViewTransform::getViewToImageBounds(const ossimDrect& viewRect)const
+{
+   ossimDpt p1;
+   ossimDpt p2;
+   ossimDpt p3;
+   ossimDpt p4;
 
-  if(sumSquaredSqrtP1P2 > FLT_EPSILON)
-    {
-      resultScale.x = sumSquaredSqrtP1P2/deltaImagePointXY.x;
-    }
-  if(sumSquaredSqrtP1P3 > FLT_EPSILON)
-    {
-      resultScale.y = sumSquaredSqrtP1P3/deltaImagePointXY.y;
-    }
+   viewToImage(viewRect.ul(), p1);
+   viewToImage(viewRect.ur(), p2);
+   viewToImage(viewRect.lr(), p3);
+   viewToImage(viewRect.ll(), p4);
+
+   return ossimDrect(p1, p2, p3, p4);
 }
 
-void ossimImageViewTransform::getViewToImageScale(ossimDpt& resultScale,
-						  const ossimDpt& viewPoint,
-						  const ossimDpt& deltaViewPointXY)const
+#if 0
+void ossimImageViewTransform::getViewToImageScale(ossimDpt &resultScale,
+                                                  const ossimDpt &viewPoint,
+                                                  const ossimDpt &deltaViewPointXY) const
 {
   ossimDpt p1 = viewPoint;
   ossimDpt p2(viewPoint.x + deltaViewPointXY.x,
-	      viewPoint.y);
+              viewPoint.y);
   ossimDpt p3(viewPoint.x,
-	      viewPoint.y + deltaViewPointXY.y);
+              viewPoint.y + deltaViewPointXY.y);
 
   ossimDpt transformedP1;
   ossimDpt transformedP2;
@@ -273,54 +265,192 @@ void ossimImageViewTransform::getViewToImageScale(ossimDpt& resultScale,
   ossimDpt deltaP1P3 = transformedP1 - transformedP3;
 
   // now compute the distances.
-  double sumSquaredSqrtP1P2 = sqrt((deltaP1P2.x*deltaP1P2.x) +
-                                   (deltaP1P2.y*deltaP1P2.y));
-  double sumSquaredSqrtP1P3 = sqrt((deltaP1P3.x*deltaP1P3.x) +
-                                   (deltaP1P3.y*deltaP1P3.y));
+  double sumSquaredSqrtP1P2 = sqrt((deltaP1P2.x * deltaP1P2.x) +
+                                   (deltaP1P2.y * deltaP1P2.y));
+  double sumSquaredSqrtP1P3 = sqrt((deltaP1P3.x * deltaP1P3.x) +
+                                   (deltaP1P3.y * deltaP1P3.y));
 
   resultScale.x = 0;
   resultScale.y = 0;
 
-  if(sumSquaredSqrtP1P2 > FLT_EPSILON)
+  if (sumSquaredSqrtP1P2 > FLT_EPSILON)
+  {
+    resultScale.x = sumSquaredSqrtP1P2 / deltaViewPointXY.x;
+  }
+  if (sumSquaredSqrtP1P3 > FLT_EPSILON)
+  {
+    resultScale.y = sumSquaredSqrtP1P3 / deltaViewPointXY.y;
+  }
+}
+#else
+void ossimImageViewTransform::getViewToImageScale(ossimDpt &result,
+                                                  const ossimDpt &viewSeedPoint,
+                                                  const ossimDpt &dxdy) const
+{
+  result.makeNan();
+
+  ossimDpt dxdyHalf(dxdy.x / 2.0, dxdy.y / 2.0);
+  ossimDpt iptdx1 = viewSeedPoint - ossimDpt(dxdyHalf.x, 0.0);
+  ossimDpt iptdx2 = iptdx1 + ossimDpt(dxdy.x, 0.0);
+  ossimDpt iptdy1 = viewSeedPoint - ossimDpt(dxdyHalf.y, 0.0);
+  ossimDpt iptdy2 = iptdx1 + ossimDpt(0.0, dxdy.y);
+  ossimDpt dx1;
+  ossimDpt dx2;
+  ossimDpt dy1;
+  ossimDpt dy2;
+
+  viewToImage(iptdx1, dx1);
+  viewToImage(iptdx2, dx2);
+
+  viewToImage(iptdy1, dy1);
+  viewToImage(iptdy2, dy2);
+
+  if (!(dx1.hasNans() || dx2.hasNans()))
+  {
+    ossimDpt delta = dx1 - dx2;
+
+    // now compute the distances.
+    ossim_float64 sumSquared = sqrt((delta.x * delta.x) +
+                                    (delta.y * delta.y));
+
+    if (sumSquared > FLT_EPSILON)
     {
-      resultScale.x = sumSquaredSqrtP1P2/deltaViewPointXY.x;
+      result.x = sumSquared / dxdy.x;
     }
-  if(sumSquaredSqrtP1P3 > FLT_EPSILON)
+    else
     {
-      resultScale.y = sumSquaredSqrtP1P3/deltaViewPointXY.y;
+      result.x = ossim::nan();
     }
-}
+  }
+  if (!(dy1.hasNans() || dy2.hasNans()))
+  {
+    ossimDpt delta = dy1 - dy2;
 
-ossimDrect ossimImageViewTransform::getImageToViewBounds(const ossimDrect& imageRect)const
-{
-   ossimDpt p1;
-   ossimDpt p2;
-   ossimDpt p3;
-   ossimDpt p4;
+    // now compute the distances.
+    ossim_float64 sumSquared = sqrt((delta.x * delta.x) +
+                                    (delta.y * delta.y));
 
-   imageToView(imageRect.ul(), p1);
-   imageToView(imageRect.ur(), p2);
-   imageToView(imageRect.lr(), p3);
-   imageToView(imageRect.ll(), p4);
+    if (sumSquared > FLT_EPSILON)
+    {
+      result.y = sumSquared / dxdy.y;
+    }
+    else
+    {
+      result.y = ossim::nan();
+    }
+  }
 
-   return ossimDrect(p1, p2, p3, p4);
+  if (result.hasNans())
+  {
+    result.makeNan();
+  }
 }
+#endif
 
-ossimDrect ossimImageViewTransform::getViewToImageBounds(const ossimDrect& viewRect)const
+#if 0
+void ossimImageViewTransform::getImageToViewScale(ossimDpt &resultScale,
+                                                  const ossimDpt &imagePoint,
+                                                  const ossimDpt &deltaImagePointXY) const
 {
-   ossimDpt p1;
-   ossimDpt p2;
-   ossimDpt p3;
-   ossimDpt p4;
+  ossimDpt p1 = imagePoint;
+  ossimDpt p2(imagePoint.x + deltaImagePointXY.x,
+              imagePoint.y);
+  ossimDpt p3(imagePoint.x,
+              imagePoint.y + deltaImagePointXY.y);
 
-   viewToImage(viewRect.ul(), p1);
-   viewToImage(viewRect.ur(), p2);
-   viewToImage(viewRect.lr(), p3);
-   viewToImage(viewRect.ll(), p4);
+  ossimDpt transformedP1;
+  ossimDpt transformedP2;
+  ossimDpt transformedP3;
 
-   return ossimDrect(p1, p2, p3, p4);
+  imageToView(p1, transformedP1);
+  imageToView(p2, transformedP2);
+  imageToView(p3, transformedP3);
+
+  ossimDpt deltaP1P2 = transformedP1 - transformedP2;
+  ossimDpt deltaP1P3 = transformedP1 - transformedP3;
+
+  // now compute the distances.
+  double sumSquaredSqrtP1P2 = sqrt((deltaP1P2.x * deltaP1P2.x) +
+                                   (deltaP1P2.y * deltaP1P2.y));
+  double sumSquaredSqrtP1P3 = sqrt((deltaP1P3.x * deltaP1P3.x) +
+                                   (deltaP1P3.y * deltaP1P3.y));
+
+  resultScale.x = 0;
+  resultScale.y = 0;
+
+  if (sumSquaredSqrtP1P2 > FLT_EPSILON)
+  {
+    resultScale.x = sumSquaredSqrtP1P2 / deltaImagePointXY.x;
+  }
+  if (sumSquaredSqrtP1P3 > FLT_EPSILON)
+  {
+    resultScale.y = sumSquaredSqrtP1P3 / deltaImagePointXY.y;
+  }
 }
+#else
+void ossimImageViewTransform::getImageToViewScale(ossimDpt &result,
+                                                  const ossimDpt &imageSeedPoint,
+                                                  const ossimDpt &dxdy) const
+{
+  result.makeNan();
 
+  ossimDpt dxdyHalf(dxdy.x / 2.0, dxdy.y / 2.0);
+  ossimDpt iptdx1 = imageSeedPoint - ossimDpt(dxdyHalf.x, 0.0);
+  ossimDpt iptdx2 = iptdx1 + ossimDpt(dxdy.x,0.0);
+  ossimDpt iptdy1 = imageSeedPoint - ossimDpt(dxdyHalf.y, 0.0);
+  ossimDpt iptdy2 = iptdx1 + ossimDpt(0.0,dxdy.y);
+  ossimDpt dx1;
+  ossimDpt dx2;
+  ossimDpt dy1;
+  ossimDpt dy2;
+
+  imageToView(iptdx1, dx1);
+  imageToView(iptdx2, dx2);
+
+  imageToView(iptdy1, dy1);
+  imageToView(iptdy2, dy2);
+
+  if (!(dx1.hasNans() || dx2.hasNans()))
+  {
+    ossimDpt delta = dx1 - dx2;
+
+    // now compute the distances.
+    ossim_float64 sumSquared = sqrt((delta.x * delta.x) +
+                                    (delta.y * delta.y));
+
+    if (sumSquared > FLT_EPSILON)
+    {
+      result.x = sumSquared / dxdy.x;
+    }
+    else
+    {
+      result.x = ossim::nan();
+    }
+  }
+  if (!(dy1.hasNans() || dy2.hasNans()))
+  {
+    ossimDpt delta = dy1 - dy2;
+
+    // now compute the distances.
+    ossim_float64 sumSquared = sqrt((delta.x * delta.x) +
+                                    (delta.y * delta.y));
+
+    if (sumSquared > FLT_EPSILON)
+    {
+      result.y = sumSquared / dxdy.y;
+    }
+    else
+    {
+      result.y = ossim::nan();
+    }
+  }
+
+  if (result.hasNans())
+  {
+    result.makeNan();
+  }
+}
+#endif
 std::ostream& ossimImageViewTransform::print(std::ostream& out) const
 {
    return out;


=====================================
src/projection/ossimRsmModel.cpp
=====================================
--- a/src/projection/ossimRsmModel.cpp
+++ b/src/projection/ossimRsmModel.cpp
@@ -338,11 +338,11 @@ void ossimRsmModel::lineSampleHeightToWorld(const ossimDpt& image_point,
    gpt.lon = ossim::radiansToDegrees(nlon*m_pca[pcaIndex].m_xnrmsf + m_pca[pcaIndex].m_xnrmo);
    gpt.hgt = (nhgt * m_pca[pcaIndex].m_znrmsf) + m_pca[pcaIndex].m_znrmo; //ellHeight;
 
+   gpt.wrap();
    //---
    // Note: See above note. Added in wrap call. Longitude was coming out 242
    // when should have been -118. (drb - 22 May 2015)
    //---
-   gpt.wrap();
    
 } // End: ossimRsmModel::lineSampleHeightToWorld( ... )
 



View it on GitLab: https://salsa.debian.org/debian-gis-team/ossim/commit/546bd5af229b0e865c6544ab3889c0f27d400ecf

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/ossim/commit/546bd5af229b0e865c6544ab3889c0f27d400ecf
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20180824/0eecbc7e/attachment-0001.html>


More information about the Pkg-grass-devel mailing list