Revision 45009

View differences:

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/export/jdbc/service/ExportJDBCService.java
133 133
                }
134 134
            }
135 135

  
136
            if (this.getParameters().getCreateIndexInGeometryRow()) {
137
                EditableFeatureAttributeDescriptor x = (EditableFeatureAttributeDescriptor) targetEditableFeatureType.getDefaultGeometryAttribute();
138
                x.setIsIndexed(true);
136
            EditableFeatureAttributeDescriptor attrdescriptor = (EditableFeatureAttributeDescriptor) targetEditableFeatureType.getDefaultGeometryAttribute();
137
            if (attrdescriptor != null && this.getParameters().getCreateIndexInGeometryRow()) {
138
                attrdescriptor.setIsIndexed(true);
139 139
            }
140 140

  
141 141
            // ======================================================
142 142
            // Reprojection: set SRS of geometry field to target SRS
143
            EditableFeatureAttributeDescriptor attrdescriptor
144
                    = (EditableFeatureAttributeDescriptor) targetEditableFeatureType.getDefaultGeometryAttribute();
145 143
            if (attrdescriptor != null) {
146 144
                attrdescriptor.setSRS(this.getParameters().getTargetProjection());
147 145
            }
......
191 189
            openStoreParameters.setTable(this.getParameters().getTableName());
192 190
            openStoreParameters.setCRS(this.getParameters().getTargetProjection());
193 191
            openStoreParameters.setDefaultGeometryField(
194
                    this.getParameters().getSourceFeatureType().getDefaultGeometryAttributeName()
192
                    this.getParameters().getTargetFeatureType().getDefaultGeometryAttributeName()
195 193
            );
196 194
            return openStoreParameters;
197 195
        } catch (DataException ex) {
......
253 251
            long featureCount = 1;
254 252
            getTaskStatus().setRangeOfValues(0, featureSet.getSize());
255 253

  
256
            int targetGeometryIndex;
257
            int sourceGeometryIndex;
254
            int targetGeometryIndex = -1;
255
            int sourceGeometryIndex = -1;
258 256
            if (getGeometryColumnCount(theSourceFeatureType) == 1
259 257
                    && getGeometryColumnCount(theTargetFeatureType) == 1) {
260 258
                // Si solo hay una columna de geometria asignaremos las geometrias
......
263 261
                sourceGeometryIndex = theSourceFeatureType.getDefaultGeometryAttributeIndex();
264 262
            } else {
265 263
                FeatureAttributeDescriptor attr = theSourceFeatureType.getDefaultGeometryAttribute();
266
                sourceGeometryIndex = attr.getIndex();
267
                targetGeometryIndex = theTargetFeatureType.getAttributeDescriptor(attr.getName()).getIndex();
264
                if (theTargetFeatureType.getAttributeDescriptor(attr.getName())!=null) {
265
                    sourceGeometryIndex = attr.getIndex();
266
                    targetGeometryIndex = theTargetFeatureType.getAttributeDescriptor(attr.getName()).getIndex();
267
                }
268 268
            }
269 269

  
270 270
            LOG.debug("Inserting rows");
......
295 295
                    }
296 296
                }
297 297

  
298
                Geometry geometry = targetFeature.getGeometry(targetGeometryIndex);
299
                FixGeometryStatus check = serviceManager.fixGeometry(getParameters(), coord_trans, geometry);
300
                switch (check.getState()) {
301
                    case FixGeometryStatus.STATE_OK:
302
                        targetFeature.setDefaultGeometry(check.getGeometry());
303
                        break;
304
                    case FixGeometryStatus.STATE_SKIP:
305
                        continue;
306
                    case FixGeometryStatus.STATE_ABORT:
307
                        throw new InvalidGeometryException(targetFeature, check.getMessage());
298
                if (targetGeometryIndex!=-1) {
299
                    Geometry geometry = targetFeature.getGeometry(targetGeometryIndex);
300
                
301
                    FixGeometryStatus check = serviceManager.fixGeometry(getParameters(), coord_trans, geometry);
302
                    switch (check.getState()) {
303
                        case FixGeometryStatus.STATE_OK:
304
                            targetFeature.setDefaultGeometry(check.getGeometry());
305
                            break;
306
                        case FixGeometryStatus.STATE_SKIP:
307
                            continue;
308
                        case FixGeometryStatus.STATE_ABORT:
309
                            throw new InvalidGeometryException(targetFeature, check.getMessage());
310
                    }
308 311
                }
309 312

  
310 313
                target.insert(targetFeature);

Also available in: Unified diff