[geos-commits] [SCM] GEOS branch main updated. 2df86bc1191f578047fb30331cae254486ace191

git at osgeo.org git at osgeo.org
Mon Jul 12 16:21:36 PDT 2021


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, main has been updated
       via  2df86bc1191f578047fb30331cae254486ace191 (commit)
       via  628391d30210802767bcaf19d6245512b163d491 (commit)
       via  5a0c4cdb39241c8b520c0045b4ea7da808a0cf77 (commit)
      from  413bdbc2014de87b3f1fda0895f5afc770226f53 (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 2df86bc1191f578047fb30331cae254486ace191
Merge: 413bdbc 628391d
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Mon Jul 12 16:21:29 2021 -0700

    Merge branch 'whuaegeanse-GeoJson' into main


commit 628391d30210802767bcaf19d6245512b163d491
Author: whuaegeansea <whuaegeansea at gmail.com>
Date:   Mon Jul 12 22:32:10 2021 +0800

    Format files of GeoJson with AStyle in GEOS

diff --git a/include/geos/io/GeoJSON.h b/include/geos/io/GeoJSON.h
index cd54c6d..08c648d 100644
--- a/include/geos/io/GeoJSON.h
+++ b/include/geos/io/GeoJSON.h
@@ -77,7 +77,7 @@ public:
     const std::string& getString() const;
     std::nullptr_t getNull() const;
     bool getBoolean() const;
-    const std::map<std::string,GeoJSONValue>& getObject() const;
+    const std::map<std::string, GeoJSONValue>& getObject() const;
     const std::vector<GeoJSONValue>& getArray() const;
 
     bool isNumber() const;
@@ -93,17 +93,19 @@ class GEOS_DLL GeoJSONFeature {
 
 public:
 
-    GeoJSONFeature(std::unique_ptr<geom::Geometry> g, const std::map<std::string, GeoJSONValue> &p);
+    GeoJSONFeature(std::unique_ptr<geom::Geometry> g,
+                   const std::map<std::string, GeoJSONValue>& p);
 
-    GeoJSONFeature(std::unique_ptr<geom::Geometry> g, std::map<std::string, GeoJSONValue>&& p);
+    GeoJSONFeature(std::unique_ptr<geom::Geometry> g,
+                   std::map<std::string, GeoJSONValue>&& p);
 
-    GeoJSONFeature(GeoJSONFeature const &other);
+    GeoJSONFeature(GeoJSONFeature const& other);
 
-    GeoJSONFeature(GeoJSONFeature && other);
+    GeoJSONFeature(GeoJSONFeature&& other);
 
     GeoJSONFeature& operator=(const GeoJSONFeature&);
 
-    GeoJSONFeature& operator=(GeoJSONFeature &&);
+    GeoJSONFeature& operator=(GeoJSONFeature&&);
 
     const geom::Geometry* getGeometry() const;
 
@@ -121,7 +123,7 @@ class GEOS_DLL GeoJSONFeatureCollection {
 
 public:
 
-    GeoJSONFeatureCollection(const std::vector<GeoJSONFeature> &f);
+    GeoJSONFeatureCollection(const std::vector<GeoJSONFeature>& f);
 
     GeoJSONFeatureCollection(std::vector<GeoJSONFeature>&& f);
 
diff --git a/src/io/GeoJSON.cpp b/src/io/GeoJSON.cpp
index 086799d..cfb28ea 100644
--- a/src/io/GeoJSON.cpp
+++ b/src/io/GeoJSON.cpp
@@ -19,59 +19,70 @@ namespace io { // geos.io
 
 // GeoJSONValue
 
-GeoJSONValue::GeoJSONValue(double value) {
+GeoJSONValue::GeoJSONValue(double value)
+{
     type = Type::NUMBER;
     d = value;
 }
 
-GeoJSONValue::GeoJSONValue(const std::string& value)  {
+GeoJSONValue::GeoJSONValue(const std::string& value)
+{
     type = Type::STRING;
-    new(&s) std::string{value};
+    new (&s) std::string{value};
 }
 
-GeoJSONValue::GeoJSONValue()  {
+GeoJSONValue::GeoJSONValue()
+{
     type = Type::NULLTYPE;
     n = nullptr;
 }
 
-GeoJSONValue::GeoJSONValue(bool value)  {
+GeoJSONValue::GeoJSONValue(bool value)
+{
     type = Type::BOOLEAN;
     b = value;
 }
 
-GeoJSONValue::GeoJSONValue(const std::map<std::string, GeoJSONValue>& value)  {
+GeoJSONValue::GeoJSONValue(const std::map<std::string, GeoJSONValue>& value)
+{
     type = Type::OBJECT;
-    new(&o) std::map<std::string, GeoJSONValue> {value};
+    new (&o) std::map<std::string, GeoJSONValue> {value};
 }
 
-GeoJSONValue::GeoJSONValue(const std::vector<GeoJSONValue>& value)  {
+GeoJSONValue::GeoJSONValue(const std::vector<GeoJSONValue>& value)
+{
     type = Type::ARRAY;
-    new(&a) std::vector<GeoJSONValue> {};
+    new (&a) std::vector<GeoJSONValue> {};
     a.reserve(value.size());
-    for(const auto& v : value) {
+    for (const auto& v : value) {
         a.push_back(v);
     }
 }
 
-void GeoJSONValue::cleanup() {
+void GeoJSONValue::cleanup()
+{
     using std::string;
     using object = std::map<std::string, GeoJSONValue>;
     using array = std::vector<GeoJSONValue>;
     if (type == Type::STRING) {
         s.~string();
-    } else if (type == Type::OBJECT) {
+    }
+    else if (type == Type::OBJECT) {
         o.~object();
-    } else if (type == Type::ARRAY) {
+    }
+    else if (type == Type::ARRAY) {
         a.~array();
     }
 }
 
-GeoJSONValue::~GeoJSONValue() {
+GeoJSONValue::~GeoJSONValue()
+{
     cleanup();
 }
 
-GeoJSONValue::GeoJSONValue(const GeoJSONValue& v) {
-    switch(v.type) {
+GeoJSONValue::GeoJSONValue(const GeoJSONValue& v)
+{
+    switch (v.type) {
     case Type::NUMBER:
         d = v.d;
         break;
@@ -79,18 +90,18 @@ GeoJSONValue::GeoJSONValue(const GeoJSONValue& v) {
         b = v.b;
         break;
     case Type::STRING:
-        new(&s) std::string{v.s};
+        new (&s) std::string{v.s};
         break;
     case Type::NULLTYPE:
         n = v.n;
         break;
     case Type::OBJECT:
-        new(&o) std::map<std::string, GeoJSONValue> {v.o};
+        new (&o) std::map<std::string, GeoJSONValue> {v.o};
         break;
     case Type::ARRAY:
-        new(&a) std::vector<GeoJSONValue> {};
+        new (&a) std::vector<GeoJSONValue> {};
         a.reserve(v.a.size());
-        for(const auto& i : v.a) {
+        for (const auto& i : v.a) {
             a.push_back(i);
         }
         break;
@@ -98,21 +109,24 @@ GeoJSONValue::GeoJSONValue(const GeoJSONValue& v) {
     type = v.type;
 }
 
-GeoJSONValue& GeoJSONValue::operator=(const GeoJSONValue& v) {
+GeoJSONValue& GeoJSONValue::operator=(const GeoJSONValue& v)
+{
     if (type == Type::STRING && v.type == Type::STRING) {
         s = v.s;
         return *this;
-    } else if (type == Type::OBJECT && v.type == Type::OBJECT) {
+    }
+    else if (type == Type::OBJECT && v.type == Type::OBJECT) {
         o = v.o;
         return *this;
-    } else if (type == Type::ARRAY && v.type == Type::ARRAY) {
+    }
+    else if (type == Type::ARRAY && v.type == Type::ARRAY) {
         a = v.a;
         return *this;
     }
 
     cleanup();
 
-    switch(v.type) {
+    switch (v.type) {
     case Type::NUMBER:
         d = v.d;
         break;
@@ -120,18 +134,18 @@ GeoJSONValue& GeoJSONValue::operator=(const GeoJSONValue& v) {
         b = v.b;
         break;
     case Type::STRING:
-        new(&s) std::string{v.s};
+        new (&s) std::string{v.s};
         break;
     case Type::NULLTYPE:
         n = v.n;
         break;
     case Type::OBJECT:
-        new(&o) std::map<std::string, GeoJSONValue> {v.o};
+        new (&o) std::map<std::string, GeoJSONValue> {v.o};
         break;
     case Type::ARRAY:
-        new(&a) std::vector<GeoJSONValue> {};
+        new (&a) std::vector<GeoJSONValue> {};
         a.reserve(v.a.size());
-        for(const auto& i : v.a) {
+        for (const auto& i : v.a) {
             a.push_back(i);
         }
         break;
@@ -140,72 +154,89 @@ GeoJSONValue& GeoJSONValue::operator=(const GeoJSONValue& v) {
     return *this;
 }
 
-double GeoJSONValue::getNumber() const {
+double GeoJSONValue::getNumber() const
+{
     if (type != Type::NUMBER) throw GeoJSONTypeError{};
     return d;
 
 }
 
-const std::string& GeoJSONValue::getString() const {
+const std::string& GeoJSONValue::getString() const
+{
     if (type != Type::STRING) throw GeoJSONTypeError{};
     return s;
 }
 
-std::nullptr_t GeoJSONValue::getNull() const {
+std::nullptr_t GeoJSONValue::getNull() const
+{
     if (type != Type::NULLTYPE) throw GeoJSONTypeError{};
     return n;
 }
 
-bool GeoJSONValue::getBoolean() const {
+bool GeoJSONValue::getBoolean() const
+{
     if (type != Type::BOOLEAN) throw GeoJSONTypeError{};
     return b;
 }
 
-const std::map<std::string,GeoJSONValue>& GeoJSONValue::getObject() const {
+const std::map<std::string, GeoJSONValue>& GeoJSONValue::getObject() const
+{
     if (type != Type::OBJECT) throw GeoJSONTypeError{};
     return o;
 }
 
-const std::vector<GeoJSONValue>& GeoJSONValue::getArray() const {
+const std::vector<GeoJSONValue>& GeoJSONValue::getArray() const
+{
     if (type != Type::ARRAY) throw GeoJSONTypeError{};
     return a;
 }
 
-bool GeoJSONValue::isNumber() const {
+bool GeoJSONValue::isNumber() const
+{
     return type == Type::NUMBER;
 }
 
-bool GeoJSONValue::isString() const {
+bool GeoJSONValue::isString() const
+{
     return type == Type::STRING;
 }
 
-bool GeoJSONValue::isNull() const {
+bool GeoJSONValue::isNull() const
+{
     return type == Type::NULLTYPE;
 }
 
-bool GeoJSONValue::isBoolean() const {
+bool GeoJSONValue::isBoolean() const
+{
     return type == Type::BOOLEAN;
 }
 
-bool GeoJSONValue::isObject() const {
+bool GeoJSONValue::isObject() const
+{
     return type == Type::OBJECT;
 }
 
-bool GeoJSONValue::isArray() const {
+bool GeoJSONValue::isArray() const
+{
     return type == Type::ARRAY;
 }
 
 // GeoJSONFeature
 
-GeoJSONFeature::GeoJSONFeature(std::unique_ptr<geom::Geometry> g, const std::map<std::string, GeoJSONValue>& p) : geometry(std::move(g)), properties(p) {}
+GeoJSONFeature::GeoJSONFeature(std::unique_ptr<geom::Geometry> g,
+                               const std::map<std::string, GeoJSONValue>& p) : geometry(std::move(g)), properties(p) {}
 
-GeoJSONFeature::GeoJSONFeature(std::unique_ptr<geom::Geometry> g, std::map<std::string, GeoJSONValue>&& p) : geometry(std::move(g)), properties(std::move(p)) {}
+GeoJSONFeature::GeoJSONFeature(std::unique_ptr<geom::Geometry> g,
+                               std::map<std::string, GeoJSONValue>&& p) : geometry(std::move(g)), properties(std::move(p)) {}
 
-GeoJSONFeature::GeoJSONFeature(GeoJSONFeature const &other) : geometry(other.geometry->clone()), properties(other.properties) {}
+GeoJSONFeature::GeoJSONFeature(GeoJSONFeature const& other) : geometry(other.geometry->clone()),
+    properties(other.properties) {}
 
-GeoJSONFeature::GeoJSONFeature(GeoJSONFeature && other) : geometry(std::move(other.geometry)), properties(std::move(other.properties)) {}
+GeoJSONFeature::GeoJSONFeature(GeoJSONFeature&& other) : geometry(std::move(other.geometry)),
+    properties(std::move(other.properties)) {}
 
-GeoJSONFeature& GeoJSONFeature::operator=(const GeoJSONFeature& other) {
+GeoJSONFeature& GeoJSONFeature::operator=(const GeoJSONFeature& other)
+{
     if (this == &other) {
         return *this;
     }
@@ -214,27 +245,31 @@ GeoJSONFeature& GeoJSONFeature::operator=(const GeoJSONFeature& other) {
     return *this;
 }
 
-GeoJSONFeature& GeoJSONFeature::operator=(GeoJSONFeature&& other) {
+GeoJSONFeature& GeoJSONFeature::operator=(GeoJSONFeature&& other)
+{
     geometry = std::move(other.geometry);
     properties = std::move(other.properties);
     return *this;
 }
 
-const geom::Geometry* GeoJSONFeature::getGeometry() const {
+const geom::Geometry* GeoJSONFeature::getGeometry() const
+{
     return geometry.get();
 }
 
-const std::map<std::string, GeoJSONValue>& GeoJSONFeature::getProperties() const {
+const std::map<std::string, GeoJSONValue>& GeoJSONFeature::getProperties() const
+{
     return properties;
 }
 
 // GeoJSONFeatureCollection
 
-GeoJSONFeatureCollection::GeoJSONFeatureCollection(const std::vector<GeoJSONFeature> &f) : features(f) {}
+GeoJSONFeatureCollection::GeoJSONFeatureCollection(const std::vector<GeoJSONFeature>& f) : features(f) {}
 
 GeoJSONFeatureCollection::GeoJSONFeatureCollection(std::vector<GeoJSONFeature>&& f) : features(std::move(f)) {}
 
-const std::vector<GeoJSONFeature>& GeoJSONFeatureCollection::getFeatures() const {
+const std::vector<GeoJSONFeature>& GeoJSONFeatureCollection::getFeatures() const
+{
     return features;
 }
 
diff --git a/src/io/GeoJSONReader.cpp b/src/io/GeoJSONReader.cpp
index 70aeefa..82cb922 100644
--- a/src/io/GeoJSONReader.cpp
+++ b/src/io/GeoJSONReader.cpp
@@ -45,94 +45,112 @@ GeoJSONReader::GeoJSONReader(): GeoJSONReader(*(GeometryFactory::getDefaultInsta
 
 GeoJSONReader::GeoJSONReader(const geom::GeometryFactory& gf) : geometryFactory(gf) {}
 
-std::unique_ptr<geom::Geometry> GeoJSONReader::read(const std::string& geoJsonText) const {
+std::unique_ptr<geom::Geometry> GeoJSONReader::read(const std::string& geoJsonText) const
+{
     try {
         const json& j = json::parse(geoJsonText);
         const std::string& type = j["type"];
         if (type == "Feature") {
             return readFeatureForGeometry(j);
-        } else if (type == "FeatureCollection") {
+        }
+        else if (type == "FeatureCollection") {
             return readFeatureCollectionForGeometry(j);
-        } else {
+        }
+        else {
             return readGeometry(j);
         }
-    } catch (json::exception& ex) {
+    }
+    catch (json::exception& ex) {
         throw ParseException("Error parsing JSON", ex.what());
     }
 }
 
-GeoJSONFeatureCollection GeoJSONReader::readFeatures(const std::string& geoJsonText) const {
+GeoJSONFeatureCollection GeoJSONReader::readFeatures(const std::string& geoJsonText) const
+{
     try {
         const json& j = json::parse(geoJsonText);
         const std::string& type = j["type"];
         if (type == "Feature") {
             const auto& feature = readFeature(j);
             return GeoJSONFeatureCollection { std::vector<GeoJSONFeature>{feature} };
-        } else if (type == "FeatureCollection") {
+        }
+        else if (type == "FeatureCollection") {
             return readFeatureCollection(j);
-        } else {
+        }
+        else {
             auto g = readGeometry(j);
             return GeoJSONFeatureCollection { std::vector<GeoJSONFeature>{GeoJSONFeature{std::move(g), std::map<std::string, GeoJSONValue>{} }}};
         }
-    } catch (json::exception& ex) {
+    }
+    catch (json::exception& ex) {
         throw ParseException("Error parsing JSON", ex.what());
     }
 }
 
 std::unique_ptr<geom::Geometry> GeoJSONReader::readFeatureForGeometry(
-    const geos_nlohmann::json& j) const {
+    const geos_nlohmann::json& j) const
+{
     const auto& geometryJson = j["geometry"];
     auto geometry = readGeometry(geometryJson);
     return geometry;
 }
 
-GeoJSONFeature GeoJSONReader::readFeature(const geos_nlohmann::json& j) const {
+GeoJSONFeature GeoJSONReader::readFeature(const geos_nlohmann::json& j) const
+{
     const auto& geometryJson = j["geometry"];
     const auto& properties = j["properties"];
     return GeoJSONFeature{readGeometry(geometryJson), readProperties(properties)};
 }
 
 std::map<std::string, GeoJSONValue> GeoJSONReader::readProperties(
-    const geos_nlohmann::json& p) const {
-    std::map<std::string,GeoJSONValue> map;
-    for(const auto& prop : p.items()) {
+    const geos_nlohmann::json& p) const
+{
+    std::map<std::string, GeoJSONValue> map;
+    for (const auto& prop : p.items()) {
         map[prop.key()] = std::move(readProperty(prop.value()));
     }
     return map;
 }
 
 GeoJSONValue GeoJSONReader::readProperty(
-    const geos_nlohmann::json& value) const {
+    const geos_nlohmann::json& value) const
+{
     if (value.is_string()) {
         return GeoJSONValue { value.get<std::string>() };
-    } else if (value.is_number()) {
+    }
+    else if (value.is_number()) {
         return GeoJSONValue { value.get<double>() };
-    } else if (value.is_boolean()) {
+    }
+    else if (value.is_boolean()) {
         return GeoJSONValue { value.get<bool>() };
-    } else if (value.is_array()) {
+    }
+    else if (value.is_array()) {
         std::vector<GeoJSONValue> v {};
         v.reserve(value.size());
         for (const auto& el : value.items()) {
             v.push_back(readProperty(el.value()));
         }
         return GeoJSONValue{ v };
-    } else if (value.is_object()) {
+    }
+    else if (value.is_object()) {
         std::map<std::string, GeoJSONValue> v {};
         for (const auto& el : value.items()) {
             v[el.key()] = std::move(readProperty(el.value()));
         }
         return GeoJSONValue{ v };
-    } else {
+    }
+    else {
         return GeoJSONValue{};
     }
 }
 
 std::unique_ptr<geom::Geometry> GeoJSONReader::readFeatureCollectionForGeometry(
-    const geos_nlohmann::json& j) const {
-    const auto &featuresJson = j["features"];
+    const geos_nlohmann::json& j) const
+{
+    const auto& featuresJson = j["features"];
     std::vector<std::unique_ptr<geom::Geometry>> geometries;
     geometries.reserve(featuresJson.size());
-    for(const auto& featureJson : featuresJson) {
+    for (const auto& featureJson : featuresJson) {
         auto g = readFeatureForGeometry(featureJson);
         geometries.push_back(std::move(g));
     }
@@ -140,11 +158,12 @@ std::unique_ptr<geom::Geometry> GeoJSONReader::readFeatureCollectionForGeometry(
 }
 
 GeoJSONFeatureCollection GeoJSONReader::readFeatureCollection(
-    const geos_nlohmann::json& j) const {
-    const auto & featuresJson = j["features"];
+    const geos_nlohmann::json& j) const
+{
+    const auto& featuresJson = j["features"];
     std::vector<GeoJSONFeature> features;
     features.reserve(featuresJson.size());
-    for(const auto& featureJson : featuresJson) {
+    for (const auto& featureJson : featuresJson) {
         features.push_back(readFeature(featureJson));
     }
     return GeoJSONFeatureCollection{std::move(features)};
@@ -152,57 +171,72 @@ GeoJSONFeatureCollection GeoJSONReader::readFeatureCollection(
 
 
 std::unique_ptr<geom::Geometry> GeoJSONReader::readGeometry(
-    const geos_nlohmann::json& j) const {
-    const std::string & type = j["type"];
+    const geos_nlohmann::json& j) const
+{
+    const std::string& type = j["type"];
     if (type == "Point") {
         return readPoint(j);
-    } else if (type == "LineString") {
+    }
+    else if (type == "LineString") {
         return readLineString(j);
-    } else if (type == "Polygon") {
+    }
+    else if (type == "Polygon") {
         return readPolygon(j);
-    } else if (type == "MultiPoint") {
+    }
+    else if (type == "MultiPoint") {
         return readMultiPoint(j);
-    } else if (type == "MultiLineString") {
+    }
+    else if (type == "MultiLineString") {
         return readMultiLineString(j);
-    } else if (type == "MultiPolygon") {
+    }
+    else if (type == "MultiPolygon") {
         return readMultiPolygon(j);
-    } else if (type == "GeometryCollection") {
+    }
+    else if (type == "GeometryCollection") {
         return readGeometryCollection(j);
-    } else {
+    }
+    else {
         throw ParseException{"Unknown geometry type!"};
     }
 }
 
 geom::Coordinate GeoJSONReader::readCoordinate(
-    const std::vector<double>& coords) const {
+    const std::vector<double>& coords) const
+{
     if (coords.size() == 1) {
         throw  ParseException("Expected two coordinates found one");
-    } else if (coords.size() > 2) {
+    }
+    else if (coords.size() > 2) {
         throw  ParseException("Expected two coordinates found more than two");
-    } else {
+    }
+    else {
         return geom::Coordinate {coords[0], coords[1]};
     }
 }
 
 std::unique_ptr<geom::Point> GeoJSONReader::readPoint(
-    const geos_nlohmann::json& j) const {
-    const auto &coords = j["coordinates"].get<std::vector<double>>();
+    const geos_nlohmann::json& j) const
+{
+    const auto& coords = j["coordinates"].get<std::vector<double>>();
     if (coords.size() == 1) {
         throw  ParseException("Expected two coordinates found one");
-    } else if (coords.size() < 2) {
+    }
+    else if (coords.size() < 2) {
         return geometryFactory.createPoint(2);
-    } else {
+    }
+    else {
         const geom::Coordinate& coord = readCoordinate(coords);
         return std::unique_ptr<geom::Point>(geometryFactory.createPoint(coord));
     }
 }
 
 std::unique_ptr<geom::LineString> GeoJSONReader::readLineString(
-    const geos_nlohmann::json& j) const {
-    const auto &coords = j["coordinates"].get<std::vector<std::vector<double>>>();
+    const geos_nlohmann::json& j) const
+{
+    const auto& coords = j["coordinates"].get<std::vector<std::vector<double>>>();
     std::vector<geom::Coordinate> coordinates;
     coordinates.reserve(coords.size());
-    for(const auto& coord : coords) {
+    for (const auto& coord : coords) {
         const geom::Coordinate& c = readCoordinate(coord);
         coordinates.push_back(c);
     }
@@ -211,17 +245,19 @@ std::unique_ptr<geom::LineString> GeoJSONReader::readLineString(
 }
 
 std::unique_ptr<geom::Polygon> GeoJSONReader::readPolygon(
-    const geos_nlohmann::json& json) const {
+    const geos_nlohmann::json& json) const
+{
     const auto& polygonCoords = json["coordinates"].get<std::vector<std::vector<std::vector<double>>>>();
     return readPolygon(polygonCoords);
 }
 
 std::unique_ptr<geom::Polygon> GeoJSONReader::readPolygon(
-    const std::vector<std::vector<std::vector<double>>>& polygonCoords) const {
+    const std::vector<std::vector<std::vector<double>>>& polygonCoords) const
+{
     std::unique_ptr<geom::LinearRing> shell;
     std::vector<std::unique_ptr<geom::LinearRing>> rings;
     rings.reserve(polygonCoords.size());
-    for(const auto& ring : polygonCoords) {
+    for (const auto& ring : polygonCoords) {
         std::vector<geom::Coordinate> coordinates;
         coordinates.reserve(ring.size());
         for (const auto& coord : ring) {
@@ -231,25 +267,29 @@ std::unique_ptr<geom::Polygon> GeoJSONReader::readPolygon(
         auto coordinateSequence = geometryFactory.getCoordinateSequenceFactory()->create(std::move(coordinates));
         if (!shell) {
             shell = geometryFactory.createLinearRing(std::move(coordinateSequence));
-        } else {
+        }
+        else {
             rings.push_back(geometryFactory.createLinearRing(std::move(coordinateSequence)));
         }
     }
     if (!shell) {
         return geometryFactory.createPolygon(2);
-    } else if (rings.size() == 0) {
+    }
+    else if (rings.size() == 0) {
         return geometryFactory.createPolygon(std::move(shell));
-    } else {
+    }
+    else {
         return geometryFactory.createPolygon(std::move(shell), std::move(rings));
     }
 }
 
 std::unique_ptr<geom::MultiPoint> GeoJSONReader::readMultiPoint(
-    const geos_nlohmann::json& j) const {
-    const auto &coords = j["coordinates"].get<std::vector<std::vector<double>>>();
+    const geos_nlohmann::json& j) const
+{
+    const auto& coords = j["coordinates"].get<std::vector<std::vector<double>>>();
     std::vector<std::unique_ptr<geom::Point>> points;
     points.reserve(coords.size());
-    for(const auto& coord : coords) {
+    for (const auto& coord : coords) {
         const geom::Coordinate& c = readCoordinate(coord);
         points.push_back(std::unique_ptr<geom::Point>(geometryFactory.createPoint(c)));
     }
@@ -257,11 +297,12 @@ std::unique_ptr<geom::MultiPoint> GeoJSONReader::readMultiPoint(
 }
 
 std::unique_ptr<geom::MultiLineString> GeoJSONReader::readMultiLineString(
-    const geos_nlohmann::json& json) const {
-    const auto &listOfCoords = json["coordinates"].get<std::vector<std::vector<std::vector<double>>>>();
+    const geos_nlohmann::json& json) const
+{
+    const auto& listOfCoords = json["coordinates"].get<std::vector<std::vector<std::vector<double>>>>();
     std::vector<std::unique_ptr<geom::LineString>> lines;
     lines.reserve(listOfCoords.size());
-    for(const auto& coords :  listOfCoords) {
+    for (const auto& coords :  listOfCoords) {
         std::vector<geom::Coordinate> coordinates;
         coordinates.reserve(coords.size());
         for (const auto& coord : coords) {
@@ -275,18 +316,20 @@ std::unique_ptr<geom::MultiLineString> GeoJSONReader::readMultiLineString(
 }
 
 std::unique_ptr<geom::MultiPolygon> GeoJSONReader::readMultiPolygon(
-    const geos_nlohmann::json& json) const {
-    const auto &multiPolygonCoords = json["coordinates"].get<std::vector<std::vector<std::vector<std::vector<double>>>>>();
+    const geos_nlohmann::json& json) const
+{
+    const auto& multiPolygonCoords = json["coordinates"].get<std::vector<std::vector<std::vector<std::vector<double>>>>>();
     std::vector<std::unique_ptr<geom::Polygon>> polygons;
     polygons.reserve(multiPolygonCoords.size());
-    for(const auto& polygonCoords : multiPolygonCoords) {
+    for (const auto& polygonCoords : multiPolygonCoords) {
         polygons.push_back(readPolygon(polygonCoords));
     }
     return geometryFactory.createMultiPolygon(std::move(polygons));
 }
 
 std::unique_ptr<geom::GeometryCollection> GeoJSONReader::readGeometryCollection(
-    const geos_nlohmann::json& j) const {
+    const geos_nlohmann::json& j) const
+{
     const auto& jsonGeometries = j["geometries"];
     std::vector<std::unique_ptr<geom::Geometry>> geometries;
     geometries.reserve(jsonGeometries.size());
diff --git a/src/io/GeoJSONWriter.cpp b/src/io/GeoJSONWriter.cpp
index 807f0fe..c35f3a3 100644
--- a/src/io/GeoJSONWriter.cpp
+++ b/src/io/GeoJSONWriter.cpp
@@ -39,58 +39,72 @@ using json = geos_nlohmann::ordered_json;
 namespace geos {
 namespace io { // geos.io
 
-std::string GeoJSONWriter::write(const geom::Geometry* geometry, GeoJSONType type) {
+std::string GeoJSONWriter::write(const geom::Geometry* geometry, GeoJSONType type)
+{
     json j;
     encode(geometry, type, j);
     const std::string& geojson = j.dump();
     return geojson;
 }
 
-std::string GeoJSONWriter::writeFormatted(const geom::Geometry* geometry, GeoJSONType type, int indent) {
+std::string GeoJSONWriter::writeFormatted(const geom::Geometry* geometry, GeoJSONType type, int indent)
+{
     json j;
     encode(geometry, type, j);
     const std::string& geojson = j.dump(indent);
     return geojson;
 }
 
-std::string GeoJSONWriter::write(const GeoJSONFeature& feature) {
+std::string GeoJSONWriter::write(const GeoJSONFeature& feature)
+{
     json j;
     encodeFeature(feature, j);
     const std::string& geojson = j.dump();
     return geojson;
 }
 
-void GeoJSONWriter::encodeGeoJSONValue(const std::string& key, const GeoJSONValue& value, geos_nlohmann::ordered_json& j) {
+void GeoJSONWriter::encodeGeoJSONValue(const std::string& key, const GeoJSONValue& value,
+                                       geos_nlohmann::ordered_json& j)
+{
     if (value.isNumber()) {
         if (j.is_object()) {
             j[key] = value.getNumber();
-        } else {
+        }
+        else {
             j.push_back(value.getNumber());
         }
-    } else if (value.isString()) {
+    }
+    else if (value.isString()) {
         if (j.is_object()) {
             j[key] = value.getString();
-        } else {
+        }
+        else {
             j.push_back(value.getString());
         }
-    } else if (value.isBoolean()) {
+    }
+    else if (value.isBoolean()) {
         if (j.is_object()) {
             j[key] = value.getBoolean();
-        } else {
+        }
+        else {
             j.push_back(value.getBoolean());
         }
-    } else if (value.isNull()) {
+    }
+    else if (value.isNull()) {
         if (j.is_object()) {
             j[key] = nullptr;
-        } else {
+        }
+        else {
             j.push_back(nullptr);
         }
-    } else if (value.isArray()) {
+    }
+    else if (value.isArray()) {
         j[key] = json::array();
         for (const GeoJSONValue& v : value.getArray()) {
             encodeGeoJSONValue("", v, j[key]);
         }
-    } else if (value.isObject()) {
+    }
+    else if (value.isObject()) {
         j[key] = json::object();
         for (const auto& entry : value.getObject()) {
             encodeGeoJSONValue(entry.first, entry.second, j[key]);
@@ -98,11 +112,12 @@ void GeoJSONWriter::encodeGeoJSONValue(const std::string& key, const GeoJSONValu
     }
 }
 
-std::string GeoJSONWriter::write(const GeoJSONFeatureCollection& features) {
+std::string GeoJSONWriter::write(const GeoJSONFeatureCollection& features)
+{
     json j;
     j["type"] = "FeatureCollection";
     json featuresJson = json::array();
-    for(auto const& feature : features.getFeatures()) {
+    for (auto const& feature : features.getFeatures()) {
         json featureJson;
         encodeFeature(feature, featureJson);
         featuresJson.push_back(featureJson);
@@ -112,13 +127,14 @@ std::string GeoJSONWriter::write(const GeoJSONFeatureCollection& features) {
     return geojson;
 }
 
-void GeoJSONWriter::encodeFeature(const GeoJSONFeature& feature, geos_nlohmann::ordered_json& j) {
+void GeoJSONWriter::encodeFeature(const GeoJSONFeature& feature, geos_nlohmann::ordered_json& j)
+{
     j["type"] = "Feature";
     json geometryJson;
     encodeGeometry(feature.getGeometry(), geometryJson);
     j["geometry"] = geometryJson;
     json propertiesJson = json::object();
-    for(auto const& property : feature.getProperties()) {
+    for (auto const& property : feature.getProperties()) {
         std::string key = property.first;
         GeoJSONValue value = property.second;
         encodeGeoJSONValue(key, value, propertiesJson);
@@ -126,24 +142,29 @@ void GeoJSONWriter::encodeFeature(const GeoJSONFeature& feature, geos_nlohmann::
     j["properties"] = propertiesJson;
 }
 
-void GeoJSONWriter::encode(const geom::Geometry* geometry, GeoJSONType geojsonType, geos_nlohmann::ordered_json& j) {
-    if(geojsonType == GeoJSONType::GEOMETRY) {
+void GeoJSONWriter::encode(const geom::Geometry* geometry, GeoJSONType geojsonType, geos_nlohmann::ordered_json& j)
+{
+    if (geojsonType == GeoJSONType::GEOMETRY) {
         encodeGeometry(geometry, j);
-    } else if (geojsonType == GeoJSONType::FEATURE) {
+    }
+    else if (geojsonType == GeoJSONType::FEATURE) {
         encodeFeature(geometry, j);
-    } else if (geojsonType == GeoJSONType::FEATURE_COLLECTION) {
+    }
+    else if (geojsonType == GeoJSONType::FEATURE_COLLECTION) {
         encodeFeatureCollection(geometry, j);
     }
 }
 
-void GeoJSONWriter::encodeFeature(const geom::Geometry* g, geos_nlohmann::ordered_json& j) {
+void GeoJSONWriter::encodeFeature(const geom::Geometry* g, geos_nlohmann::ordered_json& j)
+{
     json geometryJson;
     encodeGeometry(g, geometryJson);
     j["type"] = "Feature";
     j["geometry"] = geometryJson;
 }
 
-void GeoJSONWriter::encodeFeatureCollection(const geom::Geometry* g, geos_nlohmann::ordered_json& j) {
+void GeoJSONWriter::encodeFeatureCollection(const geom::Geometry* g, geos_nlohmann::ordered_json& j)
+{
     json featureJson;
     encodeFeature(g, featureJson);
     std::vector<json> features;
@@ -152,79 +173,92 @@ void GeoJSONWriter::encodeFeatureCollection(const geom::Geometry* g, geos_nlohma
     j["features"] = features;
 }
 
-void GeoJSONWriter::encodeGeometry(const geom::Geometry* geometry, geos_nlohmann::ordered_json& j) {
+void GeoJSONWriter::encodeGeometry(const geom::Geometry* geometry, geos_nlohmann::ordered_json& j)
+{
     auto type = geometry->getGeometryTypeId();
     if (type == GEOS_POINT) {
         auto point = static_cast<const geom::Point*>(geometry);
         encodePoint(point, j);
-    } else if (type == GEOS_LINESTRING) {
+    }
+    else if (type == GEOS_LINESTRING) {
         auto line = static_cast<const geom::LineString*>(geometry);
         encodeLineString(line, j);
-    } else if (type == GEOS_POLYGON) {
+    }
+    else if (type == GEOS_POLYGON) {
         auto poly = static_cast<const geom::Polygon*>(geometry);
         encodePolygon(poly, j);
-    } else if (type == GEOS_MULTIPOINT) {
+    }
+    else if (type == GEOS_MULTIPOINT) {
         auto multiPoint = static_cast<const geom::MultiPoint*>(geometry);
         encodeMultiPoint(multiPoint, j);
-    } else if (type == GEOS_MULTILINESTRING) {
+    }
+    else if (type == GEOS_MULTILINESTRING) {
         auto multiLineString = static_cast<const geom::MultiLineString*>(geometry);
         encodeMultiLineString(multiLineString, j);
-    } else if (type == GEOS_MULTIPOLYGON) {
+    }
+    else if (type == GEOS_MULTIPOLYGON) {
         auto multiPolygon = static_cast<const geom::MultiPolygon*>(geometry);
         encodeMultiPolygon(multiPolygon, j);
-    } else if (type == GEOS_GEOMETRYCOLLECTION) {
+    }
+    else if (type == GEOS_GEOMETRYCOLLECTION) {
         auto geometryCollection = static_cast<const geom::GeometryCollection*>(geometry);
         encodeGeometryCollection(geometryCollection, j);
     }
 }
 
-void GeoJSONWriter::encodePoint(const geom::Point* point, geos_nlohmann::ordered_json& j) {
+void GeoJSONWriter::encodePoint(const geom::Point* point, geos_nlohmann::ordered_json& j)
+{
     j["type"] = "Point";
     j["coordinates"] = convertCoordinate(point->getCoordinate());
 }
 
-void GeoJSONWriter::encodeLineString(const geom::LineString* line, geos_nlohmann::ordered_json& j) {
+void GeoJSONWriter::encodeLineString(const geom::LineString* line, geos_nlohmann::ordered_json& j)
+{
     j["type"] = "LineString";
     j["coordinates"] = convertCoordinateSequence(line->getCoordinates().get());
 }
 
-void GeoJSONWriter::encodePolygon(const geom::Polygon* poly, geos_nlohmann::ordered_json& j) {
+void GeoJSONWriter::encodePolygon(const geom::Polygon* poly, geos_nlohmann::ordered_json& j)
+{
     j["type"] = "Polygon";
     std::vector<std::vector<std::pair<double, double>>> rings;
     auto ring = poly->getExteriorRing();
     auto coords = ring->getCoordinates();
     rings.push_back(convertCoordinateSequence(ring->getCoordinates().get()));
-    for(size_t i = 0; i < poly->getNumInteriorRing(); i++) {
+    for (size_t i = 0; i < poly->getNumInteriorRing(); i++) {
         rings.push_back(convertCoordinateSequence(poly->getInteriorRingN(i)->getCoordinates().get()));
     }
     j["coordinates"] = rings;
 }
 
-void GeoJSONWriter::encodeMultiPoint(const geom::MultiPoint* multiPoint, geos_nlohmann::ordered_json& j) {
+void GeoJSONWriter::encodeMultiPoint(const geom::MultiPoint* multiPoint, geos_nlohmann::ordered_json& j)
+{
     j["type"] = "MultiPoint";
     j["coordinates"] = convertCoordinateSequence(multiPoint->getCoordinates().get());
 }
 
-void GeoJSONWriter::encodeMultiLineString(const geom::MultiLineString* multiLineString, geos_nlohmann::ordered_json& j) {
+void GeoJSONWriter::encodeMultiLineString(const geom::MultiLineString* multiLineString, geos_nlohmann::ordered_json& j)
+{
     j["type"] = "MultiLineString";
     std::vector<std::vector<std::pair<double, double>>> lines;
-    for(size_t i = 0; i < multiLineString->getNumGeometries(); i++) {
+    for (size_t i = 0; i < multiLineString->getNumGeometries(); i++) {
         lines.push_back(convertCoordinateSequence(multiLineString->getGeometryN(i)->getCoordinates().get()));
     }
     j["coordinates"] = lines;
 }
 
-void GeoJSONWriter::encodeMultiPolygon(const geom::MultiPolygon* multiPolygon, geos_nlohmann::ordered_json& json) {
+void GeoJSONWriter::encodeMultiPolygon(const geom::MultiPolygon* multiPolygon, geos_nlohmann::ordered_json& json)
+{
     json["type"] = "MultiPolygon";
     std::vector<std::vector<std::vector<std::pair<double, double>>>> polygons;
     polygons.reserve(multiPolygon->getNumGeometries());
-    for(size_t i = 0; i < multiPolygon->getNumGeometries(); i++) {
+    for (size_t i = 0; i < multiPolygon->getNumGeometries(); i++) {
         const Polygon* polygon = multiPolygon->getGeometryN(i);
         std::vector<std::vector<std::pair<double, double>>> rings;
         auto ring = polygon->getExteriorRing();
         auto coords = ring->getCoordinates();
         rings.push_back(convertCoordinateSequence(ring->getCoordinates().get()));
-        for(size_t j = 0; j < polygon->getNumInteriorRing(); j++) {
+        for (size_t j = 0; j < polygon->getNumInteriorRing(); j++) {
             rings.push_back(convertCoordinateSequence(polygon->getInteriorRingN(i)->getCoordinates().get()));
         }
         polygons.push_back(rings);
@@ -232,10 +266,11 @@ void GeoJSONWriter::encodeMultiPolygon(const geom::MultiPolygon* multiPolygon, g
     json["coordinates"] = polygons;
 }
 
-void GeoJSONWriter::encodeGeometryCollection(const geom::GeometryCollection* g, geos_nlohmann::ordered_json& j) {
+void GeoJSONWriter::encodeGeometryCollection(const geom::GeometryCollection* g, geos_nlohmann::ordered_json& j)
+{
     j["type"] = "GeometryCollection";
     auto geometryArray = j.array();
-    for(size_t i = 0; i < g->getNumGeometries(); i++) {
+    for (size_t i = 0; i < g->getNumGeometries(); i++) {
         auto geometryObj = j.object();
         encodeGeometry(g->getGeometryN(i), geometryObj);
         geometryArray.push_back(geometryObj);
@@ -243,14 +278,17 @@ void GeoJSONWriter::encodeGeometryCollection(const geom::GeometryCollection* g,
     j["geometries"] = geometryArray;
 }
 
-std::pair<double, double> GeoJSONWriter::convertCoordinate(const Coordinate* c) {
-    return std::make_pair(c->x,c->y);
+std::pair<double, double> GeoJSONWriter::convertCoordinate(const Coordinate* c)
+{
+    return std::make_pair(c->x, c->y);
 }
 
-std::vector<std::pair<double, double>> GeoJSONWriter::convertCoordinateSequence(const CoordinateSequence* coordinateSequence) {
+std::vector<std::pair<double, double>> GeoJSONWriter::convertCoordinateSequence(const CoordinateSequence*
+                                    coordinateSequence)
+{
     std::vector<std::pair<double, double>> coordinates;
     coordinates.reserve(coordinateSequence->size());
-    for(size_t i = 0; i<coordinateSequence->size(); i++) {
+    for (size_t i = 0; i<coordinateSequence->size(); i++) {
         const geom::Coordinate& c = coordinateSequence->getAt(i);
         coordinates.push_back(convertCoordinate(&c));
     }

commit 5a0c4cdb39241c8b520c0045b4ea7da808a0cf77
Author: whuaegeansea <whuaegeansea at gmail.com>
Date:   Sun Jul 11 23:41:17 2021 +0800

    Modify GeoJSON module

diff --git a/include/geos/io/GeoJSON.h b/include/geos/io/GeoJSON.h
index 14989e5..cd54c6d 100644
--- a/include/geos/io/GeoJSON.h
+++ b/include/geos/io/GeoJSON.h
@@ -41,87 +41,95 @@ namespace io {
 
 class GEOS_DLL GeoJSONValue {
 
-    private:
-
-        enum class Type { NUMBER, STRING, NULLTYPE, BOOLEAN, OBJECT, ARRAY };
-        
-        Type type;
-
-        union {
-            double d;
-            std::string s;
-            std::nullptr_t n;
-            bool b;
-            std::map<std::string, GeoJSONValue> o;
-            std::vector<GeoJSONValue> a;
-        };
-
-        void cleanup();
-
-    public:
-
-        struct GeoJSONTypeError {};
-
-        GeoJSONValue(double);
-        GeoJSONValue(const std::string&);
-        GeoJSONValue();
-        GeoJSONValue(bool);
-        GeoJSONValue(const std::map<std::string, GeoJSONValue>&);
-        GeoJSONValue(const std::vector<GeoJSONValue>&);
-
-        ~GeoJSONValue();
-        GeoJSONValue(const GeoJSONValue&);
-        GeoJSONValue& operator=(const GeoJSONValue&);
-
-        double getNumber() const;
-        const std::string& getString() const;
-        std::nullptr_t getNull() const;
-        bool getBoolean() const;
-        const std::map<std::string,GeoJSONValue>& getObject() const;
-        const std::vector<GeoJSONValue>& getArray() const;
-
-        bool isNumber() const;
-        bool isString() const;
-        bool isNull() const;
-        bool isBoolean() const;
-        bool isObject() const;
-        bool isArray() const;
+private:
+
+    enum class Type { NUMBER, STRING, NULLTYPE, BOOLEAN, OBJECT, ARRAY };
+
+    Type type;
+
+    union {
+        double d;
+        std::string s;
+        std::nullptr_t n;
+        bool b;
+        std::map<std::string, GeoJSONValue> o;
+        std::vector<GeoJSONValue> a;
+    };
+
+    void cleanup();
+
+public:
+
+    struct GeoJSONTypeError {};
+
+    GeoJSONValue(double);
+    GeoJSONValue(const std::string&);
+    GeoJSONValue();
+    GeoJSONValue(bool);
+    GeoJSONValue(const std::map<std::string, GeoJSONValue>&);
+    GeoJSONValue(const std::vector<GeoJSONValue>&);
+
+    ~GeoJSONValue();
+    GeoJSONValue(const GeoJSONValue&);
+    GeoJSONValue& operator=(const GeoJSONValue&);
+
+    double getNumber() const;
+    const std::string& getString() const;
+    std::nullptr_t getNull() const;
+    bool getBoolean() const;
+    const std::map<std::string,GeoJSONValue>& getObject() const;
+    const std::vector<GeoJSONValue>& getArray() const;
+
+    bool isNumber() const;
+    bool isString() const;
+    bool isNull() const;
+    bool isBoolean() const;
+    bool isObject() const;
+    bool isArray() const;
 
 };
 
 class GEOS_DLL GeoJSONFeature {
 
-    public:
+public:
+
+    GeoJSONFeature(std::unique_ptr<geom::Geometry> g, const std::map<std::string, GeoJSONValue> &p);
 
-        GeoJSONFeature(std::unique_ptr<geom::Geometry> g, std::map<std::string, GeoJSONValue> p);
+    GeoJSONFeature(std::unique_ptr<geom::Geometry> g, std::map<std::string, GeoJSONValue>&& p);
 
-        GeoJSONFeature(GeoJSONFeature const &other);
+    GeoJSONFeature(GeoJSONFeature const &other);
 
-        GeoJSONFeature& operator=(const GeoJSONFeature&);
+    GeoJSONFeature(GeoJSONFeature && other);
 
-        const geom::Geometry* getGeometry() const;
+    GeoJSONFeature& operator=(const GeoJSONFeature&);
 
-        const std::map<std::string, GeoJSONValue>& getProperties() const;
+    GeoJSONFeature& operator=(GeoJSONFeature &&);
 
-    private:
+    const geom::Geometry* getGeometry() const;
 
-        std::unique_ptr<geom::Geometry> geometry;
+    const std::map<std::string, GeoJSONValue>& getProperties() const;
 
-        std::map<std::string, GeoJSONValue> properties;
+private:
+
+    std::unique_ptr<geom::Geometry> geometry;
+
+    std::map<std::string, GeoJSONValue> properties;
 
 };
 
 class GEOS_DLL GeoJSONFeatureCollection {
 
-    public:
+public:
+
+    GeoJSONFeatureCollection(const std::vector<GeoJSONFeature> &f);
 
-        GeoJSONFeatureCollection(std::vector<GeoJSONFeature> f);
+    GeoJSONFeatureCollection(std::vector<GeoJSONFeature>&& f);
 
-        const std::vector<GeoJSONFeature>& getFeatures() const; 
+    const std::vector<GeoJSONFeature>& getFeatures() const;
 
-    private:
+private:
 
-        std::vector<GeoJSONFeature> features;
+    std::vector<GeoJSONFeature> features;
 
 };
 
diff --git a/include/geos/io/GeoJSONReader.h b/include/geos/io/GeoJSONReader.h
index 612e98f..65ea159 100644
--- a/include/geos/io/GeoJSONReader.h
+++ b/include/geos/io/GeoJSONReader.h
@@ -69,45 +69,55 @@ public:
     ~GeoJSONReader() = default;
 
     /// Parse a GeoJSON string returning a Geometry
-    std::unique_ptr<geom::Geometry> read(const std::string& geoJsonText);
+    std::unique_ptr<geom::Geometry> read(const std::string& geoJsonText) const;
 
-    GeoJSONFeatureCollection readFeatures(const std::string& geoJsonText);
+    GeoJSONFeatureCollection readFeatures(const std::string& geoJsonText) const;
 
 private:
 
     const geom::GeometryFactory& geometryFactory;
 
-    std::unique_ptr<geom::Geometry> readFeatureForGeometry(const geos_nlohmann::json& j);
+    std::unique_ptr<geom::Geometry> readFeatureForGeometry(const geos_nlohmann::json& j) const;
 
-    GeoJSONFeature readFeature(const geos_nlohmann::json& j);
+    GeoJSONFeature readFeature(const geos_nlohmann::json& j) const;
 
-    std::map<std::string,GeoJSONValue> readProperties(const geos_nlohmann::json& p);
+    std::map<std::string, GeoJSONValue> readProperties(const geos_nlohmann::json& p) const;
 
-    GeoJSONValue readProperty(const geos_nlohmann::json& p);
+    GeoJSONValue readProperty(const geos_nlohmann::json& p) const;
 
-    std::unique_ptr<geom::Geometry> readFeatureCollectionForGeometry(const geos_nlohmann::json& j);
+    std::unique_ptr<geom::Geometry> readFeatureCollectionForGeometry(
+        const geos_nlohmann::json& j) const;
 
-    GeoJSONFeatureCollection readFeatureCollection(const geos_nlohmann::json& j);
+    GeoJSONFeatureCollection readFeatureCollection(
+        const geos_nlohmann::json& j) const;
 
-    std::unique_ptr<geom::Geometry> readGeometry(const geos_nlohmann::json& j);
+    std::unique_ptr<geom::Geometry> readGeometry(
+        const geos_nlohmann::json& j) const;
 
-    std::unique_ptr<geom::Point> readPoint(const geos_nlohmann::json& j);
+    std::unique_ptr<geom::Point> readPoint(const geos_nlohmann::json& j) const;
 
-    geom::Coordinate readCoordinate(const std::vector<double>& coords);
+    geom::Coordinate readCoordinate(const std::vector<double>& coords) const;
 
-    std::unique_ptr<geom::LineString> readLineString(const geos_nlohmann::json& j);
+    std::unique_ptr<geom::LineString> readLineString(
+        const geos_nlohmann::json& j) const;
 
-    std::unique_ptr<geom::Polygon> readPolygon(const geos_nlohmann::json& j);
+    std::unique_ptr<geom::Polygon> readPolygon(
+        const geos_nlohmann::json& j) const;
 
-    std::unique_ptr<geom::Polygon> readPolygon(const std::vector<std::vector<std::vector<double>>>& c);
+    std::unique_ptr<geom::Polygon> readPolygon(
+        const std::vector<std::vector<std::vector<double>>>& c) const;
 
-    std::unique_ptr<geom::MultiPoint> readMultiPoint(const geos_nlohmann::json& j);
+    std::unique_ptr<geom::MultiPoint> readMultiPoint(
+        const geos_nlohmann::json& j) const;
 
-    std::unique_ptr<geom::MultiLineString> readMultiLineString(const geos_nlohmann::json& j);
+    std::unique_ptr<geom::MultiLineString> readMultiLineString(
+        const geos_nlohmann::json& j) const;
 
-    std::unique_ptr<geom::MultiPolygon> readMultiPolygon(const geos_nlohmann::json& j);
+    std::unique_ptr<geom::MultiPolygon> readMultiPolygon(
+        const geos_nlohmann::json& j) const;
 
-    std::unique_ptr<geom::GeometryCollection> readGeometryCollection(const geos_nlohmann::json& j);
+    std::unique_ptr<geom::GeometryCollection> readGeometryCollection(
+        const geos_nlohmann::json& j) const;
 
 };
 
diff --git a/include/geos/io/GeoJSONWriter.h b/include/geos/io/GeoJSONWriter.h
index dcd283f..f8e2ec7 100644
--- a/include/geos/io/GeoJSONWriter.h
+++ b/include/geos/io/GeoJSONWriter.h
@@ -65,7 +65,6 @@ enum class GeoJSONType {
  */
 class GEOS_DLL GeoJSONWriter {
 public:
-    
     ~GeoJSONWriter() = default;
 
     std::string write(const geom::Geometry* geometry, GeoJSONType type = GeoJSONType::GEOMETRY);
diff --git a/src/io/GeoJSON.cpp b/src/io/GeoJSON.cpp
index 38b4cdf..086799d 100644
--- a/src/io/GeoJSON.cpp
+++ b/src/io/GeoJSON.cpp
@@ -41,12 +41,13 @@ GeoJSONValue::GeoJSONValue(bool value)  {
 
 GeoJSONValue::GeoJSONValue(const std::map<std::string, GeoJSONValue>& value)  {
     type = Type::OBJECT;
-    new(&o) std::map<std::string, GeoJSONValue>{value};
+    new(&o) std::map<std::string, GeoJSONValue> {value};
 }
 
 GeoJSONValue::GeoJSONValue(const std::vector<GeoJSONValue>& value)  {
     type = Type::ARRAY;
-    new(&a) std::vector<GeoJSONValue>{};
+    new(&a) std::vector<GeoJSONValue> {};
+    a.reserve(value.size());
     for(const auto& v : value) {
         a.push_back(v);
     }
@@ -60,7 +61,7 @@ void GeoJSONValue::cleanup() {
         s.~string();
     } else if (type == Type::OBJECT) {
         o.~object();
-    } else if (type == Type::ARRAY) { 
+    } else if (type == Type::ARRAY) {
         a.~array();
     }
 }
@@ -71,27 +72,28 @@ GeoJSONValue::~GeoJSONValue() {
 
 GeoJSONValue::GeoJSONValue(const GeoJSONValue& v) {
     switch(v.type) {
-        case Type::NUMBER:
-            d = v.d;
-            break;
-        case Type::BOOLEAN:
-            b = v.b;
-            break;
-        case Type::STRING:
-            new(&s) std::string{v.s};
-            break;
-        case Type::NULLTYPE:
-            n = v.n;
-            break;
-        case Type::OBJECT:
-            new(&o) std::map<std::string, GeoJSONValue>{v.o};
-            break;
-        case Type::ARRAY:
-            new(&a) std::vector<GeoJSONValue>{};
-            for(const auto& i : v.a) {
-                a.push_back(i);
-            }
-            break;                
+    case Type::NUMBER:
+        d = v.d;
+        break;
+    case Type::BOOLEAN:
+        b = v.b;
+        break;
+    case Type::STRING:
+        new(&s) std::string{v.s};
+        break;
+    case Type::NULLTYPE:
+        n = v.n;
+        break;
+    case Type::OBJECT:
+        new(&o) std::map<std::string, GeoJSONValue> {v.o};
+        break;
+    case Type::ARRAY:
+        new(&a) std::vector<GeoJSONValue> {};
+        a.reserve(v.a.size());
+        for(const auto& i : v.a) {
+            a.push_back(i);
+        }
+        break;
     }
     type = v.type;
 }
@@ -106,32 +108,33 @@ GeoJSONValue& GeoJSONValue::operator=(const GeoJSONValue& v) {
     } else if (type == Type::ARRAY && v.type == Type::ARRAY) {
         a = v.a;
         return *this;
-    } 
+    }
 
     cleanup();
 
     switch(v.type) {
-        case Type::NUMBER:
-            d = v.d;
-            break;
-        case Type::BOOLEAN:
-            b = v.b;
-            break;
-        case Type::STRING:
-            new(&s) std::string{v.s};
-            break;
-        case Type::NULLTYPE:
-            n = v.n;
-            break;
-        case Type::OBJECT:
-            new(&o) std::map<std::string, GeoJSONValue>{v.o};
-            break;
-        case Type::ARRAY:
-            new(&a) std::vector<GeoJSONValue>{};
-            for(const auto& i : v.a) {
-                a.push_back(i);
-            }
-            break;                
+    case Type::NUMBER:
+        d = v.d;
+        break;
+    case Type::BOOLEAN:
+        b = v.b;
+        break;
+    case Type::STRING:
+        new(&s) std::string{v.s};
+        break;
+    case Type::NULLTYPE:
+        n = v.n;
+        break;
+    case Type::OBJECT:
+        new(&o) std::map<std::string, GeoJSONValue> {v.o};
+        break;
+    case Type::ARRAY:
+        new(&a) std::vector<GeoJSONValue> {};
+        a.reserve(v.a.size());
+        for(const auto& i : v.a) {
+            a.push_back(i);
+        }
+        break;
     }
     type = v.type;
     return *this;
@@ -194,10 +197,14 @@ bool GeoJSONValue::isArray() const {
 
 // GeoJSONFeature
 
-GeoJSONFeature::GeoJSONFeature(std::unique_ptr<geom::Geometry> g, std::map<std::string, GeoJSONValue> p) : geometry(std::move(g)), properties(p) {}
+GeoJSONFeature::GeoJSONFeature(std::unique_ptr<geom::Geometry> g, const std::map<std::string, GeoJSONValue>& p) : geometry(std::move(g)), properties(p) {}
+
+GeoJSONFeature::GeoJSONFeature(std::unique_ptr<geom::Geometry> g, std::map<std::string, GeoJSONValue>&& p) : geometry(std::move(g)), properties(std::move(p)) {}
 
 GeoJSONFeature::GeoJSONFeature(GeoJSONFeature const &other) : geometry(other.geometry->clone()), properties(other.properties) {}
 
+GeoJSONFeature::GeoJSONFeature(GeoJSONFeature && other) : geometry(std::move(other.geometry)), properties(std::move(other.properties)) {}
+
 GeoJSONFeature& GeoJSONFeature::operator=(const GeoJSONFeature& other) {
     if (this == &other) {
         return *this;
@@ -207,6 +214,12 @@ GeoJSONFeature& GeoJSONFeature::operator=(const GeoJSONFeature& other) {
     return *this;
 }
 
+GeoJSONFeature& GeoJSONFeature::operator=(GeoJSONFeature&& other) {
+    geometry = std::move(other.geometry);
+    properties = std::move(other.properties);
+    return *this;
+}
+
 const geom::Geometry* GeoJSONFeature::getGeometry() const {
     return geometry.get();
 }
@@ -217,7 +230,9 @@ const std::map<std::string, GeoJSONValue>& GeoJSONFeature::getProperties() const
 
 // GeoJSONFeatureCollection
 
-GeoJSONFeatureCollection::GeoJSONFeatureCollection(std::vector<GeoJSONFeature> f) : features(f) {}
+GeoJSONFeatureCollection::GeoJSONFeatureCollection(const std::vector<GeoJSONFeature> &f) : features(f) {}
+
+GeoJSONFeatureCollection::GeoJSONFeatureCollection(std::vector<GeoJSONFeature>&& f) : features(std::move(f)) {}
 
 const std::vector<GeoJSONFeature>& GeoJSONFeatureCollection::getFeatures() const {
     return features;
diff --git a/src/io/GeoJSONReader.cpp b/src/io/GeoJSONReader.cpp
index ae015c7..70aeefa 100644
--- a/src/io/GeoJSONReader.cpp
+++ b/src/io/GeoJSONReader.cpp
@@ -45,31 +45,31 @@ GeoJSONReader::GeoJSONReader(): GeoJSONReader(*(GeometryFactory::getDefaultInsta
 
 GeoJSONReader::GeoJSONReader(const geom::GeometryFactory& gf) : geometryFactory(gf) {}
 
-std::unique_ptr<geom::Geometry> GeoJSONReader::read(const std::string& geoJsonText) {
+std::unique_ptr<geom::Geometry> GeoJSONReader::read(const std::string& geoJsonText) const {
     try {
-        json j = json::parse(geoJsonText);
-        std::string type = j["type"];
+        const json& j = json::parse(geoJsonText);
+        const std::string& type = j["type"];
         if (type == "Feature") {
-            return readFeatureForGeometry(j);    
+            return readFeatureForGeometry(j);
         } else if (type == "FeatureCollection") {
-            return readFeatureCollectionForGeometry(j);    
+            return readFeatureCollectionForGeometry(j);
         } else {
             return readGeometry(j);
         }
     } catch (json::exception& ex) {
         throw ParseException("Error parsing JSON", ex.what());
-    }   
+    }
 }
 
-GeoJSONFeatureCollection GeoJSONReader::readFeatures(const std::string& geoJsonText) {
+GeoJSONFeatureCollection GeoJSONReader::readFeatures(const std::string& geoJsonText) const {
     try {
-        json j = json::parse(geoJsonText);
-        std::string type = j["type"];
+        const json& j = json::parse(geoJsonText);
+        const std::string& type = j["type"];
         if (type == "Feature") {
-            auto feature = readFeature(j);    
+            const auto& feature = readFeature(j);
             return GeoJSONFeatureCollection { std::vector<GeoJSONFeature>{feature} };
         } else if (type == "FeatureCollection") {
-            return readFeatureCollection(j);    
+            return readFeatureCollection(j);
         } else {
             auto g = readGeometry(j);
             return GeoJSONFeatureCollection { std::vector<GeoJSONFeature>{GeoJSONFeature{std::move(g), std::map<std::string, GeoJSONValue>{} }}};
@@ -79,22 +79,21 @@ GeoJSONFeatureCollection GeoJSONReader::readFeatures(const std::string& geoJsonT
     }
 }
 
-std::unique_ptr<geom::Geometry> GeoJSONReader::readFeatureForGeometry(const geos_nlohmann::json& j) {
-    auto geometryJson = j["geometry"];
+std::unique_ptr<geom::Geometry> GeoJSONReader::readFeatureForGeometry(
+    const geos_nlohmann::json& j) const {
+    const auto& geometryJson = j["geometry"];
     auto geometry = readGeometry(geometryJson);
     return geometry;
 }
 
-GeoJSONFeature GeoJSONReader::readFeature(const geos_nlohmann::json& j) {
-    auto geometryJson = j["geometry"];
-    auto geometry = readGeometry(geometryJson);
-    auto properties = j["properties"];
-    std::map<std::string,GeoJSONValue> map = readProperties(properties);    
-    GeoJSONFeature f = GeoJSONFeature{ std::move(geometry), std::move(map) };
-    return f;
+GeoJSONFeature GeoJSONReader::readFeature(const geos_nlohmann::json& j) const {
+    const auto& geometryJson = j["geometry"];
+    const auto& properties = j["properties"];
+    return GeoJSONFeature{readGeometry(geometryJson), readProperties(properties)};
 }
 
-std::map<std::string,GeoJSONValue> GeoJSONReader::readProperties(const geos_nlohmann::json& p) {
+std::map<std::string, GeoJSONValue> GeoJSONReader::readProperties(
+    const geos_nlohmann::json& p) const {
     std::map<std::string,GeoJSONValue> map;
     for(const auto& prop : p.items()) {
         map[prop.key()] = std::move(readProperty(prop.value()));
@@ -102,7 +101,8 @@ std::map<std::string,GeoJSONValue> GeoJSONReader::readProperties(const geos_nloh
     return map;
 }
 
-GeoJSONValue GeoJSONReader::readProperty(const geos_nlohmann::json& value) {
+GeoJSONValue GeoJSONReader::readProperty(
+    const geos_nlohmann::json& value) const {
     if (value.is_string()) {
         return GeoJSONValue { value.get<std::string>() };
     } else if (value.is_number()) {
@@ -111,15 +111,15 @@ GeoJSONValue GeoJSONReader::readProperty(const geos_nlohmann::json& value) {
         return GeoJSONValue { value.get<bool>() };
     } else if (value.is_array()) {
         std::vector<GeoJSONValue> v {};
+        v.reserve(value.size());
         for (const auto& el : value.items()) {
-            const GeoJSONValue item = readProperty(el.value());
-            v.push_back(item);
+            v.push_back(readProperty(el.value()));
         }
         return GeoJSONValue{ v };
     } else if (value.is_object()) {
         std::map<std::string, GeoJSONValue> v {};
         for (const auto& el : value.items()) {
-            v[el.key()] = readProperty(el.value());
+            v[el.key()] = std::move(readProperty(el.value()));
         }
         return GeoJSONValue{ v };
     } else {
@@ -127,9 +127,11 @@ GeoJSONValue GeoJSONReader::readProperty(const geos_nlohmann::json& value) {
     }
 }
 
-std::unique_ptr<geom::Geometry> GeoJSONReader::readFeatureCollectionForGeometry(const geos_nlohmann::json& j) {
-    auto featuresJson = j["features"];
+std::unique_ptr<geom::Geometry> GeoJSONReader::readFeatureCollectionForGeometry(
+    const geos_nlohmann::json& j) const {
+    const auto &featuresJson = j["features"];
     std::vector<std::unique_ptr<geom::Geometry>> geometries;
+    geometries.reserve(featuresJson.size());
     for(const auto& featureJson : featuresJson) {
         auto g = readFeatureForGeometry(featureJson);
         geometries.push_back(std::move(g));
@@ -137,19 +139,21 @@ std::unique_ptr<geom::Geometry> GeoJSONReader::readFeatureCollectionForGeometry(
     return geometryFactory.createGeometryCollection(std::move(geometries));
 }
 
-GeoJSONFeatureCollection GeoJSONReader::readFeatureCollection(const geos_nlohmann::json& j) {
-    auto featuresJson = j["features"];
+GeoJSONFeatureCollection GeoJSONReader::readFeatureCollection(
+    const geos_nlohmann::json& j) const {
+    const auto & featuresJson = j["features"];
     std::vector<GeoJSONFeature> features;
+    features.reserve(featuresJson.size());
     for(const auto& featureJson : featuresJson) {
-        auto f = readFeature(featureJson);
-        features.push_back(f);
+        features.push_back(readFeature(featureJson));
     }
-    return GeoJSONFeatureCollection{features};
+    return GeoJSONFeatureCollection{std::move(features)};
 }
 
 
-std::unique_ptr<geom::Geometry> GeoJSONReader::readGeometry(const geos_nlohmann::json& j) {
-    std::string type = j["type"];
+std::unique_ptr<geom::Geometry> GeoJSONReader::readGeometry(
+    const geos_nlohmann::json& j) const {
+    const std::string & type = j["type"];
     if (type == "Point") {
         return readPoint(j);
     } else if (type == "LineString") {
@@ -169,7 +173,8 @@ std::unique_ptr<geom::Geometry> GeoJSONReader::readGeometry(const geos_nlohmann:
     }
 }
 
-geom::Coordinate GeoJSONReader::readCoordinate(const std::vector<double>& coords) {
+geom::Coordinate GeoJSONReader::readCoordinate(
+    const std::vector<double>& coords) const {
     if (coords.size() == 1) {
         throw  ParseException("Expected two coordinates found one");
     } else if (coords.size() > 2) {
@@ -179,42 +184,49 @@ geom::Coordinate GeoJSONReader::readCoordinate(const std::vector<double>& coords
     }
 }
 
-std::unique_ptr<geom::Point> GeoJSONReader::readPoint(const geos_nlohmann::json& j) {
-    auto coords = j["coordinates"].get<std::vector<double>>();
+std::unique_ptr<geom::Point> GeoJSONReader::readPoint(
+    const geos_nlohmann::json& j) const {
+    const auto &coords = j["coordinates"].get<std::vector<double>>();
     if (coords.size() == 1) {
         throw  ParseException("Expected two coordinates found one");
     } else if (coords.size() < 2) {
         return geometryFactory.createPoint(2);
     } else {
-        geom::Coordinate coord = readCoordinate(coords);
+        const geom::Coordinate& coord = readCoordinate(coords);
         return std::unique_ptr<geom::Point>(geometryFactory.createPoint(coord));
     }
 }
 
-std::unique_ptr<geom::LineString> GeoJSONReader::readLineString(const geos_nlohmann::json& j) {
-    auto coords = j["coordinates"].get<std::vector<std::vector<double>>>();
+std::unique_ptr<geom::LineString> GeoJSONReader::readLineString(
+    const geos_nlohmann::json& j) const {
+    const auto &coords = j["coordinates"].get<std::vector<std::vector<double>>>();
     std::vector<geom::Coordinate> coordinates;
+    coordinates.reserve(coords.size());
     for(const auto& coord : coords) {
-        geom::Coordinate c = readCoordinate(coord);
-        coordinates.push_back(geom::Coordinate{c.x,c.y});
+        const geom::Coordinate& c = readCoordinate(coord);
+        coordinates.push_back(c);
     }
     auto coordinateSequence = geometryFactory.getCoordinateSequenceFactory()->create(std::move(coordinates));
     return geometryFactory.createLineString(std::move(coordinateSequence));
 }
 
-std::unique_ptr<geom::Polygon> GeoJSONReader::readPolygon(const geos_nlohmann::json& json) {
-    auto polygonCoords = json["coordinates"].get<std::vector<std::vector<std::vector<double>>>>();
+std::unique_ptr<geom::Polygon> GeoJSONReader::readPolygon(
+    const geos_nlohmann::json& json) const {
+    const auto& polygonCoords = json["coordinates"].get<std::vector<std::vector<std::vector<double>>>>();
     return readPolygon(polygonCoords);
 }
 
-std::unique_ptr<geom::Polygon> GeoJSONReader::readPolygon(const std::vector<std::vector<std::vector<double>>>& polygonCoords) {
+std::unique_ptr<geom::Polygon> GeoJSONReader::readPolygon(
+    const std::vector<std::vector<std::vector<double>>>& polygonCoords) const {
     std::unique_ptr<geom::LinearRing> shell;
     std::vector<std::unique_ptr<geom::LinearRing>> rings;
+    rings.reserve(polygonCoords.size());
     for(const auto& ring : polygonCoords) {
         std::vector<geom::Coordinate> coordinates;
+        coordinates.reserve(ring.size());
         for (const auto& coord : ring) {
-            geom::Coordinate c = readCoordinate(coord);
-            coordinates.push_back(geom::Coordinate{c.x, c.y});
+            const geom::Coordinate& c = readCoordinate(coord);
+            coordinates.push_back(c);
         }
         auto coordinateSequence = geometryFactory.getCoordinateSequenceFactory()->create(std::move(coordinates));
         if (!shell) {
@@ -228,27 +240,32 @@ std::unique_ptr<geom::Polygon> GeoJSONReader::readPolygon(const std::vector<std:
     } else if (rings.size() == 0) {
         return geometryFactory.createPolygon(std::move(shell));
     } else {
-        return geometryFactory.createPolygon(std::move(shell), std::move(rings));        
+        return geometryFactory.createPolygon(std::move(shell), std::move(rings));
     }
 }
 
-std::unique_ptr<geom::MultiPoint> GeoJSONReader::readMultiPoint(const geos_nlohmann::json& j) {
-    auto coords = j["coordinates"].get<std::vector<std::vector<double>>>();
+std::unique_ptr<geom::MultiPoint> GeoJSONReader::readMultiPoint(
+    const geos_nlohmann::json& j) const {
+    const auto &coords = j["coordinates"].get<std::vector<std::vector<double>>>();
     std::vector<std::unique_ptr<geom::Point>> points;
+    points.reserve(coords.size());
     for(const auto& coord : coords) {
-        geom::Coordinate c = readCoordinate(coord);
+        const geom::Coordinate& c = readCoordinate(coord);
         points.push_back(std::unique_ptr<geom::Point>(geometryFactory.createPoint(c)));
     }
     return geometryFactory.createMultiPoint(std::move(points));
 }
 
-std::unique_ptr<geom::MultiLineString> GeoJSONReader::readMultiLineString(const geos_nlohmann::json& json) {
-    auto listOfCoords = json["coordinates"].get<std::vector<std::vector<std::vector<double>>>>();
+std::unique_ptr<geom::MultiLineString> GeoJSONReader::readMultiLineString(
+    const geos_nlohmann::json& json) const {
+    const auto &listOfCoords = json["coordinates"].get<std::vector<std::vector<std::vector<double>>>>();
     std::vector<std::unique_ptr<geom::LineString>> lines;
-    for(const auto& coords :  listOfCoords) {    
+    lines.reserve(listOfCoords.size());
+    for(const auto& coords :  listOfCoords) {
         std::vector<geom::Coordinate> coordinates;
+        coordinates.reserve(coords.size());
         for (const auto& coord : coords) {
-            geom::Coordinate c = readCoordinate(coord);
+            const geom::Coordinate& c = readCoordinate(coord);
             coordinates.push_back(geom::Coordinate{c.x, c.y});
         }
         auto coordinateSequence = geometryFactory.getCoordinateSequenceFactory()->create(std::move(coordinates));
@@ -257,18 +274,22 @@ std::unique_ptr<geom::MultiLineString> GeoJSONReader::readMultiLineString(const
     return geometryFactory.createMultiLineString(std::move(lines));
 }
 
-std::unique_ptr<geom::MultiPolygon> GeoJSONReader::readMultiPolygon(const geos_nlohmann::json& json) {
-    auto multiPolygonCoords = json["coordinates"].get<std::vector<std::vector<std::vector<std::vector<double>>>>>();
+std::unique_ptr<geom::MultiPolygon> GeoJSONReader::readMultiPolygon(
+    const geos_nlohmann::json& json) const {
+    const auto &multiPolygonCoords = json["coordinates"].get<std::vector<std::vector<std::vector<std::vector<double>>>>>();
     std::vector<std::unique_ptr<geom::Polygon>> polygons;
-    for(const auto& polygonCoords : multiPolygonCoords) {    
+    polygons.reserve(multiPolygonCoords.size());
+    for(const auto& polygonCoords : multiPolygonCoords) {
         polygons.push_back(readPolygon(polygonCoords));
     }
     return geometryFactory.createMultiPolygon(std::move(polygons));
 }
 
-std::unique_ptr<geom::GeometryCollection> GeoJSONReader::readGeometryCollection(const geos_nlohmann::json& j) {
+std::unique_ptr<geom::GeometryCollection> GeoJSONReader::readGeometryCollection(
+    const geos_nlohmann::json& j) const {
+    const auto& jsonGeometries = j["geometries"];
     std::vector<std::unique_ptr<geom::Geometry>> geometries;
-    auto jsonGeometries = j["geometries"];
+    geometries.reserve(jsonGeometries.size());
     for (const auto& jsonGeometry : jsonGeometries) {
         auto g = readGeometry(jsonGeometry);
         geometries.push_back(std::move(g));
@@ -277,4 +298,4 @@ std::unique_ptr<geom::GeometryCollection> GeoJSONReader::readGeometryCollection(
 }
 
 } // namespace geos.io
-} // namespace geos
\ No newline at end of file
+} // namespace geos
diff --git a/src/io/GeoJSONWriter.cpp b/src/io/GeoJSONWriter.cpp
index 64945b7..807f0fe 100644
--- a/src/io/GeoJSONWriter.cpp
+++ b/src/io/GeoJSONWriter.cpp
@@ -42,21 +42,21 @@ namespace io { // geos.io
 std::string GeoJSONWriter::write(const geom::Geometry* geometry, GeoJSONType type) {
     json j;
     encode(geometry, type, j);
-    std::string geojson = j.dump();
+    const std::string& geojson = j.dump();
     return geojson;
 }
 
 std::string GeoJSONWriter::writeFormatted(const geom::Geometry* geometry, GeoJSONType type, int indent) {
     json j;
     encode(geometry, type, j);
-    std::string geojson = j.dump(indent);
+    const std::string& geojson = j.dump(indent);
     return geojson;
 }
 
 std::string GeoJSONWriter::write(const GeoJSONFeature& feature) {
     json j;
     encodeFeature(feature, j);
-    std::string geojson = j.dump();
+    const std::string& geojson = j.dump();
     return geojson;
 }
 
@@ -87,12 +87,12 @@ void GeoJSONWriter::encodeGeoJSONValue(const std::string& key, const GeoJSONValu
         }
     } else if (value.isArray()) {
         j[key] = json::array();
-        for (GeoJSONValue v : value.getArray()) {
+        for (const GeoJSONValue& v : value.getArray()) {
             encodeGeoJSONValue("", v, j[key]);
         }
     } else if (value.isObject()) {
         j[key] = json::object();
-        for (auto entry : value.getObject()) {
+        for (const auto& entry : value.getObject()) {
             encodeGeoJSONValue(entry.first, entry.second, j[key]);
         }
     }
@@ -108,7 +108,7 @@ std::string GeoJSONWriter::write(const GeoJSONFeatureCollection& features) {
         featuresJson.push_back(featureJson);
     }
     j["features"] = featuresJson;
-    std::string geojson = j.dump();
+    const std::string& geojson = j.dump();
     return geojson;
 }
 
@@ -217,6 +217,7 @@ void GeoJSONWriter::encodeMultiLineString(const geom::MultiLineString* multiLine
 void GeoJSONWriter::encodeMultiPolygon(const geom::MultiPolygon* multiPolygon, geos_nlohmann::ordered_json& json) {
     json["type"] = "MultiPolygon";
     std::vector<std::vector<std::vector<std::pair<double, double>>>> polygons;
+    polygons.reserve(multiPolygon->getNumGeometries());
     for(size_t i = 0; i < multiPolygon->getNumGeometries(); i++) {
         const Polygon* polygon = multiPolygon->getGeometryN(i);
         std::vector<std::vector<std::pair<double, double>>> rings;
@@ -248,12 +249,13 @@ std::pair<double, double> GeoJSONWriter::convertCoordinate(const Coordinate* c)
 
 std::vector<std::pair<double, double>> GeoJSONWriter::convertCoordinateSequence(const CoordinateSequence* coordinateSequence) {
     std::vector<std::pair<double, double>> coordinates;
+    coordinates.reserve(coordinateSequence->size());
     for(size_t i = 0; i<coordinateSequence->size(); i++) {
-        const geom::Coordinate c = coordinateSequence->getAt(i);
+        const geom::Coordinate& c = coordinateSequence->getAt(i);
         coordinates.push_back(convertCoordinate(&c));
     }
     return coordinates;
 }
 
 } // namespace geos.io
-} // namespace geos
\ No newline at end of file
+} // namespace geos

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

Summary of changes:
 include/geos/io/GeoJSON.h       | 128 ++++++++++----------
 include/geos/io/GeoJSONReader.h |  46 +++++---
 include/geos/io/GeoJSONWriter.h |   1 -
 src/io/GeoJSON.cpp              | 214 +++++++++++++++++++++-------------
 src/io/GeoJSONReader.cpp        | 250 +++++++++++++++++++++++++---------------
 src/io/GeoJSONWriter.cpp        | 148 +++++++++++++++---------
 6 files changed, 480 insertions(+), 307 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list