Skip to content

Commit

Permalink
fetch srid for geom table
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-f committed Oct 3, 2023
1 parent acb3a16 commit ec29b63
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,16 @@ public void insertTrainDirectivity() {

@Override
public void initialize(Connection connection, PointNoiseMap pointNoiseMap) throws SQLException {
this.srid = GeometryTableUtilities.getSRID(connection, pointNoiseMap.getSourcesTableName());
if(this.srid == 0) {
this.srid = GeometryTableUtilities.getSRID(connection, pointNoiseMap.getBuildingsTableName());
}
if(this.srid == 0) {
this.srid = GeometryTableUtilities.getSRID(connection, pointNoiseMap.getReceiverTableName());
}
if(ldenConfig.input_mode == LDENConfig.INPUT_MODE.INPUT_MODE_LW_DEN) {
// Fetch source fields
List<String> sourceField = JDBCUtilities.getColumnNames(connection, pointNoiseMap.getSourcesTableName());
this.srid = GeometryTableUtilities.getSRID(connection, pointNoiseMap.getSourcesTableName());
List<Integer> frequencyValues = new ArrayList<>();
List<Integer> allFrequencyValues = Arrays.asList(CnossosPropagationData.DEFAULT_FREQUENCIES_THIRD_OCTAVE);
String period = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ public ProfilerThread getProfilerThread() {
return profilerThread;
}

/**
* @return Receiver table name
*/
public String getReceiverTableName() {
return receiverTableName;
}

/**
* Computation stacks and timing are collected by this class in order
* to profile the execution of the simulation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.h2gis.functions.io.dbf.DBFRead;
import org.h2gis.functions.io.shp.SHPDriverFunction;
import org.h2gis.functions.io.shp.SHPRead;
import org.h2gis.utilities.GeometryTableUtilities;
import org.h2gis.utilities.JDBCUtilities;
import org.junit.After;
import org.junit.Before;
Expand Down Expand Up @@ -1075,7 +1076,7 @@ public void TestPointSource() throws SQLException, IOException {

connection.createStatement().execute("SELECT UpdateGeometrySRID('RCVSCIRCLE', 'THE_GEOM', 2154);");

connection.createStatement().execute("CREATE TABLE RECEIVERS(PK SERIAL PRIMARY KEY, the_geom GEOMETRY(POINTZ) ) AS SELECT (row_number() over())::int, ST_UPDATEZ(ST_FORCE3D(THE_GEOM),5.0) FROM RCVSCIRCLE;");
connection.createStatement().execute("CREATE TABLE RECEIVERS(PK SERIAL PRIMARY KEY, the_geom GEOMETRY(POINTZ, 2154) ) AS SELECT (row_number() over())::int, ST_UPDATEZ(ST_FORCE3D(THE_GEOM),5.0) FROM RCVSCIRCLE;");
// connection.createStatement().execute("UPDATE RCVS20 SET THE_GEOM = ST_UPDATEZ(ST_FORCE3D(THE_GEOM),5.0);");
connection.createStatement().execute("UPDATE SOURCESI SET THE_GEOM = ST_UPDATEZ(THE_GEOM,10.0);");
connection.createStatement().execute("SELECT UpdateGeometrySRID('NO_BUILD', 'THE_GEOM', 2154);");
Expand Down Expand Up @@ -1136,6 +1137,8 @@ public void TestPointSource() throws SQLException, IOException {
assertEquals(4361, rs.getInt(1));
}

assertEquals(2154, GeometryTableUtilities.getSRID(connection, ldenConfig.lDayTable));

try(ResultSet rs = connection.createStatement().executeQuery("SELECT * FROM "+ ldenConfig.lDayTable+" ORDER BY IDRECEIVER")) {
assertTrue(rs.next());
assertEquals(1, rs.getInt("IDRECEIVER"));
Expand Down

0 comments on commit ec29b63

Please sign in to comment.