Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
abcd1425
提交
abcd1425
authored
6 年前
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reduce number of reflective calls
上级
c8d9c301
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
36 行增加
和
26 行删除
+36
-26
JTSUtils.java
h2/src/main/org/h2/util/geometry/JTSUtils.java
+36
-26
没有找到文件。
h2/src/main/org/h2/util/geometry/JTSUtils.java
浏览文件 @
abcd1425
...
...
@@ -58,24 +58,20 @@ public final class JTSUtils {
static
final
Method
CREATE
;
private
static
final
Method
GET_
Z
,
GET_M
;
private
static
final
Method
GET_
MEASURES
;
static
{
Method
create
;
Method
getZ
,
getM
;
Method
create
,
getMeasures
;
try
{
create
=
CoordinateSequenceFactory
.
class
.
getMethod
(
"create"
,
int
.
class
,
int
.
class
,
int
.
class
);
getZ
=
CoordinateSequence
.
class
.
getMethod
(
"getZ"
,
int
.
class
);
getM
=
CoordinateSequence
.
class
.
getMethod
(
"getM"
,
int
.
class
);
getMeasures
=
CoordinateSequence
.
class
.
getMethod
(
"getMeasures"
);
}
catch
(
ReflectiveOperationException
e
)
{
create
=
null
;
getZ
=
null
;
getM
=
null
;
getMeasures
=
null
;
}
M_IS_SUPPORTED
=
create
!=
null
;
CREATE
=
create
;
GET_Z
=
getZ
;
GET_M
=
getM
;
GET_MEASURES
=
getMeasures
;
}
/**
...
...
@@ -341,7 +337,8 @@ public final class JTSUtils {
if
(
p
.
isEmpty
())
{
target
.
addCoordinate
(
Double
.
NaN
,
Double
.
NaN
,
Double
.
NaN
,
Double
.
NaN
,
0
,
1
);
}
else
{
addCoordinate
(
p
.
getCoordinateSequence
(),
target
,
0
,
1
);
CoordinateSequence
sequence
=
p
.
getCoordinateSequence
();
addCoordinate
(
sequence
,
target
,
0
,
1
,
getMeasures
(
sequence
));
}
}
else
if
(
geometry
instanceof
LineString
)
{
if
(
parentType
!=
0
&&
parentType
!=
MULTI_LINE_STRING
&&
parentType
!=
GEOMETRY_COLLECTION
)
{
...
...
@@ -354,8 +351,9 @@ public final class JTSUtils {
throw
new
IllegalArgumentException
();
}
target
.
startLineString
(
numPoints
);
int
measures
=
getMeasures
(
cs
);
for
(
int
i
=
0
;
i
<
numPoints
;
i
++)
{
addCoordinate
(
cs
,
target
,
i
,
numPoints
);
addCoordinate
(
cs
,
target
,
i
,
numPoints
,
measures
);
}
}
else
if
(
geometry
instanceof
Polygon
)
{
if
(
parentType
!=
0
&&
parentType
!=
MULTI_POLYGON
&&
parentType
!=
GEOMETRY_COLLECTION
)
{
...
...
@@ -377,7 +375,8 @@ public final class JTSUtils {
}
target
.
startPolygon
(
numInner
,
size
);
if
(
size
>
0
)
{
addRing
(
cs
,
target
,
size
);
int
measures
=
getMeasures
(
cs
);
addRing
(
cs
,
target
,
size
,
measures
);
for
(
int
i
=
0
;
i
<
numInner
;
i
++)
{
cs
=
p
.
getInteriorRingN
(
i
).
getCoordinateSequence
();
size
=
cs
.
size
();
...
...
@@ -386,7 +385,7 @@ public final class JTSUtils {
throw
new
IllegalArgumentException
();
}
target
.
startPolygonInner
(
size
);
addRing
(
cs
,
target
,
size
);
addRing
(
cs
,
target
,
size
,
measures
);
}
target
.
endNonEmptyPolygon
();
}
...
...
@@ -422,13 +421,13 @@ public final class JTSUtils {
}
private
static
void
addRing
(
CoordinateSequence
sequence
,
Target
target
,
int
size
)
{
private
static
void
addRing
(
CoordinateSequence
sequence
,
Target
target
,
int
size
,
int
measures
)
{
// 0 or 4+ are valid
if
(
size
>=
4
)
{
double
startX
=
toCanonicalDouble
(
sequence
.
getX
(
0
)),
startY
=
toCanonicalDouble
(
sequence
.
getY
(
0
));
addCoordinate
(
sequence
,
target
,
0
,
size
,
startX
,
startY
);
addCoordinate
(
sequence
,
target
,
0
,
size
,
startX
,
startY
,
measures
);
for
(
int
i
=
1
;
i
<
size
-
1
;
i
++)
{
addCoordinate
(
sequence
,
target
,
i
,
size
);
addCoordinate
(
sequence
,
target
,
i
,
size
,
measures
);
}
double
endX
=
toCanonicalDouble
(
sequence
.
getX
(
size
-
1
)),
//
endY
=
toCanonicalDouble
(
sequence
.
getY
(
size
-
1
));
...
...
@@ -439,31 +438,42 @@ public final class JTSUtils {
if
(
startX
!=
endX
||
startY
!=
endY
)
{
throw
new
IllegalArgumentException
();
}
addCoordinate
(
sequence
,
target
,
size
-
1
,
size
,
endX
,
endY
);
addCoordinate
(
sequence
,
target
,
size
-
1
,
size
,
endX
,
endY
,
measures
);
}
}
private
static
void
addCoordinate
(
CoordinateSequence
sequence
,
Target
target
,
int
index
,
int
total
)
{
private
static
void
addCoordinate
(
CoordinateSequence
sequence
,
Target
target
,
int
index
,
int
total
,
int
measures
)
{
addCoordinate
(
sequence
,
target
,
index
,
total
,
toCanonicalDouble
(
sequence
.
getX
(
index
)),
toCanonicalDouble
(
sequence
.
getY
(
index
)));
toCanonicalDouble
(
sequence
.
getY
(
index
))
,
measures
);
}
private
static
void
addCoordinate
(
CoordinateSequence
sequence
,
Target
target
,
int
index
,
int
total
,
double
x
,
double
y
)
{
double
y
,
int
measures
)
{
double
m
,
z
;
int
d
=
sequence
.
getDimension
();
if
(
M_IS_SUPPORTED
)
{
d
-=
measures
;
z
=
d
>
2
?
sequence
.
getOrdinate
(
index
,
Z
)
:
Double
.
NaN
;
m
=
measures
>=
1
?
sequence
.
getOrdinate
(
index
,
d
)
:
Double
.
NaN
;
}
else
{
z
=
d
>=
3
?
toCanonicalDouble
(
sequence
.
getOrdinate
(
index
,
Z
))
:
Double
.
NaN
;
m
=
d
>=
4
?
toCanonicalDouble
(
sequence
.
getOrdinate
(
index
,
M
))
:
Double
.
NaN
;
}
target
.
addCoordinate
(
x
,
y
,
z
,
m
,
index
,
total
);
}
private
static
int
getMeasures
(
CoordinateSequence
sequence
)
{
int
m
;
if
(
M_IS_SUPPORTED
)
{
try
{
z
=
(
double
)
GET_Z
.
invoke
(
sequence
,
index
);
m
=
(
double
)
GET_M
.
invoke
(
sequence
,
index
);
m
=
(
int
)
GET_MEASURES
.
invoke
(
sequence
);
}
catch
(
ReflectiveOperationException
e
)
{
throw
DbException
.
convert
(
e
);
}
}
else
{
int
d
=
sequence
.
getDimension
();
z
=
d
>=
3
?
toCanonicalDouble
(
sequence
.
getOrdinate
(
index
,
Z
))
:
Double
.
NaN
;
m
=
d
>=
4
?
toCanonicalDouble
(
sequence
.
getOrdinate
(
index
,
M
))
:
Double
.
NaN
;
m
=
0
;
}
target
.
addCoordinate
(
x
,
y
,
z
,
m
,
index
,
total
)
;
return
m
;
}
private
JTSUtils
()
{
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论