[geos-commits] [SCM] geos branch svn-trunk updated. 5a730fc50dab2610a9e6c037b521accc66b7777b

git at osgeo.org git at osgeo.org
Mon Apr 24 11:32:15 PDT 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "geos".

The branch, svn-trunk has been updated
       via  5a730fc50dab2610a9e6c037b521accc66b7777b (commit)
      from  e1f6205d2ed6fe317f9eccdbede8824561d196e8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 5a730fc50dab2610a9e6c037b521accc66b7777b
Author: Mateusz Łoskot <mateusz at loskot.net>
Date:   Mon Apr 24 20:28:54 2017 +0200

    Avoid use of internal geos/util/math.h
    
    Copy java_math_round geos/util/math.cpp to xmltester.cpp.
    Declared functions are internal to the library
    and not included in GEOS shared library exports.
    
    Fixes #831

diff --git a/tests/xmltester/XMLTester.cpp b/tests/xmltester/XMLTester.cpp
index 3f70ed4..54585bb 100644
--- a/tests/xmltester/XMLTester.cpp
+++ b/tests/xmltester/XMLTester.cpp
@@ -1,4 +1,4 @@
-/**********************************************************************
+/**********************************************************************
  *
  * GEOS - Geometry Engine Open Source
  * http://geos.osgeo.org
@@ -39,7 +39,6 @@
 #include <geos/operation/buffer/BufferOp.h>
 #include <geos/util.h>
 #include <geos/util/Interrupt.h>
-#include <geos/util/math.h>
 //#include <geos/geomgraph.h>
 #include <geos/io/WKBReader.h>
 #include <geos/io/WKBWriter.h>
@@ -88,6 +87,34 @@ using std::runtime_error;
 
 namespace {
 
+// Asymmetric Rounding Algorithm  - equivalent to Java Math.round()
+// Copy from geos/util/math.cpp
+double java_math_round(double val)
+{
+	double n;
+	double f = std::fabs(std::modf(val, &n));
+
+	if (val >= 0)
+	{
+		if (f < 0.5) {
+			return std::floor(val);
+		} else if (f > 0.5) {
+			return std::ceil(val);
+		} else {
+			return (n + 1.0);
+		}
+	} else {
+		if (f < 0.5) {
+			return std::ceil(val);
+		} else if (f > 0.5) {
+			return std::floor(val);
+		} else {
+			return n;
+		}
+	}
+} // java_math_round
+
+
 // a utility function defining a very simple method to indent a line of text
 const char * getIndent( unsigned int numIndents )
 {
@@ -335,7 +362,7 @@ XMLTester::printTest(bool success, const std::string& expected_result, const std
         std::cout << " test" << testCount << ": "
             << opSignature;
         std::cout << ": " << (success?"ok.":"failed.");
-        std::cout << " (" << std::setprecision(15) << geos::util::round(prof.getTot()/1000) << " ms)" << std::endl;
+        std::cout << " (" << std::setprecision(15) << java_math_round(prof.getTot()/1000) << " ms)" << std::endl;
 
         std::cout << "\tDescription: " << curr_case_desc << std::endl;
 

-----------------------------------------------------------------------

Summary of changes:
 tests/xmltester/XMLTester.cpp |   33 ++++++++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
geos


More information about the geos-commits mailing list