MCPcopy Create free account
hub / github.com/OSGeo/gdal / Run

Method Run

swig/java/apps/GDALProximity.java:255–412  ·  view source on GitHub ↗
(Band SrcBand, Band ProximityBand,
            float DistMult, float MaxDistance, float NoData,
            boolean HasBufferValue, float BufferValue, int TargetValues[])

Source from the content-addressed store, hash-verified

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);

Callers 1

mainMethod · 0.95

Calls 14

ProcessProximityLineMethod · 0.95
getDataTypeMethod · 0.80
getXSizeMethod · 0.80
getYSizeMethod · 0.80
deleteMethod · 0.80
GetXSizeMethod · 0.45
GetYSizeMethod · 0.45
CreateMethod · 0.45
GetDriverByNameMethod · 0.45
GetRasterBandMethod · 0.45
ReadRasterMethod · 0.45
WriteRasterMethod · 0.45

Tested by

no test coverage detected