请问最新版本的Addax是否支持Postgres空间数据库的Geometry类型 #935
Answered
by
wgzhao
snowfield516
asked this question in
Q&A
-
|
Beta Was this translation helpful? Give feedback.
Answered by
wgzhao
Nov 5, 2023
Replies: 2 comments 2 replies
-
如果只是读取 postgresql 里的 geometry 类型数据,你可以在 CREATE TABLE geometries (name varchar, geom geometry);
INSERT INTO geometries VALUES
('Point', 'POINT(0 0)'),
('Linestring', 'LINESTRING(0 0, 1 1, 2 1, 2 2)'),
('Polygon', 'POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))'),
('PolygonWithHole', 'POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(1 1, 1 2, 2 2, 2 1, 1 1))'),
('Collection', 'GEOMETRYCOLLECTION(POINT(2 0),POLYGON((0 0, 1 0, 1 1, 0 1, 0 0)))'); 你可以使用如下的配置文件来读取上述表的内容 {
"job": {
"setting": {
"speed": {
"byte": -1,
"channel": 1
}
},
"content": [
{
"reader": {
"name": "postgresqlreader",
"parameter": {
"username": "pguser",
"password": "pguser123",
"column": [
"name", "ST_AsText(geom)"
],
"connection": [
{
"table": [
"geometries"
],
"jdbcUrl": [
"jdbc:postgresql://127.0.0.1:54321/pguser"
]
}
],
"where": ""
}
},
"writer": {
"name": "streamwriter",
"parameter": {
"encoding": "utf-8",
"print": true
}
}
}
]
}
} 其结果类似如下:
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
snowfield516
-
如果是写入 postgresql geometry 类型数据,也可以使用上述同样的方法,这里给出一个配置示例: {
"job": {
"setting": {
"speed": {
"byte": -1,
"channel": 1
}
},
"content": [
{
"reader": {
"name": "postgresqlreader",
"parameter": {
"username": "pguser",
"password": "pguser123",
"column": [
"name", "ST_AsText(geom)"
],
"connection": [
{
"table": [
"geometries"
],
"jdbcUrl": [
"jdbc:postgresql://127.0.0.1:54321/pguser"
]
}
],
"where": ""
}
},
"writer": {
"name": "postgresqlwriter",
"parameter": {
"username": "pguser",
"password": "pguser123",
"column": [
"name", "geom"
],
"connection": [
{
"table": [
"tbl_geo"
],
"jdbcUrl": "jdbc:postgresql://127.0.0.1:54321/pguser"
}
]
}
}
}
]
}
} 执行结果类似如下:
表结果内容为 # select name, ST_AsText(geom) as geom from tbl_geo;
name | geom
-----------------+---------------------------------------------------------------
Point | POINT(0 0)
Linestring | LINESTRING(0 0,1 1,2 1,2 2)
Polygon | POLYGON((0 0,1 0,1 1,0 1,0 0))
PolygonWithHole | POLYGON((0 0,10 0,10 10,0 10,0 0),(1 1,1 2,2 2,2 1,1 1))
Collection | GEOMETRYCOLLECTION(POINT(2 0),POLYGON((0 0,1 0,1 1,0 1,0 0)))
(5 rows) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
如果只是读取 postgresql 里的 geometry 类型数据,你可以在
column
里使用ST_AsText(geom)
方式来读取数据,假定有如下的表以及相应的数据你可以使用如下的配置文件来读取上述表的内容