Revision 1132 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/shp/SHP.java
SHP.java | ||
---|---|---|
40 | 40 |
*/ |
41 | 41 |
package com.iver.cit.gvsig.fmap.drivers.shp; |
42 | 42 |
|
43 |
import java.io.File; |
|
44 |
|
|
45 |
import com.hardcode.gdbms.engine.values.Value; |
|
46 |
import com.iver.cit.gvsig.fmap.DriverException; |
|
47 |
import com.iver.cit.gvsig.fmap.FMap; |
|
48 |
import com.iver.cit.gvsig.fmap.drivers.shp.write.DBFFromSelected; |
|
49 |
import com.iver.cit.gvsig.fmap.drivers.shp.write.SHPMultiLine; |
|
50 |
import com.iver.cit.gvsig.fmap.drivers.shp.write.SHPMultiPoint; |
|
51 |
import com.iver.cit.gvsig.fmap.drivers.shp.write.SHPPoint; |
|
52 |
import com.iver.cit.gvsig.fmap.drivers.shp.write.SHPPolygon; |
|
53 |
import com.iver.cit.gvsig.fmap.drivers.shp.write.SHPSHXFromSelectedVisitor; |
|
54 |
import com.iver.cit.gvsig.fmap.drivers.shp.write.SHPShape; |
|
55 |
import com.iver.cit.gvsig.fmap.drivers.shp.write.ShapefileException; |
|
56 |
import com.iver.cit.gvsig.fmap.operations.strategies.VisitException; |
|
57 |
|
|
58 |
|
|
59 |
|
|
43 | 60 |
/** |
44 |
* Clase con las constantes que representan los diferentes tipos de Shape. |
|
61 |
* Clase con las constantes que representan los diferentes tipos de Shape y |
|
62 |
* m?todos est?ticos relativos a los shapes. |
|
45 | 63 |
* |
46 | 64 |
* @author Vicente Caballero Navarro |
47 | 65 |
*/ |
... | ... | |
55 | 73 |
public static final int POLYLINE3D = 13; |
56 | 74 |
public static final int POLYGON3D = 15; |
57 | 75 |
public static final int MULTIPOINT3D = 18; |
76 |
|
|
77 |
/** |
|
78 |
* Crea a partir del tipo de geometr?a un shape del tipo m?s adecuado. |
|
79 |
* |
|
80 |
* @param type Tipo de geometr?a. |
|
81 |
* |
|
82 |
* @return Geometr?a m?s adecuada. |
|
83 |
* |
|
84 |
* @throws ShapefileException Se lanza cuando es causada por la creaci?n del shape. |
|
85 |
*/ |
|
86 |
public static SHPShape create(int type) throws ShapefileException { |
|
87 |
SHPShape shape; |
|
88 |
|
|
89 |
switch (type) { |
|
90 |
case 1: |
|
91 |
case 11: |
|
92 |
case 21: |
|
93 |
shape = new SHPPoint(type); |
|
94 |
|
|
95 |
break; |
|
96 |
|
|
97 |
case 3: |
|
98 |
case 13: |
|
99 |
case 23: |
|
100 |
shape = new SHPMultiLine(type); |
|
101 |
|
|
102 |
break; |
|
103 |
|
|
104 |
case 5: |
|
105 |
case 15: |
|
106 |
case 25: |
|
107 |
shape = new SHPPolygon(type); |
|
108 |
|
|
109 |
break; |
|
110 |
|
|
111 |
case 8: |
|
112 |
case 18: |
|
113 |
case 28: |
|
114 |
shape = new SHPMultiPoint(type); |
|
115 |
|
|
116 |
break; |
|
117 |
|
|
118 |
default: |
|
119 |
shape = null; |
|
120 |
} |
|
121 |
|
|
122 |
return shape; |
|
123 |
} |
|
124 |
|
|
125 |
/** |
|
126 |
* Devuelve el caracter que representa el tipo de valor del shape. |
|
127 |
* |
|
128 |
* @param i Tipo de Valor. |
|
129 |
* |
|
130 |
* @return Tipo de valor entendible por el formato shape. |
|
131 |
*/ |
|
132 |
public static char getCharSelect(int i) { |
|
133 |
switch (i) { |
|
134 |
case Value.STRING: |
|
135 |
return 'M'; |
|
136 |
|
|
137 |
case Value.DECIMAL: |
|
138 |
case Value.INTEGER: |
|
139 |
return 'N'; |
|
140 |
|
|
141 |
case Value.DATE: |
|
142 |
return 'D'; |
|
143 |
|
|
144 |
case Value.BOOLEAN: |
|
145 |
return 'L'; |
|
146 |
} |
|
147 |
|
|
148 |
return 'C'; |
|
149 |
} |
|
150 |
public static void SHPFileFromSelected(FMap map,File f){ |
|
151 |
SHPSHXFromSelectedVisitor visitor = new SHPSHXFromSelectedVisitor(); |
|
152 |
visitor.setFile(f); |
|
153 |
//int type=getTypeShape(); |
|
154 |
//visitor.setType(5); |
|
155 |
try { |
|
156 |
map.getLayers().process(visitor); |
|
157 |
} catch (DriverException e1) { |
|
158 |
throw new RuntimeException("No se espera que SelectByPointVisitor lance esta excepci?n", |
|
159 |
e1); |
|
160 |
} catch (VisitException e) { |
|
161 |
throw new RuntimeException("No se espera que SelectByPointVisitor lance esta excepci?n", |
|
162 |
e); |
|
163 |
} |
|
164 |
|
|
165 |
DBFFromSelected dbf=new DBFFromSelected(); |
|
166 |
dbf.setFile(f); |
|
167 |
dbf.setGeometries(visitor.getGeometries()); |
|
168 |
dbf.setIsNewDBF(true); |
|
169 |
dbf.start(visitor.getSDS()); |
|
170 |
dbf.createdbfRow(); |
|
171 |
dbf.stop(); |
|
172 |
|
|
173 |
} |
|
58 | 174 |
} |
Also available in: Unified diff