Revision 23048

View differences:

trunk/libraries/libTopology/src/org/gvsig/jts/SnapCoordinateList.java
60 60
 * JTS coordinate list that uses snap to avoid consecutives coordinates at a
61 61
 * distance lower than the cluster tolerance.
62 62
 * 
63
 * 
64
 * FIXME There could be coordinates non consecutives at a distance slower than
65
 * snap tolerance. 
66
 * 
63 67
 * @author azabala
64 68
 * 
65 69
 */
......
101 105
	public void add(Coordinate coord, boolean allowRepeated) {
102 106
		// don't add duplicate coordinates
103 107
		if (!allowRepeated) {
104
			if (size() >= 1) {
105
				Coordinate last = (Coordinate) get(size() - 1);
108
// with this code we only filter consecutive snapped points			
109
//			if (size() >= 1) {
110
//				Coordinate last = (Coordinate) get(size() - 1);
111
//				if(SnapCGAlgorithms.snapEquals2D(last, coord, snapTolerance))
112
//					return;
113
//			}//if
114
			int size = size();
115
			/*
116
			 If size == 1, we check the existing point,
117
			 if size > 1, we dont check the first point (because closed geometries
118
			 musnt snap the first and last point
119
			 * */
120
			if(size > 1){
121
				for(int i = 1; i < size; i++){
122
					Coordinate coordinate = (Coordinate) get(i);
123
					if(SnapCGAlgorithms.snapEquals2D(coordinate, coord, snapTolerance))
124
						return;
125
				}
126
			}else if(size == 1){
127
				Coordinate last = (Coordinate) get(0);
106 128
				if(SnapCGAlgorithms.snapEquals2D(last, coord, snapTolerance))
107 129
					return;
108
			}//if
130
			}
109 131
		}//if
110 132
		super.add(coord);
111 133
	}
trunk/libraries/libTopology/src/org/gvsig/fmap/core/FeatureUtil.java
53 53
import java.util.Date;
54 54

  
55 55
import org.apache.log4j.Logger;
56
import org.gvsig.jts.JtsUtil;
56 57

  
57 58
import com.hardcode.gdbms.engine.values.BooleanValue;
58 59
import com.hardcode.gdbms.engine.values.DateValue;
......
68 69
import com.iver.cit.gvsig.fmap.core.IGeometry;
69 70
import com.iver.cit.gvsig.fmap.drivers.WKBParser2;
70 71
import com.iver.utiles.XMLEntity;
72
import com.vividsolutions.jts.geom.Geometry;
73
import com.vividsolutions.jts.geom.GeometryCollection;
74
import com.vividsolutions.jts.precision.EnhancedPrecisionOp;
71 75

  
72 76
/**
73 77
 * Class with utility methods to work with FMap features.
......
257 261
		}
258 262
		return solution;
259 263
	}
264

  
265
	public static IFeature removeOverlappingArea(IFeature featureToEdit, 
266
											 Geometry originalGeo, 
267
											 Geometry errorGeo){
268
		Geometry[] first = null;
269
		if(originalGeo instanceof GeometryCollection){
270
			first = JtsUtil.extractGeometries((GeometryCollection) originalGeo);
271
		}else
272
		{
273
			first = new Geometry[]{originalGeo};
274
		}
275
		
276
		Geometry[] second = null;
277
		if(errorGeo instanceof GeometryCollection){
278
			second = JtsUtil.extractGeometries((GeometryCollection) errorGeo);
279
		}else
280
		{
281
			second = new Geometry[]{errorGeo};
282
		}
283
		
284
		for (int i = 0; i < first.length; i++) {
285
			Geometry geom = first[i];
286
			Geometry partialSolution = null;
287
			for (int j = 0; j < second.length; j++) {
288
				Geometry aux = EnhancedPrecisionOp.difference(geom, second[j]);
289
				if(partialSolution == null)
290
					partialSolution = aux;
291
				else
292
					partialSolution = EnhancedPrecisionOp.union(partialSolution, aux);
293
			}//for
294
			first[i] = partialSolution;
295
		}//for i
296
		GeometryCollection geomCol = JtsUtil.GEOMETRY_FACTORY.createGeometryCollection(first);
297
		IGeometry newFGeo = NewFConverter.toFMap(geomCol);
298
		featureToEdit.setGeometry(newFGeo);
299
		return featureToEdit;
300
	}
260 301
}
trunk/libraries/libTopology/src/org/gvsig/fmap/core/FLyrUtil.java
111 111
		return activeVectorialLyrs;
112 112
	}
113 113
	
114
	public static List<FLyrVect> getVectorialLayers(MapContext mapContext){
115
		List<FLyrVect> activeVectorialLyrs = new ArrayList<FLyrVect>();
116
		LayersIterator it = new LayersIterator(mapContext.getLayers());
117
		while (it.hasNext())
118
		{
119
			FLayer aux = (FLayer) it.next();
120
			if(aux instanceof FLyrVect)
121
			{
122
				activeVectorialLyrs.add((FLyrVect)aux);
123
			}//if
124
		}//while
125
		return activeVectorialLyrs;
126
	}
127
	
114 128
	public static List<FLyrVect> getLayersOfType(MapContext mapContext, int shapeType){
115 129
		List<FLyrVect> activeVectorialLyrs = new ArrayList<FLyrVect>();
116 130
		LayersIterator it = new LayersIterator(mapContext.getLayers());

Also available in: Unified diff