提交 54b2b09c authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Fix dimension system detection for empty geometries (EWKB and EWKT only)

上级 df4cc289
...@@ -366,6 +366,7 @@ public final class EWKBUtils { ...@@ -366,6 +366,7 @@ public final class EWKBUtils {
case DIMENSION_SYSTEM_XYM: case DIMENSION_SYSTEM_XYM:
useM = true; useM = true;
} }
target.dimensionSystem((useZ ? DIMENSION_SYSTEM_XYZ : 0) | (useM ? DIMENSION_SYSTEM_XYM : 0));
type %= 1_000; type %= 1_000;
switch (type) { switch (type) {
case POINT: case POINT:
......
...@@ -715,6 +715,7 @@ public final class EWKTUtils { ...@@ -715,6 +715,7 @@ public final class EWKTUtils {
type = POLYGON; type = POLYGON;
break; break;
} }
target.dimensionSystem(dimensionSystem);
switch (type) { switch (type) {
case POINT: { case POINT: {
if (parentType != 0 && parentType != MULTI_POINT && parentType != GEOMETRY_COLLECTION) { if (parentType != 0 && parentType != MULTI_POINT && parentType != GEOMETRY_COLLECTION) {
......
...@@ -27,6 +27,15 @@ public final class GeometryUtils { ...@@ -27,6 +27,15 @@ public final class GeometryUtils {
protected void init(int srid) { protected void init(int srid) {
} }
/**
* Invoked to add dimension system requirement.
*
* @param dimensionSystem
* dimension system
*/
protected void dimensionSystem(int dimensionSystem) {
}
/** /**
* Invoked before writing a POINT. * Invoked before writing a POINT.
*/ */
...@@ -238,6 +247,16 @@ public final class GeometryUtils { ...@@ -238,6 +247,16 @@ public final class GeometryUtils {
public DimensionSystemTarget() { public DimensionSystemTarget() {
} }
@Override
protected void dimensionSystem(int dimensionSystem) {
if ((dimensionSystem & DIMENSION_SYSTEM_XYZ) != 0) {
hasZ = true;
}
if ((dimensionSystem & DIMENSION_SYSTEM_XYM) != 0) {
hasM = true;
}
}
@Override @Override
protected void addCoordinate(double x, double y, double z, double m, int index, int total) { protected void addCoordinate(double x, double y, double z, double m, int index, int total) {
if (!hasZ && !Double.isNaN(z)) { if (!hasZ && !Double.isNaN(z)) {
...@@ -288,6 +307,16 @@ public final class GeometryUtils { ...@@ -288,6 +307,16 @@ public final class GeometryUtils {
public EnvelopeAndDimensionSystemTarget() { public EnvelopeAndDimensionSystemTarget() {
} }
@Override
protected void dimensionSystem(int dimensionSystem) {
if ((dimensionSystem & DIMENSION_SYSTEM_XYZ) != 0) {
hasZ = true;
}
if ((dimensionSystem & DIMENSION_SYSTEM_XYM) != 0) {
hasM = true;
}
}
@Override @Override
protected void startPoint() { protected void startPoint() {
enabled = true; enabled = true;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论