github-actions[bot] commented on code in PR #22933: URL: https://github.com/apache/doris/pull/22933#discussion_r1293091291
########## be/src/geo/util/GeoLineString.cpp: ########## @@ -0,0 +1,194 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "GeoLineString.h" + +#include <s2/s2polyline.h> +#include <s2/util/coding/coder.h> + +#include <vector> + +#include "GeoMultiPoint.h" + +namespace doris { + +GeoLineString::GeoLineString() = default; +GeoLineString::~GeoLineString() = default; + +// remove adjacent duplicate points +static void remove_duplicate_points(std::vector<S2Point>* points) { + int lhs = 0; + int rhs = 1; + for (; rhs < points->size(); ++rhs) { + if ((*points)[rhs] != (*points)[lhs]) { + lhs++; + if (lhs != rhs) { + (*points)[lhs] = (*points)[rhs]; + } + } + } + points->resize(lhs + 1); +} + +bool GeoLineString::is_valid() const { + return polyline()->IsValid(); +} + +bool GeoLineString::is_closed() const { + return !is_empty() && polyline()->vertex(0) == polyline()->vertex(get_num_point() - 1); Review Comment: warning: ISO C++20 considers use of overloaded operator '==' (with operand types 'const S2Point' (aka 'const Vector3<double>') and 'const S2Point') to be ambiguous despite there being a unique best viable function [clang-diagnostic-ambiguous-reversed-operator] ```cpp return !is_empty() && polyline()->vertex(0) == polyline()->vertex(get_num_point() - 1); ^ ``` <details> <summary>Additional context</summary> **thirdparty/installed/include/s2/util/math/vector.h:100:** ambiguity is between a regular call to this operator and a call with the argument order reversed ```cpp bool operator==(const D& b) const { ^ ``` </details> ########## be/src/geo/util/GeoLineString.cpp: ########## @@ -0,0 +1,194 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "GeoLineString.h" + +#include <s2/s2polyline.h> +#include <s2/util/coding/coder.h> + +#include <vector> + +#include "GeoMultiPoint.h" + +namespace doris { + +GeoLineString::GeoLineString() = default; +GeoLineString::~GeoLineString() = default; + +// remove adjacent duplicate points +static void remove_duplicate_points(std::vector<S2Point>* points) { + int lhs = 0; + int rhs = 1; + for (; rhs < points->size(); ++rhs) { + if ((*points)[rhs] != (*points)[lhs]) { + lhs++; + if (lhs != rhs) { + (*points)[lhs] = (*points)[rhs]; + } + } + } + points->resize(lhs + 1); +} + +bool GeoLineString::is_valid() const { + return polyline()->IsValid(); +} + +bool GeoLineString::is_closed() const { + return !is_empty() && polyline()->vertex(0) == polyline()->vertex(get_num_point() - 1); +} + +GeoParseStatus GeoLineString::to_s2polyline(const GeoCoordinates& coords, + std::unique_ptr<S2Polyline>* polyline) { + // 1. convert all coordinates to points + std::vector<S2Point> points(coords.coords.size()); + for (int i = 0; i < coords.coords.size(); ++i) { + auto res = GeoPoint::to_s2point(coords.coords[i].x, coords.coords[i].y, &points[i]); + if (res != GEO_PARSE_OK) { + return res; + } + } + // 2. remove duplicate points + remove_duplicate_points(&points); + // 3. check if there is enough point + if (points.size() < 2) { + return GEO_PARSE_POLYLINE_LACK_VERTICES; + } + polyline->reset(new S2Polyline(points)); + if (!(*polyline)->IsValid()) { + return GEO_PARSE_POLYLINE_INVALID; + } + return GEO_PARSE_OK; +} + +GeoParseStatus GeoLineString::from_coords(const GeoCoordinates& coords) { + return to_s2polyline(coords, &_polyline); +} + +GeoCoordinates GeoLineString::to_coords() const { + GeoCoordinates coords; + for (int i = 0; i < GeoLineString::num_point(); ++i) { + GeoCoordinate coord; + coord.x = std::stod(absl::StrFormat( + "%.12f", S2LatLng::Longitude(*GeoLineString::get_point(i)).degrees())); + coord.y = std::stod(absl::StrFormat( + "%.12f", S2LatLng::Latitude(*GeoLineString::get_point(i)).degrees())); + coords.add(coord); + } + return coords; +} + +std::unique_ptr<GeoCoordinates> GeoLineString::to_coords_ptr() const { + std::unique_ptr<GeoCoordinates> coords(new GeoCoordinates()); + for (int i = 0; i < GeoLineString::num_point(); ++i) { + GeoCoordinate coord; + coord.x = std::stod(absl::StrFormat( + "%.12f", S2LatLng::Longitude(*GeoLineString::get_point(i)).degrees())); + coord.y = std::stod(absl::StrFormat( + "%.12f", S2LatLng::Latitude(*GeoLineString::get_point(i)).degrees())); + coords->add(coord); + } + return coords; +} + +double GeoLineString::length() const { + return _polyline->GetLength().radians(); +} + +std::unique_ptr<S2Shape> GeoLineString::get_s2shape() const { + return std::make_unique<S2Polyline::Shape>(polyline()); +} + +std::string GeoLineString::as_wkt() const { + std::stringstream ss; + ss << "LINESTRING "; + if (is_empty()) { + ss << "EMPTY"; + return ss.str(); + } + ss << "("; + for (int i = 0; i < _polyline->num_vertices(); ++i) { + if (i != 0) { + ss << ", "; + } + GeoPoint::print_s2point(ss, _polyline->vertex(i)); + } + ss << ")"; + return ss.str(); +} + +int GeoLineString::num_point() const { + return _polyline->num_vertices(); +} + +S2Point* GeoLineString::get_point(int i) const { + return const_cast<S2Point*>(&(_polyline->vertex(i))); +} + +void GeoLineString::encode(std::string* buf, size_t& data_size) { + Encoder encoder; + _polyline->Encode(&encoder); + data_size = encoder.length(); + buf->append(encoder.base(), encoder.length()); +} + +bool GeoLineString::decode(const void* data, size_t size) { + Decoder decoder(data, size); + _polyline.reset(new S2Polyline()); + return _polyline->Decode(&decoder); +} + +double GeoLineString::line_locate_point(GeoPoint* point) { + int num = num_point(); + return _polyline->UnInterpolate(_polyline->Project(*point->point(), &num), num); +} + +std::size_t GeoLineString::get_num_point() const { + if (is_empty()) return 0; + return _polyline->num_vertices(); +} + +std::unique_ptr<GeoShape> GeoLineString::boundary() const { + std::unique_ptr<GeoMultiPoint> multipoint = GeoMultiPoint::create_unique(); + if (is_empty() || is_ring()) { + multipoint->set_empty(); + return multipoint; + } + + std::unique_ptr<GeoPoint> point1 = GeoPoint::create_unique(); + std::unique_ptr<GeoPoint> point2 = GeoPoint::create_unique(); + point1->from_s2point(get_point(0)); + point2->from_s2point(get_point(num_point() - 1)); + + if (point1->contains(point2.get())) { + multipoint->set_empty(); + return multipoint; + } + + multipoint->add_one_geometry(point1.release()); + multipoint->add_one_geometry(point2.release()); + + return multipoint; +} + +bool GeoLineString::add_to_s2shape_index(MutableS2ShapeIndex& S2shape_index) const { + if (is_empty() || !is_valid()) return false; Review Comment: warning: statement should be inside braces [readability-braces-around-statements] ```suggestion if (is_empty() || !is_valid()) { return false; } ``` ########## be/src/geo/util/GeoLineString.cpp: ########## @@ -0,0 +1,194 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "GeoLineString.h" + +#include <s2/s2polyline.h> +#include <s2/util/coding/coder.h> + +#include <vector> + +#include "GeoMultiPoint.h" + +namespace doris { + +GeoLineString::GeoLineString() = default; +GeoLineString::~GeoLineString() = default; + +// remove adjacent duplicate points +static void remove_duplicate_points(std::vector<S2Point>* points) { + int lhs = 0; + int rhs = 1; + for (; rhs < points->size(); ++rhs) { + if ((*points)[rhs] != (*points)[lhs]) { + lhs++; + if (lhs != rhs) { + (*points)[lhs] = (*points)[rhs]; + } + } + } + points->resize(lhs + 1); +} + +bool GeoLineString::is_valid() const { + return polyline()->IsValid(); +} + +bool GeoLineString::is_closed() const { + return !is_empty() && polyline()->vertex(0) == polyline()->vertex(get_num_point() - 1); +} + +GeoParseStatus GeoLineString::to_s2polyline(const GeoCoordinates& coords, + std::unique_ptr<S2Polyline>* polyline) { + // 1. convert all coordinates to points + std::vector<S2Point> points(coords.coords.size()); + for (int i = 0; i < coords.coords.size(); ++i) { + auto res = GeoPoint::to_s2point(coords.coords[i].x, coords.coords[i].y, &points[i]); + if (res != GEO_PARSE_OK) { + return res; + } + } + // 2. remove duplicate points + remove_duplicate_points(&points); + // 3. check if there is enough point + if (points.size() < 2) { + return GEO_PARSE_POLYLINE_LACK_VERTICES; + } + polyline->reset(new S2Polyline(points)); + if (!(*polyline)->IsValid()) { + return GEO_PARSE_POLYLINE_INVALID; + } + return GEO_PARSE_OK; +} + +GeoParseStatus GeoLineString::from_coords(const GeoCoordinates& coords) { + return to_s2polyline(coords, &_polyline); +} + +GeoCoordinates GeoLineString::to_coords() const { + GeoCoordinates coords; + for (int i = 0; i < GeoLineString::num_point(); ++i) { + GeoCoordinate coord; + coord.x = std::stod(absl::StrFormat( + "%.12f", S2LatLng::Longitude(*GeoLineString::get_point(i)).degrees())); + coord.y = std::stod(absl::StrFormat( + "%.12f", S2LatLng::Latitude(*GeoLineString::get_point(i)).degrees())); + coords.add(coord); + } + return coords; +} + +std::unique_ptr<GeoCoordinates> GeoLineString::to_coords_ptr() const { + std::unique_ptr<GeoCoordinates> coords(new GeoCoordinates()); + for (int i = 0; i < GeoLineString::num_point(); ++i) { + GeoCoordinate coord; + coord.x = std::stod(absl::StrFormat( + "%.12f", S2LatLng::Longitude(*GeoLineString::get_point(i)).degrees())); + coord.y = std::stod(absl::StrFormat( + "%.12f", S2LatLng::Latitude(*GeoLineString::get_point(i)).degrees())); + coords->add(coord); + } + return coords; +} + +double GeoLineString::length() const { + return _polyline->GetLength().radians(); +} + +std::unique_ptr<S2Shape> GeoLineString::get_s2shape() const { + return std::make_unique<S2Polyline::Shape>(polyline()); +} + +std::string GeoLineString::as_wkt() const { + std::stringstream ss; + ss << "LINESTRING "; + if (is_empty()) { + ss << "EMPTY"; + return ss.str(); + } + ss << "("; + for (int i = 0; i < _polyline->num_vertices(); ++i) { + if (i != 0) { + ss << ", "; + } + GeoPoint::print_s2point(ss, _polyline->vertex(i)); + } + ss << ")"; + return ss.str(); +} + +int GeoLineString::num_point() const { + return _polyline->num_vertices(); +} + +S2Point* GeoLineString::get_point(int i) const { + return const_cast<S2Point*>(&(_polyline->vertex(i))); +} + +void GeoLineString::encode(std::string* buf, size_t& data_size) { + Encoder encoder; + _polyline->Encode(&encoder); + data_size = encoder.length(); + buf->append(encoder.base(), encoder.length()); +} + +bool GeoLineString::decode(const void* data, size_t size) { + Decoder decoder(data, size); + _polyline.reset(new S2Polyline()); + return _polyline->Decode(&decoder); +} + +double GeoLineString::line_locate_point(GeoPoint* point) { + int num = num_point(); + return _polyline->UnInterpolate(_polyline->Project(*point->point(), &num), num); +} + +std::size_t GeoLineString::get_num_point() const { + if (is_empty()) return 0; Review Comment: warning: statement should be inside braces [readability-braces-around-statements] ```suggestion if (is_empty()) { return 0; } ``` ########## be/src/geo/util/GeoLineString.h: ########## @@ -0,0 +1,83 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#ifndef DORIS_GEOLINESTRING_H +#define DORIS_GEOLINESTRING_H Review Comment: warning: macro is not used [clang-diagnostic-unused-macros] ```cpp #define DORIS_GEOLINESTRING_H ^ ``` ########## be/src/geo/util/GeoLineString.h: ########## @@ -0,0 +1,83 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#ifndef DORIS_GEOLINESTRING_H +#define DORIS_GEOLINESTRING_H + +#include "GeoPoint.h" +#include "GeoShape.h" +#include "common/factory_creator.h" +#include "geo/wkt_parse_type.h" + +class S2Polyline; + +namespace doris { + +class GeoLineString : public GeoShape { + ENABLE_FACTORY_CREATOR(GeoLineString); + +public: + GeoLineString(); + ~GeoLineString() override; + + bool is_valid() const override; + + bool is_closed() const override; + + static GeoParseStatus to_s2polyline(const GeoCoordinates& coords, + std::unique_ptr<S2Polyline>* polyline); + + GeoParseStatus from_coords(const GeoCoordinates& coords); + + GeoCoordinates to_coords() const; + + std::unique_ptr<GeoCoordinates> to_coords_ptr() const; + + GeoShapeType type() const override { return GEO_SHAPE_LINE_STRING; } + + [[nodiscard]] int get_dimension() const override { return 1; } + + [[nodiscard]] double length() const; + + const S2Polyline* polyline() const { return _polyline.get(); } + + std::unique_ptr<S2Shape> get_s2shape() const; Review Comment: warning: function 'get_s2shape' should be marked [[nodiscard]] [modernize-use-nodiscard] ```suggestion [[nodiscard]] std::unique_ptr<S2Shape> get_s2shape() const; ``` ########## be/src/geo/util/GeoLineString.h: ########## @@ -0,0 +1,83 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#ifndef DORIS_GEOLINESTRING_H +#define DORIS_GEOLINESTRING_H + +#include "GeoPoint.h" +#include "GeoShape.h" +#include "common/factory_creator.h" +#include "geo/wkt_parse_type.h" + +class S2Polyline; + +namespace doris { + +class GeoLineString : public GeoShape { + ENABLE_FACTORY_CREATOR(GeoLineString); + +public: + GeoLineString(); + ~GeoLineString() override; + + bool is_valid() const override; + + bool is_closed() const override; + + static GeoParseStatus to_s2polyline(const GeoCoordinates& coords, + std::unique_ptr<S2Polyline>* polyline); + + GeoParseStatus from_coords(const GeoCoordinates& coords); + + GeoCoordinates to_coords() const; + + std::unique_ptr<GeoCoordinates> to_coords_ptr() const; + + GeoShapeType type() const override { return GEO_SHAPE_LINE_STRING; } + + [[nodiscard]] int get_dimension() const override { return 1; } + + [[nodiscard]] double length() const; + + const S2Polyline* polyline() const { return _polyline.get(); } + + std::unique_ptr<S2Shape> get_s2shape() const; + + std::string as_wkt() const override; + + int num_point() const; + S2Point* get_point(int i) const; + + double line_locate_point(GeoPoint* point); + + [[nodiscard]] std::size_t get_num_point() const override; + + std::unique_ptr<GeoShape> boundary() const override; Review Comment: warning: function 'boundary' should be marked [[nodiscard]] [modernize-use-nodiscard] ```suggestion [[nodiscard]] std::unique_ptr<GeoShape> boundary() const override; ``` ########## be/src/geo/util/GeoLineString.h: ########## @@ -0,0 +1,83 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#ifndef DORIS_GEOLINESTRING_H +#define DORIS_GEOLINESTRING_H + +#include "GeoPoint.h" +#include "GeoShape.h" +#include "common/factory_creator.h" +#include "geo/wkt_parse_type.h" + +class S2Polyline; + +namespace doris { + +class GeoLineString : public GeoShape { + ENABLE_FACTORY_CREATOR(GeoLineString); + +public: + GeoLineString(); + ~GeoLineString() override; + + bool is_valid() const override; + + bool is_closed() const override; + + static GeoParseStatus to_s2polyline(const GeoCoordinates& coords, + std::unique_ptr<S2Polyline>* polyline); + + GeoParseStatus from_coords(const GeoCoordinates& coords); + + GeoCoordinates to_coords() const; + + std::unique_ptr<GeoCoordinates> to_coords_ptr() const; + + GeoShapeType type() const override { return GEO_SHAPE_LINE_STRING; } + + [[nodiscard]] int get_dimension() const override { return 1; } + + [[nodiscard]] double length() const; + + const S2Polyline* polyline() const { return _polyline.get(); } + + std::unique_ptr<S2Shape> get_s2shape() const; + + std::string as_wkt() const override; Review Comment: warning: function 'as_wkt' should be marked [[nodiscard]] [modernize-use-nodiscard] ```suggestion [[nodiscard]] std::string as_wkt() const override; ``` ########## be/src/geo/util/GeoMultiLineString.h: ########## @@ -0,0 +1,55 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#ifndef DORIS_GEOMULTILINESTRING_H +#define DORIS_GEOMULTILINESTRING_H + +#include "GeoCollection.h" +#include "common/factory_creator.h" + +namespace doris { + +class GeoMultiLineString : public GeoCollection { + ENABLE_FACTORY_CREATOR(GeoMultiLineString); + +public: + GeoMultiLineString(); + ~GeoMultiLineString() override; + + GeoShapeType type() const override { return GEO_SHAPE_MULTI_LINE_STRING; } Review Comment: warning: function 'type' should be marked [[nodiscard]] [modernize-use-nodiscard] ```suggestion [[nodiscard]] GeoShapeType type() const override { return GEO_SHAPE_MULTI_LINE_STRING; } ``` ########## be/src/geo/util/GeoMultiLineString.h: ########## @@ -0,0 +1,55 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#ifndef DORIS_GEOMULTILINESTRING_H +#define DORIS_GEOMULTILINESTRING_H + +#include "GeoCollection.h" +#include "common/factory_creator.h" + +namespace doris { + +class GeoMultiLineString : public GeoCollection { + ENABLE_FACTORY_CREATOR(GeoMultiLineString); + +public: + GeoMultiLineString(); + ~GeoMultiLineString() override; + + GeoShapeType type() const override { return GEO_SHAPE_MULTI_LINE_STRING; } + + [[nodiscard]] int get_dimension() const override { return 1; } + + GeoParseStatus from_coords(const GeoCoordinateLists& list); + + std::unique_ptr<GeoCoordinateLists> to_coords() const; Review Comment: warning: function 'to_coords' should be marked [[nodiscard]] [modernize-use-nodiscard] ```suggestion [[nodiscard]] std::unique_ptr<GeoCoordinateLists> to_coords() const; ``` ########## be/src/geo/util/GeoMultiLineString.h: ########## @@ -0,0 +1,55 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#ifndef DORIS_GEOMULTILINESTRING_H +#define DORIS_GEOMULTILINESTRING_H + +#include "GeoCollection.h" +#include "common/factory_creator.h" + +namespace doris { + +class GeoMultiLineString : public GeoCollection { + ENABLE_FACTORY_CREATOR(GeoMultiLineString); + +public: + GeoMultiLineString(); + ~GeoMultiLineString() override; + + GeoShapeType type() const override { return GEO_SHAPE_MULTI_LINE_STRING; } + + [[nodiscard]] int get_dimension() const override { return 1; } + + GeoParseStatus from_coords(const GeoCoordinateLists& list); + + std::unique_ptr<GeoCoordinateLists> to_coords() const; + + // Returns the number of geometries in this collection + std::size_t get_num_line() const; + + std::string as_wkt() const override; Review Comment: warning: function 'as_wkt' should be marked [[nodiscard]] [modernize-use-nodiscard] ```suggestion [[nodiscard]] std::string as_wkt() const override; ``` ########## be/src/geo/util/GeoLineString.h: ########## @@ -0,0 +1,83 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#ifndef DORIS_GEOLINESTRING_H +#define DORIS_GEOLINESTRING_H + +#include "GeoPoint.h" +#include "GeoShape.h" +#include "common/factory_creator.h" +#include "geo/wkt_parse_type.h" + +class S2Polyline; + +namespace doris { + +class GeoLineString : public GeoShape { + ENABLE_FACTORY_CREATOR(GeoLineString); + +public: + GeoLineString(); + ~GeoLineString() override; + + bool is_valid() const override; + + bool is_closed() const override; Review Comment: warning: function 'is_closed' should be marked [[nodiscard]] [modernize-use-nodiscard] ```suggestion [[nodiscard]] bool is_closed() const override; ``` ########## be/src/geo/util/GeoLineString.h: ########## @@ -0,0 +1,83 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#ifndef DORIS_GEOLINESTRING_H +#define DORIS_GEOLINESTRING_H + +#include "GeoPoint.h" +#include "GeoShape.h" +#include "common/factory_creator.h" +#include "geo/wkt_parse_type.h" + +class S2Polyline; + +namespace doris { + +class GeoLineString : public GeoShape { + ENABLE_FACTORY_CREATOR(GeoLineString); + +public: + GeoLineString(); + ~GeoLineString() override; + + bool is_valid() const override; Review Comment: warning: function 'is_valid' should be marked [[nodiscard]] [modernize-use-nodiscard] ```suggestion [[nodiscard]] bool is_valid() const override; ``` ########## be/src/geo/util/GeoLineString.h: ########## @@ -0,0 +1,83 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#ifndef DORIS_GEOLINESTRING_H +#define DORIS_GEOLINESTRING_H + +#include "GeoPoint.h" +#include "GeoShape.h" +#include "common/factory_creator.h" +#include "geo/wkt_parse_type.h" + +class S2Polyline; + +namespace doris { + +class GeoLineString : public GeoShape { + ENABLE_FACTORY_CREATOR(GeoLineString); + +public: + GeoLineString(); + ~GeoLineString() override; + + bool is_valid() const override; + + bool is_closed() const override; + + static GeoParseStatus to_s2polyline(const GeoCoordinates& coords, + std::unique_ptr<S2Polyline>* polyline); + + GeoParseStatus from_coords(const GeoCoordinates& coords); + + GeoCoordinates to_coords() const; + + std::unique_ptr<GeoCoordinates> to_coords_ptr() const; Review Comment: warning: function 'to_coords_ptr' should be marked [[nodiscard]] [modernize-use-nodiscard] ```suggestion [[nodiscard]] std::unique_ptr<GeoCoordinates> to_coords_ptr() const; ``` ########## be/src/geo/util/GeoLineString.h: ########## @@ -0,0 +1,83 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#ifndef DORIS_GEOLINESTRING_H +#define DORIS_GEOLINESTRING_H + +#include "GeoPoint.h" +#include "GeoShape.h" +#include "common/factory_creator.h" +#include "geo/wkt_parse_type.h" + +class S2Polyline; + +namespace doris { + +class GeoLineString : public GeoShape { + ENABLE_FACTORY_CREATOR(GeoLineString); + +public: + GeoLineString(); + ~GeoLineString() override; + + bool is_valid() const override; + + bool is_closed() const override; + + static GeoParseStatus to_s2polyline(const GeoCoordinates& coords, + std::unique_ptr<S2Polyline>* polyline); + + GeoParseStatus from_coords(const GeoCoordinates& coords); + + GeoCoordinates to_coords() const; Review Comment: warning: function 'to_coords' should be marked [[nodiscard]] [modernize-use-nodiscard] ```suggestion [[nodiscard]] GeoCoordinates to_coords() const; ``` ########## be/src/geo/util/GeoLineString.h: ########## @@ -0,0 +1,83 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#ifndef DORIS_GEOLINESTRING_H +#define DORIS_GEOLINESTRING_H + +#include "GeoPoint.h" +#include "GeoShape.h" +#include "common/factory_creator.h" +#include "geo/wkt_parse_type.h" + +class S2Polyline; + +namespace doris { + +class GeoLineString : public GeoShape { + ENABLE_FACTORY_CREATOR(GeoLineString); + +public: + GeoLineString(); + ~GeoLineString() override; + + bool is_valid() const override; + + bool is_closed() const override; + + static GeoParseStatus to_s2polyline(const GeoCoordinates& coords, + std::unique_ptr<S2Polyline>* polyline); + + GeoParseStatus from_coords(const GeoCoordinates& coords); + + GeoCoordinates to_coords() const; + + std::unique_ptr<GeoCoordinates> to_coords_ptr() const; + + GeoShapeType type() const override { return GEO_SHAPE_LINE_STRING; } + + [[nodiscard]] int get_dimension() const override { return 1; } + + [[nodiscard]] double length() const; + + const S2Polyline* polyline() const { return _polyline.get(); } Review Comment: warning: function 'polyline' should be marked [[nodiscard]] [modernize-use-nodiscard] ```suggestion [[nodiscard]] const S2Polyline* polyline() const { return _polyline.get(); } ``` ########## be/src/geo/util/GeoLineString.h: ########## @@ -0,0 +1,83 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#ifndef DORIS_GEOLINESTRING_H +#define DORIS_GEOLINESTRING_H + +#include "GeoPoint.h" +#include "GeoShape.h" +#include "common/factory_creator.h" +#include "geo/wkt_parse_type.h" + +class S2Polyline; + +namespace doris { + +class GeoLineString : public GeoShape { + ENABLE_FACTORY_CREATOR(GeoLineString); + +public: + GeoLineString(); + ~GeoLineString() override; + + bool is_valid() const override; + + bool is_closed() const override; + + static GeoParseStatus to_s2polyline(const GeoCoordinates& coords, + std::unique_ptr<S2Polyline>* polyline); + + GeoParseStatus from_coords(const GeoCoordinates& coords); + + GeoCoordinates to_coords() const; + + std::unique_ptr<GeoCoordinates> to_coords_ptr() const; + + GeoShapeType type() const override { return GEO_SHAPE_LINE_STRING; } Review Comment: warning: function 'type' should be marked [[nodiscard]] [modernize-use-nodiscard] ```suggestion [[nodiscard]] GeoShapeType type() const override { return GEO_SHAPE_LINE_STRING; } ``` ########## be/src/geo/util/GeoMultiPoint.cpp: ########## @@ -0,0 +1,88 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "GeoMultiPoint.h" + +#include <sstream> + +namespace doris { + +GeoMultiPoint::GeoMultiPoint() = default; +GeoMultiPoint::~GeoMultiPoint() = default; + +GeoParseStatus GeoMultiPoint::from_coords(const GeoCoordinates& coord_list) { + for (int i = 0; i < coord_list.coords.size(); i++) { + std::unique_ptr<doris::GeoPoint> point = GeoPoint::create_unique(); + if (point->from_coord(coord_list.coords[i]) != GeoParseStatus::GEO_PARSE_OK) { + return GEO_PARSE_COORD_INVALID; + } + geometries.emplace_back(point.release()); + } + return GEO_PARSE_OK; +} + +std::unique_ptr<GeoCoordinates> GeoMultiPoint::to_coords() const { + std::unique_ptr<GeoCoordinates> coords(new GeoCoordinates()); + for (std::size_t i = 0; i < get_num_point(); ++i) { + const GeoPoint* point = (const GeoPoint*)GeoCollection::get_geometries_n(i); + if (point->is_empty()) continue; Review Comment: warning: statement should be inside braces [readability-braces-around-statements] ```suggestion if (point->is_empty()) { continue; } ``` ########## be/src/geo/util/GeoMultiLineString.cpp: ########## @@ -0,0 +1,123 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "GeoMultiLineString.h" + +#include <sstream> + +#include "GeoMultiPoint.h" + +namespace doris { + +GeoMultiLineString::GeoMultiLineString() = default; +GeoMultiLineString::~GeoMultiLineString() = default; + +GeoParseStatus GeoMultiLineString::from_coords(const GeoCoordinateLists& coords_list) { + for (int i = 0; i < coords_list.coords_list.size(); i++) { + std::unique_ptr<doris::GeoLineString> line = GeoLineString::create_unique(); + if (line->from_coords(*coords_list.coords_list[i]) != GeoParseStatus::GEO_PARSE_OK) { + return GEO_PARSE_COORD_INVALID; + } + geometries.emplace_back(line.release()); + } + return GEO_PARSE_OK; +} + +std::unique_ptr<GeoCoordinateLists> GeoMultiLineString::to_coords() const { + std::unique_ptr<GeoCoordinateLists> coords_list(new GeoCoordinateLists()); + for (std::size_t i = 0; i < get_num_line(); ++i) { + const GeoLineString* line = (const GeoLineString*)GeoCollection::get_geometries_n(i); + if (line->is_empty()) continue; + std::unique_ptr<GeoCoordinates> coords = line->to_coords_ptr(); + coords_list->add(coords.release()); + } + return coords_list; +} + +std::size_t GeoMultiLineString::get_num_line() const { + return GeoCollection::get_num_geometries(); +} + +std::string GeoMultiLineString::as_wkt() const { + std::stringstream ss; + ss << "MULTILINESTRING "; + + if (is_empty()) { + ss << "EMPTY"; + return ss.str(); + } + + ss << "("; + for (int i = 0; i < get_num_line(); ++i) { + if (i != 0) { + ss << ", "; + } + const GeoLineString* line = (const GeoLineString*)GeoCollection::get_geometries_n(i); + if (line->is_empty()) { + ss << "EMPTY"; + continue; + } + + ss << "("; + + for (std::size_t g = 0; g < line->num_point(); g++) { + if (g != 0) { + ss << ", "; + } + GeoPoint::print_s2point(ss, *line->get_point(g)); + } + + ss << ")"; + } + ss << ")"; + return ss.str(); +} + +GeoLineString* GeoMultiLineString::get_line_string_n(std::size_t n) const { + return (GeoLineString*)GeoCollection::get_geometries_n(n); +} + +bool GeoMultiLineString::contains(const GeoShape* shape) const { + return GeoCollection::contains(shape); +} + +std::unique_ptr<GeoShape> GeoMultiLineString::boundary() const { + std::unique_ptr<GeoMultiPoint> multipoint = GeoMultiPoint::create_unique(); + if (is_empty()) { + multipoint->set_empty(); + return multipoint; + } + + for (std::size_t i = 0; i < get_num_line(); ++i) { + const GeoLineString* line = (const GeoLineString*)GeoCollection::get_geometries_n(i); + if (line->is_empty() || line->is_ring()) { + continue; + } + std::unique_ptr<GeoPoint> point1 = GeoPoint::create_unique(); + std::unique_ptr<GeoPoint> point2 = GeoPoint::create_unique(); + point1->from_s2point(line->get_point(0)); + point2->from_s2point(line->get_point(line->num_point() - 1)); + multipoint->add_one_geometry(point1.release()); + multipoint->add_one_geometry(point2.release()); + } + + if (multipoint->get_num_point() == 0) multipoint->set_empty(); Review Comment: warning: statement should be inside braces [readability-braces-around-statements] ```suggestion if (multipoint->get_num_point() == 0) { multipoint->set_empty(); } ``` ########## be/src/geo/util/GeoLineString.h: ########## @@ -0,0 +1,83 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#ifndef DORIS_GEOLINESTRING_H +#define DORIS_GEOLINESTRING_H + +#include "GeoPoint.h" +#include "GeoShape.h" +#include "common/factory_creator.h" +#include "geo/wkt_parse_type.h" + +class S2Polyline; + +namespace doris { + +class GeoLineString : public GeoShape { + ENABLE_FACTORY_CREATOR(GeoLineString); + +public: + GeoLineString(); + ~GeoLineString() override; + + bool is_valid() const override; + + bool is_closed() const override; + + static GeoParseStatus to_s2polyline(const GeoCoordinates& coords, + std::unique_ptr<S2Polyline>* polyline); + + GeoParseStatus from_coords(const GeoCoordinates& coords); + + GeoCoordinates to_coords() const; + + std::unique_ptr<GeoCoordinates> to_coords_ptr() const; + + GeoShapeType type() const override { return GEO_SHAPE_LINE_STRING; } + + [[nodiscard]] int get_dimension() const override { return 1; } + + [[nodiscard]] double length() const; + + const S2Polyline* polyline() const { return _polyline.get(); } + + std::unique_ptr<S2Shape> get_s2shape() const; + + std::string as_wkt() const override; + + int num_point() const; + S2Point* get_point(int i) const; Review Comment: warning: function 'get_point' should be marked [[nodiscard]] [modernize-use-nodiscard] ```suggestion [[nodiscard]] S2Point* get_point(int i) const; ``` ########## be/src/geo/util/GeoMultiLineString.cpp: ########## @@ -0,0 +1,123 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "GeoMultiLineString.h" + +#include <sstream> + +#include "GeoMultiPoint.h" + +namespace doris { + +GeoMultiLineString::GeoMultiLineString() = default; +GeoMultiLineString::~GeoMultiLineString() = default; + +GeoParseStatus GeoMultiLineString::from_coords(const GeoCoordinateLists& coords_list) { + for (int i = 0; i < coords_list.coords_list.size(); i++) { + std::unique_ptr<doris::GeoLineString> line = GeoLineString::create_unique(); + if (line->from_coords(*coords_list.coords_list[i]) != GeoParseStatus::GEO_PARSE_OK) { + return GEO_PARSE_COORD_INVALID; + } + geometries.emplace_back(line.release()); + } + return GEO_PARSE_OK; +} + +std::unique_ptr<GeoCoordinateLists> GeoMultiLineString::to_coords() const { + std::unique_ptr<GeoCoordinateLists> coords_list(new GeoCoordinateLists()); + for (std::size_t i = 0; i < get_num_line(); ++i) { + const GeoLineString* line = (const GeoLineString*)GeoCollection::get_geometries_n(i); + if (line->is_empty()) continue; Review Comment: warning: statement should be inside braces [readability-braces-around-statements] ```suggestion if (line->is_empty()) { continue; } ``` ########## be/src/geo/util/GeoLineString.h: ########## @@ -0,0 +1,83 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#ifndef DORIS_GEOLINESTRING_H +#define DORIS_GEOLINESTRING_H + +#include "GeoPoint.h" +#include "GeoShape.h" +#include "common/factory_creator.h" +#include "geo/wkt_parse_type.h" + +class S2Polyline; + +namespace doris { + +class GeoLineString : public GeoShape { + ENABLE_FACTORY_CREATOR(GeoLineString); + +public: + GeoLineString(); + ~GeoLineString() override; + + bool is_valid() const override; + + bool is_closed() const override; + + static GeoParseStatus to_s2polyline(const GeoCoordinates& coords, + std::unique_ptr<S2Polyline>* polyline); + + GeoParseStatus from_coords(const GeoCoordinates& coords); + + GeoCoordinates to_coords() const; + + std::unique_ptr<GeoCoordinates> to_coords_ptr() const; + + GeoShapeType type() const override { return GEO_SHAPE_LINE_STRING; } + + [[nodiscard]] int get_dimension() const override { return 1; } + + [[nodiscard]] double length() const; + + const S2Polyline* polyline() const { return _polyline.get(); } + + std::unique_ptr<S2Shape> get_s2shape() const; + + std::string as_wkt() const override; + + int num_point() const; Review Comment: warning: function 'num_point' should be marked [[nodiscard]] [modernize-use-nodiscard] ```suggestion [[nodiscard]] int num_point() const; ``` ########## be/src/geo/util/GeoMultiLineString.h: ########## @@ -0,0 +1,55 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#ifndef DORIS_GEOMULTILINESTRING_H +#define DORIS_GEOMULTILINESTRING_H Review Comment: warning: macro is not used [clang-diagnostic-unused-macros] ```cpp #define DORIS_GEOMULTILINESTRING_H ^ ``` ########## be/src/geo/util/GeoMultiLineString.h: ########## @@ -0,0 +1,55 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#ifndef DORIS_GEOMULTILINESTRING_H +#define DORIS_GEOMULTILINESTRING_H + +#include "GeoCollection.h" +#include "common/factory_creator.h" + +namespace doris { + +class GeoMultiLineString : public GeoCollection { + ENABLE_FACTORY_CREATOR(GeoMultiLineString); + +public: + GeoMultiLineString(); + ~GeoMultiLineString() override; + + GeoShapeType type() const override { return GEO_SHAPE_MULTI_LINE_STRING; } + + [[nodiscard]] int get_dimension() const override { return 1; } + + GeoParseStatus from_coords(const GeoCoordinateLists& list); + + std::unique_ptr<GeoCoordinateLists> to_coords() const; + + // Returns the number of geometries in this collection + std::size_t get_num_line() const; Review Comment: warning: function 'get_num_line' should be marked [[nodiscard]] [modernize-use-nodiscard] ```suggestion [[nodiscard]] std::size_t get_num_line() const; ``` ########## be/src/geo/util/GeoMultiLineString.h: ########## @@ -0,0 +1,55 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#ifndef DORIS_GEOMULTILINESTRING_H +#define DORIS_GEOMULTILINESTRING_H + +#include "GeoCollection.h" +#include "common/factory_creator.h" + +namespace doris { + +class GeoMultiLineString : public GeoCollection { + ENABLE_FACTORY_CREATOR(GeoMultiLineString); + +public: + GeoMultiLineString(); + ~GeoMultiLineString() override; + + GeoShapeType type() const override { return GEO_SHAPE_MULTI_LINE_STRING; } + + [[nodiscard]] int get_dimension() const override { return 1; } + + GeoParseStatus from_coords(const GeoCoordinateLists& list); + + std::unique_ptr<GeoCoordinateLists> to_coords() const; + + // Returns the number of geometries in this collection + std::size_t get_num_line() const; + + std::string as_wkt() const override; + + GeoLineString* get_line_string_n(std::size_t n) const; Review Comment: warning: function 'get_line_string_n' should be marked [[nodiscard]] [modernize-use-nodiscard] ```suggestion [[nodiscard]] GeoLineString* get_line_string_n(std::size_t n) const; ``` ########## be/src/geo/util/GeoMultiLineString.h: ########## @@ -0,0 +1,55 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#ifndef DORIS_GEOMULTILINESTRING_H +#define DORIS_GEOMULTILINESTRING_H + +#include "GeoCollection.h" +#include "common/factory_creator.h" + +namespace doris { + +class GeoMultiLineString : public GeoCollection { + ENABLE_FACTORY_CREATOR(GeoMultiLineString); + +public: + GeoMultiLineString(); + ~GeoMultiLineString() override; + + GeoShapeType type() const override { return GEO_SHAPE_MULTI_LINE_STRING; } + + [[nodiscard]] int get_dimension() const override { return 1; } + + GeoParseStatus from_coords(const GeoCoordinateLists& list); + + std::unique_ptr<GeoCoordinateLists> to_coords() const; + + // Returns the number of geometries in this collection + std::size_t get_num_line() const; + + std::string as_wkt() const override; + + GeoLineString* get_line_string_n(std::size_t n) const; + + bool contains(const GeoShape* shape) const override; + + std::unique_ptr<GeoShape> boundary() const override; Review Comment: warning: function 'boundary' should be marked [[nodiscard]] [modernize-use-nodiscard] ```suggestion [[nodiscard]] std::unique_ptr<GeoShape> boundary() const override; ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org