Revision 39588
trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/impl/dissolve/fmap/SingleFieldDissolveCriteria.java | ||
---|---|---|
77 | 77 |
import com.iver.cit.gvsig.fmap.drivers.ILayerDefinition; |
78 | 78 |
import com.iver.cit.gvsig.fmap.drivers.SHPLayerDefinition; |
79 | 79 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
80 |
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
|
80 | 81 |
import com.iver.cit.gvsig.geoprocess.core.fmap.DefinitionUtils; |
81 | 82 |
import com.iver.cit.gvsig.geoprocess.core.fmap.SummarizationFunction; |
82 | 83 |
import com.iver.cit.gvsig.geoprocess.core.fmap.XTypes; |
... | ... | |
108 | 109 |
*/ |
109 | 110 |
protected SingleFieldFeatureBuilder builder; |
110 | 111 |
|
112 |
private int dissolveFieldIndex; |
|
111 | 113 |
|
114 |
|
|
112 | 115 |
public SingleFieldDissolveCriteria(String dissolveField, |
113 | 116 |
FLyrVect layer) throws DriverException{ |
114 |
this.dissolveField = dissolveField; |
|
115 | 117 |
this.layer = layer; |
118 |
this.dissolveField = dissolveField; |
|
119 |
try { |
|
120 |
dissolveFieldIndex = layer.getRecordset().getFieldIndexByName(dissolveField); |
|
121 |
} catch (ReadDriverException e) { |
|
122 |
e.printStackTrace(); |
|
123 |
throw new DriverException(e); |
|
124 |
} |
|
116 | 125 |
builder = new SingleFieldFeatureBuilder(); |
117 | 126 |
|
118 | 127 |
} |
... | ... | |
155 | 164 |
private void fetchDissolveValue(int index){ |
156 | 165 |
if(cachedDissolveValue == null){ |
157 | 166 |
try { |
158 |
int fieldIndex = |
|
159 |
layer.getRecordset().getFieldIndexByName(dissolveField); |
|
160 | 167 |
|
161 | 168 |
cachedDissolveValue = layer.getRecordset(). |
162 | 169 |
getFieldValue(index, |
163 |
fieldIndex);
|
|
170 |
dissolveFieldIndex);
|
|
164 | 171 |
} catch (ReadDriverException e) { |
165 | 172 |
// TODO Auto-generated catch block |
166 | 173 |
e.printStackTrace(); |
... | ... | |
172 | 179 |
public boolean verifyIfDissolve(int featureIndex1, int featureIndex2) { |
173 | 180 |
try { |
174 | 181 |
fetchDissolveValue(featureIndex1); |
175 |
int fieldIndex = layer.getRecordset(). |
|
176 |
getFieldIndexByName(this.dissolveField); |
|
177 | 182 |
Value value2 = layer.getRecordset(). |
178 |
getFieldValue(featureIndex2, fieldIndex);
|
|
183 |
getFieldValue(featureIndex2, dissolveFieldIndex);
|
|
179 | 184 |
return value2.doEquals(cachedDissolveValue); |
180 | 185 |
} catch (ReadDriverException e) { |
181 | 186 |
//Ver que hacer con la excepcion |
... | ... | |
192 | 197 |
public ILayerDefinition createLayerDefinition(Map numFields_SumFunc) { |
193 | 198 |
SHPLayerDefinition resultLayerDefinition = new SHPLayerDefinition(); |
194 | 199 |
resultLayerDefinition.setShapeType(XTypes.POLYGON); |
195 |
ArrayList fields = new ArrayList();
|
|
200 |
ArrayList<FieldDescription> fields = new ArrayList<FieldDescription>();
|
|
196 | 201 |
//first of all: FID |
197 | 202 |
FieldDescription fidFd = new FieldDescription(); |
198 | 203 |
fidFd.setFieldLength(10); |
... | ... | |
229 | 234 |
}//if |
230 | 235 |
|
231 | 236 |
try { |
232 |
FieldDescription description = new FieldDescription(); |
|
233 |
int dissolveFieldIndex = layer.getRecordset(). |
|
234 |
getFieldIndexByName(dissolveField); |
|
235 |
int fieldType = layer.getRecordset(). |
|
236 |
getFieldType(dissolveFieldIndex); |
|
237 |
int fieldLenght = DefinitionUtils. |
|
238 |
getDataTypeLength(fieldType); |
|
239 |
description.setFieldName(dissolveField); |
|
240 |
description.setFieldType(fieldType); |
|
241 |
description.setFieldLength(fieldLenght); |
|
242 |
if(DefinitionUtils.isNumeric(description)){ |
|
243 |
description.setFieldDecimalCount(DefinitionUtils.NUM_DECIMALS); |
|
244 |
} |
|
245 |
fields.add(description); |
|
246 |
} catch (ReadDriverException e) { |
|
247 |
// TODO Auto-generated catch block |
|
248 |
e.printStackTrace(); |
|
249 |
} |
|
237 |
FieldDescription description = layer.getRecordset().getFieldsDescription()[dissolveFieldIndex]; |
|
238 |
fields.add(description); |
|
239 |
} catch (ReadDriverException e) { |
|
240 |
e.printStackTrace(); |
|
241 |
} |
|
250 | 242 |
|
251 | 243 |
FieldDescription[] fieldsDesc = null; |
252 | 244 |
if(fields.size() == 0){ |
Also available in: Unified diff