Skip to content

Commit

Permalink
deegree#1578 - set srid in created SQL for blob mode and PostgreSQL
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoltz committed Nov 30, 2023
1 parent 0539679 commit 3f0b8d0
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public PostGISDDLCreator(MappedAppSchema schema, SQLDialect dialect) {

@Override
protected List<String> getBLOBCreates() {
String srid = detectSrid();
List<String> ddl = new ArrayList<String>();

// create feature_type table
Expand All @@ -90,7 +91,7 @@ protected List<String> getBLOBCreates() {
ddl.add("CREATE TABLE " + ftTable + " (id smallint PRIMARY KEY, qname text NOT NULL)");
ddl.add("COMMENT ON TABLE " + ftTable + " IS 'Ids and bboxes of concrete feature types'");
ddl.add("SELECT ADDGEOMETRYCOLUMN('" + ftTableSchema.toLowerCase() + "', '" + ftTable.getTable().toLowerCase()
+ "','bbox','" + undefinedSrid + "','GEOMETRY',2)");
+ "','bbox','" + srid + "','GEOMETRY',2)");

// populate feature_type table
for (short ftId = 0; ftId < schema.getFts(); ftId++) {
Expand All @@ -105,7 +106,7 @@ protected List<String> getBLOBCreates() {
+ "gml_id text UNIQUE NOT NULL, ft_type smallint REFERENCES " + ftTable + " , binary_object bytea)");
ddl.add("COMMENT ON TABLE " + blobTable + " IS 'All objects (features and geometries)'");
ddl.add("SELECT ADDGEOMETRYCOLUMN('" + blobTableSchema.toLowerCase() + "', '"
+ blobTable.getTable().toLowerCase() + "','gml_bounded_by','" + undefinedSrid + "','GEOMETRY',2)");
+ blobTable.getTable().toLowerCase() + "','gml_bounded_by','" + srid + "','GEOMETRY',2)");
ddl.add("ALTER TABLE " + blobTable + " ADD CONSTRAINT gml_objects_geochk CHECK (ST_IsValid(gml_bounded_by))");
ddl.add("CREATE INDEX gml_objects_sidx ON " + blobTable + " USING GIST (gml_bounded_by)");
// ddl.add( "CREATE TABLE gml_names (gml_object_id integer REFERENCES
Expand All @@ -114,6 +115,13 @@ protected List<String> getBLOBCreates() {
return ddl;
}

private String detectSrid() {
String srid = schema.getGeometryParams().getSrid();
if (srid != null)
return srid;
return undefinedSrid;
}

private List<StringBuffer> getGeometryCreate(GeometryMapping mapping, DBField dbField, TableName table) {
List<StringBuffer> ddls = new ArrayList<StringBuffer>();
StringBuffer sql = new StringBuffer();
Expand Down

0 comments on commit 3f0b8d0

Please sign in to comment.