Revision 307 org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.intersection/src/main/java/org/gvsig/geoprocess/algorithm/intersection/IntersectionOperation.java
IntersectionOperation.java | ||
---|---|---|
47 | 47 |
import org.gvsig.tools.dispose.DisposableIterator; |
48 | 48 |
|
49 | 49 |
import com.vividsolutions.jts.geom.Geometry; |
50 |
import com.vividsolutions.jts.geom.GeometryCollection; |
|
51 |
import com.vividsolutions.jts.geom.LineString; |
|
52 |
import com.vividsolutions.jts.geom.MultiLineString; |
|
53 |
import com.vividsolutions.jts.geom.MultiPoint; |
|
54 |
import com.vividsolutions.jts.geom.MultiPolygon; |
|
55 |
import com.vividsolutions.jts.geom.Point; |
|
56 |
import com.vividsolutions.jts.geom.Polygon; |
|
50 | 57 |
import com.vividsolutions.jts.precision.EnhancedPrecisionOp; |
51 | 58 |
|
52 | 59 |
import es.unex.sextante.core.Sextante; |
... | ... | |
146 | 153 |
if(jtsGeom.intersects(overlaysGeom)) { |
147 | 154 |
Geometry newGeom = EnhancedPrecisionOp.intersection(jtsGeom, overlaysGeom); |
148 | 155 |
if(!newGeom.isEmpty()) { |
149 |
|
|
150 |
//Para intersecciones entre pol?gonos cuando la salida es de tipo l?nea |
|
151 |
//la generamos a partir del pol?gono resultante de la intersecci?n |
|
152 |
if( g1 instanceof Surface && |
|
153 |
g2 instanceof Surface && |
|
154 |
(outPutType == TYPES.MULTICURVE)) { |
|
155 |
GeometryOperationContext ctx = new GeometryOperationContext(); |
|
156 |
ctx.setAttribute(FromJTS.PARAM, newGeom); |
|
157 |
org.gvsig.fmap.geom.Geometry newDalGeom = (org.gvsig.fmap.geom.Geometry)geomManager.invokeOperation(FromJTS.NAME, ctx); |
|
158 |
newGeom = (Geometry)newDalGeom.invokeOperation("toJTSLineString", null); |
|
159 |
} |
|
160 |
|
|
161 |
lastEditFeature = persister.addFeature(featureInput, featureOverlay, newGeom); |
|
156 |
if(typesMatch(outPutType, newGeom) || newGeom instanceof GeometryCollection) { |
|
157 |
lastEditFeature = persister.addFeature(featureInput, featureOverlay, newGeom); |
|
158 |
} else { |
|
159 |
//Para intersecciones entre pol?gonos cuando la salida es de tipo l?nea |
|
160 |
//la generamos a partir del pol?gono resultante de la intersecci?n |
|
161 |
if( g1 instanceof Surface && |
|
162 |
g2 instanceof Surface && |
|
163 |
outPutType == TYPES.MULTICURVE && |
|
164 |
(newGeom instanceof Polygon || newGeom instanceof MultiPolygon)) { |
|
165 |
GeometryOperationContext ctx = new GeometryOperationContext(); |
|
166 |
ctx.setAttribute(FromJTS.PARAM, newGeom); |
|
167 |
org.gvsig.fmap.geom.Geometry newDalGeom = (org.gvsig.fmap.geom.Geometry)geomManager.invokeOperation(FromJTS.NAME, ctx); |
|
168 |
newGeom = (Geometry)newDalGeom.invokeOperation("toJTSLineString", null); |
|
169 |
} |
|
170 |
|
|
171 |
lastEditFeature = persister.addFeature(featureInput, featureOverlay, newGeom); |
|
172 |
} |
|
162 | 173 |
} |
163 | 174 |
} |
164 | 175 |
} catch (CreateGeometryException e) { |
... | ... | |
173 | 184 |
return lastEditFeature; |
174 | 185 |
} |
175 | 186 |
|
187 |
private boolean typesMatch(int dalType, Geometry newGeom) { |
|
188 |
return |
|
189 |
((dalType == TYPES.MULTICURVE && |
|
190 |
(newGeom instanceof MultiLineString || newGeom instanceof LineString)) || |
|
191 |
(dalType == TYPES.MULTIPOINT && |
|
192 |
(newGeom instanceof MultiPoint || newGeom instanceof Point)) || |
|
193 |
(dalType == TYPES.MULTISURFACE && |
|
194 |
(newGeom instanceof Polygon || newGeom instanceof MultiPolygon)) || |
|
195 |
(dalType == TYPES.CURVE && newGeom instanceof LineString) || |
|
196 |
(dalType == TYPES.SURFACE && newGeom instanceof Polygon) || |
|
197 |
(dalType == TYPES.POINT && newGeom instanceof Point)); |
|
198 |
|
|
199 |
} |
|
200 |
|
|
176 | 201 |
// private MultiCurve convertPolygonJTS2LineJTS(Polygon p) { |
177 | 202 |
// |
178 | 203 |
// } |
Also available in: Unified diff