emkornfield commented on code in PR #45459: URL: https://github.com/apache/arrow/pull/45459#discussion_r1953926664
########## 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 { Review Comment: or maybe not nest this in a struct and just have the static methods here as top level functions? then GeometryType could be the enum? -- 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]
