[mapguide-commits] r9516 - in sandbox/jng/v4: Common/CoordinateSystem Common/Foundation Common/Geometry Common/Geometry/Buffer Common/Geometry/Spatial Common/Renderers Common/Stylization Server/src/Services/Feature

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed May 29 04:26:20 PDT 2019


Author: jng
Date: 2019-05-29 04:26:19 -0700 (Wed, 29 May 2019)
New Revision: 9516

Modified:
   sandbox/jng/v4/Common/CoordinateSystem/CoordSysUtil.h
   sandbox/jng/v4/Common/Foundation/FoundationDefs.h
   sandbox/jng/v4/Common/Geometry/Buffer/FloatTransform.cpp
   sandbox/jng/v4/Common/Geometry/Buffer/MgBuffer.cpp
   sandbox/jng/v4/Common/Geometry/GeometryCommon.h
   sandbox/jng/v4/Common/Geometry/Spatial/MathUtility.cpp
   sandbox/jng/v4/Common/Geometry/Spatial/MathUtility.h
   sandbox/jng/v4/Common/Renderers/stdafx.h
   sandbox/jng/v4/Common/Stylization/PointAdapter.cpp
   sandbox/jng/v4/Common/Stylization/PolygonAdapter.cpp
   sandbox/jng/v4/Common/Stylization/PolylineAdapter.cpp
   sandbox/jng/v4/Common/Stylization/SE_AreaPositioning.cpp
   sandbox/jng/v4/Common/Stylization/SE_PositioningAlgorithms.cpp
   sandbox/jng/v4/Common/Stylization/stdafx.h
   sandbox/jng/v4/Server/src/Services/Feature/FeatureNumericFunctions.cpp
Log:
RFC 172: Use std::isnan() and std::isinf()

Modified: sandbox/jng/v4/Common/CoordinateSystem/CoordSysUtil.h
===================================================================
--- sandbox/jng/v4/Common/CoordinateSystem/CoordSysUtil.h	2019-05-29 10:58:08 UTC (rev 9515)
+++ sandbox/jng/v4/Common/CoordinateSystem/CoordSysUtil.h	2019-05-29 11:26:19 UTC (rev 9516)
@@ -47,13 +47,6 @@
 // Represent NAN for double
 #define DoubleNan std::numeric_limits<double>::quiet_NaN()
 
-// Checks whether value is NAN or not
-#ifdef _WIN32
-#define IsDoubleNan(x)  _isnan(x)
-#else
-#define IsDoubleNan(x)  isnan(x)
-#endif
-
 #ifndef _WIN32
 #define wmemcpy memcpy
 #endif

Modified: sandbox/jng/v4/Common/Foundation/FoundationDefs.h
===================================================================
--- sandbox/jng/v4/Common/Foundation/FoundationDefs.h	2019-05-29 10:58:08 UTC (rev 9515)
+++ sandbox/jng/v4/Common/Foundation/FoundationDefs.h	2019-05-29 11:26:19 UTC (rev 9516)
@@ -39,7 +39,6 @@
     #define _stricmp  strcasecmp
     #define _strnicmp strncasecmp
 
-    #define _isnan    isnan
     #define _finite   finite
 #endif
 

Modified: sandbox/jng/v4/Common/Geometry/Buffer/FloatTransform.cpp
===================================================================
--- sandbox/jng/v4/Common/Geometry/Buffer/FloatTransform.cpp	2019-05-29 10:58:08 UTC (rev 9515)
+++ sandbox/jng/v4/Common/Geometry/Buffer/FloatTransform.cpp	2019-05-29 11:26:19 UTC (rev 9516)
@@ -55,7 +55,7 @@
     if ( doubleExtent.Height() != 0.0)
         aspect = doubleExtent.Width() / doubleExtent.Height();
 
-    if ( IsDoubleNan( aspect ) )
+    if ( std::isnan( aspect ) )
         aspect = 1.0;
 
     if (aspect >= 1.0)

