Revision 43920
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.dbf/src/main/java/org/gvsig/fmap/dal/store/dbf/DBFLibrary.java | ||
---|---|---|
66 | 66 |
|
67 | 67 |
@Override |
68 | 68 |
protected void doPostInitialize() throws LibraryException { |
69 |
List<Throwable> exs = new ArrayList<Throwable>();
|
|
69 |
List<Throwable> exs = new ArrayList<>(); |
|
70 | 70 |
|
71 | 71 |
FileHelper.registerParametersDefinition( |
72 | 72 |
DBFStoreParameters.PARAMETERS_DEFINITION_NAME, |
73 | 73 |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.exportto.app/org.gvsig.exportto.app.mainplugin/src/main/resources-plugin/i18n/text.properties | ||
---|---|---|
71 | 71 |
projection_selected_by_user=Proyecci\u00f3n seleccionada por el usuario |
72 | 72 |
selected_projection=Proyecci\u00f3n seleccionada |
73 | 73 |
projection_selector=Selector de proyecciones |
74 |
_Trasladar_guiones_en_los_identificadores_a_guion_bajo=Trasladar guiones, "-", en los identificadores a guion-bajo, "_." |
|
74 |
_Trasladar_guiones_en_los_identificadores_a_guion_bajo=Trasladar guiones, "-", en los identificadores a guion-bajo, "_." |
|
75 |
|
|
76 |
_Selection_of_the_geometry_field=Selecci\u00f3n del campo geometria |
|
77 |
_Use_the_geometry_field_by_default=Usar el campo geometria por defecto |
|
78 |
_Use_null_as_the_value_of_the_geometry=Usar null como valor para las geometrias |
|
79 |
_Select_the_field_to_be_used_as_geometry=Seleccione el campo a usar como geometria |
|
80 |
_Select_target_geometry_type=Seleccionar el tipo de la geometria de destino |
|
81 |
_Type=Tipo |
|
82 |
_Subtype=Subtipo |
|
83 |
_Encoding=Codificaci\u00f3n |
|
84 |
_File=Fichero |
|
85 |
_Select_encoding=Selecci\u00f3n de codificaci\u00f3n |
|
86 |
_Selection_of_geometry_field=Selecci\u00f3n del campo geometria |
|
87 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.exportto.app/org.gvsig.exportto.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties | ||
---|---|---|
4 | 4 |
_All=All |
5 | 5 |
_check_geometries_before_export=Check geometries before export |
6 | 6 |
_check_geometries_before_export_header=Validation of the geometry information |
7 |
_Comprobar_la_validez_de_las_geometrias_antes_de_insertarlas=Check the if the geometry if valid
|
|
7 |
_Comprobar_la_validez_de_las_geometrias_antes_de_insertarlas=Check the validity of the geometries before inserting them
|
|
8 | 8 |
_Comprobar_que_la_geometria_no_este_corrupta=Check if the geometry is corrupt |
9 | 9 |
_Crear_indice_espacial_sobre_las_columnas_de_tipo_geometria=Create a spatial index in the geoetry columns |
10 | 10 |
_Crear_una_tabla_nueva=Create a new table |
... | ... | |
70 | 70 |
projection_selected_by_user=Projection selected by user |
71 | 71 |
selected_projection=Selected projection |
72 | 72 |
projection_selector=Projection selector |
73 |
_Trasladar_guiones_en_los_identificadores_a_guion_bajo=Change hyphens, "-", in identifiers to underscores, "_". |
|
73 |
_Trasladar_guiones_en_los_identificadores_a_guion_bajo=Change hyphens, "-", in identifiers to underscores, "_". |
|
74 |
|
|
75 |
_Selection_of_the_geometry_field=Selection of the geometry field |
|
76 |
_Use_the_geometry_field_by_default=Use the geometry field by default |
|
77 |
_Use_null_as_the_value_of_the_geometry=Use null as the value of the geometry |
|
78 |
_Select_the_field_to_be_used_as_geometry=Select the field to be used as geometry |
|
79 |
_Select_target_geometry_type=Select target geometry type |
|
80 |
_Type=Type |
|
81 |
_Subtype=Subtype |
|
82 |
_Encoding=Encoding |
|
83 |
_File=File |
|
84 |
_Select_geometry_type=Select geometry type |
|
85 |
_Select_encoding=Select encoding |
|
86 |
_Selection_of_geometry_field=Selection of geometry field |
|
87 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.exportto.app/org.gvsig.exportto.app.mainplugin/src/main/java/org/gvsig/exportto/app/extension/ExporttoTableExtension.java | ||
---|---|---|
76 | 76 |
private void showExportto(FeatureStore featureStore) { |
77 | 77 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
78 | 78 |
|
79 |
JExporttoServicePanel panel = |
|
80 |
swingManager |
|
81 |
.createExportto( |
|
82 |
featureStore, |
|
83 |
null, |
|
84 |
new LoadTableAction(), |
|
85 |
new int[] { ExporttoSwingManager.VECTORIAL_TABLE_WITHOUT_GEOMETRY }); |
|
79 |
JExporttoServicePanel panel = swingManager.createExportto( |
|
80 |
featureStore, |
|
81 |
null, |
|
82 |
new LoadTableAction(), |
|
83 |
null //new int[] { ExporttoSwingManager.VECTORIAL_TABLE_WITHOUT_GEOMETRY, ExporttoSwingManager.VECTORIAL_TABLE_WITH_GEOMETRY } |
|
84 |
); |
|
86 | 85 |
|
87 | 86 |
swingManager.getWindowManager().showWindow(panel, i18nManager.getTranslation("_Export_to"), |
88 | 87 |
ExporttoWindowManager.MODE_WINDOW); |
89 | 88 |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.impl/src/main/java/org/gvsig/exportto/impl/AttributeNamesTranslator.java | ||
---|---|---|
37 | 37 |
return this.targetToSource.getOrDefault(name, name); |
38 | 38 |
} |
39 | 39 |
|
40 |
@Override |
|
40 | 41 |
public Iterator<String> iterator() { |
41 | 42 |
return this.sourceToTarget.keySet().iterator(); |
42 | 43 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.swing/org.gvsig.exportto.swing.impl/src/main/java/org/gvsig/exportto/swing/impl/wizard/ExportTargetProjectionWizard.java | ||
---|---|---|
25 | 25 |
|
26 | 26 |
import javax.swing.JPanel; |
27 | 27 |
|
28 |
import org.cresques.cts.IProjection; |
|
29 | 28 |
import org.gvsig.exportto.swing.impl.DefaultJExporttoServicePanel; |
30 |
import org.gvsig.exportto.swing.impl.panel.ExportFilterPanel; |
|
31 | 29 |
import org.gvsig.exportto.swing.impl.panel.ExportTargetProjectionPanel; |
32 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
30 |
import org.gvsig.exportto.swing.spi.options.ExportGeometryOptions; |
|
31 |
import org.gvsig.exportto.swing.spi.options.ExportOptions; |
|
33 | 32 |
import org.gvsig.gui.beans.wizard.panel.NotContinueWizardException; |
34 | 33 |
import org.gvsig.gui.beans.wizard.panel.OptionPanel; |
35 | 34 |
|
... | ... | |
41 | 40 |
public class ExportTargetProjectionWizard extends ExportTargetProjectionPanel implements |
42 | 41 |
OptionPanel { |
43 | 42 |
|
44 |
private DefaultJExporttoServicePanel exporttoServicePanel; |
|
43 |
private final DefaultJExporttoServicePanel exporttoServicePanel; |
|
44 |
private final ExportGeometryOptions options; |
|
45 | 45 |
|
46 |
public ExportTargetProjectionWizard(DefaultJExporttoServicePanel exporttoServicePanel) { |
|
46 |
public ExportTargetProjectionWizard( |
|
47 |
DefaultJExporttoServicePanel exporttoServicePanel, |
|
48 |
ExportGeometryOptions options |
|
49 |
) { |
|
47 | 50 |
super(exporttoServicePanel); |
48 | 51 |
this.exporttoServicePanel = exporttoServicePanel; |
52 |
this.options = options; |
|
49 | 53 |
} |
50 | 54 |
|
55 |
@Override |
|
51 | 56 |
public String getPanelTitle() { |
52 | 57 |
return exporttoServicePanel.getExporttoSwingManager().getTranslation( |
53 | 58 |
"exportto_options"); |
54 | 59 |
} |
55 | 60 |
|
61 |
@Override |
|
56 | 62 |
public void nextPanel() throws NotContinueWizardException { |
63 |
this.options.setTargetProjection(this.getTargetProjection()); |
|
57 | 64 |
this.checkPanel(); |
58 | 65 |
} |
59 | 66 |
|
67 |
@Override |
|
60 | 68 |
public void lastPanel() { |
61 | 69 |
exporttoServicePanel.setExportButtonEnabled(false); |
62 | 70 |
exporttoServicePanel.setNextButtonEnabled(true); |
63 | 71 |
} |
64 | 72 |
|
73 |
@Override |
|
65 | 74 |
public void updatePanel() { |
66 | 75 |
exporttoServicePanel.setExportButtonEnabled(false); |
67 | 76 |
exporttoServicePanel.setNextButtonEnabled(true); |
68 | 77 |
} |
69 | 78 |
|
79 |
@Override |
|
70 | 80 |
public JPanel getJPanel() { |
71 | 81 |
return this; |
72 | 82 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.swing/org.gvsig.exportto.swing.impl/src/main/java/org/gvsig/exportto/swing/impl/wizard/ExportFilterWizard.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
import org.gvsig.exportto.swing.impl.DefaultJExporttoServicePanel; |
29 | 29 |
import org.gvsig.exportto.swing.impl.panel.ExportFilterPanel; |
30 |
import org.gvsig.exportto.swing.spi.options.ExportOptions; |
|
30 | 31 |
import org.gvsig.gui.beans.wizard.panel.NotContinueWizardException; |
31 | 32 |
import org.gvsig.gui.beans.wizard.panel.OptionPanel; |
32 | 33 |
|
... | ... | |
39 | 40 |
OptionPanel { |
40 | 41 |
|
41 | 42 |
private static final long serialVersionUID = 8801849211055890046L; |
42 |
private DefaultJExporttoServicePanel exporttoServicePanel; |
|
43 |
private final DefaultJExporttoServicePanel exporttoServicePanel; |
|
44 |
private final ExportOptions options; |
|
43 | 45 |
|
44 |
public ExportFilterWizard(DefaultJExporttoServicePanel exporttoServicePanel) { |
|
46 |
public ExportFilterWizard( |
|
47 |
DefaultJExporttoServicePanel exporttoServicePanel, |
|
48 |
ExportOptions options |
|
49 |
) { |
|
45 | 50 |
super(exporttoServicePanel); |
46 | 51 |
this.exporttoServicePanel = exporttoServicePanel; |
52 |
this.options = options; |
|
47 | 53 |
} |
48 | 54 |
|
55 |
@Override |
|
49 | 56 |
public String getPanelTitle() { |
50 | 57 |
return exporttoServicePanel.getExporttoSwingManager().getTranslation( |
51 | 58 |
"exportto_options"); |
52 | 59 |
} |
53 | 60 |
|
61 |
@Override |
|
54 | 62 |
public void nextPanel() throws NotContinueWizardException { |
63 |
this.options.setFilter(this.getFilter()); |
|
64 |
this.options.setFilterExpresion(this.getFilterExpresion()); |
|
65 |
this.options.setFilterName(this.getFilterName()); |
|
55 | 66 |
this.checkPanel(); |
56 | 67 |
} |
57 | 68 |
|
69 |
@Override |
|
58 | 70 |
public void lastPanel() { |
59 | 71 |
exporttoServicePanel.setExportButtonEnabled(false); |
60 | 72 |
exporttoServicePanel.setNextButtonEnabled(true); |
61 | 73 |
} |
62 | 74 |
|
75 |
@Override |
|
63 | 76 |
public void updatePanel() { |
64 | 77 |
exporttoServicePanel.setExportButtonEnabled(true); |
65 | 78 |
exporttoServicePanel.setNextButtonEnabled(false); |
66 | 79 |
} |
67 | 80 |
|
81 |
@Override |
|
68 | 82 |
public JPanel getJPanel() { |
69 | 83 |
return this; |
70 | 84 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.swing/org.gvsig.exportto.swing.impl/src/main/java/org/gvsig/exportto/swing/impl/wizard/ExporttoProgressWizard.java | ||
---|---|---|
28 | 28 |
import javax.swing.JPanel; |
29 | 29 |
|
30 | 30 |
import org.gvsig.exportto.swing.impl.DefaultJExporttoServicePanel; |
31 |
import org.gvsig.exportto.swing.spi.options.ExportOptions; |
|
31 | 32 |
import org.gvsig.gui.beans.wizard.panel.NotContinueWizardException; |
32 | 33 |
import org.gvsig.gui.beans.wizard.panel.OptionPanel; |
33 | 34 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
... | ... | |
43 | 44 |
public class ExporttoProgressWizard extends JPanel implements OptionPanel { |
44 | 45 |
|
45 | 46 |
private static final long serialVersionUID = 8235569247892299856L; |
46 |
private static final TaskStatusSwingManager TASK_STATUS_SWING_MANAGER = |
|
47 |
ToolsSwingLocator.getTaskStatusSwingManager(); |
|
48 | 47 |
|
49 | 48 |
private DefaultJExporttoServicePanel exporttoServicePanel = null; |
50 | 49 |
private JTaskStatus jTaskStatus = null; |
50 |
private final ExportOptions options; |
|
51 | 51 |
|
52 | 52 |
public ExporttoProgressWizard( |
53 |
DefaultJExporttoServicePanel exporttoServicePanel) { |
|
53 |
DefaultJExporttoServicePanel exporttoServicePanel, |
|
54 |
ExportOptions options |
|
55 |
) { |
|
54 | 56 |
super(); |
55 | 57 |
this.exporttoServicePanel = exporttoServicePanel; |
56 |
jTaskStatus = TASK_STATUS_SWING_MANAGER.createJTaskStatus(); |
|
58 |
this.options = options; |
|
59 |
TaskStatusSwingManager TaskStatusSwingManager = ToolsSwingLocator.getTaskStatusSwingManager(); |
|
60 |
|
|
61 |
jTaskStatus = TaskStatusSwingManager.createJTaskStatus(); |
|
57 | 62 |
this.setLayout(new BorderLayout()); |
58 | 63 |
this.add(jTaskStatus, BorderLayout.NORTH); |
59 | 64 |
} |
60 | 65 |
|
66 |
@Override |
|
61 | 67 |
public String getPanelTitle() { |
62 | 68 |
return exporttoServicePanel.getExporttoSwingManager().getTranslation( |
63 | 69 |
"export_progress"); |
64 | 70 |
} |
65 | 71 |
|
72 |
@Override |
|
66 | 73 |
public void nextPanel() throws NotContinueWizardException { |
67 | 74 |
// TODO Auto-generated method stub |
68 | 75 |
|
69 | 76 |
} |
70 | 77 |
|
78 |
@Override |
|
71 | 79 |
public void lastPanel() { |
72 | 80 |
exporttoServicePanel.setCancelButtonText(exporttoServicePanel |
73 | 81 |
.getExporttoSwingManager().getTranslation("cancel")); |
74 | 82 |
} |
75 | 83 |
|
84 |
@Override |
|
76 | 85 |
public void updatePanel() { |
77 | 86 |
exporttoServicePanel.setExportButtonEnabled(false); |
78 | 87 |
exporttoServicePanel.setCancelButtonText(exporttoServicePanel |
79 | 88 |
.getExporttoSwingManager().getTranslation("close")); |
80 | 89 |
} |
81 | 90 |
|
91 |
@Override |
|
82 | 92 |
public JPanel getJPanel() { |
83 | 93 |
return this; |
84 | 94 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.swing/org.gvsig.exportto.swing.impl/src/main/java/org/gvsig/exportto/swing/impl/DefaultJExporttoServicePanel.java | ||
---|---|---|
50 | 50 |
import org.gvsig.exportto.swing.spi.ExporttoSwingProviderFactory; |
51 | 51 |
import org.gvsig.exportto.swing.spi.ExporttoSwingProviderLocator; |
52 | 52 |
import org.gvsig.exportto.swing.spi.ExporttoSwingProviderManager; |
53 |
import org.gvsig.exportto.swing.spi.options.ExportGeometryOptions; |
|
54 |
import org.gvsig.exportto.swing.spi.options.ExportOptions; |
|
53 | 55 |
import org.gvsig.fmap.dal.DALLocator; |
54 | 56 |
import org.gvsig.fmap.dal.DataManager; |
55 | 57 |
import org.gvsig.fmap.dal.exception.DataException; |
... | ... | |
81 | 83 |
private static final Logger LOG = LoggerFactory |
82 | 84 |
.getLogger(DefaultJExporttoServicePanel.class); |
83 | 85 |
|
84 |
private static final ExporttoSwingProviderManager EXPORTTO_SWING_PROVIDER_MANAGER = |
|
85 |
ExporttoSwingProviderLocator.getManager(); |
|
86 | 86 |
private static final DataManager DATA_MANAGER = DALLocator.getDataManager(); |
87 | 87 |
|
88 | 88 |
private static final long serialVersionUID = -7026467582252285238L; |
... | ... | |
95 | 95 |
// Used to get the new feature store parameters |
96 | 96 |
private ExporttoSwingProvider exporttoSwingProvider; |
97 | 97 |
|
98 |
// Provider types that will be displayed |
|
99 |
private int[] providerTypes; |
|
98 |
// // Provider types that will be displayed
|
|
99 |
// private int[] providerTypes;
|
|
100 | 100 |
|
101 | 101 |
// Wizards used to create the main wizard |
102 | 102 |
private ExporterSelectionWizard exporterSelectionWizard = null; |
... | ... | |
128 | 128 |
vectorLayer = vlayer; |
129 | 129 |
} |
130 | 130 |
|
131 |
public DefaultJExporttoServicePanel(DefaultExporttoSwingManager uimanager, |
|
132 |
FeatureStore featureStore, IProjection projection, |
|
133 |
ExporttoServiceFinishAction exporttoServiceFinishAction, |
|
134 |
int[] providerTypes) { |
|
131 |
@SuppressWarnings("LeakingThisInConstructor") |
|
132 |
public DefaultJExporttoServicePanel( |
|
133 |
DefaultExporttoSwingManager uimanager, |
|
134 |
FeatureStore featureStore, |
|
135 |
IProjection projection, |
|
136 |
ExporttoServiceFinishAction exporttoServiceFinishAction, |
|
137 |
int[] providerTypes |
|
138 |
) { |
|
135 | 139 |
this.featureStore = featureStore; |
136 | 140 |
this.projection = projection; |
137 | 141 |
this.uimanager = uimanager; |
138 | 142 |
this.exporttoServiceFinishAction = exporttoServiceFinishAction; |
139 |
this.providerTypes = providerTypes; |
|
143 |
// this.providerTypes = providerTypes;
|
|
140 | 144 |
this.status = JOptionPane.UNDEFINED_CONDITION; |
141 | 145 |
|
142 | 146 |
ImageIcon ii = IconThemeHelper.getImageIcon("wizard-export-to"); |
143 | 147 |
wizardPanelWithLogo = new WizardPanelWithLogo(ii); |
144 | 148 |
|
145 | 149 |
// Initialize the wizards |
146 |
exporterSelectionWizard = |
|
147 |
new ExporterSelectionWizard(this, providerTypes); |
|
148 |
exportTargetProjectionWizard = new ExportTargetProjectionWizard(this); |
|
149 |
exportFilterWizard = new ExportFilterWizard(this); |
|
150 |
exporttoProgressWizard = new ExporttoProgressWizard(this); |
|
150 |
exporterSelectionWizard = new ExporterSelectionWizard(this, providerTypes); |
|
151 | 151 |
|
152 | 152 |
// Adding the wizards to the main wizard |
153 | 153 |
wizardPanelWithLogo.addOptionPanel(exporterSelectionWizard); |
... | ... | |
156 | 156 |
this.wizardPanelWithLogo.getWizardComponents().getFinishButton() |
157 | 157 |
.setText(uimanager.getTranslation("export")); |
158 | 158 |
|
159 |
// Set the listener for the finish and cancell events |
|
160 |
this.wizardPanelWithLogo.setWizardListener(this); |
|
161 |
|
|
162 |
this.initComponents(); |
|
163 |
} |
|
164 |
|
|
165 |
private void initComponents() { |
|
159 | 166 |
this.setLayout(new BorderLayout()); |
160 | 167 |
this.add(wizardPanelWithLogo, BorderLayout.CENTER); |
161 | 168 |
|
... | ... | |
164 | 171 |
setExportButtonEnabled(false); |
165 | 172 |
|
166 | 173 |
// Set the listener for the finish and cancell events |
167 |
this.wizardPanelWithLogo.setWizardListener(this); |
|
168 | 174 |
this.setPreferredSize(new Dimension(700, 350)); |
169 | 175 |
} |
170 | 176 |
|
... | ... | |
193 | 199 |
} |
194 | 200 |
|
195 | 201 |
/** |
196 |
* @param exporttoSwingProvider
|
|
202 |
* @param provider
|
|
197 | 203 |
* @throws ServiceException |
198 | 204 |
*/ |
199 |
public void selectExporttoSwingProvider( |
|
200 |
ExporttoSwingProviderFactory provider) |
|
205 |
public void selectExporttoSwingProvider(ExporttoSwingProviderFactory provider) |
|
201 | 206 |
throws ServiceException { |
207 |
|
|
208 |
ExporttoSwingProviderManager manager = ExporttoSwingProviderLocator.getManager(); |
|
209 |
exporttoSwingProvider = manager.createExporttoSwingProvider( |
|
210 |
provider.getName(), vectorLayer |
|
211 |
); |
|
212 |
ExportOptions options = this.exporttoSwingProvider.getOptions(); |
|
202 | 213 |
|
203 |
if (vectorLayer == null) { |
|
204 |
exporttoSwingProvider = |
|
205 |
EXPORTTO_SWING_PROVIDER_MANAGER.createExporttoSwingProvider( |
|
206 |
provider.getName(), featureStore, projection); |
|
207 |
} else { |
|
208 |
exporttoSwingProvider = |
|
209 |
EXPORTTO_SWING_PROVIDER_MANAGER.createExporttoSwingProvider( |
|
210 |
provider.getName(), vectorLayer); |
|
214 |
if( options instanceof ExportGeometryOptions ) { |
|
215 |
ExportGeometryOptions geomOptions = (ExportGeometryOptions) options; |
|
216 |
geomOptions.setTargetProjection(projection); |
|
217 |
exportTargetProjectionWizard = new ExportTargetProjectionWizard(this, geomOptions); |
|
218 |
exportTargetProjectionWizard.setVectorLayer(vectorLayer); |
|
211 | 219 |
} |
220 |
exportFilterWizard = new ExportFilterWizard(this, options); |
|
221 |
exporttoProgressWizard = new ExporttoProgressWizard(this, options); |
|
212 | 222 |
|
213 |
DefaultJWizardComponents wizardComponents = |
|
214 |
wizardPanelWithLogo.getWizardComponents(); |
|
223 |
DefaultJWizardComponents wizardComponents = wizardPanelWithLogo.getWizardComponents(); |
|
215 | 224 |
for (int i = wizardComponents.getWizardPanelList().size() - 1; i >= 1; i--) { |
216 | 225 |
wizardComponents.removeWizardPanel(i); |
217 | 226 |
} |
218 | 227 |
for (int i = 0; i < exporttoSwingProvider.getPanelCount(); i++) { |
219 |
wizardPanelWithLogo.addOptionPanel(new DefaultWizardContainer( |
|
220 |
exporttoSwingProvider.getPanelAt(i))); |
|
228 |
wizardPanelWithLogo.addOptionPanel( |
|
229 |
new DefaultWizardContainer( |
|
230 |
exporttoSwingProvider.getPanelAt(i) |
|
231 |
) |
|
232 |
); |
|
221 | 233 |
} |
222 |
exportTargetProjectionWizard.setVectorLayer(vectorLayer); |
|
223 |
if (exporttoSwingProvider.needsPanelTargetProjection()){ |
|
234 |
if (exporttoSwingProvider.needsPanelTargetProjection() && exportTargetProjectionWizard!=null ){ |
|
224 | 235 |
wizardPanelWithLogo.addOptionPanel(exportTargetProjectionWizard); |
225 | 236 |
} |
226 | 237 |
wizardPanelWithLogo.addOptionPanel(exportFilterWizard); |
227 | 238 |
wizardPanelWithLogo.addOptionPanel(exporttoProgressWizard); |
228 | 239 |
} |
229 | 240 |
|
241 |
@Override |
|
230 | 242 |
public Dimension getPreferredSize() { |
231 | 243 |
return new Dimension(800, 550); |
232 | 244 |
} |
... | ... | |
250 | 262 |
featureSet = featureStore.getFeatureSet(featureQuery); |
251 | 263 |
} |
252 | 264 |
} |
253 |
if( exporttoSwingProvider.needsPanelTargetProjection()) { |
|
254 |
exporttoSwingProvider.setTargetProjection(exportTargetProjectionWizard.getTargetProjection()); |
|
255 |
} |
|
256 | 265 |
|
257 | 266 |
Export export = new Export(featureSet); |
258 | 267 |
export.start(); |
... | ... | |
265 | 274 |
|
266 | 275 |
private class Export extends Thread { |
267 | 276 |
|
268 |
private FeatureSet featureSet; |
|
277 |
private final FeatureSet featureSet;
|
|
269 | 278 |
|
270 | 279 |
public Export(FeatureSet featureSet) { |
271 | 280 |
super(); |
272 | 281 |
this.featureSet = featureSet; |
273 | 282 |
} |
274 | 283 |
|
284 |
@Override |
|
275 | 285 |
public synchronized void run() { |
276 | 286 |
ExporttoService exportService; |
277 | 287 |
try { |
... | ... | |
314 | 324 |
); |
315 | 325 |
} |
316 | 326 |
|
327 |
@Override |
|
317 | 328 |
public void setWizardPanelActionListener( |
318 | 329 |
WizardPanelActionListener wizardActionListener) { |
319 | 330 |
this.exporttoServicePanelListener = wizardActionListener; |
320 | 331 |
} |
321 | 332 |
|
333 |
@Override |
|
322 | 334 |
public WizardPanelActionListener getWizardPanelActionListener() { |
323 | 335 |
if (exporttoServicePanelListener == null) { |
324 | 336 |
exporttoServicePanelListener = |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.swing/org.gvsig.exportto.swing.prov/org.gvsig.exportto.swing.prov.shape/src/main/java/org/gvsig/exportto/swing/prov/shape/BaseExportShapeOptions.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.exportto.swing.prov.shape; |
|
7 |
|
|
8 |
import java.io.File; |
|
9 |
import org.gvsig.exportto.swing.spi.options.BaseExportGeometryOptions; |
|
10 |
|
|
11 |
/** |
|
12 |
* |
|
13 |
* @author jjdelcerro |
|
14 |
*/ |
|
15 |
public class BaseExportShapeOptions |
|
16 |
extends BaseExportGeometryOptions |
|
17 |
implements ExportShapeOptions |
|
18 |
{ |
|
19 |
private String encoding; |
|
20 |
private File file; |
|
21 |
|
|
22 |
@Override |
|
23 |
public String getEncoding() { |
|
24 |
return this.encoding; |
|
25 |
} |
|
26 |
|
|
27 |
@Override |
|
28 |
public void setEncoding(String encoding) { |
|
29 |
this.encoding = encoding; |
|
30 |
} |
|
31 |
|
|
32 |
@Override |
|
33 |
public File getFile() { |
|
34 |
return this.file; |
|
35 |
} |
|
36 |
|
|
37 |
@Override |
|
38 |
public void setFile(File file) { |
|
39 |
this.file = file; |
|
40 |
} |
|
41 |
|
|
42 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.swing/org.gvsig.exportto.swing.prov/org.gvsig.exportto.swing.prov.shape/src/main/java/org/gvsig/exportto/swing/prov/shape/ExportShapeOptions.java | ||
---|---|---|
1 |
package org.gvsig.exportto.swing.prov.shape; |
|
2 |
|
|
3 |
import org.gvsig.exportto.swing.prov.dbf.ExportDBFOptions; |
|
4 |
import org.gvsig.exportto.swing.spi.options.ExportGeometryOptions; |
|
5 |
|
|
6 |
/** |
|
7 |
* |
|
8 |
* @author jjdelcerro |
|
9 |
*/ |
|
10 |
public interface ExportShapeOptions extends ExportDBFOptions, ExportGeometryOptions { |
|
11 |
|
|
12 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.swing/org.gvsig.exportto.swing.prov/org.gvsig.exportto.swing.prov.shape/src/main/java/org/gvsig/exportto/swing/prov/shape/ExporttoShapeProvider.java | ||
---|---|---|
25 | 25 |
|
26 | 26 |
import org.cresques.cts.IProjection; |
27 | 27 |
import org.gvsig.exportto.ExporttoService; |
28 |
import org.gvsig.exportto.swing.prov.dbf.ExporttoDBFService; |
|
29 |
import org.gvsig.exportto.swing.prov.dbf.panel.ExporttoDBFPanel; |
|
30 |
import org.gvsig.exportto.swing.prov.file.AbstractExporttoFileProvider; |
|
28 |
import org.gvsig.exportto.swing.prov.dbf.ExporttoDBFProvider; |
|
31 | 29 |
import org.gvsig.exportto.swing.spi.ExporttoSwingProvider; |
30 |
import org.gvsig.exportto.swing.spi.panels.CheckGeometriesPanel; |
|
31 |
import org.gvsig.exportto.swing.spi.panels.SelectGeometryTypePanel; |
|
32 |
import org.gvsig.exportto.swing.spi.panels.SelectionOfTheGeometryFieldPanel; |
|
32 | 33 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
34 |
import org.gvsig.fmap.geom.Geometry; |
|
33 | 35 |
import org.gvsig.tools.service.spi.ProviderServices; |
34 | 36 |
|
35 | 37 |
/** |
... | ... | |
38 | 40 |
* @author gvSIG Team |
39 | 41 |
* @version $Id$ |
40 | 42 |
*/ |
41 |
public class ExporttoShapeProvider extends AbstractExporttoFileProvider
|
|
43 |
public class ExporttoShapeProvider extends ExporttoDBFProvider
|
|
42 | 44 |
implements ExporttoSwingProvider { |
43 | 45 |
|
44 |
/** |
|
45 |
* Constructor. |
|
46 |
* |
|
47 |
* @param providerServices |
|
48 |
* the services for the provider |
|
49 |
* @param file |
|
50 |
* to get the Exporto from |
|
51 |
*/ |
|
52 |
public ExporttoShapeProvider(ProviderServices providerServices, |
|
53 |
FeatureStore featureStore, IProjection projection) { |
|
54 |
super(providerServices, featureStore, projection, new ExporttoDBFPanel()); |
|
46 |
@SuppressWarnings("OverridableMethodCallInConstructor") |
|
47 |
public ExporttoShapeProvider( |
|
48 |
ProviderServices providerServices, |
|
49 |
FeatureStore featureStore, |
|
50 |
IProjection projection |
|
51 |
) { |
|
52 |
super(providerServices, featureStore); |
|
53 |
this.getOptions().setTargetProjection(projection); |
|
55 | 54 |
} |
56 | 55 |
|
56 |
@Override |
|
57 |
protected void addPanels() { |
|
58 |
this.panelAdd(new SelectionOfTheGeometryFieldPanel(this.getOptions())); |
|
59 |
this.panelAdd(new SelectGeometryTypePanel( |
|
60 |
this.getOptions(), |
|
61 |
new int[] { |
|
62 |
Geometry.TYPES.GEOMETRY, |
|
63 |
Geometry.TYPES.POINT, |
|
64 |
Geometry.TYPES.LINE, |
|
65 |
Geometry.TYPES.POLYGON, |
|
66 |
Geometry.TYPES.MULTIPOINT, |
|
67 |
Geometry.TYPES.MULTILINE, |
|
68 |
Geometry.TYPES.MULTIPOLYGON |
|
69 |
}, |
|
70 |
new int[] { |
|
71 |
Geometry.SUBTYPES.GEOM2D, |
|
72 |
Geometry.SUBTYPES.GEOM3D, |
|
73 |
Geometry.SUBTYPES.GEOM3DM |
|
74 |
} |
|
75 |
) |
|
76 |
); |
|
77 |
this.panelAdd(new CheckGeometriesPanel(this.getOptions())); |
|
78 |
super.addPanels(); |
|
79 |
} |
|
80 |
|
|
81 |
@Override |
|
82 |
public ExportShapeOptions getOptions() { |
|
83 |
if( this.options == null ) { |
|
84 |
this.options = new BaseExportShapeOptions(); |
|
85 |
} |
|
86 |
return (ExportShapeOptions) this.options; |
|
87 |
} |
|
88 |
|
|
89 |
@Override |
|
57 | 90 |
public ExporttoService createExporttoService() { |
58 |
return new ExporttoShapeService( |
|
59 |
selectFileOptionPanel, featureStore, projection, ((ExporttoDBFPanel) selectFileOptionPanel).getEncoding()); |
|
91 |
return new ExporttoShapeService(this.getOptions()); |
|
60 | 92 |
} |
93 |
|
|
94 |
@Override |
|
95 |
public boolean needsPanelTargetProjection() { |
|
96 |
return true; |
|
97 |
} |
|
98 |
|
|
61 | 99 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.swing/org.gvsig.exportto.swing.prov/org.gvsig.exportto.swing.prov.shape/src/main/java/org/gvsig/exportto/swing/prov/shape/ExporttoShapeService.java | ||
---|---|---|
28 | 28 |
import java.util.List; |
29 | 29 |
|
30 | 30 |
import javax.swing.JOptionPane; |
31 |
import org.apache.commons.io.FilenameUtils; |
|
31 | 32 |
|
32 | 33 |
import org.cresques.cts.ICoordTrans; |
33 | 34 |
import org.cresques.cts.IProjection; |
... | ... | |
35 | 36 |
import org.gvsig.exportto.ExporttoServiceException; |
36 | 37 |
import org.gvsig.exportto.ExporttoServiceFinishAction; |
37 | 38 |
import org.gvsig.exportto.impl.AttributeNamesTranslator; |
38 |
import org.gvsig.exportto.swing.prov.file.panel.SelectFileOptionPanel; |
|
39 | 39 |
import org.gvsig.fmap.dal.DALLocator; |
40 | 40 |
import org.gvsig.fmap.dal.DataManager; |
41 | 41 |
import org.gvsig.fmap.dal.DataStoreParameters; |
... | ... | |
69 | 69 |
import org.gvsig.fmap.geom.primitive.Surface; |
70 | 70 |
import org.gvsig.fmap.geom.type.GeometryType; |
71 | 71 |
import org.gvsig.i18n.Messages; |
72 |
import org.gvsig.tools.ToolsLocator; |
|
73 |
import org.gvsig.tools.dataTypes.CoercionException; |
|
74 |
import org.gvsig.tools.dataTypes.DataTypesManager.Coercion; |
|
72 | 75 |
import org.gvsig.tools.dispose.DisposableIterator; |
73 | 76 |
import org.gvsig.tools.dispose.DisposeUtils; |
77 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
78 |
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager; |
|
74 | 79 |
import org.gvsig.tools.task.AbstractMonitorableTask; |
75 | 80 |
import org.slf4j.Logger; |
76 | 81 |
import org.slf4j.LoggerFactory; |
77 | 82 |
|
78 |
|
|
79 | 83 |
/** |
80 | 84 |
* @author gvSIG Team |
81 | 85 |
* @version $Id$ |
82 | 86 |
* |
83 | 87 |
*/ |
84 | 88 |
public class ExporttoShapeService extends AbstractMonitorableTask implements |
85 |
ExporttoService { |
|
89 |
ExporttoService {
|
|
86 | 90 |
|
87 |
private static Logger logger = LoggerFactory.getLogger(ExporttoShapeService.class); |
|
91 |
private static final Logger logger = LoggerFactory.getLogger(ExporttoShapeService.class);
|
|
88 | 92 |
|
89 | 93 |
public static final int MAX_FIELD_NAME_LENGTH = 10; |
90 | 94 |
|
91 |
private File theShapeFile; |
|
92 |
private IProjection projection; |
|
93 |
private FeatureStore featureStore; |
|
94 |
private AttributeNamesTranslator nameTranslator; |
|
95 |
private final AttributeNamesTranslator nameTranslator; |
|
95 | 96 |
|
96 |
private int geometryType = -1; |
|
97 | 97 |
private NewFeatureStoreParameters newFeatureStoreParameters; |
98 | 98 |
private FilesystemServerExplorer filesystemServerExplorer; |
99 |
private SelectFileOptionPanel filePanel = null; |
|
100 |
private String encoding = null; |
|
101 | 99 |
|
102 |
private static GeometryManager geoManager = GeometryLocator.getGeometryManager(); |
|
103 |
|
|
104 | 100 |
private ExporttoServiceFinishAction exporttoServiceFinishAction; |
101 |
private final ExportShapeOptions options; |
|
105 | 102 |
|
106 |
public ExporttoShapeService( |
|
107 |
SelectFileOptionPanel fPanel, |
|
108 |
FeatureStore featureStore, |
|
109 |
IProjection projection) { |
|
103 |
public ExporttoShapeService(ExportShapeOptions options) { |
|
110 | 104 |
|
111 |
this(fPanel, featureStore, projection, null); |
|
112 |
} |
|
113 |
|
|
114 |
public ExporttoShapeService( |
|
115 |
SelectFileOptionPanel fPanel, |
|
116 |
FeatureStore featureStore, |
|
117 |
IProjection projection, |
|
118 |
String encoding) { |
|
119 |
|
|
120 | 105 |
super("Export to shape"); |
121 |
this.featureStore = featureStore; |
|
122 |
this.filePanel = fPanel; |
|
123 |
this.theShapeFile = fPanel.getSelectedFile(); |
|
124 |
this.projection = projection; |
|
125 |
this.encoding = encoding; |
|
126 |
|
|
127 |
try { |
|
128 |
this.nameTranslator = new AttributeNamesTranslator( |
|
129 |
featureStore.getDefaultFeatureType(), |
|
106 |
this.options = options; |
|
107 |
this.nameTranslator = new AttributeNamesTranslator( |
|
108 |
this.options.getSourceFeatureType(), |
|
130 | 109 |
MAX_FIELD_NAME_LENGTH |
131 |
); |
|
132 |
} catch (DataException e) { |
|
133 |
logger.error("While getting def feat type.", e); |
|
134 |
} |
|
110 |
); |
|
135 | 111 |
} |
136 | 112 |
|
137 |
public void export(FeatureSet featureSet) throws ExporttoServiceException { |
|
113 |
@Override |
|
114 |
public void export(FeatureSet featureSet) throws ExporttoServiceException { |
|
138 | 115 |
|
139 | 116 |
ExporttoServiceException throw_exp = null; |
140 |
File item_shp = null; |
|
141 |
String pathFile = theShapeFile.getAbsolutePath(); |
|
142 |
String withoutShp = pathFile.replaceAll("\\.shp", ""); |
|
117 |
File item_shp; |
|
118 |
|
|
119 |
String layer_name = FilenameUtils.getBaseName(this.options.getFile().getName()); |
|
120 |
String pathName = FilenameUtils.removeExtension(this.options.getFile().getAbsolutePath()); |
|
143 | 121 |
|
144 |
File single_file = new File(withoutShp + ".shp"); |
|
145 |
|
|
146 |
String layer_name = single_file.getName(); |
|
147 |
int lastp = layer_name.lastIndexOf(".shp"); |
|
148 |
if (lastp > -1) { |
|
149 |
layer_name = layer_name.substring(0, lastp); |
|
150 |
} |
|
151 |
|
|
152 |
initializeParams(featureSet, single_file); |
|
153 |
|
|
122 |
int geometryType = options.getGeometryTypeAsInt(); |
|
123 |
|
|
154 | 124 |
if (geometryType == Geometry.TYPES.GEOMETRY) { |
155 | 125 |
// SURFACE |
156 |
String fileName = withoutShp + "_surface" + ".shp";
|
|
157 |
item_shp = new File(fileName);
|
|
126 |
String fullPathName = pathName + "_surface" + ".shp";
|
|
127 |
item_shp = new File(fullPathName);
|
|
158 | 128 |
initializeParams(featureSet, item_shp); |
159 | 129 |
newFeatureStoreParameters.setDynValue("shpfile", item_shp); |
160 | 130 |
taskStatus.setTitle("Exporting surfaces"); |
161 | 131 |
|
162 |
try { |
|
163 |
export(filesystemServerExplorer, newFeatureStoreParameters, |
|
164 |
featureSet, Geometry.TYPES.SURFACE, true); |
|
165 |
} catch (ExporttoServiceException ee) { |
|
166 |
throw_exp = ee; |
|
167 |
} |
|
168 |
finishAction(layer_name + " (surface)", item_shp, projection); |
|
132 |
export( |
|
133 |
filesystemServerExplorer, |
|
134 |
newFeatureStoreParameters, |
|
135 |
featureSet, |
|
136 |
Geometry.TYPES.SURFACE, |
|
137 |
true |
|
138 |
); |
|
139 |
finishAction(layer_name + " (surface)", item_shp, options.getTargetProjection()); |
|
169 | 140 |
|
170 | 141 |
// CURVE |
171 |
fileName = withoutShp + "_curve" + ".shp";
|
|
172 |
item_shp = new File(fileName);
|
|
142 |
fullPathName = pathName + "_curve" + ".shp";
|
|
143 |
item_shp = new File(fullPathName);
|
|
173 | 144 |
initializeParams(featureSet, item_shp); |
174 | 145 |
newFeatureStoreParameters.setDynValue("shpfile", item_shp); |
175 | 146 |
taskStatus.setTitle("Exporting curves"); |
176 | 147 |
|
177 |
try { |
|
178 |
export(filesystemServerExplorer, newFeatureStoreParameters, |
|
179 |
featureSet, Geometry.TYPES.CURVE, true); |
|
180 |
} catch (ExporttoServiceException ee) { |
|
181 |
throw_exp = ee; |
|
182 |
} |
|
148 |
export( |
|
149 |
filesystemServerExplorer, |
|
150 |
newFeatureStoreParameters, |
|
151 |
featureSet, |
|
152 |
Geometry.TYPES.CURVE, |
|
153 |
true |
|
154 |
); |
|
183 | 155 |
|
184 |
finishAction(layer_name + " (curve)", item_shp, projection);
|
|
156 |
finishAction(layer_name + " (curve)", item_shp, options.getTargetProjection());
|
|
185 | 157 |
|
186 | 158 |
// POINT |
187 |
fileName = withoutShp + "_point" + ".shp";
|
|
188 |
item_shp = new File(fileName);
|
|
159 |
fullPathName = pathName + "_point" + ".shp";
|
|
160 |
item_shp = new File(fullPathName);
|
|
189 | 161 |
initializeParams(featureSet, item_shp); |
190 | 162 |
|
191 | 163 |
newFeatureStoreParameters.setDynValue("shpfile", item_shp); |
192 | 164 |
taskStatus.setTitle("Exporting points"); |
193 | 165 |
|
194 |
try { |
|
195 |
export(filesystemServerExplorer, newFeatureStoreParameters, |
|
196 |
featureSet, Geometry.TYPES.POINT, true); |
|
197 |
} catch (ExporttoServiceException ee) { |
|
198 |
throw_exp = ee; |
|
199 |
} |
|
166 |
export( |
|
167 |
filesystemServerExplorer, |
|
168 |
newFeatureStoreParameters, |
|
169 |
featureSet, |
|
170 |
Geometry.TYPES.POINT, |
|
171 |
true |
|
172 |
); |
|
200 | 173 |
|
201 |
finishAction(layer_name + " (point)", item_shp, projection);
|
|
174 |
finishAction(layer_name + " (point)", item_shp, options.getTargetProjection());
|
|
202 | 175 |
|
203 |
|
|
204 | 176 |
} else { |
205 |
|
|
206 |
// params already initialized
|
|
177 |
File single_file = new File(pathName + ".shp"); |
|
178 |
initializeParams(featureSet, single_file);
|
|
207 | 179 |
newFeatureStoreParameters.setDynValue("shpfile", single_file); |
208 |
try { |
|
209 |
export(filesystemServerExplorer, newFeatureStoreParameters, |
|
210 |
featureSet, geometryType, false); |
|
211 |
} catch (ExporttoServiceException ee) { |
|
212 |
throw_exp = ee; |
|
213 |
} |
|
214 |
finishAction(layer_name, single_file, projection); |
|
180 |
export( |
|
181 |
filesystemServerExplorer, |
|
182 |
newFeatureStoreParameters, |
|
183 |
featureSet, |
|
184 |
geometryType, |
|
185 |
false |
|
186 |
); |
|
187 |
finishAction(layer_name, single_file, options.getTargetProjection()); |
|
215 | 188 |
} |
216 | 189 |
this.taskStatus.terminate(); |
217 | 190 |
this.taskStatus.remove(); |
... | ... | |
219 | 192 |
if (throw_exp != null) { |
220 | 193 |
throw throw_exp; |
221 | 194 |
} else { |
222 |
if ( this.nameTranslator.hasTranslations() ) {
|
|
223 |
showNewNamesDialog(this.nameTranslator);
|
|
224 |
}
|
|
195 |
if (this.nameTranslator.hasTranslations()) {
|
|
196 |
showNewNamesDialog(this.nameTranslator);
|
|
197 |
}
|
|
225 | 198 |
} |
226 | 199 |
} |
227 | 200 |
|
228 | 201 |
private void showNewNamesDialog(AttributeNamesTranslator nameTranslator) { |
229 |
if( nameTranslator.hasTranslations() ) {
|
|
202 |
if (nameTranslator.hasTranslations()) {
|
|
230 | 203 |
String msg = Messages.getText("_Some_field_names_too_long_automatically_changed"); |
231 | 204 |
msg = msg + ":\n"; |
232 |
for( String source_name : nameTranslator ) {
|
|
205 |
for (String source_name : nameTranslator) {
|
|
233 | 206 |
String target_name = nameTranslator.getTargetName(source_name); |
234 | 207 |
msg = msg + "\n" + source_name + " > " + target_name; |
235 | 208 |
} |
236 |
JOptionPane.showMessageDialog( |
|
237 |
this.filePanel, |
|
238 |
msg, |
|
239 |
Messages.getText("export_progress"), |
|
240 |
JOptionPane.WARNING_MESSAGE); |
|
209 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
210 |
dialogs.messageDialog( |
|
211 |
msg, |
|
212 |
null, |
|
213 |
Messages.getText("export_progress"), |
|
214 |
JOptionPane.WARNING_MESSAGE, |
|
215 |
"FieldNameTooLongInShape" |
|
216 |
); |
|
241 | 217 |
} |
242 | 218 |
} |
243 | 219 |
|
244 |
private void initializeParams(
|
|
245 |
FeatureSet featureSet, File out_shp_file) |
|
246 |
throws ExporttoServiceException { |
|
220 |
private void initializeParams(
|
|
221 |
FeatureSet featureSet, File out_shp_file)
|
|
222 |
throws ExporttoServiceException {
|
|
247 | 223 |
|
248 | 224 |
DataManager dataManager = DALLocator.getDataManager(); |
249 | 225 |
|
250 | 226 |
FilesystemServerExplorerParameters explorerParams; |
251 | 227 |
try { |
252 |
explorerParams =
|
|
253 |
(FilesystemServerExplorerParameters) dataManager |
|
254 |
.createServerExplorerParameters(FilesystemServerExplorer.NAME); |
|
255 |
} catch (InitializeException e) { |
|
228 |
explorerParams |
|
229 |
= (FilesystemServerExplorerParameters) dataManager
|
|
230 |
.createServerExplorerParameters(FilesystemServerExplorer.NAME);
|
|
231 |
} catch (InitializeException | ProviderNotRegisteredException e) {
|
|
256 | 232 |
throw new ExporttoServiceException(e); |
257 |
} catch (ProviderNotRegisteredException e) { |
|
258 |
throw new ExporttoServiceException(e); |
|
259 | 233 |
} |
260 | 234 |
explorerParams.setRoot(out_shp_file.getParent()); |
261 | 235 |
|
262 | 236 |
try { |
263 |
filesystemServerExplorer =
|
|
264 |
(FilesystemServerExplorer) dataManager.openServerExplorer( |
|
265 |
"FilesystemExplorer", explorerParams); |
|
237 |
filesystemServerExplorer |
|
238 |
= (FilesystemServerExplorer) dataManager.openServerExplorer(
|
|
239 |
"FilesystemExplorer", explorerParams);
|
|
266 | 240 |
} catch (Exception e) { |
267 | 241 |
throw new ExporttoServiceException(e); |
268 | 242 |
} |
269 | 243 |
|
270 | 244 |
try { |
271 |
newFeatureStoreParameters =
|
|
272 |
(NewFeatureStoreParameters) filesystemServerExplorer |
|
273 |
.getAddParameters(out_shp_file); |
|
245 |
newFeatureStoreParameters |
|
246 |
= (NewFeatureStoreParameters) filesystemServerExplorer
|
|
247 |
.getAddParameters(out_shp_file);
|
|
274 | 248 |
} catch (DataException e) { |
275 | 249 |
throw new ExporttoServiceException(e); |
276 | 250 |
} |
277 | 251 |
|
278 |
newFeatureStoreParameters.setDynValue("CRS", projection);
|
|
279 |
newFeatureStoreParameters.setDynValue("encoding", encoding);
|
|
252 |
newFeatureStoreParameters.setDynValue("CRS", options.getTargetProjection());
|
|
253 |
newFeatureStoreParameters.setDynValue("encoding", options.getEncoding());
|
|
280 | 254 |
|
281 |
geometryType = |
|
282 |
featureSet.getDefaultFeatureType().getDefaultGeometryAttribute() |
|
283 |
.getGeomType().getType(); |
|
284 |
|
|
285 | 255 |
} |
286 | 256 |
|
287 |
private void export(FilesystemServerExplorer explorer, |
|
288 |
NewFeatureStoreParameters params, FeatureSet featureSet, |
|
289 |
int geometryType, boolean checkType) throws ExporttoServiceException { |
|
257 |
private void export( |
|
258 |
FilesystemServerExplorer explorer, |
|
259 |
NewFeatureStoreParameters params, |
|
260 |
FeatureSet featureSet, |
|
261 |
int geometryType, |
|
262 |
boolean checkType |
|
263 |
) throws ExporttoServiceException { |
|
290 | 264 |
|
291 | 265 |
String providerName = params.getDataStoreName(); |
292 | 266 |
String explorerName = explorer.getProviderName(); |
... | ... | |
294 | 268 |
|
295 | 269 |
DisposableIterator it = null; |
296 | 270 |
try { |
297 |
EditableFeatureType type = |
|
298 |
featureStore.getDefaultFeatureType().getCopy().getEditable(); |
|
271 |
EditableFeatureType type = this.options.getSourceFeatureType().getCopy().getEditable(); |
|
299 | 272 |
|
300 |
FeatureAttributeDescriptor fad = |
|
301 |
(FeatureAttributeDescriptor) type.get(type |
|
302 |
.getDefaultGeometryAttributeName()); |
|
303 |
|
|
304 |
type.remove(fad.getName()); |
|
305 |
EditableFeatureAttributeDescriptor efad = |
|
306 |
type.add(fad.getName(), fad.getType(), fad.getSize()); |
|
307 |
efad.setDefaultValue(fad.getDefaultValue()); |
|
308 |
|
|
309 |
int gsubtype = fad.getGeomType().getSubType(); |
|
273 |
String geomFieldName = this.options.getGeometryFieldName(); |
|
274 |
|
|
275 |
FeatureAttributeDescriptor geomFieldDescSource = (FeatureAttributeDescriptor) type.getDefaultGeometryAttribute(); |
|
276 |
if( geomFieldDescSource!=null ) { |
|
277 |
type.remove(geomFieldDescSource.getName()); |
|
278 |
} |
|
279 |
EditableFeatureAttributeDescriptor geomFieldDescTarget = type.add( |
|
280 |
"GEOMETRY", |
|
281 |
this.options.getGeometryTypeAsInt() |
|
282 |
); |
|
283 |
geomFieldDescTarget.setDefaultValue(null); |
|
284 |
int gsubtype = this.options.getGeometrySubtype(); |
|
310 | 285 |
// El shp solo soporta los subtipos 2D y 3D |
311 |
switch( gsubtype ) {
|
|
312 |
case Geometry.SUBTYPES.GEOM2D: |
|
313 |
break; |
|
314 |
case Geometry.SUBTYPES.GEOM3D: |
|
315 |
break; |
|
316 |
default: |
|
317 |
// Forzaremos las geometrias a 3D |
|
318 |
gsubtype = Geometry.SUBTYPES.GEOM3D; |
|
319 |
break; |
|
286 |
switch (gsubtype) {
|
|
287 |
case Geometry.SUBTYPES.GEOM2D:
|
|
288 |
break;
|
|
289 |
case Geometry.SUBTYPES.GEOM3D:
|
|
290 |
break;
|
|
291 |
default:
|
|
292 |
// Forzaremos las geometrias a 3D
|
|
293 |
gsubtype = Geometry.SUBTYPES.GEOM3D;
|
|
294 |
break;
|
|
320 | 295 |
} |
321 | 296 |
GeometryType gty = null; |
322 | 297 |
try { |
298 |
GeometryManager geoManager = GeometryLocator.getGeometryManager(); |
|
323 | 299 |
gty = geoManager.getGeometryType(geometryType, gsubtype); |
324 | 300 |
} catch (Exception e) { |
325 | 301 |
throw new ExporttoServiceException(e); |
326 | 302 |
} |
327 | 303 |
|
328 |
efad.setGeometryType(gty);
|
|
304 |
geomFieldDescTarget.setGeometryType(gty);
|
|
329 | 305 |
|
330 |
efad.setName(this.nameTranslator.getTargetName(fad.getName()));
|
|
331 |
efad.setPrecision(fad.getPrecision());
|
|
306 |
geomFieldDescTarget.setName(this.nameTranslator.getTargetName(geomFieldDescSource.getName()));
|
|
307 |
geomFieldDescTarget.setPrecision(geomFieldDescSource.getPrecision());
|
|
332 | 308 |
|
309 |
type.setDefaultGeometryAttributeName(geomFieldDescTarget.getName()); |
|
333 | 310 |
|
334 |
type.setDefaultGeometryAttributeName(efad.getName()); |
|
335 |
|
|
336 | 311 |
// ========================== |
337 | 312 |
fixNames(type); |
338 | 313 |
// ========================== |
... | ... | |
344 | 319 |
DataManager manager = DALLocator.getDataManager(); |
345 | 320 |
|
346 | 321 |
manager.newStore(explorerName, providerName, params, true); |
347 |
FeatureStore target = |
|
348 |
(FeatureStore) manager.openStore(providerName, params); |
|
349 |
|
|
322 |
|
|
323 |
FeatureStore target = (FeatureStore) manager.openStore(providerName, params); |
|
350 | 324 |
FeatureType targetType = target.getDefaultFeatureType(); |
351 | 325 |
|
352 | 326 |
taskStatus.setRangeOfValues(0, featureSet.getSize()); |
... | ... | |
357 | 331 |
|
358 | 332 |
// ================================================ |
359 | 333 |
// Reprojection stuff |
360 |
Geometry reproj_geom = null;
|
|
361 |
EditableFeature edit_feat = null;
|
|
362 |
IProjection sourceProjection =
|
|
363 |
featureStore.getDefaultFeatureType().getDefaultGeometryAttribute().getSRS();
|
|
334 |
Geometry reproj_geom; |
|
335 |
EditableFeature edit_feat; |
|
336 |
IProjection sourceProjection |
|
337 |
= options.getSourceFeatureType().getDefaultGeometryAttribute().getSRS();
|
|
364 | 338 |
|
365 | 339 |
ICoordTrans coord_trans = null; |
366 | 340 |
// this comparison is perhaps too preventive |
367 | 341 |
// we could have two instances of same projection |
368 | 342 |
// so we would do more computations than needed |
369 |
if (sourceProjection != null && sourceProjection != this.projection) {
|
|
370 |
coord_trans = sourceProjection.getCT(this.projection);
|
|
343 |
if (sourceProjection != null && sourceProjection != this.options.getTargetProjection()) {
|
|
344 |
coord_trans = sourceProjection.getCT(this.options.getTargetProjection());
|
|
371 | 345 |
} |
372 | 346 |
// ================================================ |
373 | 347 |
|
374 |
List<Geometry> extracted = null; |
|
375 |
Geometry gitem = null; |
|
376 |
|
|
348 |
List<Geometry> extracted; |
|
349 |
Geometry gitem ; |
|
350 |
Coercion toGeometry = ToolsLocator.getDataTypesManager() |
|
351 |
.get(DataTypes.GEOMETRY).getCoercion(); |
|
352 |
|
|
377 | 353 |
while (it.hasNext()) { |
378 | 354 |
|
379 | 355 |
Feature feature = (Feature) it.next(); |
380 |
gitem = feature.getDefaultGeometry(); |
|
381 |
|
|
382 |
if (checkType) { |
|
383 |
extracted = getGeometriesFrom(gitem, geometryType); |
|
384 |
if (extracted.size() == 0) { |
|
385 |
// found no geometries of correct type |
|
386 |
continue; |
|
387 |
} else { |
|
388 |
if (geometryType != Geometry.TYPES.POINT) { |
|
389 |
// If not points, merge geometries |
|
390 |
// (curves or surfaces) |
|
391 |
try { |
|
392 |
gitem = union(extracted); |
|
393 |
extracted = new ArrayList<Geometry>(); |
|
394 |
extracted.add(gitem); |
|
395 |
} catch (Exception ex) { |
|
396 |
there_was_error = true; |
|
397 |
logger.info("Error in union.", ex); |
|
356 |
if( geomFieldName==null ) { |
|
357 |
edit_feat = target.createNewFeature(true); |
|
358 |
// |
|
359 |
// Accumulate error in boolean. |
|
360 |
// This also fixes field names (using origNameToDbfName) |
|
361 |
// |
|
362 |
there_was_error = there_was_error | |
|
363 |
setNonNulls( |
|
364 |
options.getSourceFeatureType(), |
|
365 |
targetType, |
|
366 |
feature, |
|
367 |
edit_feat |
|
368 |
); |
|
369 |
edit_feat.setDefaultGeometry(null); |
|
370 |
target.insert(edit_feat); |
|
371 |
} else { |
|
372 |
Object x = feature.getGeometry(geomFieldName); |
|
373 |
try { |
|
374 |
gitem = (Geometry) toGeometry.coerce(x); |
|
375 |
} catch (CoercionException ex) { |
|
376 |
gitem = null; |
|
377 |
} |
|
378 |
|
|
379 |
if (checkType) { |
|
380 |
extracted = getGeometriesFrom(gitem, geometryType); |
|
381 |
if (extracted.isEmpty()) { |
|
382 |
// found no geometries of correct type |
|
383 |
continue; |
|
384 |
} else { |
|
385 |
if (geometryType != Geometry.TYPES.POINT) { |
|
386 |
// If not points, merge geometries |
|
387 |
// (curves or surfaces) |
|
388 |
try { |
|
389 |
gitem = union(extracted); |
|
390 |
extracted = new ArrayList<>(); |
|
391 |
extracted.add(gitem); |
|
392 |
} catch (Exception ex) { |
|
393 |
there_was_error = true; |
|
394 |
logger.info("Error in union.", ex); |
|
395 |
} |
|
396 |
} else { |
|
397 |
// only in the case of points, we can have several |
|
398 |
// geometries if source is multipoint |
|
398 | 399 |
} |
399 |
} else { |
|
400 |
// only in the case of points, we can have several |
|
401 |
// geometries if source is multipoint |
|
402 | 400 |
} |
401 |
} else { |
|
402 |
extracted = new ArrayList<>(); |
|
403 |
extracted.add(gitem); |
|
403 | 404 |
} |
404 |
} else { |
|
405 |
extracted = new ArrayList<Geometry>(); |
|
406 |
extracted.add(gitem); |
|
407 |
} |
|
408 | 405 |
|
409 |
for (int i=0; i<extracted.size(); i++) {
|
|
410 |
gitem = extracted.get(i); |
|
406 |
for (int i = 0; i < extracted.size(); i++) {
|
|
407 |
gitem = extracted.get(i);
|
|
411 | 408 |
|
412 |
if( gsubtype==Geometry.SUBTYPES.GEOM2D ) { |
|
413 |
gitem = force2D(gitem, geometryType); |
|
414 |
} else { |
|
415 |
gitem = force3D(gitem, geometryType); |
|
409 |
if (gsubtype == Geometry.SUBTYPES.GEOM2D) { |
|
410 |
gitem = force2D(gitem, geometryType); |
|
411 |
} else { |
|
412 |
gitem = force3D(gitem, geometryType); |
|
413 |
} |
|
414 |
edit_feat = target.createNewFeature(true); |
|
415 |
// |
|
416 |
// Accumulate error in boolean. |
|
417 |
// This also fixes field names (using origNameToDbfName) |
|
418 |
// |
|
419 |
there_was_error = there_was_error | |
|
420 |
setNonNulls( |
|
421 |
options.getSourceFeatureType(), |
|
422 |
targetType, |
|
423 |
feature, |
|
424 |
edit_feat |
|
425 |
); |
|
426 |
edit_feat.setDefaultGeometry(gitem); |
|
427 |
// ================================================ |
|
428 |
// Reprojection stuff |
|
429 |
if (coord_trans != null && gitem != null) { |
|
430 |
reproj_geom = edit_feat.getDefaultGeometry(); |
|
431 |
reproj_geom = reproj_geom.cloneGeometry(); |
|
432 |
reproj_geom.reProject(coord_trans); |
|
433 |
edit_feat.setDefaultGeometry(reproj_geom); |
|
434 |
} |
|
435 |
// ================================================ |
|
436 |
target.insert(edit_feat); |
|
416 | 437 |
} |
417 |
edit_feat = target.createNewFeature(true); |
|
418 |
there_was_error = there_was_error | |
|
419 |
/* |
|
420 |
* Accumulate error in boolean. |
|
421 |
* This also fixes field names (using origNameToDbfName) |
|
422 |
*/ |
|
423 |
setNonNulls(featureStore.getDefaultFeatureType(), |
|
424 |
targetType, feature, edit_feat); |
|
425 |
edit_feat.setDefaultGeometry(gitem); |
|
426 |
// ================================================ |
|
427 |
// Reprojection stuff |
|
428 |
if (coord_trans != null && gitem != null ) { |
|
429 |
reproj_geom = edit_feat.getDefaultGeometry(); |
|
430 |
reproj_geom = reproj_geom.cloneGeometry(); |
|
431 |
reproj_geom.reProject(coord_trans); |
|
432 |
edit_feat.setDefaultGeometry(reproj_geom); |
|
433 |
} |
|
434 |
// ================================================ |
|
435 |
target.insert(edit_feat); |
|
436 | 438 |
} |
437 |
|
|
438 | 439 |
featureCount++; |
439 | 440 |
this.taskStatus.setCurValue(featureCount); |
440 | 441 |
|
... | ... | |
452 | 453 |
|
453 | 454 |
if (there_was_error) { |
454 | 455 |
Exception cause = new Exception( |
455 |
"_Issues_with_attributes_or_geometries"); |
|
456 |
"_Issues_with_attributes_or_geometries");
|
|
456 | 457 |
throw new ExporttoServiceException(cause); |
457 | 458 |
} |
458 | 459 |
} |
459 | 460 |
|
460 |
|
|
461 | 461 |
private void fixNames(EditableFeatureType eft) { |
462 | 462 |
|
463 |
FeatureAttributeDescriptor[] atts = eft.getAttributeDescriptors();
|
|
464 |
EditableFeatureAttributeDescriptor efad = null;
|
|
465 |
for (int i=0; i<atts.length; i++) {
|
|
466 |
String new_name = this.nameTranslator.getTargetName(atts[i].getName());
|
|
467 |
if (new_name != null) {
|
|
468 |
eft.remove(atts[i].getName());
|
|
469 |
efad = eft.add(new_name, atts[i].getType(), atts[i].getSize());
|
|
470 |
efad.setPrecision(atts[i].getPrecision());
|
|
471 |
if(atts[i].getDataType().getType() == DataTypes.GEOMETRY){
|
|
472 |
efad.setGeometryType(atts[i].getGeomType());
|
|
473 |
}
|
|
474 |
}
|
|
475 |
}
|
|
476 |
}
|
|
463 |
FeatureAttributeDescriptor[] atts = eft.getAttributeDescriptors();
|
|
464 |
EditableFeatureAttributeDescriptor efad;
|
|
465 |
for (int i = 0; i < atts.length; i++) {
|
|
466 |
String new_name = this.nameTranslator.getTargetName(atts[i].getName());
|
|
467 |
if (new_name != null) {
|
|
468 |
eft.remove(atts[i].getName());
|
|
469 |
efad = eft.add(new_name, atts[i].getType(), atts[i].getSize());
|
|
470 |
efad.setPrecision(atts[i].getPrecision());
|
|
471 |
if (atts[i].getDataType().getType() == DataTypes.GEOMETRY) {
|
|
472 |
efad.setGeometryType(atts[i].getGeomType());
|
|
473 |
}
|
|
474 |
}
|
|
475 |
}
|
|
476 |
}
|
|
477 | 477 |
|
478 |
/**
|
|
478 |
/**
|
|
479 | 479 |
* @param gitem |
480 | 480 |
* @param geometryType2 |
481 | 481 |
* @return |
482 | 482 |
*/ |
483 | 483 |
private Geometry force2D(Geometry ge, int gt) throws CreateGeometryException { |
484 |
if( ge == null ) {
|
|
484 |
if (ge == null) {
|
|
485 | 485 |
return null; |
486 | 486 |
} |
487 | 487 |
if (ge.getGeometryType().getSubType() == Geometry.SUBTYPES.GEOM2D) { |
488 | 488 |
return ge; |
489 | 489 |
} else { |
490 |
GeometryManager geoManager = GeometryLocator.getGeometryManager(); |
|
490 | 491 |
switch (gt) { |
491 |
case Geometry.TYPES.POINT: |
|
492 |
Point p = (Point) ge; |
|
493 |
Point point = geoManager.createPoint( |
|
494 |
p.getX(), p.getY(), |
|
495 |
Geometry.SUBTYPES.GEOM2D); |
|
496 |
return point; |
|
497 |
case Geometry.TYPES.CURVE: |
|
498 |
return geoManager.createCurve(ge.getGeneralPath(), Geometry.SUBTYPES.GEOM2D); |
|
499 |
case Geometry.TYPES.SURFACE: |
|
500 |
return geoManager.createSurface(ge.getGeneralPath(), Geometry.SUBTYPES.GEOM2D); |
|
501 |
default: |
|
502 |
return ge; |
|
492 |
case Geometry.TYPES.POINT:
|
|
493 |
Point p = (Point) ge;
|
|
494 |
Point point = geoManager.createPoint(
|
|
495 |
p.getX(), p.getY(),
|
|
496 |
Geometry.SUBTYPES.GEOM2D);
|
|
497 |
return point;
|
|
498 |
case Geometry.TYPES.CURVE:
|
|
499 |
return geoManager.createCurve(ge.getGeneralPath(), Geometry.SUBTYPES.GEOM2D);
|
|
500 |
case Geometry.TYPES.SURFACE:
|
|
501 |
return geoManager.createSurface(ge.getGeneralPath(), Geometry.SUBTYPES.GEOM2D);
|
|
502 |
default:
|
|
503 |
return ge;
|
|
503 | 504 |
} |
504 | 505 |
} |
505 | 506 |
} |
... | ... | |
510 | 511 |
* @return |
511 | 512 |
*/ |
512 | 513 |
private Geometry force3D(Geometry ge, int gt) throws CreateGeometryException { |
513 |
if( ge == null ) {
|
|
514 |
if (ge == null) {
|
|
514 | 515 |
return null; |
515 | 516 |
} |
516 | 517 |
// Los try catch que hay abajo, son para asegurarse de que la geometr?a original |
517 | 518 |
// tiene las 3 dimensiones necesarias. A veces nos llegan geometr?as que aunque son de subtipo GEOM3D |
518 | 519 |
// los puntos del generalPath que contienen no son 3D y no tienen la coordenada Z |
519 |
Point point; |
|
520 |
switch (gt) { |
|
520 |
GeometryManager geoManager = GeometryLocator.getGeometryManager(); |
|
521 |
Point point; |
|
522 |
switch (gt) { |
|
521 | 523 |
case Geometry.TYPES.POINT: |
522 | 524 |
Point p = (Point) ge; |
523 | 525 |
point = geoManager.createPoint( |
524 |
p.getX(), p.getY(), |
|
525 |
Geometry.SUBTYPES.GEOM3D); |
|
526 |
p.getX(), p.getY(),
|
|
527 |
Geometry.SUBTYPES.GEOM3D);
|
|
526 | 528 |
try { |
527 | 529 |
point.setCoordinateAt(2, p.getCoordinateAt(2)); |
528 | 530 |
} catch (Exception e) { |
... | ... | |
532 | 534 |
case Geometry.TYPES.CURVE: |
533 | 535 |
case Geometry.TYPES.LINE: |
534 | 536 |
Line line = geoManager.createLine(Geometry.SUBTYPES.GEOM3D); |
535 |
for (int i = 0; i < ((OrientablePrimitive)ge).getNumVertices(); i++) { |
|
536 |
Point vertex = ((OrientablePrimitive)ge).getVertex(i); |
|
537 |
for (int i = 0; i < ((OrientablePrimitive) ge).getNumVertices(); i++) {
|
|
538 |
Point vertex = ((OrientablePrimitive) ge).getVertex(i);
|
|
537 | 539 |
point = geoManager.createPoint(vertex.getX(), vertex.getY(), Geometry.SUBTYPES.GEOM3D); |
538 | 540 |
try { |
539 | 541 |
point.setCoordinateAt(2, vertex.getCoordinateAt(2)); |
... | ... | |
541 | 543 |
point.setCoordinateAt(2, 0); |
542 | 544 |
} |
543 | 545 |
line.addVertex(point); |
544 |
}; |
|
546 |
} |
|
547 |
; |
|
545 | 548 |
return line; |
546 | 549 |
|
547 | 550 |
case Geometry.TYPES.SURFACE: |
548 | 551 |
case Geometry.TYPES.POLYGON: |
549 | 552 |
Polygon polygon = geoManager.createPolygon(Geometry.SUBTYPES.GEOM3D); |
550 |
for (int i = 0; i < ((OrientablePrimitive)ge).getNumVertices(); i++) { |
|
551 |
Point vertex = ((OrientablePrimitive)ge).getVertex(i); |
|
553 |
for (int i = 0; i < ((OrientablePrimitive) ge).getNumVertices(); i++) {
|
|
554 |
Point vertex = ((OrientablePrimitive) ge).getVertex(i);
|
|
552 | 555 |
point = geoManager.createPoint(vertex.getX(), vertex.getY(), Geometry.SUBTYPES.GEOM3D); |
553 | 556 |
try { |
554 | 557 |
point.setCoordinateAt(2, vertex.getCoordinateAt(2)); |
... | ... | |
556 | 559 |
point.setCoordinateAt(2, 0); |
557 | 560 |
} |
558 | 561 |
polygon.addVertex(point); |
559 |
}; |
|
562 |
} |
|
563 |
; |
|
560 | 564 |
return polygon; |
561 | 565 |
default: |
562 | 566 |
return ge; |
563 |
}
|
|
567 |
} |
|
564 | 568 |
} |
565 |
private void createPoint(int geom3d) { |
|
566 |
// TODO Auto-generated method stub |
|
567 | 569 |
|
568 |
} |
|
569 | 570 |
|
570 | 571 |
/** |
571 | 572 |
* @param feature |
572 | 573 |
* @param edit_feat |
573 | 574 |
*/ |
574 | 575 |
private boolean setNonNulls( |
575 |
FeatureType src_ft, FeatureType target_ft, |
|
576 |
Feature feat, EditableFeature edit_f) { |
|
576 |
FeatureType src_ft, |
|
577 |
FeatureType target_ft, |
|
578 |
Feature feat, |
|
579 |
EditableFeature edit_f |
|
580 |
) { |
|
577 | 581 |
|
578 | 582 |
boolean error = false; |
579 | 583 |
FeatureAttributeDescriptor[] atts = src_ft.getAttributeDescriptors(); |
580 |
String orig_name = null;
|
|
581 |
String dbf_name = null;
|
|
582 |
for (int i=0; i<atts.length; i++) {
|
|
584 |
String orig_name; |
|
585 |
String dbf_name; |
|
586 |
for (int i = 0; i < atts.length; i++) {
|
|
583 | 587 |
if (atts[i].getType() != org.gvsig.fmap.geom.DataTypes.GEOMETRY) { |
584 | 588 |
|
585 | 589 |
Object val = null; |
586 | 590 |
|
587 | 591 |
try { |
588 |
orig_name = atts[i].getName();
|
|
589 |
dbf_name = this.nameTranslator.getTargetName(orig_name);
|
|
590 |
if (dbf_name == null) {
|
|
591 |
dbf_name = orig_name;
|
|
592 |
}
|
|
592 |
orig_name = atts[i].getName();
|
|
593 |
dbf_name = this.nameTranslator.getTargetName(orig_name);
|
|
594 |
if (dbf_name == null) {
|
|
595 |
dbf_name = orig_name;
|
|
596 |
}
|
|
593 | 597 |
val = feat.get(orig_name); |
594 | 598 |
if (val != null) { |
595 | 599 |
edit_f.set(dbf_name, val); |
... | ... | |
604 | 608 |
} |
605 | 609 |
|
606 | 610 |
private Geometry union(List<Geometry> geoms) |
607 |
throws GeometryOperationNotSupportedException, GeometryOperationException { |
|
611 |
throws GeometryOperationNotSupportedException, GeometryOperationException {
|
|
608 | 612 |
|
609 |
if (geoms == null || geoms.size() == 0) {
|
|
613 |
if ( geoms == null || geoms.isEmpty()) {
|
|
610 | 614 |
return null; |
611 | 615 |
} |
612 | 616 |
|
... | ... | |
615 | 619 |
} |
616 | 620 |
|
617 | 621 |
Geometry resp = geoms.get(0); |
618 |
for (int i=1; i<geoms.size(); i++) {
|
|
622 |
for (int i = 1; i < geoms.size(); i++) {
|
|
619 | 623 |
resp = resp.union(geoms.get(i)); |
620 | 624 |
} |
Also available in: Unified diff