Revision 6526 trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/impl/buffer/fmap/BufferVisitor.java
BufferVisitor.java | ||
---|---|---|
45 | 45 |
* |
46 | 46 |
* $Id$ |
47 | 47 |
* $Log$ |
48 |
* Revision 1.2 2006-07-21 11:04:50 azabala |
|
48 |
* Revision 1.3 2006-07-26 18:06:27 azabala |
|
49 |
* fixed bug when internal buffers collapses geometries |
|
50 |
* |
|
51 |
* Revision 1.2 2006/07/21 11:04:50 azabala |
|
49 | 52 |
* Unified createTask and process() methods |
50 | 53 |
* |
51 | 54 |
* Revision 1.1 2006/06/20 18:20:45 azabala |
... | ... | |
334 | 337 |
bufOp.setEndCapStyle(cap); |
335 | 338 |
Geometry out = bufOp.getResultGeometry(distRing); |
336 | 339 |
Geometry in = bufOp.getResultGeometry(-1 * distRing); |
337 |
// Geometry out = BufferOp.bufferOp(inputParam, distRing, cap); |
|
338 |
// Geometry in = BufferOp.bufferOp(inputParam, -1 * distRing, cap); |
|
340 |
boolean collapsedInterior = verifyNilGeometry(in); |
|
339 | 341 |
if(previousExteriorRing == null || previousInteriorRing == null){ |
340 |
solution = out.difference(in); |
|
342 |
if(collapsedInterior) |
|
343 |
solution = out; |
|
344 |
else |
|
345 |
solution = out.difference(in); |
|
341 | 346 |
}else{ |
342 |
Geometry outRing = out.difference(previousExteriorRing); |
|
343 |
Geometry inRing = previousInteriorRing.difference(in); |
|
344 |
Geometry[] geomArray = new Geometry[]{outRing, inRing}; |
|
345 |
solution = geomFact.createGeometryCollection(geomArray); |
|
346 |
//FMap doesnt work with GeometryCollection, so we try |
|
347 |
//to pass to a MultiPolygon. |
|
348 |
ArrayList polygons = new ArrayList(); |
|
349 |
Stack stack = new Stack(); |
|
350 |
stack.push(solution); |
|
351 |
while(stack.size() != 0){ |
|
352 |
GeometryCollection geCol = |
|
353 |
(GeometryCollection) stack.pop(); |
|
354 |
for(int j = 0; j < geCol.getNumGeometries(); j++){ |
|
355 |
Geometry geometry = geCol.getGeometryN(j); |
|
356 |
if(geometry instanceof GeometryCollection) |
|
357 |
stack.push(geometry); |
|
358 |
if(geometry instanceof Polygon) |
|
359 |
polygons.add(geometry); |
|
360 |
}//for |
|
361 |
}//for |
|
362 |
Polygon[] pols = new Polygon[polygons.size()]; |
|
363 |
polygons.toArray(pols); |
|
364 |
MultiPolygon newSolution = geomFact.createMultiPolygon(pols); |
|
365 |
solution = newSolution; |
|
347 |
if(collapsedInterior){ |
|
348 |
solution = out.difference(previousExteriorRing); |
|
349 |
}else{ |
|
350 |
Geometry outRing = out.difference(previousExteriorRing); |
|
351 |
Geometry inRing = previousInteriorRing.difference(in); |
|
352 |
Geometry[] geomArray = new Geometry[]{outRing, inRing}; |
|
353 |
solution = geomFact.createGeometryCollection(geomArray); |
|
354 |
//FMap doesnt work with GeometryCollection, so we try |
|
355 |
//to pass to a MultiPolygon. |
|
356 |
ArrayList polygons = new ArrayList(); |
|
357 |
Stack stack = new Stack(); |
|
358 |
stack.push(solution); |
|
359 |
while(stack.size() != 0){ |
|
360 |
GeometryCollection geCol = |
|
361 |
(GeometryCollection) stack.pop(); |
|
362 |
for(int j = 0; j < geCol.getNumGeometries(); j++){ |
|
363 |
Geometry geometry = geCol.getGeometryN(j); |
|
364 |
if(geometry instanceof GeometryCollection) |
|
365 |
stack.push(geometry); |
|
366 |
if(geometry instanceof Polygon) |
|
367 |
polygons.add(geometry); |
|
368 |
}//for |
|
369 |
}//while |
|
370 |
Polygon[] pols = new Polygon[polygons.size()]; |
|
371 |
polygons.toArray(pols); |
|
372 |
MultiPolygon newSolution = geomFact.createMultiPolygon(pols); |
|
373 |
solution = newSolution; |
|
374 |
} |
|
366 | 375 |
}//else |
367 | 376 |
numProcessed++; |
368 | 377 |
IFeature feature = createFeature(solution, -1 * distRing, distRing); |
369 | 378 |
resultsProcessor.processFeature(feature); |
370 | 379 |
previousExteriorRing = out; |
371 |
previousInteriorRing = in; |
|
380 |
if(!collapsedInterior) |
|
381 |
previousInteriorRing = in; |
|
372 | 382 |
}//for |
373 | 383 |
}//else |
374 | 384 |
|
375 | 385 |
} |
376 | 386 |
|
387 |
|
|
388 |
|
|
377 | 389 |
/** |
378 | 390 |
* Creates a feature for a simple buffer process for polygons |
379 | 391 |
* (the result feature will have a field with the buffer distance) |
Also available in: Unified diff