Revision 6433 trunk/extensions/extCAD/src/com/iver/cit/gvsig/ExportTo.java
ExportTo.java | ||
---|---|---|
41 | 41 |
import com.iver.cit.gvsig.fmap.edition.IWriter; |
42 | 42 |
import com.iver.cit.gvsig.fmap.edition.writers.dxf.DxfFieldsMapping; |
43 | 43 |
import com.iver.cit.gvsig.fmap.edition.writers.dxf.DxfWriter; |
44 |
import com.iver.cit.gvsig.fmap.edition.writers.gml.GMLWriter; |
|
44 | 45 |
import com.iver.cit.gvsig.fmap.edition.writers.shp.ShpWriter; |
45 | 46 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
46 | 47 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
... | ... | |
230 | 231 |
if (actionCommand.equals("POSTGIS")) { |
231 | 232 |
saveToPostGIS(mapa, lv); |
232 | 233 |
} |
234 |
if (actionCommand.equals("GML")) { |
|
235 |
saveToGml(mapa, lv); |
|
236 |
} |
|
233 | 237 |
} // actives[i] |
234 | 238 |
} // for |
235 | 239 |
} catch (EditionException e) { |
... | ... | |
530 | 534 |
// } |
531 | 535 |
|
532 | 536 |
} |
537 |
|
|
538 |
/** |
|
539 |
* This method saves a layer to GML |
|
540 |
* @param mapContext |
|
541 |
* @param layer |
|
542 |
* @throws EditionException |
|
543 |
* @throws DriverIOException |
|
544 |
*/ |
|
545 |
public void saveToGml(FMap mapContext, FLyrVect layer) throws EditionException, DriverIOException { |
|
546 |
try { |
|
547 |
JFileChooser jfc = new JFileChooser(); |
|
548 |
SimpleFileFilter filterShp = new SimpleFileFilter("gml", |
|
549 |
PluginServices.getText(this, "gml_files")); |
|
550 |
jfc.setFileFilter(filterShp); |
|
551 |
if (jfc.showSaveDialog((Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION) { |
|
552 |
File newFile = jfc.getSelectedFile(); |
|
553 |
String path = newFile.getAbsolutePath(); |
|
554 |
if (!(path.toLowerCase().endsWith(".gml"))) { |
|
555 |
path = path + ".gml"; |
|
556 |
} |
|
557 |
newFile = new File(path); |
|
558 |
|
|
559 |
GMLWriter writer = (GMLWriter)LayerFactory.getWM().getWriter("GML Writer"); |
|
560 |
|
|
561 |
SHPLayerDefinition lyrDef = new SHPLayerDefinition(); |
|
562 |
SelectableDataSource sds = layer.getRecordset(); |
|
563 |
FieldDescription[] fieldsDescrip = sds.getFieldsDescription(); |
|
564 |
lyrDef.setFieldsDesc(fieldsDescrip); |
|
565 |
lyrDef.setName(layer.getName()); |
|
566 |
lyrDef.setShapeType(layer.getShapeType()); |
|
567 |
|
|
568 |
writer.setFile(newFile); |
|
569 |
writer.setSchema(lyrDef); |
|
570 |
writer.setBoundedBy(layer.getFullExtent(),layer.getProjection()); |
|
571 |
|
|
572 |
writeFeatures(mapContext, layer, writer, null); |
|
573 |
} |
|
533 | 574 |
|
575 |
} catch (DriverException e) { |
|
576 |
e.printStackTrace(); |
|
577 |
throw new EditionException(e); |
|
578 |
} catch (com.hardcode.gdbms.engine.data.driver.DriverException e) { |
|
579 |
e.printStackTrace(); |
|
580 |
throw new EditionException(e); |
|
581 |
} |
|
582 |
// catch (IOException e) { |
|
583 |
// e.printStackTrace(); |
|
584 |
// throw new EditionException(e); |
|
585 |
// } |
|
586 |
|
|
587 |
} |
|
588 |
|
|
534 | 589 |
/** |
535 | 590 |
* @see com.iver.andami.plugins.IExtension#isEnabled() |
536 | 591 |
*/ |
Also available in: Unified diff