Unverified 提交 7d2fd6e9 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov 提交者: GitHub

Merge pull request #1445 from katzyn/geometry

Use PostGIS-compatible format for SRID-only constraint in GEOMETRY
...@@ -3037,8 +3037,15 @@ ENUM('clubs', 'diamonds', 'hearts', 'spades') ...@@ -3037,8 +3037,15 @@ ENUM('clubs', 'diamonds', 'hearts', 'spades')
" "
"Data Types","GEOMETRY Type"," "Data Types","GEOMETRY Type","
GEOMETRY GEOMETRY
[({ sridInt | { {POINT|LINESTRING|POLYGON|MULTIPOINT|MULTILINESTRING [({ GEOMETRY |
|MULTIPOLYGON|GEOMETRYCOLLECTION} [Z|M|ZM] [, sridInt]} })] { POINT
| LINESTRING
| POLYGON
| MULTIPOINT
| MULTILINESTRING
| MULTIPOLYGON
| GEOMETRYCOLLECTION } [Z|M|ZM]}
[, sridInt] )]
"," ","
A spatial geometry type. A spatial geometry type.
If additional constraints are not specified this type accepts all supported types of geometries. If additional constraints are not specified this type accepts all supported types of geometries.
...@@ -3046,8 +3053,8 @@ A constraint with required geometry type and dimension system can be set by spec ...@@ -3046,8 +3053,8 @@ A constraint with required geometry type and dimension system can be set by spec
dimension system. A whitespace between them is optional. dimension system. A whitespace between them is optional.
2D dimension system does not have a name and assumed if only a geometry type name is specified. 2D dimension system does not have a name and assumed if only a geometry type name is specified.
POINT means 2D point, POINT Z or POINTZ means 3D point. POINT means 2D point, POINT Z or POINTZ means 3D point.
GEOMETRY constraint means no restrictions on type or dimension system of geometry.
A constraint with required spatial reference system identifier (SRID) can be set by specifying this identifier. A constraint with required spatial reference system identifier (SRID) can be set by specifying this identifier.
Both constraints for type and SRID can be specified together.
Mapped to ""org.locationtech.jts.geom.Geometry"" if JTS library is in classpath and to ""java.lang.String"" otherwise. Mapped to ""org.locationtech.jts.geom.Geometry"" if JTS library is in classpath and to ""java.lang.String"" otherwise.
May be represented in textual format using the WKT (well-known text) or EWKT (extended well-known text) format. May be represented in textual format using the WKT (well-known text) or EWKT (extended well-known text) format.
...@@ -3064,7 +3071,7 @@ GEOMETRY ...@@ -3064,7 +3071,7 @@ GEOMETRY
GEOMETRY(POINT) GEOMETRY(POINT)
GEOMETRY(POINT Z) GEOMETRY(POINT Z)
GEOMETRY(POINT Z, 4326) GEOMETRY(POINT Z, 4326)
GEOMETRY(4326) GEOMETRY(GEOMETRY, 4326)
" "
"Data Types","INTERVAL Type"," "Data Types","INTERVAL Type","
......
...@@ -5049,7 +5049,10 @@ public class Parser { ...@@ -5049,7 +5049,10 @@ public class Parser {
if (extTypeInfo == null) { if (extTypeInfo == null) {
if (readIf(OPEN_PAREN)) { if (readIf(OPEN_PAREN)) {
int type = 0; int type = 0;
if (currentTokenType == IDENTIFIER && !currentTokenQuoted) { if (currentTokenType != IDENTIFIER || currentTokenQuoted) {
throw getSyntaxError();
}
if (!readIf("GEOMETRY")) {
try { try {
type = EWKTUtils.parseGeometryType(currentToken); type = EWKTUtils.parseGeometryType(currentToken);
read(); read();
...@@ -5062,7 +5065,7 @@ public class Parser { ...@@ -5062,7 +5065,7 @@ public class Parser {
} }
} }
Integer srid = null; Integer srid = null;
if (type == 0 || readIf(COMMA)) { if (readIf(COMMA)) {
srid = readInt(); srid = readInt();
} }
read(CLOSE_PAREN); read(CLOSE_PAREN);
......
...@@ -24,14 +24,13 @@ public final class ExtTypeInfoGeometry extends ExtTypeInfo { ...@@ -24,14 +24,13 @@ public final class ExtTypeInfoGeometry extends ExtTypeInfo {
} }
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append('('); builder.append('(');
if (type != 0) { if (type == 0) {
builder.append("GEOMETRY");
} else {
builder.append(EWKTUtils.formatGeometryTypeAndDimensionSystem(type)); builder.append(EWKTUtils.formatGeometryTypeAndDimensionSystem(type));
} }
if (srid != null) { if (srid != null) {
if (type != 0) { builder.append(", ").append((int) srid);
builder.append(", ");
}
builder.append((int) srid);
} }
return builder.append(')').toString(); return builder.append(')').toString();
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
-- Initial Developer: H2 Group -- Initial Developer: H2 Group
-- --
CREATE TABLE TEST(G GEOMETRY, G_S GEOMETRY(1), P GEOMETRY(POINT), P_S GEOMETRY(POINT, 1), CREATE TABLE TEST(G GEOMETRY, G_S GEOMETRY(GEOMETRY, 1), P GEOMETRY(POINT), P_S GEOMETRY(POINT, 1),
PZ1 GEOMETRY(POINT Z), PZ2 GEOMETRY(POINTZ), PZ1_S GEOMETRY(POINT Z, 1), PZ2_S GEOMETRY(POINTZ, 1), PZ1 GEOMETRY(POINT Z), PZ2 GEOMETRY(POINTZ), PZ1_S GEOMETRY(POINT Z, 1), PZ2_S GEOMETRY(POINTZ, 1),
PM GEOMETRY(POINT M), PZM GEOMETRY(POINT ZM), PZM_S GEOMETRY(POINT ZM, -100), PM GEOMETRY(POINT M), PZM GEOMETRY(POINT ZM), PZM_S GEOMETRY(POINT ZM, -100),
LS GEOMETRY(LINESTRING), PG GEOMETRY(POLYGON), LS GEOMETRY(LINESTRING), PG GEOMETRY(POLYGON),
...@@ -24,7 +24,7 @@ SELECT COLUMN_NAME, TYPE_NAME, COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS ...@@ -24,7 +24,7 @@ SELECT COLUMN_NAME, TYPE_NAME, COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS
> COLUMN_NAME TYPE_NAME COLUMN_TYPE > COLUMN_NAME TYPE_NAME COLUMN_TYPE
> ----------- --------- ---------------------------- > ----------- --------- ----------------------------
> G GEOMETRY GEOMETRY > G GEOMETRY GEOMETRY
> G_S GEOMETRY GEOMETRY(1) > G_S GEOMETRY GEOMETRY(GEOMETRY, 1)
> P GEOMETRY GEOMETRY(POINT) > P GEOMETRY GEOMETRY(POINT)
> P_S GEOMETRY GEOMETRY(POINT, 1) > P_S GEOMETRY GEOMETRY(POINT, 1)
> PZ1 GEOMETRY GEOMETRY(POINT Z) > PZ1 GEOMETRY GEOMETRY(POINT Z)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论