[geos-commits] [SCM] GEOS branch master updated. 274993b1638d22ca150e71694f576032520d6a8d

git at osgeo.org git at osgeo.org
Thu Dec 10 15:17:22 PST 2020


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, master has been updated
       via  274993b1638d22ca150e71694f576032520d6a8d (commit)
       via  d248c9d6db1c9064febbba083bf5ae11056f889d (commit)
       via  e0f11f25478431bb9f73fea241467af919375aa8 (commit)
       via  5b34c2380226fc10c5bba7990b063b1074650f82 (commit)
       via  93fde33283c3c545d55dd8a5875b1e78d2c578d5 (commit)
       via  bc5faf6eed42fbfc01c77f03ac23ab3784f0c88b (commit)
       via  e47abc04cb0fc55955da9e6413cf997da93f6955 (commit)
       via  82e6f0fc63ff4e07e66ee44ef86c09b4a83b4f69 (commit)
      from  f6f8586c863bb61bec7bc1362d005510dbe7ff33 (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 274993b1638d22ca150e71694f576032520d6a8d
Merge: d248c9d 5b34c23
Author: Daniel Baston <dbaston at gmail.com>
Date:   Thu Dec 10 18:17:02 2020 -0500

    Merge remote-tracking branch 'rouault/createSineStar_warning'


commit d248c9d6db1c9064febbba083bf5ae11056f889d
Merge: e0f11f2 93fde33
Author: Daniel Baston <dbaston at gmail.com>
Date:   Thu Dec 10 18:16:11 2020 -0500

    Merge branch 'dbaston/wkb2'


commit e0f11f25478431bb9f73fea241467af919375aa8
Merge: f6f8586 82e6f0f
Author: Daniel Baston <dbaston at gmail.com>
Date:   Thu Dec 10 18:15:29 2020 -0500

    Merge branch 'remove-coordinate-default-args'


commit 5b34c2380226fc10c5bba7990b063b1074650f82
Author: Even Rouault <even.rouault at spatialys.com>
Date:   Thu Dec 10 01:39:04 2020 +0100

    SineStarFactory::createSineStar(): fix compiler warning about signed/unsigned comparison in for() comparison

diff --git a/src/geom/util/SineStarFactory.cpp b/src/geom/util/SineStarFactory.cpp
index d96225c..dfa37ce 100644
--- a/src/geom/util/SineStarFactory.cpp
+++ b/src/geom/util/SineStarFactory.cpp
@@ -57,8 +57,8 @@ SineStarFactory::createSineStar() const
     double centreY = env->getMinY() + radius;
 
     std::vector<Coordinate> pts(nPts + 1);
-    int iPt = 0;
-    for(int i = 0; i < nPts; i++) {
+    uint32_t iPt = 0;
+    for(uint32_t i = 0; i < nPts; i++) {
         // the fraction of the way thru the current arm - in [0,1]
         double ptArcFrac = (i / (double) nPts) * numArms;
         double armAngFrac = ptArcFrac - floor(ptArcFrac);

commit 93fde33283c3c545d55dd8a5875b1e78d2c578d5
Author: Daniel Baston <dbaston at gmail.com>
Date:   Fri Jun 26 18:20:17 2020 -0400

    Inline PrecisionModel::makePrecise

diff --git a/include/geos/geom/PrecisionModel.inl b/include/geos/geom/PrecisionModel.inl
index b9b8b80..502d5ce 100644
--- a/include/geos/geom/PrecisionModel.inl
+++ b/include/geos/geom/PrecisionModel.inl
@@ -21,6 +21,7 @@
 #define GEOS_GEOM_PRECISIONMODEL_INL
 
 #include <geos/geom/PrecisionModel.h>
+#include <geos/geom/Coordinate.h>
 
 #include <cassert>
 
@@ -35,6 +36,18 @@ PrecisionModel::makePrecise(Coordinate* coord) const
     return makePrecise(*coord);
 }
 
+INLINE void
+PrecisionModel::makePrecise(Coordinate& coord) const
+{
+    // optimization for full precision
+    if(modelType == FLOATING) {
+        return;
+    }
+
+    coord.x = makePrecise(coord.x);
+    coord.y = makePrecise(coord.y);
+}
+
 /*public*/
 INLINE PrecisionModel::Type
 PrecisionModel::getType() const
diff --git a/src/geom/PrecisionModel.cpp b/src/geom/PrecisionModel.cpp
index 779a160..fd00480 100644
--- a/src/geom/PrecisionModel.cpp
+++ b/src/geom/PrecisionModel.cpp
@@ -65,20 +65,6 @@ PrecisionModel::makePrecise(double val) const
 }
 
 /*public*/
-void
-PrecisionModel::makePrecise(Coordinate& coord) const
-{
-    // optimization for full precision
-    if(modelType == FLOATING) {
-        return;
-    }
-
-    coord.x = makePrecise(coord.x);
-    coord.y = makePrecise(coord.y);
-}
-
-
-/*public*/
 PrecisionModel::PrecisionModel()
     :
     modelType(FLOATING),

commit bc5faf6eed42fbfc01c77f03ac23ab3784f0c88b
Author: Daniel Baston <dbaston at gmail.com>
Date:   Fri Jun 26 17:17:25 2020 -0400

    Inline GeometryFactory::getPrecisionModel

diff --git a/include/geos/geom/GeometryFactory.inl b/include/geos/geom/GeometryFactory.inl
index 2bdd6a1..686ab5a 100644
--- a/include/geos/geom/GeometryFactory.inl
+++ b/include/geos/geom/GeometryFactory.inl
@@ -41,6 +41,13 @@ GeometryFactory::getCoordinateSequenceFactory() const
     return coordinateListFactory;
 }
 
