Revision 5901 trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/snapping/NearestPointSnapper.java

View differences:

NearestPointSnapper.java
19 19
		PathIterator theIterator = geom.getPathIterator(null, FConverter.flatness); //polyLine.getPathIterator(null, flatness);
20 20
		double[] theData = new double[6];
21 21
		double minDist = tolerance;
22
		Coordinate from = null;
22
		Coordinate from = null, first = null;
23 23
		while (!theIterator.isDone()) {
24 24
			//while not done
25 25
			int theType = theIterator.currentSegment(theData);
......
27 27
			switch (theType) {
28 28
				case PathIterator.SEG_MOVETO:
29 29
					from = new Coordinate(theData[0], theData[1]);
30
					first = from;
30 31
					break;
31 32

  
32 33
				case PathIterator.SEG_LINETO:
......
43 44
					
44 45
					from = to;
45 46
					break;
47
				case PathIterator.SEG_CLOSE:
48
					line = new LineSegment(from, first);
49
					closestPoint = line.closestPoint(c);
50
					dist = c.distance(closestPoint);
51
					if ((dist < minDist)) {
52
						resul = new Point2D.Double(closestPoint.x, closestPoint.y);
53
						minDist = dist;
54
					}
55
					
56
					from = first;
57
					break;
58
					
46 59

  
47 60
			} //end switch
48 61

  

Also available in: Unified diff