Revision 2786
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.split/src/main/java/org/gvsig/vectorediting/lib/prov/split/SplitEditingProvider.java | ||
---|---|---|
38 | 38 |
import org.gvsig.fmap.geom.GeometryException; |
39 | 39 |
import org.gvsig.fmap.geom.GeometryLocator; |
40 | 40 |
import org.gvsig.fmap.geom.GeometryManager; |
41 |
import org.gvsig.fmap.geom.aggregate.Aggregate; |
|
41 | 42 |
import org.gvsig.fmap.geom.aggregate.MultiCurve; |
42 | 43 |
import org.gvsig.fmap.geom.aggregate.MultiPrimitive; |
44 |
import org.gvsig.fmap.geom.complex.Complex; |
|
43 | 45 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
44 | 46 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
45 | 47 |
import org.gvsig.fmap.geom.primitive.Curve; |
... | ... | |
212 | 214 |
Geometry geometry = feature.getDefaultGeometry(); |
213 | 215 |
|
214 | 216 |
Geometry intersection = geometry.intersection(curve); |
215 |
|
|
216 |
if (intersection == null |
|
217 |
|| (!intersection.getGeometryType().isTypeOf(POINT) |
|
218 |
&& !intersection.getGeometryType().isTypeOf(MULTIPOINT) |
|
219 |
&& !intersection.getGeometryType().isTypeOf(CURVE) |
|
220 |
&& !intersection.getGeometryType().isTypeOf(MULTICURVE))) { |
|
221 |
throw new VectorEditingException(); |
|
217 |
|
|
218 |
if (intersection instanceof Complex) { |
|
219 |
intersection = ((Complex) intersection).createAggregate( |
|
220 |
Geometry.TYPES.MULTIPOLYGON, |
|
221 |
(Geometry t) -> t.getGeometryType().getType() == Geometry.TYPES.MULTIPOLYGON || t.getGeometryType().getType() == Geometry.TYPES.POLYGON |
|
222 |
); |
|
223 |
if( ((Aggregate) intersection).getPrimitivesNumber() == 0){ |
|
224 |
throw new VectorEditingException(); |
|
225 |
} |
|
226 |
} else { |
|
227 |
if (intersection == null |
|
228 |
|| (!intersection.getGeometryType().isTypeOf(POINT) |
|
229 |
&& !intersection.getGeometryType().isTypeOf(MULTIPOINT) |
|
230 |
&& !intersection.getGeometryType().isTypeOf(CURVE) |
|
231 |
&& !intersection.getGeometryType().isTypeOf(MULTICURVE))) { |
|
232 |
throw new VectorEditingException(); |
|
233 |
} |
|
222 | 234 |
} |
223 | 235 |
}); |
224 | 236 |
return true; |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.split/src/main/java/org/gvsig/vectorediting/lib/prov/split/operation/CurveSplitOperation.java | ||
---|---|---|
29 | 29 |
import org.gvsig.fmap.geom.GeometryLocator; |
30 | 30 |
import org.gvsig.fmap.geom.aggregate.MultiCurve; |
31 | 31 |
import org.gvsig.fmap.geom.aggregate.MultiPoint; |
32 |
import org.gvsig.fmap.geom.complex.Complex; |
|
32 | 33 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
33 | 34 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
34 | 35 |
import org.gvsig.fmap.geom.primitive.Curve; |
... | ... | |
64 | 65 |
Curve curveToBeSplitted = (Curve) geometryToBeSplitted.cloneGeometry(); |
65 | 66 |
|
66 | 67 |
Geometry intersection = geometryToBeSplitted.intersection(splitter); |
68 |
|
|
69 |
if (intersection instanceof Complex) { |
|
70 |
intersection = ((Complex) intersection).createAggregate( |
|
71 |
Geometry.TYPES.MULTIPOINT, |
|
72 |
(Geometry t) -> t.getGeometryType().getType() == Geometry.TYPES.MULTIPOINT || t.getGeometryType().getType() == Geometry.TYPES.POINT |
|
73 |
); |
|
74 |
} |
|
75 |
|
|
67 | 76 |
MultiCurve multicurveSplitted = null; |
68 | 77 |
|
69 | 78 |
if (intersection instanceof MultiPoint) { |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.split/src/main/java/org/gvsig/vectorediting/lib/prov/split/operation/ArcSplitOperation.java | ||
---|---|---|
32 | 32 |
import org.gvsig.fmap.geom.GeometryManager; |
33 | 33 |
import org.gvsig.fmap.geom.aggregate.MultiCurve; |
34 | 34 |
import org.gvsig.fmap.geom.aggregate.MultiPoint; |
35 |
import org.gvsig.fmap.geom.complex.Complex; |
|
35 | 36 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
36 | 37 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
37 | 38 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
... | ... | |
73 | 74 |
|
74 | 75 |
if (intersections == null) { |
75 | 76 |
return geometryToBeSplitted; |
76 |
} else if (intersections instanceof Point) { |
|
77 |
} |
|
78 |
|
|
79 |
if (intersections instanceof Complex) { |
|
80 |
intersections = ((Complex) intersections).createAggregate( |
|
81 |
Geometry.TYPES.MULTIPOINT, |
|
82 |
(Geometry t) -> t.getGeometryType().getType() == Geometry.TYPES.MULTIPOINT || t.getGeometryType().getType() == Geometry.TYPES.POINT |
|
83 |
); |
|
84 |
} |
|
85 |
|
|
86 |
if (intersections instanceof Point) { |
|
77 | 87 |
|
78 | 88 |
if(isClosed(arcToBeSplitted)){ // Closed arcs can be splitted by one point |
79 | 89 |
return arcToBeSplitted; |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.split/src/main/java/org/gvsig/vectorediting/lib/prov/split/operation/LineSplitOperation.java | ||
---|---|---|
28 | 28 |
import org.gvsig.fmap.geom.GeometryLocator; |
29 | 29 |
import org.gvsig.fmap.geom.aggregate.MultiLine; |
30 | 30 |
import org.gvsig.fmap.geom.aggregate.MultiPoint; |
31 |
import org.gvsig.fmap.geom.complex.Complex; |
|
31 | 32 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
32 | 33 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
33 | 34 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
... | ... | |
64 | 65 |
Line lineToBeSplitted = (Line) geometryToBeSplitted; |
65 | 66 |
|
66 | 67 |
Geometry intersection = geometryToBeSplitted.intersection(splitter); |
68 |
if (intersection instanceof Complex) { |
|
69 |
intersection = ((Complex) intersection).createAggregate( |
|
70 |
Geometry.TYPES.MULTIPOINT, |
|
71 |
(Geometry t) -> t.getGeometryType().getType() == Geometry.TYPES.MULTIPOINT || t.getGeometryType().getType() == Geometry.TYPES.POINT |
|
72 |
); |
|
73 |
} |
|
74 |
|
|
67 | 75 |
MultiLine multilineSplitted = null; |
68 | 76 |
|
69 | 77 |
if (intersection instanceof MultiPoint) { |
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 | ||
---|---|---|
25 | 25 |
|
26 | 26 |
import java.util.HashMap; |
27 | 27 |
import java.util.Map; |
28 |
import java.util.function.Predicate; |
|
28 | 29 |
import org.gvsig.fmap.dal.exception.DataException; |
29 | 30 |
import org.gvsig.fmap.dal.feature.Feature; |
30 | 31 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
... | ... | |
33 | 34 |
import org.gvsig.fmap.geom.GeometryException; |
34 | 35 |
import org.gvsig.fmap.geom.GeometryLocator; |
35 | 36 |
import org.gvsig.fmap.geom.GeometryManager; |
37 |
import org.gvsig.fmap.geom.GeometryUtils; |
|
38 |
import org.gvsig.fmap.geom.aggregate.Aggregate; |
|
36 | 39 |
import org.gvsig.fmap.geom.aggregate.MultiLine; |
37 | 40 |
import org.gvsig.fmap.geom.aggregate.MultiPoint; |
41 |
import org.gvsig.fmap.geom.complex.Complex; |
|
38 | 42 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
39 | 43 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
40 | 44 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
... | ... | |
216 | 220 |
Geometry geometry = feature.getDefaultGeometry(); |
217 | 221 |
if (tmpArc.intersects(geometry)) { |
218 | 222 |
Geometry intersectionGeometry = tmpArc.intersection(geometry); |
223 |
|
|
224 |
if(intersectionGeometry instanceof Complex){ |
|
225 |
intersectionGeometry = ((Complex)intersectionGeometry).createAggregate( |
|
226 |
Geometry.TYPES.MULTIPOINT, |
|
227 |
(Geometry t) -> t.getGeometryType().getType() == Geometry.TYPES.MULTIPOINT || t.getGeometryType().getType() == Geometry.TYPES.POINT |
|
228 |
); |
|
229 |
} |
|
219 | 230 |
|
220 | 231 |
if (intersectionGeometry instanceof MultiPoint) { |
221 | 232 |
MultiPoint intersectionMultiPoint |
... | ... | |
310 | 321 |
double minDistance = Double.POSITIVE_INFINITY; |
311 | 322 |
if (tmpArc.intersects(boundaryObject)) { |
312 | 323 |
Geometry intersectionGeometry = tmpArc.intersection(boundaryObject); |
324 |
if (intersectionGeometry instanceof Complex) { |
|
325 |
intersectionGeometry = ((Complex) intersectionGeometry).createAggregate( |
|
326 |
Geometry.TYPES.MULTIPOINT, |
|
327 |
(Geometry t) -> t.getGeometryType().getType() == Geometry.TYPES.MULTIPOINT || t.getGeometryType().getType() == Geometry.TYPES.POINT |
|
328 |
); |
|
329 |
} |
|
313 | 330 |
|
314 | 331 |
if (intersectionGeometry instanceof MultiPoint) { |
315 | 332 |
MultiPoint intersectionMultiPoint |
... | ... | |
419 | 436 |
|
420 | 437 |
if (tmpLine.intersects(geometry)) { |
421 | 438 |
|
422 |
Geometry intersecionGeometry |
|
439 |
Geometry intersectionGeometry
|
|
423 | 440 |
= geometry.intersection(tmpLine); |
424 | 441 |
|
425 |
if (intersecionGeometry instanceof Point) { |
|
442 |
if (intersectionGeometry instanceof Complex) { |
|
443 |
Aggregate intersection = ((Complex) intersectionGeometry).createAggregate( |
|
444 |
Geometry.TYPES.MULTIPOINT, |
|
445 |
(Geometry g) -> g.getGeometryType().getType() == Geometry.TYPES.MULTIPOINT || g.getGeometryType().getType() == Geometry.TYPES.POINT |
|
446 |
); |
|
447 |
if(intersection.getPrimitivesNumber() > 0) { |
|
448 |
intersectionGeometry = intersection; |
|
449 |
} else { |
|
450 |
intersection = ((Complex) intersectionGeometry).createAggregate( |
|
451 |
Geometry.TYPES.MULTILINE, |
|
452 |
(Geometry g) -> GeometryUtils.isSubtype(Geometry.TYPES.MULTICURVE, g.getGeometryType().getType()) || GeometryUtils.isSubtype(Geometry.TYPES.CURVE, g.getGeometryType().getType()) |
|
453 |
); |
|
454 |
if(intersection.getPrimitivesNumber() > 0){ |
|
455 |
intersectionGeometry = intersection.getPrimitiveAt(0); |
|
456 |
} |
|
457 |
} |
|
458 |
} |
|
426 | 459 |
|
460 |
if (intersectionGeometry instanceof Point) { |
|
461 |
|
|
427 | 462 |
double distance |
428 |
= ((Point) intersecionGeometry) |
|
463 |
= ((Point) intersectionGeometry)
|
|
429 | 464 |
.distance(initPoint); |
430 | 465 |
|
431 | 466 |
if (distance < minDistance && distance > (module + 0.01)) { |
432 |
intersectionPoint = (Point) intersecionGeometry; |
|
467 |
intersectionPoint = (Point) intersectionGeometry;
|
|
433 | 468 |
minDistance = distance; |
434 | 469 |
} |
435 | 470 |
|
436 |
} else if (intersecionGeometry instanceof MultiPoint) { |
|
471 |
} else if (intersectionGeometry instanceof MultiPoint) {
|
|
437 | 472 |
|
438 | 473 |
MultiPoint intersectionMultiPoint |
439 |
= (MultiPoint) intersecionGeometry; |
|
474 |
= (MultiPoint) intersectionGeometry;
|
|
440 | 475 |
|
441 | 476 |
for (int i = 0; i < intersectionMultiPoint |
442 | 477 |
.getPrimitivesNumber(); i++) { |
... | ... | |
451 | 486 |
minDistance = distance; |
452 | 487 |
} |
453 | 488 |
} |
454 |
} else if (intersecionGeometry instanceof Curve) { |
|
489 |
} else if (intersectionGeometry instanceof Curve) {
|
|
455 | 490 |
|
456 | 491 |
Curve intersectionCurve |
457 |
= (Curve) intersecionGeometry; |
|
492 |
= (Curve) intersectionGeometry;
|
|
458 | 493 |
|
459 | 494 |
for (int i = 0; i < intersectionCurve |
460 | 495 |
.getNumVertices(); i++) { |
... | ... | |
540 | 575 |
|
541 | 576 |
if (tmpLine.intersects(boundaryObject)) { |
542 | 577 |
|
543 |
Geometry intersecionGeometry |
|
578 |
Geometry intersectionGeometry
|
|
544 | 579 |
= boundaryObjectLines.intersection(tmpLine); |
545 | 580 |
|
546 |
if (intersecionGeometry instanceof Point) { |
|
581 |
if (intersectionGeometry instanceof Complex) { |
|
582 |
Aggregate intersection = ((Complex) intersectionGeometry).createAggregate( |
|
583 |
Geometry.TYPES.MULTIPOINT, |
|
584 |
(Geometry g) -> g.getGeometryType().getType() == Geometry.TYPES.MULTIPOINT || g.getGeometryType().getType() == Geometry.TYPES.POINT |
|
585 |
); |
|
586 |
if(intersection.getPrimitivesNumber() > 0) { |
|
587 |
intersectionGeometry = intersection; |
|
588 |
} else { |
|
589 |
intersection = ((Complex) intersectionGeometry).createAggregate( |
|
590 |
Geometry.TYPES.MULTILINE, |
|
591 |
(Geometry g) -> GeometryUtils.isSubtype(Geometry.TYPES.MULTICURVE, g.getGeometryType().getType()) || GeometryUtils.isSubtype(Geometry.TYPES.CURVE, g.getGeometryType().getType()) |
|
592 |
); |
|
593 |
if(intersection.getPrimitivesNumber() > 0){ |
|
594 |
intersectionGeometry = intersection.getPrimitiveAt(0); |
|
595 |
} |
|
596 |
} |
|
597 |
} |
|
598 |
|
|
599 |
if (intersectionGeometry instanceof Point) { |
|
547 | 600 |
|
548 | 601 |
double distance |
549 |
= ((Point) intersecionGeometry) |
|
602 |
= ((Point) intersectionGeometry)
|
|
550 | 603 |
.distance(initPoint); |
551 | 604 |
|
552 | 605 |
if (distance < minDistance && distance > (module + 0.01)) { |
553 |
intersectionPoint = (Point) intersecionGeometry; |
|
606 |
intersectionPoint = (Point) intersectionGeometry;
|
|
554 | 607 |
minDistance = distance; |
555 | 608 |
} |
556 | 609 |
|
557 |
} else if (intersecionGeometry instanceof MultiPoint) { |
|
610 |
} else if (intersectionGeometry instanceof MultiPoint) {
|
|
558 | 611 |
|
559 | 612 |
MultiPoint intersectionMultiPoint |
560 |
= (MultiPoint) intersecionGeometry; |
|
613 |
= (MultiPoint) intersectionGeometry;
|
|
561 | 614 |
|
562 | 615 |
for (int i = 0; i < intersectionMultiPoint |
563 | 616 |
.getPrimitivesNumber(); i++) { |
... | ... | |
572 | 625 |
minDistance = distance; |
573 | 626 |
} |
574 | 627 |
} |
575 |
} else if (intersecionGeometry instanceof Curve) { |
|
628 |
} else if (intersectionGeometry instanceof Curve) {
|
|
576 | 629 |
|
577 | 630 |
Curve intersectionCurve |
578 |
= (Curve) intersecionGeometry; |
|
631 |
= (Curve) intersectionGeometry;
|
|
579 | 632 |
|
580 | 633 |
for (int i = 0; i < intersectionCurve |
581 | 634 |
.getNumVertices(); i++) { |
Also available in: Unified diff