Revision 47385 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/main/java/org/gvsig/fmap/geom/jts/AbstractGeometry.java
AbstractGeometry.java | ||
---|---|---|
42 | 42 |
import org.gvsig.fmap.geom.Geometry; |
43 | 43 |
import org.gvsig.fmap.geom.GeometryLocator; |
44 | 44 |
import org.gvsig.fmap.geom.GeometryManager; |
45 |
import org.gvsig.fmap.geom.GeometryUtils; |
|
45 | 46 |
import org.gvsig.fmap.geom.aggregate.Aggregate; |
46 | 47 |
import org.gvsig.fmap.geom.aggregate.MultiPrimitive; |
47 | 48 |
import org.gvsig.fmap.geom.complex.Complex; |
... | ... | |
859 | 860 |
if(other instanceof Aggregate){ |
860 | 861 |
otherJTS = otherJTS.union(); |
861 | 862 |
} |
862 |
return JTSUtils.createGeometry(this.getProjection(), getJTS().difference(otherJTS), null); |
|
863 |
} |
|
863 |
return JTSUtils.createGeometry(this.getProjection(), getJTS().difference(otherJTS), null);
|
|
864 |
}
|
|
864 | 865 |
|
865 | 866 |
@Override |
866 | 867 |
public Geometry intersection(Geometry other) throws GeometryOperationNotSupportedException, |
... | ... | |
973 | 974 |
public Geometry boundary() { |
974 | 975 |
return JTSUtils.createGeometry(this.getProjection(), getJTS().getBoundary(), null); |
975 | 976 |
} |
977 |
|
|
978 |
@Override |
|
979 |
public Geometry fix() { |
|
980 |
try { |
|
981 |
ValidationStatus status = this.getValidationStatus(); |
|
982 |
if(status.isValid()) { |
|
983 |
return this.cloneGeometry(); |
|
984 |
} |
|
985 |
int statusCode = status.getStatusCode(); |
|
986 |
Geometry fixed; |
|
987 |
switch (statusCode) { |
|
988 |
case ValidationStatus.VALID: |
|
989 |
return this.cloneGeometry(); |
|
990 |
case ValidationStatus.SELF_INTERSECTION: |
|
991 |
case ValidationStatus.RING_SELF_INTERSECTION: |
|
992 |
fixed = this.buffer(Double.MIN_VALUE); |
|
993 |
break; |
|
994 |
case ValidationStatus.CURRUPTED: |
|
995 |
case ValidationStatus.UNKNOW: |
|
996 |
case ValidationStatus.DISCONNECTED_INTERIOR: |
|
997 |
case ValidationStatus.DUPLICATE_RINGS: |
|
998 |
case ValidationStatus.HOLE_OUTSIDE_SHELL: |
|
999 |
case ValidationStatus.INVALID_COORDINATE: |
|
1000 |
case ValidationStatus.NESTED_HOLES: |
|
1001 |
case ValidationStatus.NESTED_SHELLS: |
|
1002 |
case ValidationStatus.RING_NOT_CLOSED: |
|
1003 |
case ValidationStatus.TOO_FEW_POINTS: |
|
1004 |
default: |
|
1005 |
return null; |
|
1006 |
} |
|
1007 |
if(!fixed.isValid()){ |
|
1008 |
return null; |
|
1009 |
} |
|
1010 |
if(this.getGeometryType().getType() != fixed.getGeometryType().getType()){ |
|
1011 |
return null; |
|
1012 |
} |
|
1013 |
return fixed; |
|
1014 |
} catch (Exception ex) { |
|
1015 |
return null; |
|
1016 |
} |
|
1017 |
} |
|
976 | 1018 |
|
977 | 1019 |
|
978 | 1020 |
} |
Also available in: Unified diff