Modified: sandbox/jng/v4/Common/Geometry/Buffer/MgBuffer.cpp
===================================================================
--- sandbox/jng/v4/Common/Geometry/Buffer/MgBuffer.cpp	2019-05-29 10:58:08 UTC (rev 9515)
+++ sandbox/jng/v4/Common/Geometry/Buffer/MgBuffer.cpp	2019-05-29 11:26:19 UTC (rev 9516)
@@ -77,7 +77,7 @@
 MgGeometryCollection* MgBuffer::CreateBuffer(MgGeometryCollection* geometries, double offset, bool merge)
 {
     //  check parameters
-    if ( geometries == NULL || IsDoubleNan( offset ) || fabs(offset) > DoubleMaxValue )
+    if ( geometries == NULL || std::isnan( offset ) || fabs(offset) > DoubleMaxValue )
         return NULL;
 
     Ptr<MgGeometryCollection> geomCol;

Modified: sandbox/jng/v4/Common/Geometry/GeometryCommon.h
===================================================================
--- sandbox/jng/v4/Common/Geometry/GeometryCommon.h	2019-05-29 10:58:08 UTC (rev 9515)
+++ sandbox/jng/v4/Common/Geometry/GeometryCommon.h	2019-05-29 11:26:19 UTC (rev 9516)
@@ -183,13 +183,6 @@
 // Represent NAN for double
 #define DoubleNan std::numeric_limits<double>::quiet_NaN()
 
-// Checks whether value is NAN or not
-#ifdef _WIN32
-#define IsDoubleNan(x)  _isnan(x)
-#else
-#define IsDoubleNan(x)  isnan(x)
-#endif
-
 #define GEOMETRY_SEP    " "
 #define POINT_SEPARATOR L", "
 

Modified: sandbox/jng/v4/Common/Geometry/Spatial/MathUtility.cpp
===================================================================
--- sandbox/jng/v4/Common/Geometry/Spatial/MathUtility.cpp	2019-05-29 10:58:08 UTC (rev 9515)
+++ sandbox/jng/v4/Common/Geometry/Spatial/MathUtility.cpp	2019-05-29 11:26:19 UTC (rev 9516)
@@ -17,6 +17,7 @@
 
 #include "Foundation.h"
 #include "MathUtility.h"
+#include <cmath>
 
 using namespace std;
 
@@ -35,11 +36,7 @@
 
 bool MgMathUtility::IsNan(double n)
 {
-#ifdef _WIN32
-    return _isnan(n);
-#else
-    return isnan(n);
-#endif
+    return std::isnan(n);
 }
 
 

Modified: sandbox/jng/v4/Common/Geometry/Spatial/MathUtility.h
===================================================================
--- sandbox/jng/v4/Common/Geometry/Spatial/MathUtility.h	2019-05-29 10:58:08 UTC (rev 9515)
+++ sandbox/jng/v4/Common/Geometry/Spatial/MathUtility.h	2019-05-29 11:26:19 UTC (rev 9516)
@@ -19,7 +19,6 @@
 #define MgMathUtility_H
 
 #include <limits>       // For quiet_NaN()
-#include <float.h>      // For _isnan()
 #ifdef _WIN32
 // For M_PI in math.h on Windows (doesn't seem to work though).
 #define _USE_MATH_DEFINES

Modified: sandbox/jng/v4/Common/Renderers/stdafx.h
===================================================================
--- sandbox/jng/v4/Common/Renderers/stdafx.h	2019-05-29 10:58:08 UTC (rev 9515)
+++ sandbox/jng/v4/Common/Renderers/stdafx.h	2019-05-29 11:26:19 UTC (rev 9516)
@@ -37,7 +37,6 @@
 typedef unsigned long DWORD;
 #define _wcsnicmp wcsncasecmp
 #define _wcsicmp wcscasecmp
-#define _isnan isnan
 #define _finite finite
 
 #endif //_WIN32

Modified: sandbox/jng/v4/Common/Stylization/PointAdapter.cpp
===================================================================
--- sandbox/jng/v4/Common/Stylization/PointAdapter.cpp	2019-05-29 10:58:08 UTC (rev 9515)
+++ sandbox/jng/v4/Common/Stylization/PointAdapter.cpp	2019-05-29 11:26:19 UTC (rev 9516)
@@ -20,8 +20,8 @@
 #include "PointAdapter.h"
 #include "LineBuffer.h"
 #include "FeatureTypeStyleVisitor.h"
+#include <cmath>
 
-
 //////////////////////////////////////////////////////////////////////////////
 PointAdapter::PointAdapter(LineBufferPool* lbp) : GeometryAdapter(lbp)
 {
@@ -207,7 +207,7 @@
         // multi should work for simple polygons also
         lb->Centroid(LineBuffer::ctPoint, &cx, &cy, &dummy);
 
-        if (!_isnan(cx) && !_isnan(cy))
+        if (!std::isnan(cx) && !std::isnan(cy))
         {
             // if there was no point symbol, the label is the symbol,
             // so we send without overposting and at the center point

Modified: sandbox/jng/v4/Common/Stylization/PolygonAdapter.cpp
===================================================================
--- sandbox/jng/v4/Common/Stylization/PolygonAdapter.cpp	2019-05-29 10:58:08 UTC (rev 9515)
+++ sandbox/jng/v4/Common/Stylization/PolygonAdapter.cpp	2019-05-29 11:26:19 UTC (rev 9516)
@@ -20,8 +20,8 @@
 #include "PolygonAdapter.h"
 #include "LineBuffer.h"
 #include "FeatureTypeStyleVisitor.h"
+#include <cmath>
 
-
 //////////////////////////////////////////////////////////////////////////////
 PolygonAdapter::PolygonAdapter(LineBufferPool* lbp) : GeometryAdapter(lbp)
 {
@@ -232,7 +232,7 @@
         // multi should work for simple polygons too
         lb->Centroid(LineBuffer::ctArea, &cx, &cy, &dummy);
 
-        if (!_isnan(cx) && !_isnan(cy))
+        if (!std::isnan(cx) && !std::isnan(cy))
             AddLabel(cx, cy, 0.0, false, label, RS_OverpostType_AllFit, true, renderer, lb);
     }
 

Modified: sandbox/jng/v4/Common/Stylization/PolylineAdapter.cpp
===================================================================
--- sandbox/jng/v4/Common/Stylization/PolylineAdapter.cpp	2019-05-29 10:58:08 UTC (rev 9515)
+++ sandbox/jng/v4/Common/Stylization/PolylineAdapter.cpp	2019-05-29 11:26:19 UTC (rev 9516)
@@ -20,8 +20,8 @@
 #include "PolylineAdapter.h"
 #include "LineBuffer.h"
 #include "FeatureTypeStyleVisitor.h"
+#include <cmath>
 
-
 //////////////////////////////////////////////////////////////////////////////
 PolylineAdapter::PolylineAdapter(LineBufferPool* lbp) : GeometryAdapter(lbp)
 {
@@ -288,7 +288,7 @@
         // multi should work for simple polylines too
         lb->Centroid(LineBuffer::ctLine, &cx, &cy, &slope_rad);
 
-        if (!_isnan(cx) && !_isnan(cy))
+        if (!std::isnan(cx) && !std::isnan(cy))
             AddLabel(cx, cy, slope_rad, true, label, RS_OverpostType_AllFit, true, renderer, label->GetSymbol()->IsAdvancedPlacement()? lb : NULL);
     }
 

Modified: sandbox/jng/v4/Common/Stylization/SE_AreaPositioning.cpp
===================================================================
--- sandbox/jng/v4/Common/Stylization/SE_AreaPositioning.cpp	2019-05-29 10:58:08 UTC (rev 9515)
+++ sandbox/jng/v4/Common/Stylization/SE_AreaPositioning.cpp	2019-05-29 11:26:19 UTC (rev 9516)
@@ -17,8 +17,8 @@
 
 #include "stdafx.h"
 #include "SE_AreaPositioning.h"
+#include <cmath>
 
-
 ///////////////////////////////////////////////////////////////////////////////
 // Initializes the area positioning class for iteration over the geometry.
 SE_AreaPositioning::SE_AreaPositioning(LineBuffer* geom, SE_RenderAreaStyle* style, double w2sAngleRad)
@@ -57,7 +57,7 @@
         geom->Centroid(LineBuffer::ctArea, &m_base_pt.x, &m_base_pt.y, &slope);
 
         // if we can't compute the centroid then just set the base point to the origin
-        if (_isnan(m_base_pt.x) || _isnan(m_base_pt.y))
+        if (std::isnan(m_base_pt.x) || std::isnan(m_base_pt.y))
         {
             m_base_pt.x = 0.0;
             m_base_pt.y = 0.0;

Modified: sandbox/jng/v4/Common/Stylization/SE_PositioningAlgorithms.cpp
===================================================================
--- sandbox/jng/v4/Common/Stylization/SE_PositioningAlgorithms.cpp	2019-05-29 10:58:08 UTC (rev 9515)
+++ sandbox/jng/v4/Common/Stylization/SE_PositioningAlgorithms.cpp	2019-05-29 11:26:19 UTC (rev 9516)
@@ -23,8 +23,8 @@
 #include "RS_FontEngine.h"
 #include "RS_FeatureReader.h"
 #include "SE_SymbolDefProxies.h"
+#include <cmath>
 
-
 // Recomputes the bounds of an SE_RenderStyle that contains a text
 // whose alignment we have messed with.
 void UpdateStyleBounds(SE_RenderStyle* st, SE_Renderer* se_renderer)
@@ -141,7 +141,7 @@
     }
 
     // don't add a label if we can't compute the centroid
-    if (_isnan(cx) || _isnan(cy))
+    if (std::isnan(cx) || std::isnan(cy))
         return;
 
     // need to convert centroid to screen units
@@ -206,7 +206,7 @@
     geometry->Centroid(LineBuffer::ctPoint, &cx, &cy, NULL);
 
     // don't add a label if we can't compute the centroid
-    if (_isnan(cx) || _isnan(cy))
+    if (std::isnan(cx) || std::isnan(cy))
         return;
 
     se_renderer->WorldToScreenPoint(cx, cy, cx, cy);

Modified: sandbox/jng/v4/Common/Stylization/stdafx.h
===================================================================
--- sandbox/jng/v4/Common/Stylization/stdafx.h	2019-05-29 10:58:08 UTC (rev 9515)
+++ sandbox/jng/v4/Common/Stylization/stdafx.h	2019-05-29 11:26:19 UTC (rev 9516)
@@ -33,6 +33,4 @@
 #define _wcsicmp  wcscasecmp
 #define _wcsnicmp wcsncasecmp
 
-#define _isnan    isnan
-
 #endif

Modified: sandbox/jng/v4/Server/src/Services/Feature/FeatureNumericFunctions.cpp
===================================================================
--- sandbox/jng/v4/Server/src/Services/Feature/FeatureNumericFunctions.cpp	2019-05-29 10:58:08 UTC (rev 9515)
+++ sandbox/jng/v4/Server/src/Services/Feature/FeatureNumericFunctions.cpp	2019-05-29 11:26:19 UTC (rev 9516)
@@ -689,29 +689,12 @@
 
 bool MgFeatureNumericFunctions::IsInf(double x)
 {
-    bool isInfinity = false;
-#ifdef _WIN32
-    int code = _fpclass(x);
-    if ((code == _FPCLASS_NINF) || (code == _FPCLASS_PINF))
-    {
-        isInfinity = true;
-    }
-#else
-    isInfinity = isinf(x);
-#endif
-
-    return isInfinity;
+    return std::isinf(x);
 }
 
 bool MgFeatureNumericFunctions::IsNan(double x)
 {
-    bool isNan = false;
-#ifdef _WIN32
-    isNan = _isnan(x);
-#else
-    isNan = isnan(x);
-#endif
-    return isNan;
+    return std::isnan(x);
 }
 
 // Calculate Standard Deviation for the values



More information about the mapguide-commits mailing list