paleolimbot commented on code in PR #45459:
URL: https://github.com/apache/arrow/pull/45459#discussion_r1955190059


##########
cpp/src/parquet/geometry_util_internal.h:
##########
@@ -0,0 +1,395 @@
+// 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.
+
+#pragma once
+
+#include <algorithm>
+#include <limits>
+#include <string>
+#include <unordered_set>
+
+#include "arrow/util/endian.h"
+#include "arrow/util/macros.h"
+#include "arrow/util/ubsan.h"
+#include "parquet/exception.h"
+
+namespace parquet::geometry {
+
+constexpr double kInf = std::numeric_limits<double>::infinity();
+
+struct Dimensions {
+  enum class dimensions { XY = 0, XYZ = 1, XYM = 2, XYZM = 3 };
+
+  static ::arrow::Result<dimensions> FromWKB(uint32_t wkb_geometry_type) {
+    switch (wkb_geometry_type / 1000) {
+      case 0:
+        return dimensions::XY;
+      case 1:
+        return dimensions::XYZ;
+      case 2:
+        return dimensions::XYM;
+      case 3:
+        return dimensions::XYZM;
+      default:
+        return ::arrow::Status::SerializationError("Invalid wkb_geometry_type: 
",
+                                                   wkb_geometry_type);
+    }
+  }
+
+  static uint32_t size(dimensions dims) {
+    switch (dims) {
+      case dimensions::XY:
+        return 2;
+      case dimensions::XYZ:
+      case dimensions::XYM:
+        return 3;
+      case dimensions::XYZM:
+        return 4;
+      default:
+        return 0;
+    }
+  }
+
+  static std::string ToString(dimensions dims) {
+    switch (dims) {
+      case dimensions::XY:
+        return "XY";
+      case dimensions::XYZ:
+        return "XYZ";
+      case dimensions::XYM:
+        return "XYM";
+      case dimensions::XYZM:
+        return "XYZM";
+      default:
+        return "";
+    }
+  }
+};
+
+struct GeometryType {
+  enum class geometry_type {
+    POINT = 1,
+    LINESTRING = 2,
+    POLYGON = 3,
+    MULTIPOINT = 4,
+    MULTILINESTRING = 5,
+    MULTIPOLYGON = 6,
+    GEOMETRYCOLLECTION = 7
+  };
+
+  static ::arrow::Result<geometry_type> FromWKB(uint32_t wkb_geometry_type) {
+    switch (wkb_geometry_type % 1000) {
+      case 1:
+        return geometry_type::POINT;
+      case 2:
+        return geometry_type::LINESTRING;
+      case 3:
+        return geometry_type::POLYGON;
+      case 4:
+        return geometry_type::MULTIPOINT;
+      case 5:
+        return geometry_type::MULTILINESTRING;
+      case 6:
+        return geometry_type::MULTIPOLYGON;
+      case 7:
+        return geometry_type::GEOMETRYCOLLECTION;
+      default:
+        return ::arrow::Status::SerializationError("Invalid wkb_geometry_type: 
",
+                                                   wkb_geometry_type);
+    }
+  }
+
+  static std::string ToString(geometry_type geometry_type) {
+    switch (geometry_type) {
+      case geometry_type::POINT:
+        return "POINT";
+      case geometry_type::LINESTRING:
+        return "LINESTRING";
+      case geometry_type::POLYGON:
+        return "POLYGON";
+      case geometry_type::MULTIPOINT:
+        return "MULTIPOINT";
+      case geometry_type::MULTILINESTRING:
+        return "MULTILINESTRING";
+      case geometry_type::MULTIPOLYGON:
+        return "MULTIPOLYGON";
+      case geometry_type::GEOMETRYCOLLECTION:
+        return "GEOMETRYCOLLECTION";
+      default:
+        return "";
+    }
+  }
+};
+
+class WKBBuffer {

Review Comment:
   This is a great point! I'll circle back to this one this evening.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to