Revision 32916
trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/impl/buffer/fmap/AttributeBufferVisitor.java | ||
---|---|---|
153 | 153 |
resultsProcessor.finish(); |
154 | 154 |
} |
155 | 155 |
|
156 |
public boolean start(FLayer layer) throws StartVisitorException { |
|
157 |
if(layer instanceof AlphanumericData && layer instanceof VectorialData){ |
|
158 |
try { |
|
159 |
this.recordset = ((AlphanumericData)layer).getRecordset(); |
|
160 |
} catch (ReadDriverException e) { |
|
161 |
return false; |
|
162 |
} |
|
163 |
return true; |
|
164 |
} |
|
165 |
return false; |
|
166 |
} |
|
167 |
|
|
168 | 156 |
public double getBufferDistance(IGeometry g, int index){ |
169 | 157 |
NumericValue value = null; |
170 | 158 |
try { |
trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/impl/buffer/fmap/ConstantDistanceBufferVisitor.java | ||
---|---|---|
108 | 108 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
109 | 109 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
110 | 110 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
111 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.AlphanumericData; |
|
111 | 112 |
import com.iver.cit.gvsig.geoprocess.core.fmap.GeoprocessException; |
112 | 113 |
import com.iver.cit.gvsig.geoprocess.core.util.UnitUtils; |
113 | 114 |
import org.cresques.cts.IProjection; |
... | ... | |
153 | 154 |
//we must flush JTS processors |
154 | 155 |
resultsProcessor.finish(); |
155 | 156 |
} |
156 |
/** |
|
157 |
* This FeatureVisitor only work with Vectorial |
|
158 |
* Layers |
|
159 |
*/ |
|
160 |
public boolean start(FLayer layer) throws StartVisitorException { |
|
161 |
if(layer instanceof FLyrVect){ |
|
162 |
return true; |
|
163 |
}else |
|
164 |
return false; |
|
165 |
} |
|
166 |
|
|
157 |
|
|
167 | 158 |
public double getBufferDistance(IGeometry g, int index) { |
168 | 159 |
//first: pass the user entry to internal units |
169 | 160 |
return UnitUtils.getInInternalUnits(distance, projection, distanceUnits, mapUnits); |
trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/impl/buffer/fmap/BufferGeoprocess.java | ||
---|---|---|
138 | 138 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
139 | 139 |
import com.iver.cit.gvsig.fmap.drivers.FieldDescription; |
140 | 140 |
import com.iver.cit.gvsig.fmap.drivers.ILayerDefinition; |
141 |
import com.iver.cit.gvsig.fmap.drivers.LayerDefinition; |
|
141 | 142 |
import com.iver.cit.gvsig.fmap.drivers.SHPLayerDefinition; |
142 | 143 |
import com.iver.cit.gvsig.fmap.drivers.shp.IndexedShpDriver; |
143 | 144 |
import com.iver.cit.gvsig.fmap.edition.writers.shp.ShpWriter; |
... | ... | |
234 | 235 |
if (onlySelection != null) |
235 | 236 |
bufferOnlySelection = onlySelection.booleanValue(); |
236 | 237 |
|
237 |
Boolean dissolve = (Boolean) params.get("dissolve_buffers"); |
|
238 |
if (dissolve != null) |
|
239 |
dissolveBuffers = dissolve.booleanValue(); |
|
240 |
|
|
238 |
|
|
241 | 239 |
IProjection projection = (IProjection) params.get("projection"); |
242 | 240 |
int distanceUnits = ((Integer)params.get("distanceunits")).intValue(); |
243 | 241 |
int mapUnits = ((Integer)params.get("mapunits")).intValue(); |
... | ... | |
265 | 263 |
} |
266 | 264 |
}// else |
267 | 265 |
|
266 |
Boolean dissolve = (Boolean) params.get("dissolve_buffers"); |
|
267 |
if (dissolve != null) |
|
268 |
dissolveBuffers = dissolve.booleanValue(); |
|
269 |
bufferVisitor.setIsDissolve(dissolveBuffers); |
|
270 |
|
|
268 | 271 |
Byte capflag = (Byte) params.get("cap"); |
269 | 272 |
if(capflag != null){ |
270 | 273 |
bufferVisitor.setTypeOfCap(capflag.byteValue()); |
... | ... | |
381 | 384 |
// In a buffer geoprocess we only well have a geometry |
382 | 385 |
// and a FID |
383 | 386 |
if (resultLayerDefinition == null) { |
384 |
// if(dissolveBuffers){ |
|
385 |
// resultLayerDefinition = createDissolvedBuffersDefinition(); |
|
386 |
// }else{ |
|
387 |
if(!dissolveBuffers){ |
|
388 |
resultLayerDefinition = new SHPLayerDefinition(); |
|
389 |
try { |
|
390 |
resultLayerDefinition.setShapeType(firstLayer.getShapeType()); |
|
391 |
resultLayerDefinition.setProjection(firstLayer.getProjection()); |
|
392 |
resultLayerDefinition.setName(firstLayer.getName()); |
|
393 |
resultLayerDefinition.setFieldsDesc(firstLayer.getRecordset().getFieldsDescription()); |
|
394 |
} catch (ReadDriverException e) { |
|
395 |
e.printStackTrace(); |
|
396 |
} |
|
397 |
return resultLayerDefinition; |
|
398 |
}else{ |
|
387 | 399 |
if(bufferVisitor.getTypeOfBuffer() == BufferVisitor.BUFFER_INSIDE_OUTSIDE_POLY){ |
388 | 400 |
resultLayerDefinition = createPositiveAndNegativeBufferDefinition(); |
389 | 401 |
}else{ |
390 | 402 |
resultLayerDefinition = createPositiveOrNegativeBufferDefinition(); |
391 | 403 |
} |
392 |
// }
|
|
404 |
} |
|
393 | 405 |
} |
394 | 406 |
return resultLayerDefinition; |
395 | 407 |
} |
trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/impl/buffer/fmap/BufferVisitor.java | ||
---|---|---|
94 | 94 |
import java.util.ArrayList; |
95 | 95 |
import java.util.Stack; |
96 | 96 |
|
97 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
97 | 98 |
import com.hardcode.gdbms.engine.values.Value; |
98 | 99 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
99 | 100 |
import com.iver.cit.gvsig.exceptions.visitors.ProcessVisitorException; |
101 |
import com.iver.cit.gvsig.exceptions.visitors.StartVisitorException; |
|
100 | 102 |
import com.iver.cit.gvsig.exceptions.visitors.VisitorException; |
101 | 103 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
102 | 104 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
103 | 105 |
import com.iver.cit.gvsig.fmap.core.v02.FConverter; |
106 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
107 |
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
|
108 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.AlphanumericData; |
|
109 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.VectorialData; |
|
104 | 110 |
import com.iver.cit.gvsig.fmap.operations.strategies.FeatureVisitor; |
105 | 111 |
import com.iver.cit.gvsig.geoprocess.core.fmap.FeatureFactory; |
106 | 112 |
import com.iver.cit.gvsig.geoprocess.core.fmap.GeoprocessingResultsProcessor; |
... | ... | |
183 | 189 |
*/ |
184 | 190 |
private boolean simplifyGeometry = true; |
185 | 191 |
|
192 |
private boolean dissolveBuffers; |
|
186 | 193 |
|
194 |
protected SelectableDataSource recordset; |
|
195 |
|
|
196 |
|
|
187 | 197 |
public void setSimplifyGeometry(boolean simplify){ |
188 | 198 |
this.simplifyGeometry = simplify; |
189 | 199 |
} |
190 |
|
|
200 |
|
|
201 |
public boolean isSimplifyGeometry(){ |
|
202 |
return this.simplifyGeometry; |
|
203 |
} |
|
204 |
|
|
191 | 205 |
/** |
192 | 206 |
* Sets type of buffer flag |
193 | 207 |
* @param typeOfBuffer |
... | ... | |
317 | 331 |
solution = newGeometry; |
318 | 332 |
} |
319 | 333 |
numProcessed++; |
320 |
IFeature feature = createFeature(solution, distRing); |
|
334 |
IFeature feature=null; |
|
335 |
try { |
|
336 |
feature = createFeature(solution, distRing, index); |
|
337 |
} catch (ReadDriverException e) { |
|
338 |
e.printStackTrace(); |
|
339 |
} |
|
321 | 340 |
resultsProcessor.processFeature(feature); |
322 | 341 |
previousInteriorRing = newGeometry; |
323 | 342 |
} |
... | ... | |
334 | 353 |
solution = newGeometry; |
335 | 354 |
} |
336 | 355 |
numProcessed++; |
337 |
IFeature feature = createFeature(solution, distRing); |
|
356 |
IFeature feature=null; |
|
357 |
try { |
|
358 |
feature = createFeature(solution, distRing, index); |
|
359 |
} catch (ReadDriverException e) { |
|
360 |
e.printStackTrace(); |
|
361 |
} |
|
338 | 362 |
resultsProcessor.processFeature(feature); |
339 | 363 |
previousExteriorRing = newGeometry; |
340 | 364 |
} |
... | ... | |
389 | 413 |
} |
390 | 414 |
}//else |
391 | 415 |
numProcessed++; |
392 |
IFeature feature = createFeature(solution, -1 * distRing, distRing); |
|
416 |
IFeature feature=null; |
|
417 |
try { |
|
418 |
feature = createFeature(solution, -1 * distRing, distRing, index); |
|
419 |
} catch (ReadDriverException e) { |
|
420 |
e.printStackTrace(); |
|
421 |
} |
|
393 | 422 |
resultsProcessor.processFeature(feature); |
394 | 423 |
previousExteriorRing = out; |
395 | 424 |
if(!collapsedInterior) |
... | ... | |
407 | 436 |
* @param jtsGeo |
408 | 437 |
* @param distance |
409 | 438 |
* @return |
439 |
* @throws ReadDriverException |
|
410 | 440 |
*/ |
411 |
protected IFeature createFeature(Geometry jtsGeo, double distance){
|
|
441 |
protected IFeature createFeature(Geometry jtsGeo, double distance, int index) throws ReadDriverException{
|
|
412 | 442 |
IGeometry iGeo = FConverter.jts_to_igeometry(jtsGeo); |
413 |
Value[] values = new Value[2]; |
|
414 |
values[0] = ValueFactory.createValue(numProcessed); |
|
415 |
values[1] = ValueFactory.createValue(distance); |
|
443 |
Value[] values = null; |
|
444 |
if (!dissolveBuffers){ |
|
445 |
int fieldCount = recordset.getFieldCount(); |
|
446 |
values=new Value[fieldCount]; |
|
447 |
for (int i = 0; i < fieldCount; i++) { |
|
448 |
values[i]=recordset.getFieldValue(index, i); |
|
449 |
} |
|
450 |
}else{ |
|
451 |
values = new Value[2]; |
|
452 |
values[0] = ValueFactory.createValue(numProcessed); |
|
453 |
values[1] = ValueFactory.createValue(distance); |
|
454 |
} |
|
416 | 455 |
return FeatureFactory.createFeature(values, iGeo); |
417 | 456 |
} |
418 | 457 |
|
... | ... | |
423 | 462 |
* @param jtsGeo |
424 | 463 |
* @param distance |
425 | 464 |
* @return |
465 |
* @throws ReadDriverException |
|
426 | 466 |
*/ |
427 |
protected IFeature createFeature(Geometry jtsGeo, double distanceFrom, double distanceTo){
|
|
467 |
protected IFeature createFeature(Geometry jtsGeo, double distanceFrom, double distanceTo, int index) throws ReadDriverException{
|
|
428 | 468 |
IGeometry iGeo = FConverter.jts_to_igeometry(jtsGeo); |
429 |
Value[] values = new Value[3]; |
|
430 |
values[0] = ValueFactory.createValue(numProcessed); |
|
431 |
values[1] = ValueFactory.createValue(distanceFrom); |
|
432 |
values[2] = ValueFactory.createValue(distanceTo); |
|
469 |
Value[] values = null; |
|
470 |
if (!dissolveBuffers){ |
|
471 |
int fieldCount = recordset.getFieldCount(); |
|
472 |
values=new Value[fieldCount]; |
|
473 |
for (int i = 0; i < fieldCount; i++) { |
|
474 |
values[i]=recordset.getFieldValue(index, i); |
|
475 |
} |
|
476 |
}else{ |
|
477 |
values = new Value[3]; |
|
478 |
values[0] = ValueFactory.createValue(numProcessed); |
|
479 |
values[1] = ValueFactory.createValue(distanceFrom); |
|
480 |
values[2] = ValueFactory.createValue(distanceTo); |
|
481 |
} |
|
482 |
|
|
433 | 483 |
return FeatureFactory.createFeature(values, iGeo); |
434 | 484 |
} |
435 | 485 |
|
... | ... | |
461 | 511 |
return typeOfBuffer; |
462 | 512 |
} |
463 | 513 |
|
514 |
public void setIsDissolve(boolean dissolveBuffers) { |
|
515 |
this.dissolveBuffers=dissolveBuffers; |
|
516 |
} |
|
517 |
public boolean start(FLayer layer) throws StartVisitorException { |
|
518 |
if(layer instanceof VectorialData && layer instanceof AlphanumericData){ |
|
519 |
try { |
|
520 |
this.recordset = ((AlphanumericData)layer).getRecordset(); |
|
521 |
} catch (ReadDriverException e) { |
|
522 |
return false; |
|
523 |
} |
|
524 |
return true; |
|
525 |
} |
|
526 |
return false; |
|
527 |
} |
|
528 |
|
|
464 | 529 |
} |
465 | 530 |
|
Also available in: Unified diff