Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
05953f4c
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
05953f4c
编写于
6月 21, 2020
作者:
A
Alexey Ilyukhov
提交者:
Nikita Mikhaylov
3月 11, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add readWkt, svg
上级
938ca686
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
227 addition
and
3 deletion
+227
-3
src/Functions/geometryConverters.h
src/Functions/geometryConverters.h
+0
-2
src/Functions/readWkt.cpp
src/Functions/readWkt.cpp
+114
-0
src/Functions/registerFunctionsGeo.cpp
src/Functions/registerFunctionsGeo.cpp
+4
-0
src/Functions/svg.cpp
src/Functions/svg.cpp
+107
-0
src/Functions/wkt.cpp
src/Functions/wkt.cpp
+0
-1
src/Functions/ya.make
src/Functions/ya.make
+2
-0
未找到文件。
src/Functions/geometryConverters.h
浏览文件 @
05953f4c
...
...
@@ -100,8 +100,6 @@ public:
container
.
reserve
(
r
-
l
+
1
);
container
.
resize
(
r
-
l
);
LOG_FATAL
(
&
Poco
::
Logger
::
get
(
"geoconv"
),
"ring: l = {}, r = {}"
,
l
,
r
);
for
(
size_t
j
=
l
;
j
<
r
;
j
++
)
{
pointParser
.
get
(
container
[
j
-
l
],
j
);
}
...
...
src/Functions/readWkt.cpp
0 → 100644
浏览文件 @
05953f4c
#include <DataTypes/DataTypeString.h>
#include <DataTypes/DataTypeCustomGeo.h>
#include <Functions/FunctionFactory.h>
#include <Functions/FunctionHelpers.h>
#include <Functions/geometryConverters.h>
#include <Columns/ColumnString.h>
#include <string>
#include <memory>
namespace
DB
{
namespace
ErrorCodes
{
extern
const
int
ILLEGAL_TYPE_OF_ARGUMENT
;
extern
const
int
BAD_ARGUMENT
;
}
template
<
class
DataType
,
class
Geometry
,
class
Serializer
>
class
FunctionReadWkt
:
public
IFunction
{
public:
explicit
FunctionReadWkt
()
{}
size_t
getNumberOfArguments
()
const
override
{
return
1
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
checkAndGetDataType
<
DataTypeString
>
(
arguments
[
0
].
get
())
==
nullptr
)
{
throw
Exception
(
"First argument should be String"
,
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
}
return
DataType
::
nestedDataType
();
}
void
executeImpl
(
Block
&
block
,
const
ColumnNumbers
&
arguments
,
size_t
result
,
size_t
input_rows_count
)
override
{
auto
column_string
=
checkAndGetColumn
<
ColumnString
>
(
block
.
getByPosition
(
arguments
[
0
]).
column
.
get
());
Serializer
serializer
;
Geometry
geometry
;
for
(
size_t
i
=
0
;
i
<
input_rows_count
;
i
++
)
{
const
auto
&
str
=
column_string
->
getDataAt
(
i
).
toString
();
boost
::
geometry
::
read_wkt
(
str
,
geometry
);
serializer
.
add
(
geometry
);
}
block
.
getByPosition
(
result
).
column
=
serializer
.
finalize
();
}
bool
useDefaultImplementationForConstants
()
const
override
{
return
true
;
}
};
class
FunctionReadWktPoint
:
public
FunctionReadWkt
<
DataTypeCustomPointSerialization
,
Float64Point
,
Float64PointSerializer
>
{
public:
static
inline
const
char
*
name
=
"readWktPoint"
;
String
getName
()
const
override
{
return
name
;
}
static
FunctionPtr
create
(
const
Context
&
)
{
return
std
::
make_shared
<
FunctionReadWktPoint
>
();
}
};
class
FunctionReadWktPolygon
:
public
FunctionReadWkt
<
DataTypeCustomPolygonSerialization
,
Float64Polygon
,
Float64PolygonSerializer
>
{
public:
static
inline
const
char
*
name
=
"readWktPolygon"
;
String
getName
()
const
override
{
return
name
;
}
static
FunctionPtr
create
(
const
Context
&
)
{
return
std
::
make_shared
<
FunctionReadWktPolygon
>
();
}
};
class
FunctionReadWktMultiPolygon
:
public
FunctionReadWkt
<
DataTypeCustomMultiPolygonSerialization
,
Float64MultiPolygon
,
Float64MultiPolygonSerializer
>
{
public:
static
inline
const
char
*
name
=
"readWktMultiPolygon"
;
String
getName
()
const
override
{
return
name
;
}
static
FunctionPtr
create
(
const
Context
&
)
{
return
std
::
make_shared
<
FunctionReadWktMultiPolygon
>
();
}
};
void
registerFunctionReadWkt
(
FunctionFactory
&
factory
)
{
factory
.
registerFunction
<
FunctionReadWktPoint
>
();
factory
.
registerFunction
<
FunctionReadWktPolygon
>
();
factory
.
registerFunction
<
FunctionReadWktMultiPolygon
>
();
}
}
src/Functions/registerFunctionsGeo.cpp
浏览文件 @
05953f4c
...
...
@@ -16,6 +16,8 @@ void registerFunctionGeohashEncode(FunctionFactory & factory);
void
registerFunctionGeohashDecode
(
FunctionFactory
&
factory
);
void
registerFunctionGeohashesInBox
(
FunctionFactory
&
factory
);
void
registerFunctionWkt
(
FunctionFactory
&
factory
);
void
registerFunctionReadWkt
(
FunctionFactory
&
factory
);
void
registerFunctionSvg
(
FunctionFactory
&
factory
);
#if USE_H3
void
registerFunctionGeoToH3
(
FunctionFactory
&
);
...
...
@@ -45,6 +47,8 @@ void registerFunctionsGeo(FunctionFactory & factory)
registerFunctionGeohashDecode
(
factory
);
registerFunctionGeohashesInBox
(
factory
);
registerFunctionWkt
(
factory
);
registerFunctionReadWkt
(
factory
);
registerFunctionSvg
(
factory
);
#if USE_H3
registerFunctionGeoToH3
(
factory
);
...
...
src/Functions/svg.cpp
0 → 100644
浏览文件 @
05953f4c
#include <DataTypes/DataTypeString.h>
#include <Functions/FunctionFactory.h>
#include <Functions/FunctionHelpers.h>
#include <Functions/geometryConverters.h>
#include <Columns/ColumnString.h>
#include <string>
#include <memory>
namespace
DB
{
namespace
ErrorCodes
{
extern
const
int
TOO_MANY_ARGUMENTS_FOR_FUNCTION
;
extern
const
int
TOO_FEW_ARGUMENTS_FOR_FUNCTION
;
}
class
FunctionSvg
:
public
IFunction
{
public:
static
inline
const
char
*
name
=
"svg"
;
explicit
FunctionSvg
()
{}
static
FunctionPtr
create
(
const
Context
&
)
{
return
std
::
make_shared
<
FunctionSvg
>
();
}
String
getName
()
const
override
{
return
name
;
}
bool
isVariadic
()
const
override
{
return
true
;
}
size_t
getNumberOfArguments
()
const
override
{
return
2
;
}
DataTypePtr
getReturnTypeImpl
(
const
DataTypes
&
arguments
)
const
override
{
if
(
arguments
.
size
()
>
2
)
{
throw
Exception
(
"Too many arguments"
,
ErrorCodes
::
TOO_MANY_ARGUMENTS_FOR_FUNCTION
);
}
if
(
arguments
.
size
()
==
0
)
{
throw
Exception
(
"Too few arguments"
,
ErrorCodes
::
TOO_FEW_ARGUMENTS_FOR_FUNCTION
);
}
if
(
arguments
.
size
()
==
2
&&
checkAndGetDataType
<
DataTypeString
>
(
arguments
[
1
].
get
())
==
nullptr
)
{
throw
Exception
(
"Second argument should be String"
,
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
}
return
std
::
make_shared
<
DataTypeString
>
();
}
void
executeImpl
(
Block
&
block
,
const
ColumnNumbers
&
arguments
,
size_t
result
,
size_t
input_rows_count
)
override
{
const
auto
*
const_col
=
checkAndGetColumn
<
ColumnConst
>
(
block
.
getByPosition
(
arguments
[
0
]).
column
.
get
());
auto
parser
=
const_col
?
makeGeometryFromColumnParser
(
ColumnWithTypeAndName
(
const_col
->
getDataColumnPtr
(),
block
.
getByPosition
(
arguments
[
0
]).
type
,
block
.
getByPosition
(
arguments
[
0
]).
name
))
:
makeGeometryFromColumnParser
(
block
.
getByPosition
(
arguments
[
0
]));
bool
geo_column_is_const
=
static_cast
<
bool
>
(
const_col
);
auto
res_column
=
ColumnString
::
create
();
auto
container
=
createContainer
(
parser
);
bool
has_style
=
arguments
.
size
()
>
1
;
ColumnPtr
style
;
if
(
has_style
)
{
style
=
block
.
getByPosition
(
arguments
[
1
]).
column
;
}
for
(
size_t
i
=
0
;
i
<
input_rows_count
;
i
++
)
{
std
::
stringstream
str
;
if
(
!
geo_column_is_const
||
i
==
0
)
get
(
parser
,
container
,
i
);
str
<<
boost
::
geometry
::
svg
(
container
,
has_style
?
style
->
getDataAt
(
i
).
toString
()
:
""
);
std
::
string
serialized
=
str
.
str
();
res_column
->
insertData
(
serialized
.
c_str
(),
serialized
.
size
());
}
block
.
getByPosition
(
result
).
column
=
std
::
move
(
res_column
);
}
bool
useDefaultImplementationForConstants
()
const
override
{
return
true
;
}
};
void
registerFunctionSvg
(
FunctionFactory
&
factory
)
{
factory
.
registerFunction
<
FunctionSvg
>
();
}
}
src/Functions/wkt.cpp
浏览文件 @
05953f4c
...
...
@@ -61,7 +61,6 @@ public:
}
};
void
registerFunctionWkt
(
FunctionFactory
&
factory
)
{
factory
.
registerFunction
<
FunctionWkt
>
();
...
...
src/Functions/ya.make
浏览文件 @
05953f4c
...
...
@@ -392,6 +392,7 @@ SRCS(
randomStringUTF8.cpp
regexpQuoteMeta.cpp
registerFunctions.cpp
readWkt.cpp
registerFunctionsArithmetic.cpp
registerFunctionsComparison.cpp
registerFunctionsConditional.cpp
...
...
@@ -448,6 +449,7 @@ SRCS(
subtractSeconds.cpp
subtractWeeks.cpp
subtractYears.cpp
svg.cpp
tan.cpp
tanh.cpp
tcpPort.cpp
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录