Revision 23048 trunk/libraries/libTopology/src/org/gvsig/fmap/core/FeatureUtil.java
FeatureUtil.java | ||
---|---|---|
53 | 53 |
import java.util.Date; |
54 | 54 |
|
55 | 55 |
import org.apache.log4j.Logger; |
56 |
import org.gvsig.jts.JtsUtil; |
|
56 | 57 |
|
57 | 58 |
import com.hardcode.gdbms.engine.values.BooleanValue; |
58 | 59 |
import com.hardcode.gdbms.engine.values.DateValue; |
... | ... | |
68 | 69 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
69 | 70 |
import com.iver.cit.gvsig.fmap.drivers.WKBParser2; |
70 | 71 |
import com.iver.utiles.XMLEntity; |
72 |
import com.vividsolutions.jts.geom.Geometry; |
|
73 |
import com.vividsolutions.jts.geom.GeometryCollection; |
|
74 |
import com.vividsolutions.jts.precision.EnhancedPrecisionOp; |
|
71 | 75 |
|
72 | 76 |
/** |
73 | 77 |
* Class with utility methods to work with FMap features. |
... | ... | |
257 | 261 |
} |
258 | 262 |
return solution; |
259 | 263 |
} |
264 |
|
|
265 |
public static IFeature removeOverlappingArea(IFeature featureToEdit, |
|
266 |
Geometry originalGeo, |
|
267 |
Geometry errorGeo){ |
|
268 |
Geometry[] first = null; |
|
269 |
if(originalGeo instanceof GeometryCollection){ |
|
270 |
first = JtsUtil.extractGeometries((GeometryCollection) originalGeo); |
|
271 |
}else |
|
272 |
{ |
|
273 |
first = new Geometry[]{originalGeo}; |
|
274 |
} |
|
275 |
|
|
276 |
Geometry[] second = null; |
|
277 |
if(errorGeo instanceof GeometryCollection){ |
|
278 |
second = JtsUtil.extractGeometries((GeometryCollection) errorGeo); |
|
279 |
}else |
|
280 |
{ |
|
281 |
second = new Geometry[]{errorGeo}; |
|
282 |
} |
|
283 |
|
|
284 |
for (int i = 0; i < first.length; i++) { |
|
285 |
Geometry geom = first[i]; |
|
286 |
Geometry partialSolution = null; |
|
287 |
for (int j = 0; j < second.length; j++) { |
|
288 |
Geometry aux = EnhancedPrecisionOp.difference(geom, second[j]); |
|
289 |
if(partialSolution == null) |
|
290 |
partialSolution = aux; |
|
291 |
else |
|
292 |
partialSolution = EnhancedPrecisionOp.union(partialSolution, aux); |
|
293 |
}//for |
|
294 |
first[i] = partialSolution; |
|
295 |
}//for i |
|
296 |
GeometryCollection geomCol = JtsUtil.GEOMETRY_FACTORY.createGeometryCollection(first); |
|
297 |
IGeometry newFGeo = NewFConverter.toFMap(geomCol); |
|
298 |
featureToEdit.setGeometry(newFGeo); |
|
299 |
return featureToEdit; |
|
300 |
} |
|
260 | 301 |
} |
Also available in: Unified diff