Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
f921d388
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,发现更多精彩内容 >>
提交
f921d388
编写于
3月 25, 2020
作者:
A
Alexey Milovidov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use only 64bit float for pointInPolygon
上级
ec915f16
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
18 addition
and
53 deletion
+18
-53
dbms/src/Functions/GeoUtils.h
dbms/src/Functions/GeoUtils.h
+2
-2
dbms/src/Functions/pointInPolygon.cpp
dbms/src/Functions/pointInPolygon.cpp
+16
-51
未找到文件。
dbms/src/Functions/GeoUtils.h
浏览文件 @
f921d388
...
...
@@ -80,7 +80,7 @@ UInt64 getMultiPolygonAllocatedBytes(const MultiPolygon & multi_polygon)
return
size
;
}
template
<
typename
CoordinateType
=
Float32
>
template
<
typename
CoordinateType
>
class
PointInPolygonWithGrid
{
public:
...
...
@@ -506,7 +506,7 @@ void PointInPolygonWithGrid<CoordinateType>::addCell(
}
template
<
typename
Strategy
,
typename
CoordinateType
=
Float32
>
template
<
typename
Strategy
,
typename
CoordinateType
>
class
PointInPolygon
{
public:
...
...
dbms/src/Functions/pointInPolygon.cpp
浏览文件 @
f921d388
...
...
@@ -41,7 +41,7 @@ namespace ErrorCodes
extern
const
int
ILLEGAL_COLUMN
;
}
namespace
FunctionPointInPolygonDetail
namespace
{
template
<
typename
Polygon
,
typename
PointInPolygonImpl
>
...
...
@@ -79,16 +79,15 @@ ColumnPtr callPointInPolygonImpl(const IColumn & x, const IColumn & y, Polygon &
}
template
<
t
emplate
<
typename
>
t
ypename
PointInPolygonImpl
,
bool
use_object_pool
>
template
<
typename
PointInPolygonImpl
,
bool
use_object_pool
>
class
FunctionPointInPolygon
:
public
IFunction
{
public:
template
<
typename
Type
>
using
Point
=
boost
::
geometry
::
model
::
d2
::
point_xy
<
Type
>
;
template
<
typename
Type
>
using
Polygon
=
boost
::
geometry
::
model
::
polygon
<
Point
<
Type
>
,
false
>
;
template
<
typename
Type
>
using
Box
=
boost
::
geometry
::
model
::
box
<
Point
<
Type
>>
;
using
CoordinateType
=
Float64
;
using
Point
=
boost
::
geometry
::
model
::
d2
::
point_xy
<
CoordinateType
>
;
using
Polygon
=
boost
::
geometry
::
model
::
polygon
<
Point
,
false
>
;
using
Box
=
boost
::
geometry
::
model
::
box
<
Point
>
;
static
inline
const
char
*
name
=
"pointInPolygon"
;
...
...
@@ -160,22 +159,13 @@ public:
auto
tuple_col
=
checkAndGetColumn
<
ColumnTuple
>
(
point_col
);
if
(
!
tuple_col
)
{
throw
Exception
(
"First argument for function "
+
getName
()
+
" must be constant array of tuples."
,
ErrorCodes
::
ILLEGAL_COLUMN
);
}
const
auto
&
tuple_columns
=
tuple_col
->
getColumns
();
const
DataTypes
&
tuple_types
=
typeid_cast
<
const
DataTypeTuple
&>
(
*
block
.
getByPosition
(
arguments
[
0
]).
type
).
getElements
();
bool
use_float64
=
WhichDataType
(
tuple_types
[
0
]).
isFloat64
()
||
WhichDataType
(
tuple_types
[
1
]).
isFloat64
();
auto
&
result_column
=
block
.
safeGetByPosition
(
result
).
column
;
if
(
use_float64
)
result_column
=
executeForType
<
Float64
>
(
*
tuple_columns
[
0
],
*
tuple_columns
[
1
],
block
,
arguments
);
else
result_column
=
executeForType
<
Float32
>
(
*
tuple_columns
[
0
],
*
tuple_columns
[
1
],
block
,
arguments
);
const
auto
&
tuple_columns
=
tuple_col
->
getColumns
();
result_column
=
executeForType
(
*
tuple_columns
[
0
],
*
tuple_columns
[
1
],
block
,
arguments
);
if
(
const_tuple_col
)
result_column
=
ColumnConst
::
create
(
result_column
,
const_tuple_col
->
size
());
...
...
@@ -184,28 +174,9 @@ public:
private:
bool
validate
;
Float64
getCoordinateFromField
(
const
Field
&
field
)
{
switch
(
field
.
getType
())
{
case
Field
::
Types
::
Float64
:
return
field
.
get
<
Float64
>
();
case
Field
::
Types
::
Int64
:
return
field
.
get
<
Int64
>
();
case
Field
::
Types
::
UInt64
:
return
field
.
get
<
UInt64
>
();
default:
{
std
::
string
msg
=
"Expected numeric field, but got "
;
throw
Exception
(
msg
+
Field
::
Types
::
toString
(
field
.
getType
()),
ErrorCodes
::
LOGICAL_ERROR
);
}
}
}
template
<
typename
Type
>
ColumnPtr
executeForType
(
const
IColumn
&
x
,
const
IColumn
&
y
,
Block
&
block
,
const
ColumnNumbers
&
arguments
)
{
Polygon
<
Type
>
polygon
;
Polygon
polygon
;
auto
get_message_prefix
=
[
this
](
size_t
i
)
{
return
"Argument "
+
toString
(
i
+
1
)
+
" for function "
+
getName
();
};
...
...
@@ -234,9 +205,9 @@ private:
for
(
auto
j
:
ext
::
range
(
0
,
size
))
{
Type
x_coord
=
getCoordinateFromField
((
*
column_x
)[
j
]
);
Type
y_coord
=
getCoordinateFromField
((
*
column_y
)[
j
]
);
container
.
push_back
(
Point
<
Type
>
(
x_coord
,
y_coord
));
CoordinateType
x_coord
=
column_x
->
getFloat64
(
j
);
CoordinateType
y_coord
=
column_y
->
getFloat64
(
j
);
container
.
push_back
(
Point
(
x_coord
,
y_coord
));
}
}
...
...
@@ -253,23 +224,17 @@ private:
#endif
auto
call_impl
=
use_object_pool
?
FunctionPointInPolygonDetail
::
callPointInPolygonImplWithPool
<
Polygon
<
Type
>
,
PointInPolygonImpl
<
Type
>
>
:
FunctionPointInPolygonDetail
::
callPointInPolygonImpl
<
Polygon
<
Type
>
,
PointInPolygonImpl
<
Type
>
>
;
?
callPointInPolygonImplWithPool
<
Polygon
,
PointInPolygonImpl
>
:
callPointInPolygonImpl
<
Polygon
,
PointInPolygonImpl
>
;
return
call_impl
(
x
,
y
,
polygon
);
}
};
template
<
typename
Type
>
using
Point
=
boost
::
geometry
::
model
::
d2
::
point_xy
<
Type
>
;
template
<
typename
Type
>
using
PointInPolygonWithGrid
=
GeoUtils
::
PointInPolygonWithGrid
<
Type
>
;
void
registerFunctionPointInPolygon
(
FunctionFactory
&
factory
)
{
factory
.
registerFunction
<
FunctionPointInPolygon
<
PointInPolygonWithGrid
,
true
>>
();
factory
.
registerFunction
<
FunctionPointInPolygon
<
GeoUtils
::
PointInPolygonWithGrid
<
Float64
>
,
true
>>
();
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录