Revision 26
org.gvsig.lrs/trunk/org.gvsig.lrs/org.gvsig.lrs.lib/org.gvsig.lrs.lib.impl/src/main/java/org/gvsig/lrs/lib/impl/DefaultLrsAlgorithmsManager.java | ||
---|---|---|
89 | 89 |
if(params instanceof LrsCreateRouteAlgorithmParams){ |
90 | 90 |
return new LrsCreateRouteAlgorithm((LrsCreateRouteAlgorithmParams)params); |
91 | 91 |
} |
92 |
// if(params instanceof LrsCalibrateRouteAlgorithmParams){ |
|
93 |
// return new LrsCalibrateRouteAlgorithm((LrsCalibrateRouteAlgorithmParams)params); |
|
94 |
// } |
|
92 |
if(params instanceof LrsCalibrateRouteAlgorithmParams){ |
|
93 |
return new LrsCalibrateRouteAlgorithm((LrsCalibrateRouteAlgorithmParams)params); |
|
94 |
} |
|
95 |
if(params instanceof LrsGenerateDynamicSegmentationAlgorithmParams){ |
|
96 |
return new LrsGenerateDynamicSegmentationAlgorithm((LrsGenerateDynamicSegmentationAlgorithmParams)params); |
|
97 |
} |
|
95 | 98 |
return null; |
96 | 99 |
} |
97 | 100 |
|
org.gvsig.lrs/trunk/org.gvsig.lrs/org.gvsig.lrs.lib/org.gvsig.lrs.lib.impl/src/main/java/org/gvsig/lrs/lib/impl/LrsGenerateDynamicSegmentationAlgorithm.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2015 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.lrs.lib.impl; |
|
24 |
|
|
25 |
import java.awt.Dimension; |
|
26 |
import java.awt.geom.Point2D; |
|
27 |
import java.io.File; |
|
28 |
import java.sql.Array; |
|
29 |
import java.util.ArrayList; |
|
30 |
import java.util.Arrays; |
|
31 |
import java.util.Comparator; |
|
32 |
import java.util.HashMap; |
|
33 |
import java.util.Iterator; |
|
34 |
import java.util.List; |
|
35 |
import java.util.Map; |
|
36 |
import java.util.Map.Entry; |
|
37 |
|
|
38 |
import javax.xml.transform.Source; |
|
39 |
|
|
40 |
import org.apache.commons.lang3.StringUtils; |
|
41 |
import org.apache.commons.lang3.mutable.MutableDouble; |
|
42 |
|
|
43 |
import org.gvsig.fmap.dal.DALLocator; |
|
44 |
import org.gvsig.fmap.dal.DataManager; |
|
45 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
46 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
|
47 |
import org.gvsig.fmap.dal.DataStore; |
|
48 |
import org.gvsig.fmap.dal.DataTypes; |
|
49 |
import org.gvsig.fmap.dal.exception.DataException; |
|
50 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
|
51 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
|
52 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
53 |
import org.gvsig.fmap.dal.feature.Feature; |
|
54 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
55 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
|
56 |
import org.gvsig.fmap.dal.feature.FeatureReference; |
|
57 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
|
58 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
59 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
60 |
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
|
61 |
import org.gvsig.fmap.dal.store.shp.SHPNewStoreParameters; |
|
62 |
import org.gvsig.fmap.geom.Geometry; |
|
63 |
import org.gvsig.fmap.geom.Geometry.DIMENSIONS; |
|
64 |
import org.gvsig.fmap.geom.GeometryException; |
|
65 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
66 |
import org.gvsig.fmap.geom.GeometryManager; |
|
67 |
import org.gvsig.fmap.geom.aggregate.MultiLine; |
|
68 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
|
69 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
70 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
|
71 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
|
72 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
73 |
import org.gvsig.fmap.geom.primitive.Line; |
|
74 |
import org.gvsig.fmap.geom.primitive.Point; |
|
75 |
import org.gvsig.fmap.geom.type.GeometryType; |
|
76 |
import org.gvsig.lrs.lib.api.LrsAlgorithm; |
|
77 |
import org.gvsig.lrs.lib.api.LrsAlgorithmParams; |
|
78 |
import org.gvsig.lrs.lib.api.LrsCoordinatesPriority; |
|
79 |
import org.gvsig.lrs.lib.api.LrsCreateRouteAlgorithmParams; |
|
80 |
import org.gvsig.lrs.lib.api.LrsGenerateDynamicSegmentationAlgorithmParams; |
|
81 |
import org.gvsig.lrs.lib.api.LrsSourceOfMeasures; |
|
82 |
import org.gvsig.lrs.lib.api.exceptions.LrsCreateRouteException; |
|
83 |
import org.gvsig.lrs.lib.api.exceptions.LrsException; |
|
84 |
import org.gvsig.tools.ToolsLocator; |
|
85 |
import org.gvsig.tools.dataTypes.DataType; |
|
86 |
import org.gvsig.tools.exception.BaseException; |
|
87 |
import org.gvsig.tools.i18n.I18nManager; |
|
88 |
import org.gvsig.tools.locator.LocatorException; |
|
89 |
import org.gvsig.tools.service.Manager; |
|
90 |
import org.gvsig.tools.task.SimpleTaskStatus; |
|
91 |
import org.gvsig.tools.visitor.VisitCanceledException; |
|
92 |
import org.gvsig.tools.visitor.Visitor; |
|
93 |
|
|
94 |
import org.slf4j.Logger; |
|
95 |
import org.slf4j.LoggerFactory; |
|
96 |
|
|
97 |
/** |
|
98 |
* @author fdiaz |
|
99 |
* |
|
100 |
*/ |
|
101 |
public class LrsGenerateDynamicSegmentationAlgorithm implements LrsAlgorithm { |
|
102 |
|
|
103 |
private static final Logger logger = LoggerFactory.getLogger(LrsGenerateDynamicSegmentationAlgorithm.class); |
|
104 |
|
|
105 |
private LrsGenerateDynamicSegmentationAlgorithmParams parameters; |
|
106 |
|
|
107 |
|
|
108 |
/** |
|
109 |
* |
|
110 |
*/ |
|
111 |
public LrsGenerateDynamicSegmentationAlgorithm(LrsGenerateDynamicSegmentationAlgorithmParams parameters) { |
|
112 |
this.parameters = parameters; |
|
113 |
|
|
114 |
} |
|
115 |
|
|
116 |
/* |
|
117 |
* (non-Javadoc) |
|
118 |
* |
|
119 |
* @see org.gvsig.tools.service.Service#getManager() |
|
120 |
*/ |
|
121 |
public Manager getManager() { |
|
122 |
return null; |
|
123 |
} |
|
124 |
|
|
125 |
/* |
|
126 |
* (non-Javadoc) |
|
127 |
* |
|
128 |
* @see org.gvsig.lrs.lib.api.LrsAlgorithm#getParams() |
|
129 |
*/ |
|
130 |
public LrsAlgorithmParams getParams() { |
|
131 |
return this.parameters; |
|
132 |
} |
|
133 |
|
|
134 |
/* |
|
135 |
* (non-Javadoc) |
|
136 |
* @see org.gvsig.lrs.lib.api.LrsAlgorithm#execute(org.gvsig.tools.task.SimpleTaskStatus) |
|
137 |
*/ |
|
138 |
public void execute(final SimpleTaskStatus taskStatus) throws LrsException { |
|
139 |
NewFeatureStoreParameters newFeatureStoreParameters = parameters.getNewFeatureStoreParameters(); |
|
140 |
final FeatureStore sourceFeatureStore = parameters.getSourceFeatureStore(); |
|
141 |
final FeatureAttributeDescriptor idRouteField = parameters.getIdRouteField(); |
|
142 |
final FeatureAttributeDescriptor idTableRouteField = parameters.getValueTableIdRouteField(); |
|
143 |
FeatureStore tableFeatureStore = parameters.getValueTableFeatureStore(); |
|
144 |
final FeatureAttributeDescriptor landmarkField = parameters.getLandmarkField(); |
|
145 |
final FeatureAttributeDescriptor finalLandmarkField = parameters.getFinalLandmarkField(); |
|
146 |
final FeatureAttributeDescriptor valueField = parameters.getValueField(); |
|
147 |
|
|
148 |
logger.info(parameters.toString()); |
|
149 |
|
|
150 |
taskStatus.setTitle(parameters.getName()); |
|
151 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
152 |
taskStatus.message(i18nManager.getTranslation("processing")); |
|
153 |
|
|
154 |
try { |
|
155 |
final String routeFieldName=idRouteField.getName(); |
|
156 |
final String tableRouteFieldName=idTableRouteField.getName(); |
|
157 |
final String fromFieldName; |
|
158 |
final DataType fromDataType; |
|
159 |
final String toFieldName; |
|
160 |
final DataType toDataType; |
|
161 |
final int geomType; |
|
162 |
if (landmarkField!=null){ |
|
163 |
fromDataType=landmarkField.getDataType(); |
|
164 |
if (finalLandmarkField!=null){ |
|
165 |
fromFieldName="PK INICIAL"; |
|
166 |
toFieldName="PK FINAL"; |
|
167 |
toDataType=finalLandmarkField.getDataType(); |
|
168 |
geomType = Geometry.TYPES.MULTILINE; |
|
169 |
}else{ |
|
170 |
fromFieldName="PK"; |
|
171 |
toFieldName=null; |
|
172 |
toDataType=null; |
|
173 |
geomType = Geometry.TYPES.POINT; |
|
174 |
} |
|
175 |
}else{ |
|
176 |
//TODO: Si no hay fromFieldName ?salir por patas? |
|
177 |
fromFieldName=null; |
|
178 |
fromDataType=null; |
|
179 |
toFieldName=null; |
|
180 |
toDataType=null; |
|
181 |
geomType = Geometry.TYPES.POINT; |
|
182 |
} |
|
183 |
|
|
184 |
final FeatureStore newFeatureStore = createNewDataStore( |
|
185 |
newFeatureStoreParameters, |
|
186 |
idRouteField, |
|
187 |
fromFieldName, |
|
188 |
toFieldName, |
|
189 |
valueField, |
|
190 |
geomType |
|
191 |
); |
|
192 |
|
|
193 |
FeatureSet tableFeatures; |
|
194 |
tableFeatures=tableFeatureStore.getFeatureSet(); |
|
195 |
GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
196 |
taskStatus.setRangeOfValues(0, tableFeatures.getSize()-1); |
|
197 |
newFeatureStore.edit(FeatureStore.MODE_FULLEDIT); |
|
198 |
|
|
199 |
tableFeatures.accept(new Visitor() { |
|
200 |
|
|
201 |
int taskCount=0; |
|
202 |
public void visit(Object obj) throws VisitCanceledException, BaseException { |
|
203 |
Feature feature = (Feature) obj; |
|
204 |
String routeName = (String) feature.get(tableRouteFieldName); |
|
205 |
Object objFrom = null; |
|
206 |
Object objTo = null; |
|
207 |
if (fromFieldName != null) { |
|
208 |
objFrom = feature.get(landmarkField.getName()); |
|
209 |
double fromValue = LrsAlgorithmUtils.getAsDouble(objFrom, fromDataType); |
|
210 |
Object value = feature.get(valueField.getName()); |
|
211 |
if (toFieldName == null || toFieldName.isEmpty()) { |
|
212 |
addSegmentatePointsFeatures(newFeatureStore, sourceFeatureStore, idRouteField, routeName, fromFieldName, fromValue, valueField, value); |
|
213 |
} else { |
|
214 |
objTo = feature.get(finalLandmarkField.getName()); |
|
215 |
double toValue = LrsAlgorithmUtils.getAsDouble(objTo, toDataType); |
|
216 |
addSegmentateLinesFeatures(newFeatureStore, sourceFeatureStore, idRouteField, routeName, |
|
217 |
fromFieldName, fromValue, toFieldName, toValue, valueField, value); |
|
218 |
} |
|
219 |
|
|
220 |
} else { |
|
221 |
//TODO: ?Exception? |
|
222 |
} |
|
223 |
taskStatus.setCurValue(taskCount++); |
|
224 |
} |
|
225 |
|
|
226 |
private void addSegmentatePointsFeatures(final FeatureStore featureStore, |
|
227 |
FeatureStore sourceFeatureStore, final FeatureAttributeDescriptor idRouteField, |
|
228 |
final String routeName, final String fromFieldName, final double fromValue, final FeatureAttributeDescriptor valueField, final Object value) |
|
229 |
throws LocatorException, BaseException { |
|
230 |
|
|
231 |
DataManager dataManager = DALLocator.getDataManager(); |
|
232 |
FeatureQuery query = sourceFeatureStore.createFeatureQuery(); |
|
233 |
String expression = StringUtils.replace(StringUtils.replace("NOMBRE like 'a%'", "NOMBRE", idRouteField.getName()), "a%", routeName); |
|
234 |
query.setFilter( dataManager.createExpresion(expression) ); |
|
235 |
|
|
236 |
FeatureSet features = sourceFeatureStore.getFeatureSet(query); |
|
237 |
features.accept(new Visitor() { |
|
238 |
|
|
239 |
public void visit(Object obj) throws VisitCanceledException, BaseException { |
|
240 |
Feature feature = (Feature)obj; |
|
241 |
Geometry geom = feature.getDefaultGeometry(); |
|
242 |
List<Point>points = LrsAlgorithmUtils.getPointsWithM(geom, fromValue); |
|
243 |
for (Iterator<Point> iterator = points.iterator(); iterator.hasNext();) { |
|
244 |
Point point = (Point) iterator.next(); |
|
245 |
EditableFeature newFeature = featureStore.createNewFeature(true); |
|
246 |
newFeature.set(idRouteField.getName(), routeName); |
|
247 |
newFeature.set(fromFieldName, fromValue); |
|
248 |
newFeature.set(valueField.getName(), value); |
|
249 |
newFeature.setDefaultGeometry(point); |
|
250 |
featureStore.insert(newFeature); |
|
251 |
} |
|
252 |
} |
|
253 |
}); |
|
254 |
} |
|
255 |
|
|
256 |
private void addSegmentateLinesFeatures(final FeatureStore featureStore, |
|
257 |
FeatureStore sourceFeatureStore, final FeatureAttributeDescriptor idRouteField, |
|
258 |
final String routeName, final String fromFieldName, final double fromValue, |
|
259 |
final String toFieldName, final double toValue, final FeatureAttributeDescriptor valueField, final Object value) throws LocatorException, BaseException { |
|
260 |
|
|
261 |
DataManager dataManager = DALLocator.getDataManager(); |
|
262 |
FeatureQuery query = sourceFeatureStore.createFeatureQuery(); |
|
263 |
String expression = StringUtils.replace(StringUtils.replace("NOMBRE like 'a%'", "NOMBRE", idRouteField.getName()), "a%", routeName); |
|
264 |
query.setFilter( dataManager.createExpresion(expression) ); |
|
265 |
|
|
266 |
FeatureSet features = sourceFeatureStore.getFeatureSet(query); |
|
267 |
features.accept(new Visitor() { |
|
268 |
|
|
269 |
public void visit(Object obj) throws VisitCanceledException, BaseException { |
|
270 |
Feature feature = (Feature) obj; |
|
271 |
Geometry geom = feature.getDefaultGeometry(); |
|
272 |
MultiLine lines = LrsAlgorithmUtils.getLinesBetweenTwoM(geom, fromValue, toValue); |
|
273 |
if (lines != null && lines.getPrimitivesNumber()>0) { |
|
274 |
EditableFeature newFeature = featureStore.createNewFeature(true); |
|
275 |
newFeature.set(idRouteField.getName(), routeName); |
|
276 |
newFeature.set(fromFieldName, fromValue); |
|
277 |
newFeature.set(toFieldName, toValue); |
|
278 |
newFeature.set(valueField.getName(), value); |
|
279 |
newFeature.setDefaultGeometry(lines); |
|
280 |
featureStore.insert(newFeature); |
|
281 |
} |
|
282 |
} |
|
283 |
}); |
|
284 |
} |
|
285 |
}); |
|
286 |
|
|
287 |
newFeatureStore.finishEditing(); |
|
288 |
|
|
289 |
} catch (Exception e1) { |
|
290 |
taskStatus.abort(); |
|
291 |
throw new LrsCreateRouteException("Error creating routes", e1); |
|
292 |
} |
|
293 |
|
|
294 |
|
|
295 |
taskStatus.terminate(); |
|
296 |
|
|
297 |
} |
|
298 |
|
|
299 |
|
|
300 |
/* (non-Javadoc) |
|
301 |
* @see org.gvsig.lrs.lib.api.LrsAlgorithm#setParams(org.gvsig.lrs.lib.api.LrsAlgorithmParams) |
|
302 |
*/ |
|
303 |
public void setParams(LrsAlgorithmParams params) throws IllegalArgumentException { |
|
304 |
if(!(params instanceof LrsCreateRouteAlgorithmParams)){ |
|
305 |
throw new IllegalArgumentException("params should be LrsCreateRouteAlgorithmParams type."); |
|
306 |
} |
|
307 |
// TODO Auto-generated method stub |
|
308 |
|
|
309 |
} |
|
310 |
|
|
311 |
private FeatureStore createNewDataStore( |
|
312 |
NewFeatureStoreParameters newFeatureStoreParameters, |
|
313 |
FeatureAttributeDescriptor idRouteField, |
|
314 |
String fromFieldName, |
|
315 |
String toFieldName, |
|
316 |
FeatureAttributeDescriptor valueField, |
|
317 |
int type) throws Exception{ |
|
318 |
try { |
|
319 |
SHPNewStoreParameters shapeStoreParams = (SHPNewStoreParameters)newFeatureStoreParameters; |
|
320 |
File file=shapeStoreParams.getFile(); |
|
321 |
String filePath=file.getPath().substring(0, file.getPath().lastIndexOf(File.separator)); |
|
322 |
|
|
323 |
DataManager dataManager = DALLocator.getDataManager(); |
|
324 |
DataServerExplorerParameters serverParams = |
|
325 |
dataManager.createServerExplorerParameters("FilesystemExplorer"); |
|
326 |
serverParams.setDynValue("initialpath", filePath); |
|
327 |
DataServerExplorer serverExplorer = |
|
328 |
dataManager.openServerExplorer(serverParams.getExplorerName(), serverParams); |
|
329 |
|
|
330 |
EditableFeatureType featureType = (EditableFeatureType)shapeStoreParams.getDefaultFeatureType(); |
|
331 |
featureType.add(idRouteField.getName(), idRouteField.getType(), idRouteField.getSize()); |
|
332 |
featureType.add(fromFieldName, DataTypes.DOUBLE); |
|
333 |
if(toFieldName!=null){ |
|
334 |
featureType.add(toFieldName, DataTypes.DOUBLE); |
|
335 |
} |
|
336 |
featureType.add(valueField.getName(), valueField.getType(), valueField.getSize()); |
|
337 |
EditableFeatureAttributeDescriptor geometryField = featureType.add("Geometry", DataTypes.GEOMETRY); |
|
338 |
GeometryType geometryType = GeometryLocator.getGeometryManager().getGeometryType(type, Geometry.SUBTYPES.GEOM2DM); |
|
339 |
geometryField.setGeometryType(geometryType); |
|
340 |
|
|
341 |
featureType.setDefaultGeometryAttributeName("Geometry"); |
|
342 |
|
|
343 |
shapeStoreParams.setDefaultFeatureType(featureType); |
|
344 |
serverExplorer.add("Shape", shapeStoreParams, true); |
|
345 |
|
|
346 |
DataStore store = dataManager.createStore(shapeStoreParams); |
|
347 |
|
|
348 |
return (FeatureStore)store; |
|
349 |
|
|
350 |
} catch (Exception e) { |
|
351 |
throw new LrsCreateRouteException("Error creating new dataStore", e); |
|
352 |
} |
|
353 |
} |
|
354 |
|
|
355 |
|
|
356 |
} |
|
357 |
|
|
358 |
|
|
359 |
|
|
360 |
|
org.gvsig.lrs/trunk/org.gvsig.lrs/org.gvsig.lrs.lib/org.gvsig.lrs.lib.impl/src/main/java/org/gvsig/lrs/lib/impl/LrsAlgorithmUtils.java | ||
---|---|---|
7 | 7 |
package org.gvsig.lrs.lib.impl; |
8 | 8 |
|
9 | 9 |
import java.io.File; |
10 |
import java.util.ArrayList; |
|
11 |
import java.util.Iterator; |
|
12 |
import java.util.List; |
|
10 | 13 |
|
14 |
import javax.swing.text.html.HTMLDocument.HTMLReader.IsindexAction; |
|
15 |
|
|
11 | 16 |
import org.gvsig.fmap.dal.DALLocator; |
12 | 17 |
import org.gvsig.fmap.dal.DataManager; |
13 | 18 |
import org.gvsig.fmap.dal.DataServerExplorer; |
... | ... | |
22 | 27 |
import org.gvsig.fmap.dal.store.shp.SHPNewStoreParameters; |
23 | 28 |
import org.gvsig.fmap.geom.Geometry; |
24 | 29 |
import org.gvsig.fmap.geom.GeometryLocator; |
30 |
import org.gvsig.fmap.geom.GeometryManager; |
|
31 |
import org.gvsig.fmap.geom.aggregate.MultiLine; |
|
32 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
33 |
import org.gvsig.fmap.geom.primitive.Line; |
|
34 |
import org.gvsig.fmap.geom.primitive.Point; |
|
25 | 35 |
import org.gvsig.fmap.geom.type.GeometryType; |
26 | 36 |
import org.gvsig.lrs.lib.api.exceptions.LrsCreateRouteException; |
27 | 37 |
import org.gvsig.tools.dataTypes.DataType; |
38 |
import org.gvsig.tools.locator.LocatorException; |
|
28 | 39 |
|
29 | 40 |
public class LrsAlgorithmUtils { |
30 | 41 |
|
31 |
static protected FeatureStore createNewDataStore(NewFeatureStoreParameters newFeatureStoreParameters,FeatureAttributeDescriptor idRouteField) |
|
32 |
throws Exception{ |
|
42 |
static protected FeatureStore createNewDataStore(NewFeatureStoreParameters newFeatureStoreParameters, |
|
43 |
FeatureAttributeDescriptor idRouteField) throws Exception { |
|
44 |
return createNewDataStore(newFeatureStoreParameters, idRouteField, Geometry.TYPES.MULTILINE); |
|
45 |
} |
|
46 |
|
|
47 |
static protected FeatureStore createNewDataStore(NewFeatureStoreParameters newFeatureStoreParameters, |
|
48 |
FeatureAttributeDescriptor idRouteField, int type) throws Exception { |
|
33 | 49 |
try { |
34 |
SHPNewStoreParameters shapeStoreParams = (SHPNewStoreParameters)newFeatureStoreParameters; |
|
35 |
File file=shapeStoreParams.getFile();
|
|
36 |
String filePath=file.getPath().substring(0, file.getPath().lastIndexOf(File.separator));
|
|
50 |
SHPNewStoreParameters shapeStoreParams = (SHPNewStoreParameters) newFeatureStoreParameters;
|
|
51 |
File file = shapeStoreParams.getFile();
|
|
52 |
String filePath = file.getPath().substring(0, file.getPath().lastIndexOf(File.separator));
|
|
37 | 53 |
|
38 | 54 |
DataManager dataManager = DALLocator.getDataManager(); |
39 | 55 |
DataServerExplorerParameters serverParams = |
... | ... | |
42 | 58 |
DataServerExplorer serverExplorer = |
43 | 59 |
dataManager.openServerExplorer(serverParams.getExplorerName(), serverParams); |
44 | 60 |
|
45 |
EditableFeatureType featureType = (EditableFeatureType)shapeStoreParams.getDefaultFeatureType(); |
|
61 |
EditableFeatureType featureType = (EditableFeatureType) shapeStoreParams.getDefaultFeatureType();
|
|
46 | 62 |
featureType.add(idRouteField.getName(), idRouteField.getType(), idRouteField.getSize()); |
47 | 63 |
EditableFeatureAttributeDescriptor geometryField = featureType.add("Geometry", DataTypes.GEOMETRY); |
48 |
//GeometryType geometryType = GeometryLocator.getGeometryManager().getGeometryType(Geometry.TYPES.MULTICURVE, Geometry.SUBTYPES.GEOM2D);
|
|
49 |
GeometryType geometryType = GeometryLocator.getGeometryManager().getGeometryType(Geometry.TYPES.MULTILINE, Geometry.SUBTYPES.GEOM2DM);
|
|
64 |
GeometryType geometryType =
|
|
65 |
GeometryLocator.getGeometryManager().getGeometryType(type, Geometry.SUBTYPES.GEOM2DM);
|
|
50 | 66 |
geometryField.setGeometryType(geometryType); |
51 | 67 |
|
52 | 68 |
featureType.setDefaultGeometryAttributeName("Geometry"); |
... | ... | |
56 | 72 |
|
57 | 73 |
DataStore store = dataManager.createStore(shapeStoreParams); |
58 | 74 |
|
59 |
return (FeatureStore)store; |
|
75 |
return (FeatureStore) store;
|
|
60 | 76 |
|
61 | 77 |
} catch (Exception e) { |
62 | 78 |
throw new LrsCreateRouteException("Error creating new dataStore", e); |
63 | 79 |
} |
64 | 80 |
} |
65 | 81 |
|
66 |
|
|
67 |
static protected Double getAsDouble(Object obj,DataType dataType){ |
|
68 |
if (obj==null||dataType==null) return null; |
|
69 |
Double result=Double.NaN; |
|
70 |
if (dataType.equals(DataTypes.DOUBLE)){ |
|
71 |
result=(Double)obj; |
|
72 |
}else if(dataType.isNumeric()){ |
|
73 |
result=Double.valueOf(String.valueOf(obj)); |
|
82 |
static protected Double getAsDouble(Object obj, DataType dataType) { |
|
83 |
if (obj == null || dataType == null) { |
|
84 |
return null; |
|
74 | 85 |
} |
86 |
Double result = Double.NaN; |
|
87 |
if (dataType.equals(DataTypes.DOUBLE)) { |
|
88 |
result = (Double) obj; |
|
89 |
} else if (dataType.isNumeric()) { |
|
90 |
result = Double.valueOf(String.valueOf(obj)); |
|
91 |
} |
|
75 | 92 |
return result; |
76 | 93 |
} |
94 |
|
|
95 |
static List<Point> getPointsWithM(Geometry geom, double m) throws CreateGeometryException, LocatorException { |
|
96 |
List<Point> points = new ArrayList<Point>(); |
|
97 |
|
|
98 |
if (geom instanceof Line) { |
|
99 |
Line line = (Line) geom; |
|
100 |
for (int i = 0; i < line.getNumVertices() - 1; i++) { |
|
101 |
Point point = getPointWithMBetweenTwoMPoints(m, line.getVertex(i), line.getVertex(i + 1)); |
|
102 |
if (point != null) { |
|
103 |
points.add(point); |
|
104 |
} |
|
105 |
} |
|
106 |
} else if (geom instanceof MultiLine) { |
|
107 |
MultiLine multiLine = (MultiLine) geom; |
|
108 |
for (int p = 0; p < multiLine.getPrimitivesNumber(); p++) { |
|
109 |
Line line = (Line) multiLine.getPrimitiveAt(p); |
|
110 |
for (int i = 0; i < line.getNumVertices() - 1; i++) { |
|
111 |
Point point = getPointWithMBetweenTwoMPoints(m, line.getVertex(i), line.getVertex(i + 1)); |
|
112 |
if (point != null) { |
|
113 |
points.add(point); |
|
114 |
} |
|
115 |
} |
|
116 |
} |
|
117 |
} |
|
118 |
return points; |
|
119 |
} |
|
120 |
|
|
121 |
private static boolean isInRange(double v, double r1, double r2) { |
|
122 |
if (r1 < r2) { |
|
123 |
return v >= r1 && v <= r2; |
|
124 |
} else if (r1 > r2) { |
|
125 |
return v >= r2 && v <= r1; |
|
126 |
} else { |
|
127 |
return v == r1; |
|
128 |
} |
|
129 |
} |
|
130 |
|
|
131 |
static MultiLine getLinesBetweenTwoM(Geometry geom, double m1, double m2) throws CreateGeometryException, |
|
132 |
LocatorException { |
|
133 |
GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
134 |
|
|
135 |
MultiLine lines = null; |
|
136 |
if (geom instanceof Line) { |
|
137 |
lines = getLinesBetweenTwoM((Line) geom, m1, m2); |
|
138 |
} else if (geom instanceof MultiLine) { |
|
139 |
lines = (MultiLine) geomManager.create(Geometry.TYPES.MULTILINE, geom.getGeometryType().getSubType()); |
|
140 |
MultiLine multiLine = (MultiLine) geom; |
|
141 |
for (int i = 0; i < multiLine.getPrimitivesNumber(); i++) { |
|
142 |
MultiLine auxMultiLine = getLinesBetweenTwoM(multiLine.getPrimitiveAt(i), m1, m2); |
|
143 |
for (int j = 0; j < auxMultiLine.getPrimitivesNumber(); j++) { |
|
144 |
lines.addPrimitive(auxMultiLine.getPrimitiveAt(j)); |
|
145 |
} |
|
146 |
} |
|
147 |
} |
|
148 |
return lines; |
|
149 |
} |
|
150 |
|
|
151 |
static private MultiLine getLinesBetweenTwoM(Line line, double m1, double m2) throws CreateGeometryException { |
|
152 |
GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
153 |
MultiLine lines = (MultiLine) geomManager.create(Geometry.TYPES.MULTILINE, line.getGeometryType().getSubType()); |
|
154 |
Line auxLine = (Line) geomManager.create(Geometry.TYPES.LINE, line.getGeometryType().getSubType()); |
|
155 |
|
|
156 |
boolean inSegment = false; |
|
157 |
if (line.getNumVertices() > 0) { |
|
158 |
int ivertex = 0; |
|
159 |
Point previousVertex = null; |
|
160 |
while (ivertex < line.getNumVertices()) { |
|
161 |
if (!inSegment) { // NO ESTAMOS EN UN SEGMENTO VALIDO |
|
162 |
Point vertex = line.getVertex(ivertex); |
|
163 |
double m = vertex.getCoordinateAt(vertex.getDimension() - 1); |
|
164 |
if (isInRange(m, m1, m2)) { |
|
165 |
// Si la m del vertice actual entra en el rango: |
|
166 |
if (previousVertex == null) { |
|
167 |
// Si no hay previousVertex, este debe ser el primer |
|
168 |
// vertice, entonces |
|
169 |
// - a?adimos el v?rtice a la linea |
|
170 |
// - marcamos que estamos en un segmento valido |
|
171 |
// - nos guardamos el vertice como previousVertex |
|
172 |
// - aumentamos el indice para coger el siguiente |
|
173 |
// v?rtice en la pr?xima iteraci?n |
|
174 |
auxLine.addVertex(vertex); |
|
175 |
previousVertex = vertex; |
|
176 |
inSegment = true; |
|
177 |
ivertex++; |
|
178 |
} else { |
|
179 |
// - Calculamos qu? punto habr?a iniciado el |
|
180 |
// segmento v?lido |
|
181 |
double previousM = previousVertex.getCoordinateAt(previousVertex.getDimension() - 1); |
|
182 |
// FIXME: Esta comprobaci?n se podr?a quitar |
|
183 |
if (isInRange(m1, previousM, m) || isInRange(m2, previousM, m)) { |
|
184 |
Point point = getPointWithMBetweenTwoMPoints(m1, previousVertex, vertex); |
|
185 |
if (point == null) { |
|
186 |
point = getPointWithMBetweenTwoMPoints(m2, previousVertex, vertex); |
|
187 |
} |
|
188 |
if (point != null) { |
|
189 |
// - A?adimos el punto a la linea auxiliar |
|
190 |
// - Marcamos que estamos en un segmento v?lido |
|
191 |
// - nos guardamos el punto como previousVertex |
|
192 |
// - y NO aumentamos el indice |
|
193 |
auxLine.addVertex(point); |
|
194 |
inSegment = true; |
|
195 |
previousVertex = point; |
|
196 |
} else { |
|
197 |
// Nunca deber?a pasar por aqu? |
|
198 |
} |
|
199 |
} |
|
200 |
} |
|
201 |
} else { |
|
202 |
// Cabe la posibilidad de que entre un vertice y otro se |
|
203 |
// entre y se salga del rango |
|
204 |
if (previousVertex != null) { |
|
205 |
double previousM = previousVertex.getCoordinateAt(previousVertex.getDimension() - 1); |
|
206 |
if (isInRange(m1, previousM, m) && isInRange(m2, previousM, m)) { |
|
207 |
Point point1 = getPointWithMBetweenTwoMPoints(m1, previousVertex, vertex); |
|
208 |
Point point2 = getPointWithMBetweenTwoMPoints(m2, previousVertex, vertex); |
|
209 |
auxLine.addVertex(point1); |
|
210 |
auxLine.addVertex(point2); |
|
211 |
lines.addPrimitive(auxLine); |
|
212 |
} |
|
213 |
} |
|
214 |
|
|
215 |
// Si la m del v?rtice actual no entra en el rango: |
|
216 |
// - nos guardamos el vertice como previousVertex |
|
217 |
// - aumentamos el indice para coger el siguiente |
|
218 |
// v?rtice en la pr?xima iteraci?n |
|
219 |
previousVertex = vertex; |
|
220 |
ivertex++; |
|
221 |
} |
|
222 |
} else { // ESTAMOS EN UN SEGMENTO VALIDO |
|
223 |
Point vertex = line.getVertex(ivertex); |
|
224 |
double m = vertex.getCoordinateAt(previousVertex.getDimension() - 1); |
|
225 |
if (isInRange(m, m1, m2)) { |
|
226 |
// Si la m del vertice actual entra en el rango: |
|
227 |
// - a?adimos el v?rtice a la linea |
|
228 |
// - aumentamos el indice para coger el siguiente |
|
229 |
// v?rtice en la pr?xima iteraci?n |
|
230 |
auxLine.addVertex(vertex); |
|
231 |
previousVertex = vertex; |
|
232 |
ivertex++; |
|
233 |
} else { |
|
234 |
// Si la m del v?rtice actual no entra en el rango: |
|
235 |
// - Calculamos el punto que habr?a finalizado el |
|
236 |
// segmento v?lido entre el vertice anterior y el actual |
|
237 |
Point point = getPointWithMBetweenTwoMPoints(m1, previousVertex, vertex); |
|
238 |
if (point == null) { |
|
239 |
point = getPointWithMBetweenTwoMPoints(m2, previousVertex, vertex); |
|
240 |
} |
|
241 |
if (point != null) { |
|
242 |
// - A?adimos el punto a la linea auxiliar |
|
243 |
// - a?adimos la linea y creamos una nueva |
|
244 |
// - Marcamos que NO estamos en un segmento v?lido |
|
245 |
// - nos guardamos el punto como previousVertex |
|
246 |
// - y NO aumentamos el indice |
|
247 |
auxLine.addVertex(point); |
|
248 |
lines.addPrimitive(auxLine); |
|
249 |
auxLine = |
|
250 |
(Line) geomManager.create(Geometry.TYPES.LINE, line.getGeometryType().getSubType()); |
|
251 |
inSegment = false; |
|
252 |
previousVertex = point; |
|
253 |
} else { |
|
254 |
// Nunca deber?a pasar por aqu? |
|
255 |
} |
|
256 |
} |
|
257 |
} |
|
258 |
} |
|
259 |
} |
|
260 |
if (inSegment && auxLine.getNumVertices() > 0) { |
|
261 |
lines.addPrimitive(auxLine); |
|
262 |
} |
|
263 |
return lines; |
|
264 |
} |
|
265 |
|
|
266 |
/* |
|
267 |
* |
|
268 |
*/ |
|
269 |
private static Point getPointWithMBetweenTwoMPoints(double m, Point p1, Point p2) throws CreateGeometryException, |
|
270 |
LocatorException { |
|
271 |
double x; |
|
272 |
double y; |
|
273 |
double m1 = p1.getCoordinateAt(p1.getDimension() - 1); |
|
274 |
double m2 = p2.getCoordinateAt(p2.getDimension() - 1); |
|
275 |
|
|
276 |
if (m1 <= m2) { |
|
277 |
if (m < m1 || m > m2) { |
|
278 |
return null; |
|
279 |
} |
|
280 |
} else { |
|
281 |
if (m < m2 || m > m1) { |
|
282 |
return null; |
|
283 |
} |
|
284 |
} |
|
285 |
|
|
286 |
double x1 = p1.getX(); |
|
287 |
double x2 = p2.getX(); |
|
288 |
double y1 = p1.getY(); |
|
289 |
double y2 = p2.getY(); |
|
290 |
if (x1 == x2) { |
|
291 |
x = x1; |
|
292 |
} else { |
|
293 |
x = ((x2 - x1) * (m - m1) / (m2 - m1)) + x1; |
|
294 |
} |
|
295 |
if (y1 == y2) { |
|
296 |
y = y1; |
|
297 |
} else { |
|
298 |
y = ((y2 - y1) * (m - m1) / (m2 - m1)) + y1; |
|
299 |
} |
|
300 |
|
|
301 |
Point point = (Point) GeometryLocator.getGeometryManager().create(p1.getGeometryType()); |
|
302 |
point.setX(x); |
|
303 |
point.setY(y); |
|
304 |
point.setCoordinateAt(point.getDimension() - 1, m); |
|
305 |
return point; |
|
306 |
} |
|
77 | 307 |
} |
org.gvsig.lrs/trunk/org.gvsig.lrs/org.gvsig.lrs.swing/org.gvsig.lrs.swing.impl/src/main/java/org/gvsig/lrs/swing/impl/FLayersAttributeDescriptorCellRenderer.java | ||
---|---|---|
27 | 27 |
if (value instanceof FeatureAttributeDescriptor) { |
28 | 28 |
renderer.setText(((FeatureAttributeDescriptor) value).getName()); |
29 | 29 |
} |
30 |
if (value == null) { |
|
31 |
renderer.setText(""); |
|
32 |
} |
|
30 | 33 |
return renderer; |
31 | 34 |
} |
32 | 35 |
|
org.gvsig.lrs/trunk/org.gvsig.lrs/org.gvsig.lrs.swing/org.gvsig.lrs.swing.impl/src/main/java/org/gvsig/lrs/swing/impl/JLrsGenerateDynamicSegmentationParamsController.java | ||
---|---|---|
14 | 14 |
import java.util.List; |
15 | 15 |
import java.util.Locale; |
16 | 16 |
|
17 |
import javax.swing.JButton; |
|
18 | 17 |
import javax.swing.JComponent; |
19 | 18 |
import javax.swing.JOptionPane; |
20 | 19 |
import javax.swing.ListCellRenderer; |
21 | 20 |
|
22 | 21 |
import org.apache.commons.io.FileUtils; |
23 | 22 |
import org.apache.commons.lang3.StringUtils; |
24 |
import org.apache.commons.lang3.mutable.MutableBoolean; |
|
25 | 23 |
import org.cresques.cts.IProjection; |
26 |
import org.gvsig.fmap.dal.DALLocator;
|
|
27 |
import org.gvsig.fmap.dal.DataManager;
|
|
28 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
24 |
import org.slf4j.Logger;
|
|
25 |
import org.slf4j.LoggerFactory;
|
|
26 |
|
|
29 | 27 |
import org.gvsig.fmap.dal.exception.DataException; |
30 | 28 |
import org.gvsig.fmap.dal.exception.ReadException; |
31 | 29 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
... | ... | |
34 | 32 |
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
35 | 33 |
import org.gvsig.fmap.dal.store.shp.SHPNewStoreParameters; |
36 | 34 |
import org.gvsig.fmap.geom.DataTypes; |
37 |
import org.gvsig.fmap.geom.Geometry; |
|
38 | 35 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
39 | 36 |
import org.gvsig.fmap.mapcontext.layers.operations.LayerCollection; |
40 | 37 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
... | ... | |
46 | 43 |
import org.gvsig.lrs.lib.api.exceptions.LrsNeededParameterException; |
47 | 44 |
import org.gvsig.lrs.swing.api.JLrsAlgorithmParams; |
48 | 45 |
import org.gvsig.tools.ToolsLocator; |
49 |
import org.gvsig.tools.exception.BaseException; |
|
50 | 46 |
import org.gvsig.tools.i18n.I18nManager; |
51 | 47 |
import org.gvsig.tools.swing.api.ActionListenerSupport; |
52 | 48 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
53 | 49 |
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager; |
54 |
import org.gvsig.tools.visitor.VisitCanceledException; |
|
55 |
import org.gvsig.tools.visitor.Visitor; |
|
56 |
import org.slf4j.Logger; |
|
57 |
import org.slf4j.LoggerFactory; |
|
58 | 50 |
|
59 | 51 |
public class JLrsGenerateDynamicSegmentationParamsController extends |
60 | 52 |
JLrsGenerateDynamicSegmentationParamsView implements JLrsAlgorithmParams { |
61 | 53 |
|
54 |
/** |
|
55 |
* |
|
56 |
*/ |
|
57 |
private static final long serialVersionUID = -5764089056918981236L; |
|
58 |
|
|
62 | 59 |
private static final Logger logger = LoggerFactory |
63 | 60 |
.getLogger(JLrsGenerateDynamicSegmentationParamsController.class); |
64 | 61 |
|
... | ... | |
230 | 227 |
cmbInputLayer.setModel(inputLayerModel); |
231 | 228 |
cmbTable.setModel(tableLayerModel); |
232 | 229 |
|
233 |
// listener del combo de capas para que actualice el resto de |
|
234 |
// componentes |
|
230 |
// listener del combo de capas para que actualice el resto de componentes |
|
235 | 231 |
cmbInputLayer.addItemListener(new ItemListener() { |
236 | 232 |
|
237 | 233 |
public void itemStateChanged(ItemEvent e) { |
... | ... | |
249 | 245 |
if (item instanceof FeatureStore) { |
250 | 246 |
FeatureStore featureStore = (FeatureStore) item; |
251 | 247 |
updateTable(featureStore); |
248 |
clearTableFields(); |
|
252 | 249 |
} |
253 | 250 |
} |
254 | 251 |
}); |
... | ... | |
352 | 349 |
logger.error("Error getting selected item from cmbInputLayer"); |
353 | 350 |
throw new LrsGettingParametersException("error_getting_selected_item_from_cmbInputLayer", null); |
354 | 351 |
} |
355 |
FLyrVect fLyrVect = (FLyrVect) this.cmbIdRouteField.getSelectedItem();
|
|
352 |
FLyrVect fLyrVect = (FLyrVect) this.cmbInputLayer.getSelectedItem();
|
|
356 | 353 |
IProjection projection= fLyrVect.getProjection(); |
357 | 354 |
if (!(fLyrVect.getFeatureStore() instanceof FeatureStore)){ |
358 | 355 |
logger.error("Error getting selected item from cmbInputLayer"); |
... | ... | |
406 | 403 |
params.setLandmarkField(landmarkField); |
407 | 404 |
|
408 | 405 |
//cmbFinalLandmarkField |
409 |
if (!(this.cmbFinalLandmarkField.getSelectedItem() instanceof FeatureAttributeDescriptor)){ |
|
406 |
if (this.cmbFinalLandmarkField.getSelectedItem()!=null && !(this.cmbFinalLandmarkField.getSelectedItem() instanceof FeatureAttributeDescriptor)){
|
|
410 | 407 |
logger.error("Error getting selected item from cmbFinalLandmarkField"); |
411 | 408 |
throw new LrsGettingParametersException("error_getting_selected_item_from_cmbFinalLandmarkField", null); |
412 | 409 |
} |
... | ... | |
479 | 476 |
if (inputLayerSelected != null) { |
480 | 477 |
this.updateLayerSource((FLyrVect) inputLayerSelected); |
481 | 478 |
} |
479 |
if (this.cmbIdRouteField.getItemCount() > 0) { |
|
480 |
this.cmbIdRouteField.setSelectedIndex(0); |
|
481 |
} |
|
482 | 482 |
this.cmbTable.setSelectedIndex(0); |
483 | 483 |
Object tableSelected = this.cmbTable.getSelectedItem(); |
484 | 484 |
if (tableSelected != null) { |
485 | 485 |
this.updateTable((FeatureStore) tableSelected); |
486 | 486 |
} |
487 |
this.cmbIdRouteField.setSelectedIndex(0); |
|
488 |
this.cmbTableIdRouteField.setSelectedIndex(0); |
|
489 |
this.cmbLandmarkField.setSelectedIndex(0); |
|
490 |
this.cmbFinalLandmarkField.setSelectedIndex(0); |
|
491 |
this.cmbValueField.setSelectedIndex(0); |
|
487 |
clearTableFields(); |
|
492 | 488 |
} |
493 | 489 |
|
490 |
/** |
|
491 |
* |
|
492 |
*/ |
|
493 |
private void clearTableFields() { |
|
494 |
logger.info(String.valueOf(this.cmbTableIdRouteField.getItemCount())); |
|
495 |
if (this.cmbTableIdRouteField.getItemCount() > 0) { |
|
496 |
this.cmbTableIdRouteField.setSelectedIndex(0); |
|
497 |
} |
|
498 |
logger.info(String.valueOf(this.cmbLandmarkField.getItemCount())); |
|
499 |
if (this.cmbLandmarkField.getItemCount() > 0) { |
|
500 |
this.cmbLandmarkField.setSelectedIndex(0); |
|
501 |
} |
|
502 |
logger.info(String.valueOf(this.cmbFinalLandmarkField.getItemCount())); |
|
503 |
this.cmbFinalLandmarkField.setSelectedIndex(-1); |
|
504 |
|
|
505 |
logger.info(String.valueOf(this.cmbValueField.getItemCount())); |
|
506 |
if (this.cmbValueField.getItemCount() > 0) { |
|
507 |
this.cmbValueField.setSelectedIndex(0); |
|
508 |
} |
|
509 |
this.cmbTableIdRouteField.repaint(); |
|
510 |
this.cmbLandmarkField.repaint(); |
|
511 |
this.cmbFinalLandmarkField.repaint(); |
|
512 |
this.cmbValueField.repaint(); |
|
513 |
|
|
514 |
} |
|
515 |
|
|
494 | 516 |
private void updateLayerSource(FLyrVect layer) { |
495 | 517 |
logger.info(new StringBuilder().append("Setting layer ") |
496 | 518 |
.append(layer.getName()).toString()); |
... | ... | |
547 | 569 |
this.cmbFinalLandmarkField.setModel(finalLandmarkComboBoxModel); |
548 | 570 |
this.cmbValueField.setModel(valueComboBoxModel); |
549 | 571 |
|
550 |
FeatureAttributeDescriptor[] attributeDescriptors = |
|
551 |
type.getAttributeDescriptors(); |
|
552 |
for (int i = 0; i < attributeDescriptors.length; i++) { |
|
572 |
// Renderer para los combos de attributeDescriptors |
|
573 |
ListCellRenderer featureAttributeDescriptorCellRenderer = |
|
574 |
new FLayersAttributeDescriptorCellRenderer(); |
|
575 |
// asignaci?n de renderers |
|
576 |
cmbTableIdRouteField |
|
577 |
.setRenderer(featureAttributeDescriptorCellRenderer); |
|
578 |
cmbLandmarkField.setRenderer(featureAttributeDescriptorCellRenderer); |
|
579 |
cmbFinalLandmarkField |
|
580 |
.setRenderer(featureAttributeDescriptorCellRenderer); |
|
581 |
cmbValueField.setRenderer(featureAttributeDescriptorCellRenderer); |
|
582 |
|
|
583 |
this.cmbFinalLandmarkField.insertItemAt(null,0); |
|
584 |
|
|
585 |
FeatureAttributeDescriptor[] attributeDescriptors = type.getAttributeDescriptors(); |
|
586 |
for (int i = 0; i<attributeDescriptors.length; i++) { |
|
553 | 587 |
FeatureAttributeDescriptor featureAttributeDescriptor = |
554 | 588 |
attributeDescriptors[i]; |
555 |
if (featureAttributeDescriptor.getDataType() |
|
556 |
.getType() != DataTypes.GEOMETRY) { |
|
557 |
logger.info(new StringBuilder().append("Adding field ") |
|
589 |
if (featureAttributeDescriptor.getDataType().getType() != DataTypes.GEOMETRY) { |
|
590 |
logger.info(new StringBuilder().append("0 - Adding field ") |
|
558 | 591 |
.append(featureAttributeDescriptor.getName()) |
559 | 592 |
.toString()); |
560 | 593 |
|
561 |
JLrsGenerateDynamicSegmentationParamsController.this.cmbTableIdRouteField |
|
562 |
.addItem(featureAttributeDescriptor); |
|
563 |
JLrsGenerateDynamicSegmentationParamsController.this.cmbValueField |
|
564 |
.addItem(featureAttributeDescriptor); |
|
594 |
JLrsGenerateDynamicSegmentationParamsController.this.cmbTableIdRouteField.addItem(featureAttributeDescriptor); |
|
595 |
JLrsGenerateDynamicSegmentationParamsController.this.cmbValueField.addItem(featureAttributeDescriptor); |
|
565 | 596 |
if (featureAttributeDescriptor.getDataType().isNumeric()) { |
566 |
JLrsGenerateDynamicSegmentationParamsController.this.cmbLandmarkField |
|
567 |
.addItem(featureAttributeDescriptor); |
|
568 |
JLrsGenerateDynamicSegmentationParamsController.this.cmbFinalLandmarkField |
|
569 |
.addItem(featureAttributeDescriptor); |
|
597 |
JLrsGenerateDynamicSegmentationParamsController.this.cmbLandmarkField.addItem(featureAttributeDescriptor); |
|
598 |
JLrsGenerateDynamicSegmentationParamsController.this.cmbFinalLandmarkField.addItem(featureAttributeDescriptor); |
|
570 | 599 |
} |
600 |
logger.info(new StringBuilder().append("1 - Adding field ") |
|
601 |
.append(featureAttributeDescriptor.getName()) |
|
602 |
.toString()); |
|
571 | 603 |
} |
572 | 604 |
} |
573 |
this.cmbTableIdRouteField.invalidate(); |
|
574 |
this.cmbLandmarkField.invalidate(); |
|
575 |
this.cmbFinalLandmarkField.invalidate(); |
|
576 |
this.cmbValueField.invalidate(); |
|
577 |
|
|
578 | 605 |
} catch (DataException e1) { |
579 | 606 |
logger |
580 | 607 |
.warn(new StringBuilder() |
Also available in: Unified diff