Revision 27631 branches/v2_0_0_prep/extensions/extGeocoding/src/org/gvsig/geocoding/extension/GeocodingTask.java
GeocodingTask.java | ||
---|---|---|
31 | 31 |
import java.util.Set; |
32 | 32 |
|
33 | 33 |
import javax.swing.JTable; |
34 |
import javax.swing.table.DefaultTableModel; |
|
34 | 35 |
|
36 |
import org.gvsig.fmap.geom.primitive.Point2D; |
|
35 | 37 |
import org.gvsig.geocoding.Address; |
36 | 38 |
import org.gvsig.geocoding.DataGeocoder; |
37 | 39 |
import org.gvsig.geocoding.DataGeocoderImpl; |
38 | 40 |
import org.gvsig.geocoding.gui.TableResultsModel; |
39 | 41 |
import org.gvsig.geocoding.pattern.Patterngeocoding; |
40 | 42 |
import org.gvsig.geocoding.result.GeocodingResult; |
43 |
import org.gvsig.geocoding.utils.GeocoUtils; |
|
41 | 44 |
import org.slf4j.Logger; |
42 | 45 |
import org.slf4j.LoggerFactory; |
43 | 46 |
|
... | ... | |
77 | 80 |
// Remove old results of the model list |
78 | 81 |
control.getGmodel().clearResults(); |
79 | 82 |
|
80 |
String log = ""; |
|
83 |
String logtask = "";
|
|
81 | 84 |
|
82 | 85 |
Address address = null; |
83 | 86 |
|
84 | 87 |
// SIMPLE GEOCODING |
85 | 88 |
if (finalStep == 1) { |
86 |
log = PluginServices.getText(this, "addressgeocoded"); |
|
89 |
logtask = PluginServices.getText(this, "addressgeocoded");
|
|
87 | 90 |
|
88 | 91 |
if (!isCanceled()) { |
89 | 92 |
setCurrentStep(1); |
... | ... | |
91 | 94 |
Set<GeocodingResult> result = geocoding(control.getPattern(), |
92 | 95 |
address); |
93 | 96 |
control.getGmodel().addResult(result); |
94 |
setNote(1 + " " + log); |
|
97 |
setNote(1 + " " + logtask);
|
|
95 | 98 |
} else { |
96 | 99 |
return; |
97 | 100 |
} |
... | ... | |
100 | 103 |
|
101 | 104 |
// TABLE GEOCODING (MASSIVE) |
102 | 105 |
else { |
103 |
log = PluginServices.getText(this, "addressesgeocoded"); |
|
106 |
logtask = PluginServices.getText(this, "addressesgeocoded");
|
|
104 | 107 |
for (int i = 1; i < finalStep + 1; i++) { |
105 | 108 |
if (!isCanceled()) { |
106 | 109 |
setCurrentStep(i); |
... | ... | |
108 | 111 |
Set<GeocodingResult> result = geocoding(control |
109 | 112 |
.getPattern(), address); |
110 | 113 |
control.getGmodel().addResult(result); |
111 |
setNote(i + " " + log); |
|
114 |
setNote(i + " " + logtask);
|
|
112 | 115 |
} else { |
113 | 116 |
return; |
114 | 117 |
} |
... | ... | |
123 | 126 |
Integer[] expElems = control |
124 | 127 |
.createInitialResultsExportElements(results); |
125 | 128 |
control.getGmodel().setExportElements(expElems); |
129 |
|
|
126 | 130 |
if (result.size() > 0) { |
127 | 131 |
int max = control.getPattern().getSettings().getResultsNumber(); |
128 | 132 |
|
129 | 133 |
JTable jTableResults = control.getJTableResults(); |
130 |
TableResultsModel model = new TableResultsModel(control, address);
|
|
134 |
TableResultsModel model = new TableResultsModel(address); |
|
131 | 135 |
model.setResultSet(result, max, control.getPattern().getSettings() |
132 | 136 |
.getScore()); |
137 |
|
|
133 | 138 |
jTableResults.setModel(model); |
134 | 139 |
jTableResults.validate(); |
135 | 140 |
jTableResults.repaint(); |
141 |
|
|
142 |
//select first result position |
|
143 |
jTableResults.setRowSelectionInterval(0, 0); |
|
144 |
//show position in view |
|
145 |
Point2D pto = model.getGeometry(0); |
|
146 |
try { |
|
147 |
GeocoUtils.zoomToPoint(pto.getX(), pto.getY()); |
|
148 |
} catch (Exception e1) { |
|
149 |
log.error("Doing zoom to point",e1); |
|
150 |
} |
|
136 | 151 |
|
137 | 152 |
if (results.size() > 1) { |
138 | 153 |
control.getGpanel().activeTableGUIFeatures(true); |
139 | 154 |
control.getGpanel().setLabRow(control.ROW + 1); |
140 | 155 |
control.getGmodel().setNumResultShowed(0); |
141 | 156 |
} |
157 |
// select |
|
158 |
|
|
159 |
|
|
160 |
|
|
142 | 161 |
|
143 | 162 |
} |
144 | 163 |
} |
Also available in: Unified diff