Revision 45917 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.api/src/main/java/org/gvsig/fmap/geom/GeometryUtils.java
GeometryUtils.java | ||
---|---|---|
1019 | 1019 |
} |
1020 | 1020 |
|
1021 | 1021 |
|
1022 |
/** |
|
1023 |
* Returns true if two polygons overlap taking into account the given tolerance |
|
1024 |
* |
|
1025 |
* @param polygon |
|
1026 |
* @param polygon2 |
|
1027 |
* @param theTolerance |
|
1028 |
* @return |
|
1029 |
* @throws GeometryOperationNotSupportedException |
|
1030 |
* @throws GeometryOperationException |
|
1031 |
*/ |
|
1032 |
public static boolean overlaps(Geometry polygon, Geometry polygon2, double theTolerance) throws GeometryOperationNotSupportedException, GeometryOperationException { |
|
1033 |
if (polygon != null && polygon2 != null) { |
|
1034 |
if (theTolerance > 0) { |
|
1035 |
Geometry buffer1 = polygon.buffer(-theTolerance); |
|
1036 |
if (buffer1 != null) { |
|
1037 |
return buffer1.overlaps(polygon2); |
|
1038 |
} else{ |
|
1039 |
Geometry buffer2 = polygon2.buffer(-theTolerance); |
|
1040 |
if (buffer2 != null) { |
|
1041 |
return polygon.overlaps(buffer2); |
|
1042 |
} |
|
1043 |
} |
|
1044 |
} else { |
|
1045 |
return polygon.overlaps(polygon2); |
|
1046 |
} |
|
1047 |
} |
|
1048 |
return false; |
|
1049 |
} |
|
1050 |
|
|
1022 | 1051 |
|
1023 | 1052 |
// public static void main(String[] args) throws GeometryException { |
1024 | 1053 |
// String s; |
Also available in: Unified diff