// Path: src/main/java/org/openstreetmap/osmaxil/model/ElevationImport.java
// public class ElevationImport extends AbstractImport {
// 
// 	// private Coordinates coordinates;
// 
// 	public float x, y, z;
// 
// 	public ElevationImport(float x, float y, float z) {
// 		this.x = x;
// 		this.y = y;
// 		this.z = z;
// 		this.setId(Math.round(z));
// 	}
// 
// 	@Override
// 	public String getValueByTagName(String tagName) {
// 		return "Sorry, there is no tag for that type of import";
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return "Elevation import with x=" + x + " y=" + y + " z=" + z;
// 	}
// 
// }


import java.util.ArrayList;
import java.util.List;
import org.gdal.gdal.Band;
import org.gdal.gdal.Dataset;
import org.gdal.gdal.gdal;
import org.gdal.gdalconst.gdalconstConstants;
import org.openstreetmap.osmaxil.model.ElevationImport;

		int numBands = dataset.getRasterCount();
		bands = new ArrayList<>();
		LOGGER.info("Number of bands is: " + numBands);
		for (int i = 1; i <= numBands; i++) {
			this.bands.add(dataset.GetRasterBand(i));
		}
		// Store the coordinates of the lower left point
		double[] geotransform = dataset.GetGeoTransform();
		this.xUpperLeft = geotransform[0];
		this.yUpperLeft = geotransform[3];
		LOGGER.info("Upper left coordinates are: " + this.xUpperLeft + " " + this.yUpperLeft);
		// Store the pixel sizes
		this.xPixelSize = geotransform[1];
		this.yPixelSize = Math.abs(geotransform[5]);
		LOGGER.info("Pixel sizes are: " + this.xPixelSize + " " + this.yPixelSize);
	}

	@Override
	public ElevationImport findElevationByCoordinates(float x, float y, float valueScale, int srid) {
		int xFile = (int) Math.round((x - xUpperLeft) / this.xPixelSize);
		int yFile = (int) Math.round((yUpperLeft - y) / this.yPixelSize);
		float[] data = new float[1];
		bands.get(0).ReadRaster(xFile, yFile, 1, 1, data);
		ElevationImport result = new ElevationImport(x, y, data[0] * valueScale);
		return result;
	}

	@Override
	public List<ElevationImport> findAllElevationsByGeometry(String includingGeomAsWKT, String excludingGeomAsWKT, float valueScale, float shrinkRadius,
			int geomSrid) {

// Path: src/main/java/org/openstreetmap/osmaxil/model/ElevationImport.java
// public class ElevationImport extends AbstractImport {
// 
// 	// private Coordinates coordinates;
// 
// 	public float x, y, z;
// 
// 	public ElevationImport(float x, float y, float z) {
// 		this.x = x;
// 		this.y = y;
// 		this.z = z;
// 		this.setId(Math.round(z));
// 	}
// 
// 	@Override
// 	public String getValueByTagName(String tagName) {
// 		return "Sorry, there is no tag for that type of import";
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return "Elevation import with x=" + x + " y=" + y + " z=" + z;
// 	}
// 
// }


// Path: src/main/java/org/openstreetmap/osmaxil/dao/ElevationRasterFile.java
import java.util.ArrayList;
import java.util.List;
import org.gdal.gdal.Band;
import org.gdal.gdal.Dataset;
import org.gdal.gdal.gdal;
import org.gdal.gdalconst.gdalconstConstants;
import org.openstreetmap.osmaxil.model.ElevationImport;

		int numBands = dataset.getRasterCount();
		bands = new ArrayList<>();
		LOGGER.info("Number of bands is: " + numBands);
		for (int i = 1; i <= numBands; i++) {
			this.bands.add(dataset.GetRasterBand(i));
		}
		// Store the coordinates of the lower left point
		double[] geotransform = dataset.GetGeoTransform();
		this.xUpperLeft = geotransform[0];
		this.yUpperLeft = geotransform[3];
		LOGGER.info("Upper left coordinates are: " + this.xUpperLeft + " " + this.yUpperLeft);
		// Store the pixel sizes
		this.xPixelSize = geotransform[1];
		this.yPixelSize = Math.abs(geotransform[5]);
		LOGGER.info("Pixel sizes are: " + this.xPixelSize + " " + this.yPixelSize);
	}

	@Override
	public ElevationImport findElevationByCoordinates(float x, float y, float valueScale, int srid) {
		int xFile = (int) Math.round((x - xUpperLeft) / this.xPixelSize);
		int yFile = (int) Math.round((yUpperLeft - y) / this.yPixelSize);
		float[] data = new float[1];
		bands.get(0).ReadRaster(xFile, yFile, 1, 1, data);
		ElevationImport result = new ElevationImport(x, y, data[0] * valueScale);
		return result;
	}

	@Override
	public List<ElevationImport> findAllElevationsByGeometry(String includingGeomAsWKT, String excludingGeomAsWKT, float valueScale, float shrinkRadius,
			int geomSrid) {

		List<ElevationImport> result = new ArrayList<>();
