Revision 8763 trunk/extensions/extGraph_predes/src/com/iver/cit/gvsig/topology/lineclean/fmap/LineCleanVisitor.java
LineCleanVisitor.java | ||
---|---|---|
45 | 45 |
* |
46 | 46 |
* $Id$ |
47 | 47 |
* $Log$ |
48 |
* Revision 1.6 2006-11-14 18:01:09 azabala |
|
48 |
* Revision 1.7 2006-11-14 18:34:16 azabala |
|
49 |
* *** empty log message *** |
|
50 |
* |
|
51 |
* Revision 1.6 2006/11/14 18:01:09 azabala |
|
49 | 52 |
* removed system.out.println |
50 | 53 |
* |
51 | 54 |
* Revision 1.5 2006/11/13 20:41:08 azabala |
... | ... | |
93 | 96 |
import com.iver.cit.gvsig.geoprocess.core.fmap.FeaturePersisterProcessor2; |
94 | 97 |
import com.iver.cit.gvsig.geoprocess.core.fmap.FeatureProcessor; |
95 | 98 |
import com.iver.cit.gvsig.geoprocess.core.fmap.XTypes; |
99 |
import com.iver.cit.gvsig.util.SnappingCoordinateMap; |
|
96 | 100 |
import com.vividsolutions.jts.geom.Coordinate; |
97 | 101 |
import com.vividsolutions.jts.geom.Geometry; |
98 | 102 |
import com.vividsolutions.jts.geom.GeometryCollection; |
... | ... | |
174 | 178 |
* Counter of new features |
175 | 179 |
*/ |
176 | 180 |
int fid = 0; |
177 |
|
|
181 |
|
|
182 |
/** |
|
183 |
* It caches all written pseudonodes, to avoid |
|
184 |
* writing the same pseudonode twice. |
|
185 |
* |
|
186 |
* */ |
|
187 |
SnappingCoordinateMap snapCoordMap; |
|
188 |
|
|
189 |
/** |
|
190 |
* Constructor. |
|
191 |
* @param processor |
|
192 |
* @param intersectsProcessor |
|
193 |
* @param cleanOnlySelection |
|
194 |
* @param layerDefinition |
|
195 |
* @param intersectDefinition |
|
196 |
* @param firstLayer |
|
197 |
* @param source |
|
198 |
* @param snapCoordMap |
|
199 |
*/ |
|
178 | 200 |
public LineCleanVisitor(FeatureProcessor processor, |
179 | 201 |
FeaturePersisterProcessor2 intersectsProcessor, |
180 | 202 |
boolean cleanOnlySelection, |
181 | 203 |
ILayerDefinition layerDefinition, |
182 | 204 |
ILayerDefinition intersectDefinition, |
183 | 205 |
FLyrVect firstLayer, |
184 |
SelectableDataSource source) { |
|
206 |
SelectableDataSource source, |
|
207 |
SnappingCoordinateMap snapCoordMap) { |
|
185 | 208 |
this.featureProcessor = processor; |
186 | 209 |
this.cleanOnlySelection = cleanOnlySelection; |
187 | 210 |
processedFeatures = new FBitSet(); |
... | ... | |
191 | 214 |
this.layerToClean = firstLayer; |
192 | 215 |
this.recordset = source; |
193 | 216 |
this.strategy = StrategyManager.getStrategy(layerToClean); |
217 |
this.snapCoordMap = snapCoordMap; |
|
194 | 218 |
} |
195 | 219 |
|
196 | 220 |
public void setLayerDefinition(ILayerDefinition layerDefinition) { |
... | ... | |
343 | 367 |
Coordinate coord = p.getCoordinate(); |
344 | 368 |
if (!checkIsNode(coord, geomNodes)){ |
345 | 369 |
nodes.addNode(coord); |
346 |
IFeature feature = createIntersectFeature(coord, fid1, fid2); |
|
347 |
intersectProcessor.processFeature(feature); |
|
370 |
|
|
371 |
/* |
|
372 |
* We are computing intersections twice: A intersection B |
|
373 |
* and B intersection A. This is simpler than manage caches. |
|
374 |
* With this logic, we avoid to write the same pseudonode twice |
|
375 |
* |
|
376 |
* */ |
|
377 |
if(snapCoordMap.containsKey(coord)) |
|
378 |
return; |
|
379 |
else{ |
|
380 |
snapCoordMap.put(coord, coord); |
|
381 |
IFeature feature = createIntersectFeature(coord, fid1, fid2); |
|
382 |
intersectProcessor.processFeature(feature); |
|
383 |
} |
|
348 | 384 |
} |
349 | 385 |
} else if (intersections instanceof MultiPoint) { |
350 | 386 |
MultiPoint points = (MultiPoint) intersections; |
... | ... | |
353 | 389 |
.getCoordinate(); |
354 | 390 |
if (!checkIsNode(coord, geomNodes)){ |
355 | 391 |
nodes.addNode(coord); |
356 |
IFeature feature = createIntersectFeature(coord, fid1, fid2); |
|
357 |
intersectProcessor.processFeature(feature); |
|
392 |
if(snapCoordMap.containsKey(coord)) |
|
393 |
return; |
|
394 |
else{ |
|
395 |
snapCoordMap.put(coord, coord); |
|
396 |
IFeature feature = createIntersectFeature(coord, fid1, fid2); |
|
397 |
intersectProcessor.processFeature(feature); |
|
398 |
} |
|
358 | 399 |
} |
359 | 400 |
} |
360 | 401 |
} else if (intersections instanceof LineString) { |
... | ... | |
364 | 405 |
Coordinate coord2 = line.getCoordinateN(numPoints - 1); |
365 | 406 |
if (!checkIsNode(coord1, geomNodes)){ |
366 | 407 |
nodes.addNode(coord1); |
367 |
IFeature feature = createIntersectFeature(coord1, fid1, fid2); |
|
368 |
intersectProcessor.processFeature(feature); |
|
408 |
if(snapCoordMap.containsKey(coord1)) |
|
409 |
return; |
|
410 |
else{ |
|
411 |
snapCoordMap.put(coord1, coord1); |
|
412 |
IFeature feature = createIntersectFeature(coord1, fid1, fid2); |
|
413 |
intersectProcessor.processFeature(feature); |
|
414 |
} |
|
369 | 415 |
} |
370 | 416 |
if (!checkIsNode(coord2, geomNodes)){ |
371 | 417 |
nodes.addNode(coord2); |
372 |
IFeature feature = createIntersectFeature(coord2, fid1, fid2); |
|
373 |
intersectProcessor.processFeature(feature); |
|
418 |
if(snapCoordMap.containsKey(coord2)) |
|
419 |
return; |
|
420 |
else{ |
|
421 |
snapCoordMap.put(coord2, coord2); |
|
422 |
IFeature feature = createIntersectFeature(coord2, fid1, fid2); |
|
423 |
intersectProcessor.processFeature(feature); |
|
424 |
} |
|
374 | 425 |
} |
375 | 426 |
} else if (intersections instanceof GeometryCollection) { |
376 | 427 |
GeometryCollection col = (GeometryCollection) intersections; |
Also available in: Unified diff