Revision 286 org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.fusespatially/src/main/java/org/gvsig/geoprocess/algorithm/fusespatially/FuseSpatiallyOperation.java
FuseSpatiallyOperation.java | ||
---|---|---|
45 | 45 |
package org.gvsig.geoprocess.algorithm.fusespatially; |
46 | 46 |
|
47 | 47 |
import java.util.ArrayList; |
48 |
import java.util.List; |
|
48 | 49 |
import java.util.Stack; |
49 | 50 |
|
50 | 51 |
import org.gvsig.fmap.dal.exception.DataException; |
... | ... | |
67 | 68 |
public class FuseSpatiallyOperation extends GeometryOperation { |
68 | 69 |
protected GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
69 | 70 |
private int id = 0; |
70 |
private Stack<Feature> featList = null;
|
|
71 |
private List<Feature> featList = null;
|
|
71 | 72 |
private FeatureStore outFeatureStoreTable = null; |
72 | 73 |
private String idField = "FID"; |
73 | 74 |
|
74 |
public FuseSpatiallyOperation(Stack<Feature> f, FeatureStore outFeatStoreTable, String[] fieldNames, String idField) throws DataException {
|
|
75 |
public FuseSpatiallyOperation(List<Feature> f, FeatureStore outFeatStoreTable, String[] fieldNames, String idField) throws DataException {
|
|
75 | 76 |
this.featList = f; |
76 | 77 |
this.outFeatureStoreTable = outFeatStoreTable; |
77 | 78 |
this.idField = idField; |
... | ... | |
88 | 89 |
*/ |
89 | 90 |
public EditableFeature invoke(org.gvsig.fmap.geom.Geometry g, Feature feature) { |
90 | 91 |
try { |
91 |
org.gvsig.fmap.geom.Geometry geom = feature.getDefaultGeometry(); |
|
92 |
Geometry jtsInputGeom = GeometryUtil.geomToJTS(geom); |
|
92 |
Geometry jtsInputGeom = GeometryUtil.geomToJTS(g); |
|
93 | 93 |
insertInTable(feature); |
94 | 94 |
|
95 |
int i = featList.size() - 1; |
|
95 |
for (int i = featList.size() - 1; i >= 0; i--) { |
|
96 |
Feature f = featList.get(i); |
|
97 |
g = f.getDefaultGeometry(); |
|
98 |
Geometry jtsGeom = GeometryUtil.geomToJTS(g); //Multigeometry support |
|
99 |
if(jtsGeom.intersects(jtsInputGeom)) { |
|
100 |
jtsInputGeom = jtsInputGeom.union(jtsGeom); |
|
101 |
featList.remove(i); |
|
102 |
insertInTable(f); |
|
103 |
} |
|
104 |
} |
|
105 |
|
|
106 |
/*int i = featList.size() - 1; |
|
96 | 107 |
while(i >= 0) { |
97 | 108 |
Feature f = featList.get(i); |
98 | 109 |
geom = f.getDefaultGeometry(); |
... | ... | |
104 | 115 |
i = featList.size(); |
105 | 116 |
} |
106 | 117 |
i --; |
107 |
} |
|
118 |
}*/
|
|
108 | 119 |
|
109 | 120 |
//Cuando no genera dos capas mete los campos de la feature de entrada en la de salida perdiendose el resto |
110 | 121 |
if(outFeatureStoreTable == null) { |
Also available in: Unified diff