Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
c47184ef
提交
c47184ef
authored
9月 12, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Combine flags into dimension system in EWKTUtils
上级
c7830320
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
29 行增加
和
38 行删除
+29
-38
EWKTUtils.java
h2/src/main/org/h2/util/geometry/EWKTUtils.java
+29
-38
没有找到文件。
h2/src/main/org/h2/util/geometry/EWKTUtils.java
浏览文件 @
c47184ef
...
...
@@ -577,7 +577,7 @@ public final class EWKTUtils {
* output target
*/
public
static
void
parseEWKT
(
String
ewkt
,
Target
target
)
{
parseEWKT
(
new
EWKTSource
(
ewkt
),
target
,
0
,
false
,
false
);
parseEWKT
(
new
EWKTSource
(
ewkt
),
target
,
0
,
0
);
}
/**
...
...
@@ -589,12 +589,10 @@ public final class EWKTUtils {
* output target
* @param parentType
* type of parent geometry collection, or 0 for the root geometry
* @param useZ
* parent geometry uses dimension Z
* @param useM
* parent geometry uses dimension M
* @param dimensionSystem
* dimension system of parent geometry
*/
private
static
void
parseEWKT
(
EWKTSource
source
,
Target
target
,
int
parentType
,
boolean
useZ
,
boolean
useM
)
{
private
static
void
parseEWKT
(
EWKTSource
source
,
Target
target
,
int
parentType
,
int
dimensionSystem
)
{
if
(
parentType
==
0
)
{
target
.
init
(
source
.
readSRID
());
}
...
...
@@ -602,13 +600,7 @@ public final class EWKTUtils {
switch
(
parentType
)
{
default
:
{
type
=
source
.
readType
();
int
ds
=
source
.
readDimensionSystem
();
if
((
ds
&
DIMENSION_SYSTEM_XYZ
)
!=
0
)
{
useZ
=
true
;
}
if
((
ds
&
DIMENSION_SYSTEM_XYM
)
!=
0
)
{
useM
=
true
;
}
dimensionSystem
=
source
.
readDimensionSystem
();
break
;
}
case
MULTI_POINT:
...
...
@@ -631,7 +623,7 @@ public final class EWKTUtils {
if
(
empty
)
{
target
.
addCoordinate
(
Double
.
NaN
,
Double
.
NaN
,
Double
.
NaN
,
Double
.
NaN
,
0
,
1
);
}
else
{
addCoordinate
(
source
,
target
,
useZ
,
useM
,
0
,
1
);
addCoordinate
(
source
,
target
,
dimensionSystem
,
0
,
1
);
source
.
read
(
')'
);
}
break
;
...
...
@@ -646,7 +638,7 @@ public final class EWKTUtils {
}
else
{
ArrayList
<
double
[]>
coordinates
=
new
ArrayList
<>();
do
{
coordinates
.
add
(
readCoordinate
(
source
,
useZ
,
useM
));
coordinates
.
add
(
readCoordinate
(
source
,
dimensionSystem
));
}
while
(
source
.
hasMoreCoordinates
());
int
numPoints
=
coordinates
.
size
();
if
(
numPoints
<
0
||
numPoints
==
1
)
{
...
...
@@ -668,10 +660,10 @@ public final class EWKTUtils {
if
(
empty
)
{
target
.
startPolygon
(
0
,
0
);
}
else
{
ArrayList
<
double
[]>
outer
=
readRing
(
source
,
useZ
,
useM
);
ArrayList
<
double
[]>
outer
=
readRing
(
source
,
dimensionSystem
);
ArrayList
<
ArrayList
<
double
[]>>
inner
=
new
ArrayList
<>();
while
(
source
.
hasMoreCoordinates
())
{
inner
.
add
(
readRing
(
source
,
useZ
,
useM
));
inner
.
add
(
readRing
(
source
,
dimensionSystem
));
}
int
numInner
=
inner
.
size
();
int
size
=
outer
.
size
();
...
...
@@ -684,7 +676,7 @@ public final class EWKTUtils {
}
target
.
startPolygon
(
numInner
,
size
);
if
(
size
>
0
)
{
addRing
(
outer
,
target
,
useZ
,
useM
);
addRing
(
outer
,
target
);
for
(
int
i
=
0
;
i
<
numInner
;
i
++)
{
ArrayList
<
double
[]>
ring
=
inner
.
get
(
i
);
size
=
ring
.
size
();
...
...
@@ -693,7 +685,7 @@ public final class EWKTUtils {
throw
new
IllegalArgumentException
();
}
target
.
startPolygonInner
(
size
);
addRing
(
ring
,
target
,
useZ
,
useM
);
addRing
(
ring
,
target
);
}
target
.
endNonEmptyPolygon
();
}
...
...
@@ -701,16 +693,16 @@ public final class EWKTUtils {
break
;
}
case
MULTI_POINT:
parseCollection
(
source
,
target
,
MULTI_POINT
,
parentType
,
useZ
,
useM
);
parseCollection
(
source
,
target
,
MULTI_POINT
,
parentType
,
dimensionSystem
);
break
;
case
MULTI_LINE_STRING:
parseCollection
(
source
,
target
,
MULTI_LINE_STRING
,
parentType
,
useZ
,
useM
);
parseCollection
(
source
,
target
,
MULTI_LINE_STRING
,
parentType
,
dimensionSystem
);
break
;
case
MULTI_POLYGON:
parseCollection
(
source
,
target
,
MULTI_POLYGON
,
parentType
,
useZ
,
useM
);
parseCollection
(
source
,
target
,
MULTI_POLYGON
,
parentType
,
dimensionSystem
);
break
;
case
GEOMETRY_COLLECTION:
parseCollection
(
source
,
target
,
GEOMETRY_COLLECTION
,
parentType
,
useZ
,
useM
);
parseCollection
(
source
,
target
,
GEOMETRY_COLLECTION
,
parentType
,
0
);
break
;
default
:
throw
new
IllegalArgumentException
();
...
...
@@ -720,8 +712,8 @@ public final class EWKTUtils {
}
}
private
static
void
parseCollection
(
EWKTSource
source
,
Target
target
,
int
type
,
int
parentType
,
boolean
useZ
,
boolean
useM
)
{
private
static
void
parseCollection
(
EWKTSource
source
,
Target
target
,
int
type
,
int
parentType
,
int
dimensionSystem
)
{
if
(
parentType
!=
0
&&
parentType
!=
GEOMETRY_COLLECTION
)
{
throw
new
IllegalArgumentException
();
}
...
...
@@ -729,7 +721,7 @@ public final class EWKTUtils {
target
.
startCollection
(
type
,
0
);
}
else
{
if
(
type
==
MULTI_POINT
&&
source
.
hasCoordinate
())
{
parseMultiPointAlternative
(
source
,
target
,
useZ
,
useM
);
parseMultiPointAlternative
(
source
,
target
,
dimensionSystem
);
}
else
{
int
numItems
=
source
.
getItemCount
();
target
.
startCollection
(
type
,
numItems
);
...
...
@@ -738,7 +730,7 @@ public final class EWKTUtils {
source
.
read
(
','
);
}
Target
innerTarget
=
target
.
startCollectionItem
(
i
,
numItems
);
parseEWKT
(
source
,
innerTarget
,
type
,
useZ
,
useM
);
parseEWKT
(
source
,
innerTarget
,
type
,
dimensionSystem
);
target
.
endCollectionItem
(
innerTarget
,
i
,
numItems
);
}
source
.
read
(
')'
);
...
...
@@ -747,11 +739,11 @@ public final class EWKTUtils {
target
.
endCollection
(
type
);
}
private
static
void
parseMultiPointAlternative
(
EWKTSource
source
,
Target
target
,
boolean
useZ
,
boolean
useM
)
{
private
static
void
parseMultiPointAlternative
(
EWKTSource
source
,
Target
target
,
int
dimensionSystem
)
{
// Special case for MULTIPOINT (1 2, 3 4)
ArrayList
<
double
[]>
points
=
new
ArrayList
<>();
do
{
points
.
add
(
readCoordinate
(
source
,
useZ
,
useM
));
points
.
add
(
readCoordinate
(
source
,
dimensionSystem
));
}
while
(
source
.
hasMoreCoordinates
());
int
numItems
=
points
.
size
();
target
.
startCollection
(
MULTI_POINT
,
numItems
);
...
...
@@ -764,16 +756,16 @@ public final class EWKTUtils {
}
}
private
static
ArrayList
<
double
[]>
readRing
(
EWKTSource
source
,
boolean
useZ
,
boolean
useM
)
{
private
static
ArrayList
<
double
[]>
readRing
(
EWKTSource
source
,
int
dimensionSystem
)
{
if
(
source
.
readEmpty
())
{
return
new
ArrayList
<>(
0
);
}
ArrayList
<
double
[]>
result
=
new
ArrayList
<>();
double
[]
c
=
readCoordinate
(
source
,
useZ
,
useM
);
double
[]
c
=
readCoordinate
(
source
,
dimensionSystem
);
double
startX
=
c
[
X
],
startY
=
c
[
Y
];
result
.
add
(
c
);
while
(
source
.
hasMoreCoordinates
())
{
result
.
add
(
readCoordinate
(
source
,
useZ
,
useM
));
result
.
add
(
readCoordinate
(
source
,
dimensionSystem
));
}
int
size
=
result
.
size
();
if
(
size
<
4
)
{
...
...
@@ -791,20 +783,19 @@ public final class EWKTUtils {
return
result
;
}
private
static
void
addRing
(
ArrayList
<
double
[]>
ring
,
Target
target
,
boolean
useZ
,
boolean
useM
)
{
private
static
void
addRing
(
ArrayList
<
double
[]>
ring
,
Target
target
)
{
for
(
int
i
=
0
,
size
=
ring
.
size
();
i
<
size
;
i
++)
{
double
[]
coordinates
=
ring
.
get
(
i
);
target
.
addCoordinate
(
coordinates
[
X
],
coordinates
[
Y
],
coordinates
[
Z
],
coordinates
[
M
],
i
,
size
);
}
}
private
static
void
addCoordinate
(
EWKTSource
source
,
Target
target
,
boolean
useZ
,
boolean
useM
,
int
index
,
int
total
)
{
private
static
void
addCoordinate
(
EWKTSource
source
,
Target
target
,
int
dimensionSystem
,
int
index
,
int
total
)
{
double
x
=
source
.
readCoordinate
();
double
y
=
source
.
readCoordinate
();
double
z
=
Double
.
NaN
,
m
=
Double
.
NaN
;
if
(
source
.
hasCoordinate
())
{
if
(
!
useZ
&&
use
M
)
{
if
(
dimensionSystem
==
DIMENSION_SYSTEM_XY
M
)
{
m
=
source
.
readCoordinate
();
}
else
{
z
=
source
.
readCoordinate
();
...
...
@@ -816,12 +807,12 @@ public final class EWKTUtils {
target
.
addCoordinate
(
x
,
y
,
z
,
m
,
index
,
total
);
}
private
static
double
[]
readCoordinate
(
EWKTSource
source
,
boolean
useZ
,
boolean
useM
)
{
private
static
double
[]
readCoordinate
(
EWKTSource
source
,
int
dimensionSystem
)
{
double
x
=
source
.
readCoordinate
();
double
y
=
source
.
readCoordinate
();
double
z
=
Double
.
NaN
,
m
=
Double
.
NaN
;
if
(
source
.
hasCoordinate
())
{
if
(
!
useZ
&&
use
M
)
{
if
(
dimensionSystem
==
DIMENSION_SYSTEM_XY
M
)
{
m
=
source
.
readCoordinate
();
}
else
{
z
=
source
.
readCoordinate
();
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论