(Band SrcBand, Band ProximityBand,
float DistMult, float MaxDistance, float NoData,
boolean HasBufferValue, float BufferValue, int TargetValues[])
| 253 | } |
| 254 | |
| 255 | public static void Run(Band SrcBand, Band ProximityBand, |
| 256 | float DistMult, float MaxDistance, float NoData, |
| 257 | boolean HasBufferValue, float BufferValue, int TargetValues[]) { |
| 258 | |
| 259 | /* |
| 260 | * What is our maxdist value? |
| 261 | */ |
| 262 | |
| 263 | if (MaxDistance == -1.0F) { |
| 264 | MaxDistance = SrcBand.GetXSize() + SrcBand.GetYSize(); |
| 265 | } |
| 266 | |
| 267 | /* |
| 268 | * Create working band |
| 269 | */ |
| 270 | |
| 271 | Band WorkProximityBand = ProximityBand; |
| 272 | Dataset WorkProximityDS = null; |
| 273 | |
| 274 | int ProxType = ProximityBand.getDataType(); |
| 275 | |
| 276 | String tempFilename = null; |
| 277 | |
| 278 | if (ProxType == gdalconstConstants.GDT_Byte |
| 279 | || ProxType == gdalconstConstants.GDT_UInt16 |
| 280 | || ProxType == gdalconstConstants.GDT_UInt32) { |
| 281 | tempFilename = "/vsimem/proximity_" + String.valueOf(System.currentTimeMillis()) + ".tif"; |
| 282 | WorkProximityDS = gdal.GetDriverByName("GTiff").Create(tempFilename, |
| 283 | ProximityBand.getXSize(), ProximityBand.getYSize(), 1, |
| 284 | gdalconstConstants.GDT_Float32); |
| 285 | WorkProximityBand = WorkProximityDS.GetRasterBand(1); |
| 286 | } |
| 287 | |
| 288 | int xSize = WorkProximityBand.getXSize(); |
| 289 | int ySize = WorkProximityBand.getYSize(); |
| 290 | |
| 291 | /* |
| 292 | * Allocate buffers |
| 293 | */ |
| 294 | |
| 295 | short nearXBuffer[] = new short[xSize]; |
| 296 | short nearYBuffer[] = new short[xSize]; |
| 297 | int scanline[] = new int[xSize]; |
| 298 | float proximityBuffer[] = new float[xSize]; |
| 299 | |
| 300 | /* |
| 301 | * Loop from top to bottom of the image |
| 302 | */ |
| 303 | |
| 304 | for (int i = 0; i < xSize; i++) { |
| 305 | nearXBuffer[i] = -1; |
| 306 | nearYBuffer[i] = -1; |
| 307 | } |
| 308 | |
| 309 | for (int iLine = 0; iLine < ySize; iLine++) { |
| 310 | |
| 311 | SrcBand.ReadRaster(0, iLine, xSize, 1, xSize, 1, |
| 312 | gdalconstConstants.GDT_Int32, scanline); |
no test coverage detected