Hi everyone, there’s no Rugged-related post on this forum so i’m gonna go first and still hope for answers:
The example with the artificial volcano-DEM and the documentation led me to believe that we must code our own class implementing the TileUpdater interface in order to feed Rugged with a DEM.
Isn’t it possible to directly read an external file or any workaround to still use the RuggedBuilder.setDigitalElevationModel(xxx) method ?
Or is my only option to implement TileUpdater with a file reader ?
You will have to implement TileUpdater.
This is in fact a design decision. In an early version of Rugged, there was an updater that directly parsed Geotiff files. However, it was considered to be a dead end to maintain this as:
there are several different DEM formats
there are lots of very good libraries to read standard formats (typically gdal)
some Earth observing mission even use the own internal format
So we decided to drop the parsing of DEM in Rugged itself.
We also refrained from adding a dependency to gdal. This second design decision was due to the fact Rugged is quite low level and imposing at this level a specific version of gdal was considered a risk to introduce incompatibilities for users. In operational projects, Rugged is called from a stack of upper level
libraries, and these libraries often already depend on gdal, so letting these upper level layers select their
gdal version and use it to implement TileUpdater was considered a good compromise.
Thank you very much for the fast answer and the detailed explanations.
I understand your reasons and will put my hands back into some Java then! (I am using it from Matlab).
public double[][] altitude;
public double minLat;
public double minLon;
public double stepLat;
public double stepLon;
public int nLat;
public int nLon;
public DEMTile(double[][] altitude, double minLat, double minLon, double stepLat, double stepLon, int nLat, int nLon) {
this.altitude = altitude;
this.minLat = minLat;
this.minLon = minLon;
this.stepLat = stepLat;
this.stepLon = stepLon;
this.nLat = nLat;
this.nLon = nLon;
}
public void updateTile(double latitude, double longitude, UpdatableTile tile)
throws RuggedException {
tile.setGeometry(this.minLat, this.minLon, this.stepLat, this.stepLon, this.nLat, this.nLon);
for (int i = 0; i < nLat; ++i) {
for (int j = 0; j < nLon; ++j) {
tile.setElevation(i, j, altitude[i][j]);
}
}
}
}
Here is the class, i simply load all the values of my regularly sampled tile in altitude[][]. I’m using a DEM that i know is covering my area so this does the job good enough.