Revision 2204 org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.extendline/src/main/java/org/gvsig/vectorediting/lib/prov/extendline/operation/CurveExtendLineOperation.java

View differences:

CurveExtendLineOperation.java
26 26

  
27 27
import org.gvsig.fmap.dal.exception.DataException;
28 28
import org.gvsig.fmap.dal.feature.FeatureSelection;
29
import org.gvsig.fmap.geom.Geometry;
29 30
import org.gvsig.fmap.geom.GeometryLocator;
30 31
import org.gvsig.fmap.geom.GeometryManager;
31 32
import org.gvsig.fmap.geom.exception.CreateGeometryException;
......
81 82

  
82 83
        return extendedLine;
83 84
    }
85

  
86
    @Override
87
    public Curve extendLine(Curve lineToExtend, Point insertedPoint, Geometry boundaryObject) throws GeometryOperationNotSupportedException, GeometryOperationException, DataException, CreateGeometryException {
88
        GeometryManager geoManager = GeometryLocator.getGeometryManager();
89
        int subtype = lineToExtend.getGeometryType().getSubType();
90
        Curve extendedLine = geoManager.createLine(subtype);
91

  
92
        Point startVertex = lineToExtend.getVertex(0);
93
        Point endVertex =
94
            lineToExtend.getVertex(lineToExtend.getNumVertices() - 1);
95

  
96
        Point startIntersectionPoint = null;
97
        Point endIntersectionPoint = null;
98
        if (insertedPoint.distance(startVertex) < insertedPoint
99
            .distance(endVertex)) {
100
            startIntersectionPoint =
101
                ExtendLineOperationUtils.curveIntersection(lineToExtend,
102
                    ExtendLineOperationUtils.START_SIDE, boundaryObject);
103

  
104
        } else {
105
            endIntersectionPoint =
106
                ExtendLineOperationUtils.curveIntersection(lineToExtend,
107
                    ExtendLineOperationUtils.END_SIDE, boundaryObject);
108
        }
109

  
110
        if (startIntersectionPoint != null) {
111
            extendedLine.addVertex(startIntersectionPoint);
112
        }
113

  
114
        for (int i = 0; i < lineToExtend.getNumVertices(); i++) {
115
            extendedLine.addVertex(lineToExtend.getVertex(i));
116
        }
117

  
118
        if (endIntersectionPoint != null) {
119
            extendedLine.addVertex(endIntersectionPoint);
120
        }
121

  
122
        return extendedLine;
123
    }
124
    
125
    
84 126
}

Also available in: Unified diff