Revision 2603 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/ExtendLineOperationUtils.java
ExtendLineOperationUtils.java | ||
---|---|---|
30 | 30 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
31 | 31 |
import org.gvsig.fmap.geom.Geometry; |
32 | 32 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
33 |
import org.gvsig.fmap.geom.GeometryException; |
|
33 | 34 |
import org.gvsig.fmap.geom.GeometryLocator; |
34 | 35 |
import org.gvsig.fmap.geom.GeometryManager; |
36 |
import org.gvsig.fmap.geom.aggregate.MultiLine; |
|
35 | 37 |
import org.gvsig.fmap.geom.aggregate.MultiPoint; |
36 | 38 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
37 | 39 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
... | ... | |
133 | 135 |
* @throws org.gvsig.fmap.geom.operation.GeometryOperationException |
134 | 136 |
*/ |
135 | 137 |
public static Point curveIntersection(Curve line, String sideToExtend, |
136 |
Geometry boundaryObject) throws CreateGeometryException,
|
|
138 |
Geometry boundaryObject) throws GeometryException, |
|
137 | 139 |
DataException, GeometryOperationNotSupportedException, |
138 | 140 |
GeometryOperationException { |
139 | 141 |
|
... | ... | |
507 | 509 |
public static Point getIntersectionOfProjectedLine(Point initPoint, |
508 | 510 |
Point endPoint, Geometry boundaryObject) |
509 | 511 |
throws GeometryOperationNotSupportedException, |
510 |
GeometryOperationException, DataException, CreateGeometryException {
|
|
512 |
GeometryOperationException, DataException, GeometryException { |
|
511 | 513 |
|
512 | 514 |
GeometryManager geoManager = GeometryLocator.getGeometryManager(); |
513 | 515 |
int subtype = initPoint.getGeometryType().getSubType(); |
... | ... | |
524 | 526 |
double y2 = endPoint.getY(); |
525 | 527 |
|
526 | 528 |
double projectionLimit = 2 * endPoint.distance(boundaryObject); |
529 |
double step = projectionLimit/PROJECTION_STEPS; |
|
527 | 530 |
|
528 |
for (int t = 1; t < projectionLimit; t += projectionLimit/PROJECTION_STEPS) {
|
|
531 |
for (double t = 1; t < projectionLimit; t += step) {
|
|
529 | 532 |
x = (x2 - x1) * t + x1; |
530 | 533 |
y = (y2 - y1) * t + y1; |
531 | 534 |
|
532 | 535 |
Point projectedPoint = geoManager.createPoint(x, y, subtype); |
533 |
|
|
534 |
if (!boundaryObject.contains(projectedPoint)) { |
|
536 |
MultiLine boundaryObjectLines= boundaryObject.toLines(); |
|
537 |
if (!boundaryObjectLines.contains(projectedPoint)) {
|
|
535 | 538 |
Curve tmpLine = geoManager.createLine(subtype); |
536 | 539 |
tmpLine.setPoints(initPoint, projectedPoint); |
537 | 540 |
|
538 | 541 |
if (tmpLine.intersects(boundaryObject)) { |
539 | 542 |
|
540 | 543 |
Geometry intersecionGeometry |
541 |
= boundaryObject.intersection(tmpLine); |
|
544 |
= boundaryObjectLines.intersection(tmpLine);
|
|
542 | 545 |
|
543 | 546 |
if (intersecionGeometry instanceof Point) { |
544 | 547 |
|
Also available in: Unified diff