mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
H3 remove functions degsToRads, radsToDegs
This commit is contained in:
parent
f9d73479d0
commit
110b39add4
@ -740,74 +740,6 @@ Result:
|
||||
└───────┘
|
||||
```
|
||||
|
||||
## h3DegsToRads {#h3degstorads}
|
||||
|
||||
Converts degrees to radians.
|
||||
|
||||
**Syntax**
|
||||
|
||||
``` sql
|
||||
h3DegsToRads(degrees)
|
||||
```
|
||||
|
||||
**Parameter**
|
||||
|
||||
- `degrees` — Input in degrees. Type: [Float64](../../../sql-reference/data-types/float.md).
|
||||
|
||||
**Returned values**
|
||||
|
||||
- Radians. Type: [Float64](../../../sql-reference/data-types/float.md).
|
||||
|
||||
**Example**
|
||||
|
||||
Query:
|
||||
|
||||
``` sql
|
||||
SELECT h3DegsToRads(180.0) AS radians;
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
``` text
|
||||
┌───────────radians─┐
|
||||
│ 3.141592653589793 │
|
||||
└───────────────────┘
|
||||
```
|
||||
|
||||
## h3RadsToDegs {#h3radstodegs}
|
||||
|
||||
Converts radians to degrees.
|
||||
|
||||
**Syntax**
|
||||
|
||||
``` sql
|
||||
h3RadsToDegs(radians)
|
||||
```
|
||||
|
||||
**Parameter**
|
||||
|
||||
- `radians` — Input in radians. Type: [Float64](../../../sql-reference/data-types/float.md).
|
||||
|
||||
**Returned values**
|
||||
|
||||
- Degrees. Type: [Float64](../../../sql-reference/data-types/float.md).
|
||||
|
||||
**Example**
|
||||
|
||||
Query:
|
||||
|
||||
``` sql
|
||||
SELECT h3RadsToDegs(3.141592653589793) AS degrees;
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
``` text
|
||||
┌─degrees─┐
|
||||
│ 180 │
|
||||
└─────────┘
|
||||
```
|
||||
|
||||
## h3CellAreaM2 {#h3cellaream2}
|
||||
|
||||
Returns the exact area of a specific cell in square meters corresponding to the given input H3 index.
|
||||
|
@ -1,90 +0,0 @@
|
||||
#include "config_functions.h"
|
||||
|
||||
#if USE_H3
|
||||
|
||||
#include <Columns/ColumnsNumber.h>
|
||||
#include <Columns/ColumnArray.h>
|
||||
#include <DataTypes/DataTypesNumber.h>
|
||||
#include <Functions/FunctionFactory.h>
|
||||
#include <Functions/IFunction.h>
|
||||
#include <Common/typeid_cast.h>
|
||||
|
||||
#include <h3api.h>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
||||
extern const int ILLEGAL_COLUMN;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
class FunctionH3DegsToRads final : public IFunction
|
||||
{
|
||||
public:
|
||||
static constexpr auto name = "h3DegsToRads";
|
||||
|
||||
static FunctionPtr create(ContextPtr) { return std::make_shared<FunctionH3DegsToRads>(); }
|
||||
|
||||
std::string getName() const override { return name; }
|
||||
|
||||
size_t getNumberOfArguments() const override { return 1; }
|
||||
|
||||
bool useDefaultImplementationForConstants() const override { return true; }
|
||||
|
||||
bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) const override { return true; }
|
||||
|
||||
DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override
|
||||
{
|
||||
const auto * arg = arguments[0].get();
|
||||
if (!WhichDataType(arg).isFloat64())
|
||||
throw Exception(
|
||||
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
|
||||
"Illegal type {} of argument {} of function {}. Must be Float64",
|
||||
arg->getName(), 1, getName());
|
||||
|
||||
return std::make_shared<DataTypeFloat64>();
|
||||
}
|
||||
|
||||
ColumnPtr executeImpl(const ColumnsWithTypeAndName & arguments, const DataTypePtr &, size_t input_rows_count) const override
|
||||
{
|
||||
const auto * column = checkAndGetColumn<ColumnFloat64>(arguments[0].column.get());
|
||||
|
||||
if (!column)
|
||||
throw Exception(
|
||||
ErrorCodes::ILLEGAL_COLUMN,
|
||||
"Illegal type {} of argument {} of function {}. Must be Float64",
|
||||
arguments[0].type->getName(),
|
||||
1,
|
||||
getName());
|
||||
|
||||
const auto & data = column->getData();
|
||||
|
||||
auto dst = ColumnVector<Float64>::create();
|
||||
auto & dst_data = dst->getData();
|
||||
dst_data.resize(input_rows_count);
|
||||
|
||||
for (size_t row = 0; row < input_rows_count; ++row)
|
||||
{
|
||||
const Float64 degrees = data[row];
|
||||
auto res = degsToRads(degrees);
|
||||
dst_data[row] = res;
|
||||
}
|
||||
|
||||
return dst;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
void registerFunctionH3DegsToRads(FunctionFactory & factory)
|
||||
{
|
||||
factory.registerFunction<FunctionH3DegsToRads>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -1,88 +0,0 @@
|
||||
#include "config_functions.h"
|
||||
|
||||
#if USE_H3
|
||||
|
||||
#include <Columns/ColumnsNumber.h>
|
||||
#include <Columns/ColumnArray.h>
|
||||
#include <DataTypes/DataTypesNumber.h>
|
||||
#include <Functions/FunctionFactory.h>
|
||||
#include <Functions/IFunction.h>
|
||||
#include <Common/typeid_cast.h>
|
||||
|
||||
#include <h3api.h>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
||||
extern const int ILLEGAL_COLUMN;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
class FunctionH3RadsToDegs final : public IFunction
|
||||
{
|
||||
public:
|
||||
static constexpr auto name = "h3RadsToDegs";
|
||||
|
||||
static FunctionPtr create(ContextPtr) { return std::make_shared<FunctionH3RadsToDegs>(); }
|
||||
|
||||
std::string getName() const override { return name; }
|
||||
|
||||
size_t getNumberOfArguments() const override { return 1; }
|
||||
|
||||
bool useDefaultImplementationForConstants() const override { return true; }
|
||||
|
||||
bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) const override { return true; }
|
||||
|
||||
DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override
|
||||
{
|
||||
const auto * arg = arguments[0].get();
|
||||
if (!WhichDataType(arg).isFloat64())
|
||||
throw Exception(
|
||||
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
|
||||
"Illegal type {} of argument {} of function {}. Must be Float64",
|
||||
arg->getName(), 1, getName());
|
||||
|
||||
return std::make_shared<DataTypeFloat64>();
|
||||
}
|
||||
|
||||
ColumnPtr executeImpl(const ColumnsWithTypeAndName & arguments, const DataTypePtr &, size_t input_rows_count) const override
|
||||
{
|
||||
const auto * column = checkAndGetColumn<ColumnFloat64>(arguments[0].column.get());
|
||||
if (!column)
|
||||
throw Exception(
|
||||
ErrorCodes::ILLEGAL_COLUMN,
|
||||
"Illegal type {} of argument {} of function {}. Must be Float64",
|
||||
arguments[0].type->getName(),
|
||||
1,
|
||||
getName());
|
||||
|
||||
const auto & col_rads = column->getData();
|
||||
|
||||
auto dst = ColumnVector<Float64>::create();
|
||||
auto & dst_data = dst->getData();
|
||||
dst_data.resize(input_rows_count);
|
||||
|
||||
for (size_t row = 0; row < input_rows_count; ++row)
|
||||
{
|
||||
const Float64 rads = col_rads[row];
|
||||
auto res = radsToDegs(rads);
|
||||
dst_data[row] = res;
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
void registerFunctionH3RadsToDegs(FunctionFactory & factory)
|
||||
{
|
||||
factory.registerFunction<FunctionH3RadsToDegs>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -43,8 +43,6 @@ void registerFunctionH3HexAreaM2(FunctionFactory &);
|
||||
void registerFunctionH3IsResClassIII(FunctionFactory &);
|
||||
void registerFunctionH3IsPentagon(FunctionFactory &);
|
||||
void registerFunctionH3GetFaces(FunctionFactory &);
|
||||
void registerFunctionH3DegsToRads(FunctionFactory &);
|
||||
void registerFunctionH3RadsToDegs(FunctionFactory &);
|
||||
void registerFunctionH3HexAreaKm2(FunctionFactory &);
|
||||
void registerFunctionH3CellAreaM2(FunctionFactory &);
|
||||
void registerFunctionH3CellAreaRads2(FunctionFactory &);
|
||||
@ -105,8 +103,6 @@ void registerFunctionsGeo(FunctionFactory & factory)
|
||||
registerFunctionH3IsResClassIII(factory);
|
||||
registerFunctionH3IsPentagon(factory);
|
||||
registerFunctionH3GetFaces(factory);
|
||||
registerFunctionH3DegsToRads(factory);
|
||||
registerFunctionH3RadsToDegs(factory);
|
||||
registerFunctionH3HexAreaKm2(factory);
|
||||
registerFunctionH3CellAreaM2(factory);
|
||||
registerFunctionH3CellAreaRads2(factory);
|
||||
|
@ -1,9 +0,0 @@
|
||||
-360
|
||||
-180.6
|
||||
-180
|
||||
-1
|
||||
0
|
||||
1
|
||||
180
|
||||
180.5
|
||||
360
|
@ -1,21 +0,0 @@
|
||||
-- Tags: no-fasttest
|
||||
|
||||
DROP TABLE IF EXISTS h3_indexes;
|
||||
|
||||
|
||||
CREATE TABLE h3_indexes (degrees Float64) ENGINE = Memory;
|
||||
|
||||
|
||||
INSERT INTO h3_indexes VALUES (-1);
|
||||
INSERT INTO h3_indexes VALUES (-180);
|
||||
INSERT INTO h3_indexes VALUES (-180.6);
|
||||
INSERT INTO h3_indexes VALUES (-360);
|
||||
INSERT INTO h3_indexes VALUES (0);
|
||||
INSERT INTO h3_indexes VALUES (1);
|
||||
INSERT INTO h3_indexes VALUES (180);
|
||||
INSERT INTO h3_indexes VALUES (180.5);
|
||||
INSERT INTO h3_indexes VALUES (360);
|
||||
|
||||
select h3RadsToDegs(h3DegsToRads(degrees)) from h3_indexes order by degrees;
|
||||
|
||||
DROP TABLE h3_indexes;
|
Loading…
Reference in New Issue
Block a user