+INLINE
+const PrecisionModel*
+GeometryFactory::getPrecisionModel() const
+{
+    return &precisionModel;
+}
+
 } // namespace geos::geom
 } // namespace geos
 
diff --git a/src/geom/GeometryFactory.cpp b/src/geom/GeometryFactory.cpp
index 3618ee7..398e3b7 100644
--- a/src/geom/GeometryFactory.cpp
+++ b/src/geom/GeometryFactory.cpp
@@ -290,13 +290,6 @@ GeometryFactory::toGeometry(const Envelope* envelope) const
 }
 
 /*public*/
-const PrecisionModel*
-GeometryFactory::getPrecisionModel() const
-{
-    return &precisionModel;
-}
-
-/*public*/
 std::unique_ptr<Point>
 GeometryFactory::createPoint(std::size_t coordinateDimension) const
 {

commit e47abc04cb0fc55955da9e6413cf997da93f6955
Author: Daniel Baston <dbaston at gmail.com>
Date:   Fri Jun 26 19:59:52 2020 -0400

    Use char array instead of std::istream in WKBReader
    
    Improves performance by factor of > 2

diff --git a/capi/geos_ts_c.cpp b/capi/geos_ts_c.cpp
index cbc94a8..5c7ab3a 100644
--- a/capi/geos_ts_c.cpp
+++ b/capi/geos_ts_c.cpp
@@ -921,13 +921,8 @@ extern "C" {
         return execute(extHandle, [&]() {
             GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
 
-            std::string wkbstring(reinterpret_cast<const char*>(wkb), size); // make it binary !
             WKBReader r(*(static_cast<GeometryFactory const*>(handle->geomFactory)));
-            std::istringstream is(std::ios_base::binary);
-            is.str(wkbstring);
-            is.seekg(0, std::ios::beg); // rewind reader pointer
-            auto g = r.read(is);
-            return g.release();
+            return r.read(wkb, size).release();
         });
     }
 
@@ -2705,11 +2700,7 @@ extern "C" {
     GEOSWKBReader_read_r(GEOSContextHandle_t extHandle, WKBReader* reader, const unsigned char* wkb, size_t size)
     {
         return execute(extHandle, [&]() {
-            // http://stackoverflow.com/questions/2079912/simpler-way-to-create-a-c-memorystream-from-char-size-t-without-copying-t
-            membuf mb((char*)wkb, size);
-            istream is(&mb);
-
-            return reader->read(is).release();
+            return reader->read(wkb, size).release();
         });
     }
 
diff --git a/include/geos/io/ByteOrderDataInStream.h b/include/geos/io/ByteOrderDataInStream.h
index 88346be..b2530af 100644
--- a/include/geos/io/ByteOrderDataInStream.h
+++ b/include/geos/io/ByteOrderDataInStream.h
@@ -42,16 +42,10 @@ class GEOS_DLL ByteOrderDataInStream {
 
 public:
 
-    ByteOrderDataInStream(std::istream* s = nullptr);
+    ByteOrderDataInStream(const unsigned char* buff = nullptr, size_t buff_sz = 0);
 
     ~ByteOrderDataInStream();
 
-    /**
-     * Allows a single ByteOrderDataInStream to be reused
-     * on multiple istream.
-     */
-    void setInStream(std::istream* s);
-
     void setOrder(int order);
 
     unsigned char readByte(); // throws ParseException
@@ -62,13 +56,12 @@ public:
 
     double readDouble(); // throws ParseException
 
+    size_t size() const;
+
 private:
     int byteOrder;
-    std::istream* stream;
-
-    // buffers to hold primitive datatypes
-    unsigned char buf[8];
-
+    const unsigned char* buf;
+    const unsigned char* end;
 };
 
 } // namespace io
diff --git a/include/geos/io/ByteOrderDataInStream.inl b/include/geos/io/ByteOrderDataInStream.inl
index ab8dcdb..399cbbb 100644
--- a/include/geos/io/ByteOrderDataInStream.inl
+++ b/include/geos/io/ByteOrderDataInStream.inl
@@ -31,10 +31,11 @@ namespace geos {
 namespace io {
 
 INLINE
-ByteOrderDataInStream::ByteOrderDataInStream(std::istream* s)
+ByteOrderDataInStream::ByteOrderDataInStream(const unsigned char* buff, size_t buffsz)
     :
     byteOrder(getMachineByteOrder()),
-    stream(s)
+    buf(buff),
+    end(buff + buffsz)
 {
 }
 
@@ -44,12 +45,6 @@ ByteOrderDataInStream::~ByteOrderDataInStream()
 }
 
 INLINE void
-ByteOrderDataInStream::setInStream(std::istream* s)
-{
-    stream = s;
-}
-
-INLINE void
 ByteOrderDataInStream::setOrder(int order)
 {
     byteOrder = order;
@@ -58,41 +53,52 @@ ByteOrderDataInStream::setOrder(int order)
 INLINE unsigned char
 ByteOrderDataInStream::readByte() // throws ParseException
 {
-    stream->read(reinterpret_cast<char*>(buf), 1);
-    if(stream->eof()) {
+    if(size() < 1) {
         throw  ParseException("Unexpected EOF parsing WKB");
     }
-    return buf[0];
+    auto ret = buf[0];
+    buf++;
+    return ret;
 }
 
 INLINE int
 ByteOrderDataInStream::readInt()
 {
-    stream->read(reinterpret_cast<char*>(buf), 4);
-    if(stream->eof()) {
-        throw  ParseException("Unexpected EOF parsing WKB");
+    if(size() < 4) {
+        throw ParseException("Unexpected EOF parsing WKB");
     }
-    return ByteOrderValues::getInt(buf, byteOrder);
+    auto ret =  ByteOrderValues::getInt(buf , byteOrder);
+    buf += 4;
+    return ret;
 }
 
 INLINE long
 ByteOrderDataInStream::readLong()
 {
-    stream->read(reinterpret_cast<char*>(buf), 8);
-    if(stream->eof()) {
-        throw  ParseException("Unexpected EOF parsing WKB");
+    if(size() < 8) {
+        throw ParseException("Unexpected EOF parsing WKB");
     }
-    return static_cast<long>(ByteOrderValues::getLong(buf, byteOrder));
+
+    auto ret = static_cast<long>(ByteOrderValues::getLong(buf, byteOrder));
+    buf += 8;
+    return ret;
 }
 
 INLINE double
 ByteOrderDataInStream::readDouble()
 {
-    stream->read(reinterpret_cast<char*>(buf), 8);
-    if(stream->eof()) {
+    if(size() < 8) {
         throw  ParseException("Unexpected EOF parsing WKB");
     }
-    return ByteOrderValues::getDouble(buf, byteOrder);
+    auto ret = ByteOrderValues::getDouble(buf, byteOrder);
+    buf += 8;
+    return ret;
+}
+
+INLINE size_t
+ByteOrderDataInStream::size() const
+{
+    return static_cast<size_t>(end - buf);
 }
 
 } // namespace io
diff --git a/include/geos/io/WKBReader.h b/include/geos/io/WKBReader.h
index 33461ee..c775a96 100644
--- a/include/geos/io/WKBReader.h
+++ b/include/geos/io/WKBReader.h
@@ -97,6 +97,17 @@ public:
     std::unique_ptr<geom::Geometry> read(std::istream& is);
 
     /**
+     * \brief Reads a Geometry from a buffer
+     *
+     * @param buf the buffer to read from
+     * @param size the size of the buffer in bytes
+     * @return the Geometry read
+     * @throws IOException
+     * @throws ParseException
+     */
+    std::unique_ptr<geom::Geometry> read(const unsigned char* buf, size_t size);
+
+    /**
      * \brief Reads a Geometry from an istream in hex format.
      *
      * @param is the stream to read from
diff --git a/src/io/WKBReader.cpp b/src/io/WKBReader.cpp
index aa13d29..c8c0fa6 100644
--- a/src/io/WKBReader.cpp
+++ b/src/io/WKBReader.cpp
@@ -171,9 +171,22 @@ WKBReader::readHEX(istream& is)
 }
 
 std::unique_ptr<Geometry>
-WKBReader::read(istream& is)
+WKBReader::read(std::istream& is)
 {
-    dis.setInStream(&is); // will default to machine endian
+    is.seekg(0, std::ios::end);
+    auto size = is.tellg();
+    is.seekg(0, std::ios::beg);
+
+    std::vector<unsigned char> buf(size);
+    is.read((char*) buf.data(), size);
+
+    return read(buf.data(), buf.size());
+}
+
+std::unique_ptr<Geometry>
+WKBReader::read(const unsigned char* buf, size_t size)
+{
+    dis = ByteOrderDataInStream(buf, size); // will default to machine endian
     return readGeometry();
 }
 

commit 82e6f0fc63ff4e07e66ee44ef86c09b4a83b4f69
Author: Daniel Baston <dbaston at gmail.com>
Date:   Sat Nov 28 22:15:25 2020 -0500

    Remove default arguments for Coordinate constructor
    
    The previously defined constructor allow a Coordinate to be constructed
    from only a single value, i.e. Coordinate(3) would produce (3, 0, NaN).
    It's not clear what the use for this is, and it allowed further
    complications like Envelope(3) compiling by implicitly constructing the
    coordinate above.
    
    This commit adds a no-argument constructor to preserve the behavior of
    Coordinate() producing (0, 0, NaN).

diff --git a/include/geos/geom/Coordinate.h b/include/geos/geom/Coordinate.h
index c6b5877..59b2eda 100644
--- a/include/geos/geom/Coordinate.h
+++ b/include/geos/geom/Coordinate.h
@@ -91,7 +91,9 @@ public:
 
     bool isNull() const;
 
-    Coordinate(double xNew = 0.0, double yNew = 0.0, double zNew = DoubleNotANumber);
+    Coordinate();
+
+    Coordinate(double xNew, double yNew, double zNew = DoubleNotANumber);
 
     bool equals2D(const Coordinate& other) const;
 
diff --git a/include/geos/geom/Coordinate.inl b/include/geos/geom/Coordinate.inl
index 983931e..83ec21c 100644
--- a/include/geos/geom/Coordinate.inl
+++ b/include/geos/geom/Coordinate.inl
@@ -39,6 +39,10 @@ Coordinate::isNull() const
 }
 
 INLINE
+Coordinate::Coordinate() : x(0.0), y(0.0), z(DoubleNotANumber)
+{}
+
+INLINE
 Coordinate::Coordinate(double xNew, double yNew, double zNew)
     :
     x(xNew),

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

Summary of changes:
 capi/geos_ts_c.cpp                        | 13 ++------
 include/geos/geom/Coordinate.h            |  4 ++-
 include/geos/geom/Coordinate.inl          |  4 +++
 include/geos/geom/GeometryFactory.inl     |  7 +++++
 include/geos/geom/PrecisionModel.inl      | 13 ++++++++
 include/geos/io/ByteOrderDataInStream.h   | 17 ++++-------
 include/geos/io/ByteOrderDataInStream.inl | 50 +++++++++++++++++--------------
 include/geos/io/WKBReader.h               | 11 +++++++
 src/geom/GeometryFactory.cpp              |  7 -----
 src/geom/PrecisionModel.cpp               | 14 ---------
 src/geom/util/SineStarFactory.cpp         |  4 +--
 src/io/WKBReader.cpp                      | 17 +++++++++--
 12 files changed, 90 insertions(+), 71 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list