Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
88fa4120
提交
88fa4120
authored
6 年前
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move envelope2wkb() to EWKBUtils
上级
7c5fa8c6
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
56 行增加
和
53 行删除
+56
-53
EWKBUtils.java
h2/src/main/org/h2/util/geometry/EWKBUtils.java
+49
-0
GeometryUtils.java
h2/src/main/org/h2/util/geometry/GeometryUtils.java
+1
-49
ValueGeometry.java
h2/src/main/org/h2/value/ValueGeometry.java
+4
-2
TestGeometryUtils.java
h2/src/test/org/h2/test/unit/TestGeometryUtils.java
+2
-2
没有找到文件。
h2/src/main/org/h2/util/geometry/EWKBUtils.java
浏览文件 @
88fa4120
...
@@ -10,6 +10,10 @@ import static org.h2.util.geometry.GeometryUtils.DIMENSION_SYSTEM_XYZ;
...
@@ -10,6 +10,10 @@ import static org.h2.util.geometry.GeometryUtils.DIMENSION_SYSTEM_XYZ;
import
static
org
.
h2
.
util
.
geometry
.
GeometryUtils
.
DIMENSION_SYSTEM_XYZM
;
import
static
org
.
h2
.
util
.
geometry
.
GeometryUtils
.
DIMENSION_SYSTEM_XYZM
;
import
static
org
.
h2
.
util
.
geometry
.
GeometryUtils
.
GEOMETRY_COLLECTION
;
import
static
org
.
h2
.
util
.
geometry
.
GeometryUtils
.
GEOMETRY_COLLECTION
;
import
static
org
.
h2
.
util
.
geometry
.
GeometryUtils
.
LINE_STRING
;
import
static
org
.
h2
.
util
.
geometry
.
GeometryUtils
.
LINE_STRING
;
import
static
org
.
h2
.
util
.
geometry
.
GeometryUtils
.
MAX_X
;
import
static
org
.
h2
.
util
.
geometry
.
GeometryUtils
.
MAX_Y
;
import
static
org
.
h2
.
util
.
geometry
.
GeometryUtils
.
MIN_X
;
import
static
org
.
h2
.
util
.
geometry
.
GeometryUtils
.
MIN_Y
;
import
static
org
.
h2
.
util
.
geometry
.
GeometryUtils
.
MULTI_LINE_STRING
;
import
static
org
.
h2
.
util
.
geometry
.
GeometryUtils
.
MULTI_LINE_STRING
;
import
static
org
.
h2
.
util
.
geometry
.
GeometryUtils
.
MULTI_POINT
;
import
static
org
.
h2
.
util
.
geometry
.
GeometryUtils
.
MULTI_POINT
;
import
static
org
.
h2
.
util
.
geometry
.
GeometryUtils
.
MULTI_POLYGON
;
import
static
org
.
h2
.
util
.
geometry
.
GeometryUtils
.
MULTI_POLYGON
;
...
@@ -450,6 +454,51 @@ public final class EWKBUtils {
...
@@ -450,6 +454,51 @@ public final class EWKBUtils {
index
,
total
);
index
,
total
);
}
}
/**
* Converts an envelope to a WKB.
*
* @param envelope
* envelope, or null
* @return WKB, or null
*/
public
static
byte
[]
envelope2wkb
(
double
[]
envelope
)
{
if
(
envelope
==
null
)
{
return
null
;
}
byte
[]
result
;
double
minX
=
envelope
[
MIN_X
],
maxX
=
envelope
[
MAX_X
],
minY
=
envelope
[
MIN_Y
],
maxY
=
envelope
[
MAX_Y
];
if
(
minX
==
maxX
&&
minY
==
maxY
)
{
result
=
new
byte
[
21
];
result
[
4
]
=
POINT
;
Bits
.
writeLong
(
result
,
5
,
Double
.
doubleToRawLongBits
(
minX
));
Bits
.
writeLong
(
result
,
13
,
Double
.
doubleToRawLongBits
(
minY
));
}
else
if
(
minX
==
maxX
||
minY
==
maxY
)
{
result
=
new
byte
[
41
];
result
[
4
]
=
LINE_STRING
;
result
[
8
]
=
2
;
Bits
.
writeLong
(
result
,
9
,
Double
.
doubleToRawLongBits
(
minX
));
Bits
.
writeLong
(
result
,
17
,
Double
.
doubleToRawLongBits
(
minY
));
Bits
.
writeLong
(
result
,
25
,
Double
.
doubleToRawLongBits
(
maxX
));
Bits
.
writeLong
(
result
,
33
,
Double
.
doubleToRawLongBits
(
maxY
));
}
else
{
result
=
new
byte
[
93
];
result
[
4
]
=
POLYGON
;
result
[
8
]
=
1
;
result
[
12
]
=
5
;
Bits
.
writeLong
(
result
,
13
,
Double
.
doubleToRawLongBits
(
minX
));
Bits
.
writeLong
(
result
,
21
,
Double
.
doubleToRawLongBits
(
minY
));
Bits
.
writeLong
(
result
,
29
,
Double
.
doubleToRawLongBits
(
minX
));
Bits
.
writeLong
(
result
,
37
,
Double
.
doubleToRawLongBits
(
maxY
));
Bits
.
writeLong
(
result
,
45
,
Double
.
doubleToRawLongBits
(
maxX
));
Bits
.
writeLong
(
result
,
53
,
Double
.
doubleToRawLongBits
(
maxY
));
Bits
.
writeLong
(
result
,
61
,
Double
.
doubleToRawLongBits
(
maxX
));
Bits
.
writeLong
(
result
,
69
,
Double
.
doubleToRawLongBits
(
minY
));
Bits
.
writeLong
(
result
,
77
,
Double
.
doubleToRawLongBits
(
minX
));
Bits
.
writeLong
(
result
,
85
,
Double
.
doubleToRawLongBits
(
minY
));
}
return
result
;
}
private
EWKBUtils
()
{
private
EWKBUtils
()
{
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/geometry/GeometryUtils.java
浏览文件 @
88fa4120
...
@@ -5,8 +5,6 @@
...
@@ -5,8 +5,6 @@
*/
*/
package
org
.
h2
.
util
.
geometry
;
package
org
.
h2
.
util
.
geometry
;
import
org.h2.util.Bits
;
/**
/**
* Utilities for GEOMETRY data type.
* Utilities for GEOMETRY data type.
*/
*/
...
@@ -119,8 +117,7 @@ public final class GeometryUtils {
...
@@ -119,8 +117,7 @@ public final class GeometryUtils {
* Invoked after writing of a collection.
* Invoked after writing of a collection.
*
*
* @param type
* @param type
* type of collection, see
* type of collection, see {@link #startCollection(int, int)}
* {@link #startCollection(int, int)}
*/
*/
protected
void
endCollection
(
int
type
)
{
protected
void
endCollection
(
int
type
)
{
}
}
...
@@ -474,51 +471,6 @@ public final class GeometryUtils {
...
@@ -474,51 +471,6 @@ public final class GeometryUtils {
return
target
.
getEnvelope
();
return
target
.
getEnvelope
();
}
}
/**
* Converts an envelope to a WKB.
*
* @param envelope
* envelope, or null
* @return WKB, or null
*/
public
static
byte
[]
envelope2wkb
(
double
[]
envelope
)
{
if
(
envelope
==
null
)
{
return
null
;
}
byte
[]
result
;
double
minX
=
envelope
[
MIN_X
],
maxX
=
envelope
[
MAX_X
],
minY
=
envelope
[
MIN_Y
],
maxY
=
envelope
[
MAX_Y
];
if
(
minX
==
maxX
&&
minY
==
maxY
)
{
result
=
new
byte
[
21
];
result
[
4
]
=
POINT
;
Bits
.
writeLong
(
result
,
5
,
Double
.
doubleToRawLongBits
(
minX
));
Bits
.
writeLong
(
result
,
13
,
Double
.
doubleToRawLongBits
(
minY
));
}
else
if
(
minX
==
maxX
||
minY
==
maxY
)
{
result
=
new
byte
[
41
];
result
[
4
]
=
LINE_STRING
;
result
[
8
]
=
2
;
Bits
.
writeLong
(
result
,
9
,
Double
.
doubleToRawLongBits
(
minX
));
Bits
.
writeLong
(
result
,
17
,
Double
.
doubleToRawLongBits
(
minY
));
Bits
.
writeLong
(
result
,
25
,
Double
.
doubleToRawLongBits
(
maxX
));
Bits
.
writeLong
(
result
,
33
,
Double
.
doubleToRawLongBits
(
maxY
));
}
else
{
result
=
new
byte
[
93
];
result
[
4
]
=
POLYGON
;
result
[
8
]
=
1
;
result
[
12
]
=
5
;
Bits
.
writeLong
(
result
,
13
,
Double
.
doubleToRawLongBits
(
minX
));
Bits
.
writeLong
(
result
,
21
,
Double
.
doubleToRawLongBits
(
minY
));
Bits
.
writeLong
(
result
,
29
,
Double
.
doubleToRawLongBits
(
minX
));
Bits
.
writeLong
(
result
,
37
,
Double
.
doubleToRawLongBits
(
maxY
));
Bits
.
writeLong
(
result
,
45
,
Double
.
doubleToRawLongBits
(
maxX
));
Bits
.
writeLong
(
result
,
53
,
Double
.
doubleToRawLongBits
(
maxY
));
Bits
.
writeLong
(
result
,
61
,
Double
.
doubleToRawLongBits
(
maxX
));
Bits
.
writeLong
(
result
,
69
,
Double
.
doubleToRawLongBits
(
minY
));
Bits
.
writeLong
(
result
,
77
,
Double
.
doubleToRawLongBits
(
minX
));
Bits
.
writeLong
(
result
,
85
,
Double
.
doubleToRawLongBits
(
minY
));
}
return
result
;
}
/**
/**
* Checks whether two envelopes intersect with each other.
* Checks whether two envelopes intersect with each other.
*
*
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueGeometry.java
浏览文件 @
88fa4120
...
@@ -157,8 +157,10 @@ public class ValueGeometry extends Value {
...
@@ -157,8 +157,10 @@ public class ValueGeometry extends Value {
* @return the value
* @return the value
*/
*/
public
static
Value
fromEnvelope
(
double
[]
envelope
)
{
public
static
Value
fromEnvelope
(
double
[]
envelope
)
{
return
envelope
!=
null
?
Value
.
cache
(
new
ValueGeometry
(
GeometryUtils
.
envelope2wkb
(
envelope
),
return
envelope
!=
null
GeometryUtils
.
DIMENSION_SYSTEM_XY
,
envelope
)):
ValueNull
.
INSTANCE
;
?
Value
.
cache
(
new
ValueGeometry
(
EWKBUtils
.
envelope2wkb
(
envelope
),
GeometryUtils
.
DIMENSION_SYSTEM_XY
,
envelope
))
:
ValueNull
.
INSTANCE
;
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/unit/TestGeometryUtils.java
浏览文件 @
88fa4120
...
@@ -241,14 +241,14 @@ public class TestGeometryUtils extends TestBase {
...
@@ -241,14 +241,14 @@ public class TestGeometryUtils extends TestBase {
private
void
testEnvelope
(
Envelope
envelopeFromJTS
,
double
[]
envelopeFromH2
)
{
private
void
testEnvelope
(
Envelope
envelopeFromJTS
,
double
[]
envelopeFromH2
)
{
if
(
envelopeFromJTS
.
isNull
())
{
if
(
envelopeFromJTS
.
isNull
())
{
assertNull
(
envelopeFromH2
);
assertNull
(
envelopeFromH2
);
assertNull
(
Geometry
Utils
.
envelope2wkb
(
envelopeFromH2
));
assertNull
(
EWKB
Utils
.
envelope2wkb
(
envelopeFromH2
));
}
else
{
}
else
{
assertEquals
(
envelopeFromJTS
.
getMinX
(),
envelopeFromH2
[
0
]);
assertEquals
(
envelopeFromJTS
.
getMinX
(),
envelopeFromH2
[
0
]);
assertEquals
(
envelopeFromJTS
.
getMaxX
(),
envelopeFromH2
[
1
]);
assertEquals
(
envelopeFromJTS
.
getMaxX
(),
envelopeFromH2
[
1
]);
assertEquals
(
envelopeFromJTS
.
getMinY
(),
envelopeFromH2
[
2
]);
assertEquals
(
envelopeFromJTS
.
getMinY
(),
envelopeFromH2
[
2
]);
assertEquals
(
envelopeFromJTS
.
getMaxY
(),
envelopeFromH2
[
3
]);
assertEquals
(
envelopeFromJTS
.
getMaxY
(),
envelopeFromH2
[
3
]);
assertEquals
(
new
WKBWriter
(
2
).
write
(
new
GeometryFactory
().
toGeometry
(
envelopeFromJTS
)),
assertEquals
(
new
WKBWriter
(
2
).
write
(
new
GeometryFactory
().
toGeometry
(
envelopeFromJTS
)),
Geometry
Utils
.
envelope2wkb
(
envelopeFromH2
));
EWKB
Utils
.
envelope2wkb
(
envelopeFromH2
));
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论