Revision 4430 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/writers/shp/ShpWriter.java
ShpWriter.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.awt.geom.Rectangle2D; |
4 | 4 |
import java.io.File; |
5 |
import java.io.FileInputStream; |
|
5 | 6 |
import java.io.IOException; |
6 | 7 |
import java.io.RandomAccessFile; |
7 | 8 |
import java.nio.channels.FileChannel; |
... | ... | |
11 | 12 |
import com.iver.cit.gvsig.fmap.DriverException; |
12 | 13 |
import com.iver.cit.gvsig.fmap.core.FShape; |
13 | 14 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
15 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
|
14 | 16 |
import com.iver.cit.gvsig.fmap.drivers.LayerDefinition; |
15 | 17 |
import com.iver.cit.gvsig.fmap.drivers.shp.DbaseFileHeaderNIO; |
16 | 18 |
import com.iver.cit.gvsig.fmap.drivers.shp.DbaseFileWriterNIO; |
... | ... | |
19 | 21 |
import com.iver.cit.gvsig.fmap.edition.EditionException; |
20 | 22 |
import com.iver.cit.gvsig.fmap.edition.IRowEdited; |
21 | 23 |
import com.iver.cit.gvsig.fmap.edition.ISpatialWriter; |
24 |
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter; |
|
22 | 25 |
import com.iver.cit.gvsig.fmap.edition.writers.AbstractWriter; |
23 | 26 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
24 | 27 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
25 | 28 |
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
29 |
import com.iver.cit.gvsig.fmap.layers.VectorialFileAdapter; |
|
30 |
import com.iver.utiles.bigfile.BigByteBuffer2; |
|
26 | 31 |
|
27 | 32 |
public class ShpWriter extends AbstractWriter implements ISpatialWriter { |
28 | 33 |
private String shpPath; |
29 | 34 |
private String shxPath; |
30 | 35 |
private String dbfPath; |
36 |
|
|
37 |
private File shpFile; |
|
31 | 38 |
|
32 | 39 |
private SHPFileWrite shpWrite; |
33 | 40 |
private DbaseFileWriterNIO dbfWrite; |
... | ... | |
43 | 50 |
// private FLyrVect lyrVect; |
44 | 51 |
private FBitSet selection = null; |
45 | 52 |
|
46 |
private void setFile(File f)
|
|
53 |
public void setFile(File f)
|
|
47 | 54 |
{ |
48 | 55 |
shpPath = f.getAbsolutePath(); |
49 | 56 |
|
... | ... | |
52 | 59 |
|
53 | 60 |
String strFichDbf = f.getAbsolutePath().replaceAll("\\.shp", ".dbf"); |
54 | 61 |
dbfPath = strFichDbf.replaceAll("\\.SHP", ".DBF"); |
62 |
|
|
63 |
shpFile = f; |
|
55 | 64 |
} |
56 | 65 |
|
57 | 66 |
private WritableByteChannel getWriteChannel(String path) |
... | ... | |
109 | 118 |
myHeader = DbaseFileHeaderNIO.createDbaseHeader(lyrDef.getFieldsDesc()); |
110 | 119 |
initialize(shpFile, lyrDef.getShapeType()); |
111 | 120 |
} |
121 |
|
|
122 |
/** |
|
123 |
* To be used when you need to write to another existing shp file. |
|
124 |
* It is used inside IndexedShpDriver. |
|
125 |
* @param shpFile |
|
126 |
* @throws IOException |
|
127 |
* @throws IOException |
|
128 |
* @throws DriverException |
|
129 |
*/ |
|
130 |
public void initialize(VectorialEditableAdapter vea) throws EditionException |
|
131 |
{ |
|
132 |
try { |
|
133 |
SelectableDataSource sds = vea.getRecordset(); |
|
134 |
myHeader = DbaseFileHeaderNIO.createDbaseHeader(sds); |
|
135 |
initialize(shpFile, vea.getShapeType()); |
|
136 |
} catch (IOException e) { |
|
137 |
e.printStackTrace(); |
|
138 |
throw new EditionException(e); |
|
139 |
} catch (DriverIOException e) { |
|
140 |
e.printStackTrace(); |
|
141 |
throw new EditionException(e); |
|
142 |
} |
|
143 |
|
|
144 |
|
|
145 |
} |
|
146 |
|
|
112 | 147 |
/* public ShpWriter(File shpFile, FLyrVect lyrVect, FBitSet selection) throws IOException, DriverException |
113 | 148 |
{ |
114 | 149 |
SelectableDataSource sds = lyrVect.getRecordset(); |
Also available in: Unified diff