Revision 42708
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.jdbc/src/main/java/org/gvsig/exportto/swing/prov/jdbc/ExporrtoJDBCService.java | ||
---|---|---|
167 | 167 |
try { |
168 | 168 |
|
169 | 169 |
// ====================================== |
170 |
// Reprojection
|
|
170 |
// Reprojection |
|
171 | 171 |
FeatureAttributeDescriptor geo_att = this.options.getSource().getDefaultFeatureType().getDefaultGeometryAttribute(); |
172 | 172 |
IProjection sourceProjection = null; |
173 | 173 |
ICoordTrans coord_trans = null; |
174 | 174 |
Geometry reproj_geom = null; |
175 |
IProjection targetProjection = this.options.getTargetProjection(); |
|
175 | 176 |
if (geo_att != null) { |
176 | 177 |
sourceProjection = geo_att.getSRS(); |
177 | 178 |
// this comparison is perhaps too preventive |
178 | 179 |
// we could have two instances of same projection |
179 | 180 |
// so we would do more computations than needed |
180 |
if (sourceProjection != null && sourceProjection != this.options.getTargetProjection()) {
|
|
181 |
coord_trans = sourceProjection.getCT(this.options.getTargetProjection());
|
|
181 |
if (sourceProjection != null && targetProjection != null && sourceProjection != targetProjection) {
|
|
182 |
coord_trans = sourceProjection.getCT(targetProjection);
|
|
182 | 183 |
} |
183 | 184 |
} |
184 | 185 |
// ============================================ |
... | ... | |
199 | 200 |
JDBCStoreParameters openParams = (JDBCStoreParameters) explorer.getOpenParameters(); |
200 | 201 |
openParams.setSchema(this.options.getSchema()); |
201 | 202 |
openParams.setTable(this.options.getTableName()); |
202 |
openParams.setCRS(this.options.getTargetProjection());
|
|
203 |
openParams.setCRS(targetProjection);
|
|
203 | 204 |
openParams.setDefaultGeometryField( |
204 | 205 |
this.options.getSource().getDefaultFeatureType().getDefaultGeometryAttributeName() |
205 | 206 |
); |
... | ... | |
215 | 216 |
|
216 | 217 |
int targetGeometryIndex = -1; |
217 | 218 |
int sourceGeometryIndex = -1; |
218 |
if( getGeometryColumnCount(sourceFeatureType)==1
|
|
219 |
if( getGeometryColumnCount(sourceFeatureType)==1 |
|
219 | 220 |
&& getGeometryColumnCount(targetFeatureType)==1 ) { |
220 |
// Solo si hay una columna de geometria asignaremos las geometrias
|
|
221 |
// Solo si hay una columna de geometria asignaremos las geometrias |
|
221 | 222 |
// independientemente de como se llamen los campos. |
222 | 223 |
targetGeometryIndex = targetFeatureType.getDefaultGeometryAttributeIndex(); |
223 | 224 |
sourceGeometryIndex = sourceFeatureType.getDefaultGeometryAttributeIndex(); |
224 | 225 |
} |
225 |
|
|
226 |
|
|
226 | 227 |
logger.debug("Inserting rows"); |
227 | 228 |
taskStatus.message("Inserting rows"); |
228 | 229 |
it = featureSet.fastIterator(); |
... | ... | |
298 | 299 |
break; |
299 | 300 |
} |
300 | 301 |
// ================================================ |
301 |
// Reprojection
|
|
302 |
// Reprojection |
|
302 | 303 |
if (geo_att != null && coord_trans != null) { |
303 | 304 |
reproj_geom = targetFeature.getDefaultGeometry(); |
304 | 305 |
reproj_geom = reproj_geom.cloneGeometry(); |
... | ... | |
349 | 350 |
this.taskStatus.remove(); |
350 | 351 |
} |
351 | 352 |
} |
352 |
|
|
353 |
|
|
353 | 354 |
private int getGeometryColumnCount(FeatureType featureType) { |
354 | 355 |
int count = 0; |
355 | 356 |
for( int i=0; i<featureType.size(); i++ ) { |
Also available in: Unified diff