Skip to content

Commit

Permalink
minor change
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhihang Yao committed Jul 4, 2024
1 parent 63c9572 commit 976ccfc
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,22 @@ public int getMaximumNumberOfItemsForInOperator() {
@Override
public String getFeatureHierarchyQuery() {
try {
return featureHierarchyQuery.get();
return PlainText.of(featureHierarchyQuery.get(),
PlainText.of("F.ENVELOPE"),
PlainText.of("G.GEOMETRY"),
PlainText.of("A.MULTI_POINT")).toString();
} catch (Exception e) {
throw new IllegalStateException("Failed to create feature hierarchy query.", e);
}
}

@Override
public String getFeatureHierarchyQuery(int targetSRID) {
try {
return PlainText.of(featureHierarchyQuery.get(),
PlainText.of(getTransformOperator("F.ENVELOPE", targetSRID)),
PlainText.of(getTransformOperator("G.GEOMETRY", targetSRID)),
PlainText.of(getTransformOperator("A.MULTI_POINT", targetSRID))).toString();
} catch (Exception e) {
throw new IllegalStateException("Failed to create feature hierarchy query.", e);
}
Expand Down Expand Up @@ -155,7 +170,7 @@ private String readFeatureHierarchyQuery() throws IOException {
}
}

public String readRecursiveImplicitGeometryQuery() throws IOException {
private String readRecursiveImplicitGeometryQuery() throws IOException {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(Objects.requireNonNull(
SchemaAdapter.class.getResourceAsStream("/org/citydb/database/postgres/query_recursive_implicit_geometry.sql"))))) {
return reader.lines()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.citydb.database.util.SqlHelper;
import org.citydb.sqlbuilder.common.SqlObject;
import org.citydb.sqlbuilder.query.Select;
import org.citydb.sqlbuilder.util.PlainText;

public abstract class SchemaAdapter {
protected final DatabaseAdapter adapter;
Expand All @@ -51,6 +52,8 @@ protected SchemaAdapter(DatabaseAdapter adapter) {

public abstract String getFeatureHierarchyQuery();

public abstract String getFeatureHierarchyQuery(int targetSRID);

public abstract SqlObject getRecursiveImplicitGeometryQuery(Select featureQuery);

public abstract String getCreateIndex(Index index);
Expand Down Expand Up @@ -84,4 +87,10 @@ public SqlHelper getSqlHelper() {
public IndexHelper getIndexHelper() {
return indexHelper;
}

public String getTransformOperator(String column, int targetSRID) {
return adapter.getGeometryAdapter().getSpatialOperationHelper()
.transform(PlainText.of(column), targetSRID)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,7 @@ public String getInOperator(String column, Set<Long> values) {
public String getTransformOperator(String column) {
return adapter.getDatabaseMetadata().getSpatialReference().getSRID() == getSRID() ?
column :
adapter.getGeometryAdapter().getSpatialOperationHelper()
.transform(PlainText.of(column), getSRID())
.toString();
adapter.getSchemaAdapter().getTransformOperator(column, getSRID());
}

Feature exportFeature(long id, long sequenceId) throws ExportException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.citydb.operation.exporter.ExportHelper;
import org.citydb.operation.exporter.common.DatabaseExporter;
import org.citydb.operation.exporter.hierarchy.HierarchyBuilder;
import org.citydb.sqlbuilder.util.PlainText;

import java.sql.ResultSet;
import java.sql.SQLException;
Expand All @@ -42,11 +41,9 @@ public FeatureExporter(ExportHelper helper) throws SQLException {
}

private String getQuery() {
return PlainText.of(adapter.getSchemaAdapter().getFeatureHierarchyQuery(),
PlainText.of(helper.getTransformOperator("F.ENVELOPE")),
PlainText.of(helper.getTransformOperator("G.GEOMETRY")),
PlainText.of(helper.getTransformOperator("A.MULTI_POINT"))
).toString();
return adapter.getDatabaseMetadata().getSpatialReference().getSRID() == helper.getSRID() ?
adapter.getSchemaAdapter().getFeatureHierarchyQuery() :
adapter.getSchemaAdapter().getFeatureHierarchyQuery(helper.getSRID());
}

public Feature doExport(long id) throws ExportException, SQLException {
Expand Down

0 comments on commit 976ccfc

Please sign in to comment.