root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / drivers / dgn / DGNDriver.java @ 1773
History | View | Annotate | Download (19.3 KB)
1 | 1100 | fjp | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
4 | *
|
||
5 | * This program is free software; you can redistribute it and/or
|
||
6 | * modify it under the terms of the GNU General Public License
|
||
7 | * as published by the Free Software Foundation; either version 2
|
||
8 | * of the License, or (at your option) any later version.
|
||
9 | *
|
||
10 | * This program is distributed in the hope that it will be useful,
|
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | * GNU General Public License for more details.
|
||
14 | *
|
||
15 | * You should have received a copy of the GNU General Public License
|
||
16 | * along with this program; if not, write to the Free Software
|
||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
18 | *
|
||
19 | * For more information, contact:
|
||
20 | *
|
||
21 | * Generalitat Valenciana
|
||
22 | * Conselleria d'Infraestructures i Transport
|
||
23 | * Av. Blasco Ib??ez, 50
|
||
24 | * 46010 VALENCIA
|
||
25 | * SPAIN
|
||
26 | *
|
||
27 | * +34 963862235
|
||
28 | * gvsig@gva.es
|
||
29 | * www.gvsig.gva.es
|
||
30 | *
|
||
31 | * or
|
||
32 | *
|
||
33 | * IVER T.I. S.A
|
||
34 | * Salamanca 50
|
||
35 | * 46005 Valencia
|
||
36 | * Spain
|
||
37 | *
|
||
38 | * +34 963163400
|
||
39 | * dac@iver.es
|
||
40 | */
|
||
41 | 307 | vcaballero | package com.iver.cit.gvsig.fmap.drivers.dgn; |
42 | |||
43 | 559 | fjp | import com.hardcode.gdbms.engine.data.DriverException; |
44 | import com.hardcode.gdbms.engine.data.FileDriver; |
||
45 | import com.hardcode.gdbms.engine.values.Value; |
||
46 | 1005 | vcaballero | |
47 | 378 | fjp | import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
48 | 307 | vcaballero | import com.iver.cit.gvsig.fmap.core.IGeometry; |
49 | 378 | fjp | import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
50 | 1233 | fjp | import com.iver.cit.gvsig.fmap.drivers.DriverAttributes; |
51 | 307 | vcaballero | import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver; |
52 | |||
53 | 1005 | vcaballero | import java.awt.geom.AffineTransform; |
54 | import java.awt.geom.Arc2D; |
||
55 | import java.awt.geom.Rectangle2D; |
||
56 | 307 | vcaballero | |
57 | 1005 | vcaballero | import java.io.File; |
58 | import java.io.IOException; |
||
59 | |||
60 | import java.util.ArrayList; |
||
61 | |||
62 | |||
63 | 307 | vcaballero | /**
|
64 | 1005 | vcaballero | * Driver DGN.
|
65 | 307 | vcaballero | *
|
66 | * @author Vicente Caballero Navarro
|
||
67 | */
|
||
68 | 559 | fjp | public class DGNDriver implements VectorialFileDriver, FileDriver { |
69 | 378 | fjp | DGNReader m_DgnReader; |
70 | 1005 | vcaballero | private final int ID_FIELD_ID = 0; |
71 | private final int ID_FIELD_ENTITY = 1; |
||
72 | private final int ID_FIELD_LAYER = 2; |
||
73 | private final int ID_FIELD_COLOR = 3; |
||
74 | private final int ID_FIELD_HEIGHTTEXT = 4; |
||
75 | private final int ID_FIELD_ROTATIONTEXT = 5; |
||
76 | private final int ID_FIELD_TEXT = 6; |
||
77 | 378 | fjp | private String path; |
78 | 559 | fjp | private File m_Fich; |
79 | 378 | fjp | |
80 | 695 | fjp | // Campos del registro en cache:
|
81 | 1005 | vcaballero | Object[] auxRow = new Object[7]; |
82 | Object[] cellRow = new Object[7]; |
||
83 | Object[] complexRow = new Object[7]; |
||
84 | |||
85 | 695 | fjp | /**
|
86 | 1005 | vcaballero | * Traduce las posiciones de comienzo de las entidades del DGN a nuestras
|
87 | * entidades FShape. (Una FShape puede corresponder a varias entidades de
|
||
88 | * un DGN).
|
||
89 | 695 | fjp | */
|
90 | private int[] m_posShapes; |
||
91 | |||
92 | 1005 | vcaballero | /**
|
93 | * @see com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#open(java.io.File)
|
||
94 | */
|
||
95 | public void open(File f) throws IOException { |
||
96 | m_Fich = f; |
||
97 | } |
||
98 | 307 | vcaballero | |
99 | 1005 | vcaballero | /**
|
100 | * @see com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#close()
|
||
101 | */
|
||
102 | public void close() throws IOException { |
||
103 | } |
||
104 | 307 | vcaballero | |
105 | 1005 | vcaballero | /**
|
106 | * @see com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#getShape(int)
|
||
107 | */
|
||
108 | public IGeometry getShape(int index) throws IOException { |
||
109 | boolean bElementoCompuesto = false; |
||
110 | boolean bEsPoligono = false; |
||
111 | 378 | fjp | boolean bInsideCell = false; |
112 | boolean bFirstHoleEntity = false; |
||
113 | boolean bConnect = false; // Se usa para que los pol?gonos cierren bien cuando son formas compuestas |
||
114 | 1005 | vcaballero | |
115 | 378 | fjp | // int contadorSubElementos =0, numSubElementos = 0;
|
116 | 1005 | vcaballero | int complex_index_fill_color = -1; |
117 | 378 | fjp | int nClass; // Para filtrar los elementos de construcci?n, etc. |
118 | 1005 | vcaballero | |
119 | 378 | fjp | ArrayList arrayFields = new ArrayList(); |
120 | arrayFields.add("ID");
|
||
121 | arrayFields.add("Entity");
|
||
122 | arrayFields.add("Layer");
|
||
123 | arrayFields.add("Color");
|
||
124 | 695 | fjp | arrayFields.add("HeightText");
|
125 | arrayFields.add("RotationText");
|
||
126 | arrayFields.add("Text");
|
||
127 | 1005 | vcaballero | |
128 | 378 | fjp | IGeometry aux; |
129 | GeneralPathX elementoCompuesto = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD);
|
||
130 | 1005 | vcaballero | |
131 | 378 | fjp | m_DgnReader.DGNGotoElement(index); |
132 | 1005 | vcaballero | |
133 | DGNElemCore elemento = m_DgnReader.DGNReadElement(); |
||
134 | nClass = 0;
|
||
135 | |||
136 | if (elemento.properties != 0) { |
||
137 | nClass = elemento.properties & DGNFileHeader.DGNPF_CLASS; |
||
138 | } |
||
139 | |||
140 | if ((elemento != null) && (elemento.deleted == 0) && (nClass == 0)) //Leer un elemento |
||
141 | { |
||
142 | aux = null;
|
||
143 | |||
144 | // if ((elemento.element_id > 3800) && (elemento.element_id < 3850))
|
||
145 | // m_DgnReader.DGNDumpElement(m_DgnReader.getInfo(),elemento,"");
|
||
146 | if ((elemento.stype == DGNFileHeader.DGNST_MULTIPOINT) ||
|
||
147 | (elemento.stype == DGNFileHeader.DGNST_ARC) || |
||
148 | (elemento.stype == DGNFileHeader.DGNST_CELL_HEADER) || |
||
149 | (elemento.stype == DGNFileHeader.DGNST_SHARED_CELL_DEFN) || |
||
150 | (elemento.stype == DGNFileHeader.DGNST_COMPLEX_HEADER)) { |
||
151 | if (elemento.complex != 0) { |
||
152 | bElementoCompuesto = true;
|
||
153 | } else {
|
||
154 | if (bElementoCompuesto) {
|
||
155 | if (bInsideCell) {
|
||
156 | auxRow[ID_FIELD_ENTITY] = cellRow[ID_FIELD_ENTITY]; |
||
157 | } else {
|
||
158 | auxRow = complexRow; |
||
159 | } |
||
160 | |||
161 | // System.err.println("Entidad compuesta. bInsideCell = " + bInsideCell + " auxRow = " + auxRow[ID_FIELD_ENTITY]);
|
||
162 | // TODO: CREACION DE LINEA lyrLines.addShape(new FShape(FConstant.SHAPE_TYPE_POLYLINE, elementoCompuesto), auxRow);
|
||
163 | if (bEsPoligono) {
|
||
164 | if (complex_index_fill_color != -1) { |
||
165 | 378 | fjp | auxRow[ID_FIELD_COLOR] = new Integer(complex_index_fill_color); |
166 | 1005 | vcaballero | } |
167 | 378 | fjp | |
168 | 1005 | vcaballero | // TODO: CREAR POLIGONO lyrPolygons.addShape(new FShape(FConstant.SHAPE_TYPE_POLYGON, elementoCompuesto), auxRow);
|
169 | } |
||
170 | |||
171 | elementoCompuesto = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD);
|
||
172 | } |
||
173 | |||
174 | // System.err.println("Entidad simple");
|
||
175 | bElementoCompuesto = false;
|
||
176 | bEsPoligono = false;
|
||
177 | bConnect = false;
|
||
178 | |||
179 | // elementoCompuesto = new GeneralPathX();
|
||
180 | bInsideCell = false;
|
||
181 | } |
||
182 | } |
||
183 | |||
184 | switch (elemento.stype) {
|
||
185 | 378 | fjp | case DGNFileHeader.DGNST_SHARED_CELL_DEFN:
|
186 | bInsideCell = true;
|
||
187 | cellRow[ID_FIELD_ID] = new Integer(elemento.element_id); |
||
188 | 1005 | vcaballero | cellRow[ID_FIELD_LAYER] = new Integer(elemento.level); |
189 | cellRow[ID_FIELD_COLOR] = new Integer(elemento.color); |
||
190 | cellRow[ID_FIELD_ENTITY] = new String("Shared Cell"); |
||
191 | |||
192 | 378 | fjp | break;
|
193 | 1005 | vcaballero | |
194 | 378 | fjp | case DGNFileHeader.DGNST_CELL_HEADER:
|
195 | bInsideCell = true;
|
||
196 | 1005 | vcaballero | |
197 | 378 | fjp | DGNElemCellHeader psCellHeader = (DGNElemCellHeader) elemento; |
198 | cellRow[ID_FIELD_ID] = new Integer(elemento.element_id); |
||
199 | 1005 | vcaballero | cellRow[ID_FIELD_LAYER] = new Integer(elemento.level); |
200 | cellRow[ID_FIELD_COLOR] = new Integer(elemento.color); |
||
201 | cellRow[ID_FIELD_ENTITY] = new String("Cell"); |
||
202 | complex_index_fill_color = m_DgnReader.DGNGetShapeFillInfo(elemento); |
||
203 | |||
204 | // System.err.println("Cell Header " + complex_index_fill_color);
|
||
205 | 378 | fjp | break;
|
206 | |||
207 | case DGNFileHeader.DGNST_COMPLEX_HEADER:
|
||
208 | 1005 | vcaballero | |
209 | 378 | fjp | // bElementoCompuesto = true;
|
210 | // System.err.println("Complex Header");
|
||
211 | // contadorSubElementos = 0;
|
||
212 | DGNElemComplexHeader psComplexHeader = (DGNElemComplexHeader) elemento; |
||
213 | 1005 | vcaballero | |
214 | 378 | fjp | // numSubElementos = psComplexHeader.numelems;
|
215 | complexRow[ID_FIELD_ID] = new Integer(elemento.element_id); |
||
216 | 1005 | vcaballero | complexRow[ID_FIELD_LAYER] = new Integer(elemento.level); |
217 | complexRow[ID_FIELD_COLOR] = new Integer(elemento.color); |
||
218 | complexRow[ID_FIELD_ENTITY] = new String("Complex"); |
||
219 | |||
220 | if (psComplexHeader.type == DGNFileHeader.DGNT_COMPLEX_SHAPE_HEADER) {
|
||
221 | 378 | fjp | bEsPoligono = true;
|
222 | 1005 | vcaballero | |
223 | 378 | fjp | // Si es un agujero, no conectamos con el anterior
|
224 | 1005 | vcaballero | if ((psComplexHeader.properties & 0x8000) != 0) { |
225 | 378 | fjp | bFirstHoleEntity = true;
|
226 | 1005 | vcaballero | } else {
|
227 | 378 | fjp | // Miramos si tiene color de relleno
|
228 | // complex_index_fill_color = -1;
|
||
229 | // if (elemento.attr_bytes > 0) {
|
||
230 | 1005 | vcaballero | complex_index_fill_color = m_DgnReader.DGNGetShapeFillInfo(elemento); |
231 | |||
232 | // System.err.println("complex shape fill color = " + elemento.color);
|
||
233 | 378 | fjp | // }
|
234 | } |
||
235 | 1005 | vcaballero | |
236 | 378 | fjp | bConnect = true;
|
237 | 1005 | vcaballero | } else {
|
238 | 378 | fjp | bEsPoligono = false;
|
239 | bConnect = false;
|
||
240 | } |
||
241 | 1005 | vcaballero | |
242 | 378 | fjp | break;
|
243 | 1005 | vcaballero | |
244 | 378 | fjp | case DGNFileHeader.DGNST_MULTIPOINT:
|
245 | 1005 | vcaballero | |
246 | 378 | fjp | // OJO: Si lo que viene en este multipoint es un elemento con type=11 (curve), se trata de una "parametric
|
247 | // spline curve". La vamos a tratar como si no fuera curva, pero seg?n la documentaci?n, los 2 primeros puntos
|
||
248 | // y los 2 ?ltimos puntos definen "endpoint derivatives" y NO se muestran.
|
||
249 | // TODAV?A HAY UN PEQUE?O FALLO CON EL FICHERO dgn-sample.dgn, pero lo dejo por ahora.
|
||
250 | // Es posible que tenga que ver con lo de los arcos (arco distorsionado), que
|
||
251 | // todav?a no est? metido.
|
||
252 | 1005 | vcaballero | DGNElemMultiPoint psLine = (DGNElemMultiPoint) elemento; |
253 | auxRow[ID_FIELD_LAYER] = new Integer(elemento.level); |
||
254 | auxRow[ID_FIELD_COLOR] = new Integer(elemento.color); |
||
255 | |||
256 | if ((psLine.num_vertices == 2) && |
||
257 | (psLine.vertices[0].x == psLine.vertices[1].x) && |
||
258 | (psLine.vertices[0].y == psLine.vertices[1].y)) { |
||
259 | auxRow[ID_FIELD_ENTITY] = new String("Point"); |
||
260 | |||
261 | // TODO: CREAR PUNTO lyrPoints.addShape(new FShape(new FPoint(psLine.vertices[0].x,
|
||
262 | // psLine.vertices[0].y,psLine.vertices[0].z),FConstant.SHAPE_TYPE_POINT), auxRow);
|
||
263 | return ShapeFactory.createPoint3D(psLine.vertices[0].x, |
||
264 | psLine.vertices[0].y, psLine.vertices[0].z); |
||
265 | } else {
|
||
266 | GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD);
|
||
267 | |||
268 | if (psLine.type == DGNFileHeader.DGNT_CURVE) {
|
||
269 | psLine.num_vertices = psLine.num_vertices - 4;
|
||
270 | |||
271 | for (int aux_n = 0; aux_n < psLine.num_vertices; |
||
272 | aux_n++) { |
||
273 | psLine.vertices[aux_n] = psLine.vertices[aux_n + |
||
274 | 2];
|
||
275 | } |
||
276 | } |
||
277 | |||
278 | if ((psLine.type == DGNFileHeader.DGNT_SHAPE) &&
|
||
279 | ((psLine.properties & 0x8000) != 0)) { |
||
280 | // Invertimos el orden porque es un agujero
|
||
281 | elShape.moveTo(psLine.vertices[psLine.num_vertices - |
||
282 | 1].x, psLine.vertices[psLine.num_vertices - 1].y); |
||
283 | |||
284 | for (int i = psLine.num_vertices - 2; i >= 0; |
||
285 | i--) |
||
286 | elShape.lineTo(psLine.vertices[i].x, |
||
287 | psLine.vertices[i].y); |
||
288 | } else {
|
||
289 | elShape.moveTo(psLine.vertices[0].x,
|
||
290 | psLine.vertices[0].y);
|
||
291 | |||
292 | for (int i = 1; i < psLine.num_vertices; i++) |
||
293 | elShape.lineTo(psLine.vertices[i].x, |
||
294 | psLine.vertices[i].y); |
||
295 | } |
||
296 | |||
297 | auxRow[ID_FIELD_ID] = new Integer(elemento.element_id); |
||
298 | auxRow[ID_FIELD_ENTITY] = new String("Multipoint"); |
||
299 | |||
300 | if ((psLine.vertices[0].x == psLine.vertices[psLine.num_vertices - |
||
301 | 1].x) &&
|
||
302 | (psLine.vertices[0].y == psLine.vertices[psLine.num_vertices -
|
||
303 | 1].y)) {
|
||
304 | // Lo a?adimos tambi?n como pol?gono
|
||
305 | bEsPoligono = true;
|
||
306 | |||
307 | 378 | fjp | // Miramos si tiene color de relleno
|
308 | if (elemento.attr_bytes > 0) { |
||
309 | elemento.color = m_DgnReader.DGNGetShapeFillInfo(elemento); |
||
310 | 1005 | vcaballero | |
311 | 378 | fjp | // System.err.println("fill color = " + elemento.color);
|
312 | 1005 | vcaballero | if (elemento.color != -1) { |
313 | 378 | fjp | auxRow[ID_FIELD_COLOR] = new Integer(elemento.color); |
314 | 1005 | vcaballero | } |
315 | 378 | fjp | } |
316 | |||
317 | 1005 | vcaballero | if (elemento.complex == 0) { |
318 | // TODO: A?adir POLIGONO lyrPolygons.addShape(new FShape(FConstant.SHAPE_TYPE_POLYGON, elShape), auxRow);
|
||
319 | return ShapeFactory.createPolygon2D(elShape);
|
||
320 | } |
||
321 | } |
||
322 | 378 | fjp | |
323 | 1005 | vcaballero | if (elemento.complex != 0) { |
324 | // Si es un agujero o
|
||
325 | // es la primera entidad del agujero, lo a?adimos sin unir al anterior
|
||
326 | if (bFirstHoleEntity ||
|
||
327 | ((psLine.type == DGNFileHeader.DGNT_SHAPE) && |
||
328 | ((psLine.properties & 0x8000) != 0))) { |
||
329 | elementoCompuesto.append(elShape, false);
|
||
330 | bFirstHoleEntity = false;
|
||
331 | } else {
|
||
332 | elementoCompuesto.append(elShape, bConnect); |
||
333 | } |
||
334 | } else {
|
||
335 | // TODO: A?adir LINEA lyrLines.addShape(new FShape(FConstant.SHAPE_TYPE_POLYLINE, elShape), auxRow);
|
||
336 | return ShapeFactory.createPolyline2D(elShape);
|
||
337 | } |
||
338 | } |
||
339 | 378 | fjp | |
340 | 1005 | vcaballero | break;
|
341 | |||
342 | case DGNFileHeader.DGNST_ARC:
|
||
343 | |||
344 | // m_DgnReader.DGNDumpElement(m_DgnReader.getInfo(), elemento,"");
|
||
345 | DGNElemArc psArc = (DGNElemArc) elemento; |
||
346 | |||
347 | // La definici?n de arco de MicroStation es distinta a la de Java.
|
||
348 | // En el dgn el origin se entiende que es el centro del arco,
|
||
349 | // y a la hora de crear un Arc2D las 2 primeras coordenadas son
|
||
350 | // la esquina inferior izquierda del rect?ngulo que rodea al arco.
|
||
351 | // 1.- Creamos la elipse sin rotaci?n.
|
||
352 | // 2.- Creamos el arco
|
||
353 | // 3.- Rotamos el resultado
|
||
354 | |||
355 | /* System.out.println("Arco con primari axis: " + psArc.primary_axis +
|
||
356 | " start angle: " + psArc.startang + " sweepang = " + psArc.sweepang);
|
||
357 | System.out.println("secondaria axis: " + psArc.secondary_axis +
|
||
358 | " rotation = " + psArc.rotation); */
|
||
359 | AffineTransform mT = AffineTransform.getRotateInstance(Math.toRadians( |
||
360 | psArc.rotation), psArc.origin.x, psArc.origin.y); |
||
361 | |||
362 | // mT.preConcatenate(AffineTransform.getScaleInstance(100.0,100.0));
|
||
363 | Arc2D.Double elArco = new Arc2D.Double(psArc.origin.x - |
||
364 | psArc.primary_axis, |
||
365 | psArc.origin.y - psArc.secondary_axis, |
||
366 | 2.0 * psArc.primary_axis,
|
||
367 | 2.0 * psArc.secondary_axis, -psArc.startang,
|
||
368 | -psArc.sweepang, Arc2D.OPEN);
|
||
369 | |||
370 | // Ellipse2D.Double elArco = new Ellipse2D.Double(psArc.origin.x - psArc.primary_axis,
|
||
371 | // psArc.origin.y - psArc.secondary_axis,2.0 * psArc.primary_axis, 2.0 * psArc.secondary_axis);
|
||
372 | GeneralPathX elShapeArc = new GeneralPathX(elArco);
|
||
373 | |||
374 | // Transformamos el GeneralPahtX porque si transformamos elArco nos lo convierte
|
||
375 | // a GeneralPath y nos guarda las coordenadas en float, con la correspondiente p?rdida de precisi?n
|
||
376 | elShapeArc.transform(mT); |
||
377 | |||
378 | if (m_DgnReader.getInfo().dimension == 3) { |
||
379 | //Aqu? podr?amos hacer cosas con la coordenada Z
|
||
380 | } |
||
381 | |||
382 | auxRow[ID_FIELD_ID] = new Integer(elemento.element_id); |
||
383 | auxRow[ID_FIELD_ENTITY] = new String("Arc"); |
||
384 | auxRow[ID_FIELD_LAYER] = new Integer(elemento.level); |
||
385 | auxRow[ID_FIELD_COLOR] = new Integer(elemento.color); |
||
386 | |||
387 | /* Line2D.Double ejeMayor = new Line2D.Double(psArc.origin.x - psArc.primary_axis, psArc.origin.y,
|
||
388 | psArc.origin.x + psArc.primary_axis, psArc.origin.y);
|
||
389 | |||
390 | lyrLines.addShape(new FShape(FConstant.SHAPE_TYPE_POLYLINE, new GeneralPathX(ejeMayor)), auxRow); */
|
||
391 | |||
392 | // lyrLines.addShape(new FShape(FConstant.SHAPE_TYPE_POLYLINE, elShapeArc), auxRow);
|
||
393 | if (elemento.complex != 0) { |
||
394 | // Esto es una posible fuente de fallos si detr?s de una
|
||
395 | // elipse vienen m?s cosas pegadas. Deber?amos volver
|
||
396 | // a conectar una vez pasada la elipse.
|
||
397 | if (elemento.type == DGNFileHeader.DGNT_ELLIPSE) {
|
||
398 | bConnect = false;
|
||
399 | } |
||
400 | |||
401 | // SI LA ELIPSE ES UN AGUJERO, SE A?ADE SIN PEGAR
|
||
402 | // Y EL ELEMENTO ES UN POLIGONO
|
||
403 | if (bFirstHoleEntity ||
|
||
404 | ((elemento.type == DGNFileHeader.DGNT_SHAPE) && |
||
405 | ((elemento.properties & 0x8000) != 0))) { |
||
406 | elementoCompuesto.append(elShapeArc, false);
|
||
407 | bFirstHoleEntity = false;
|
||
408 | } else {
|
||
409 | elementoCompuesto.append(elShapeArc, bConnect); |
||
410 | } |
||
411 | } else {
|
||
412 | // TODO: A?ADIR LINEA lyrLines.addShape(new FShape(FConstant.SHAPE_TYPE_POLYLINE, elShapeArc), auxRow);
|
||
413 | if (psArc.type == DGNFileHeader.DGNT_ELLIPSE) {
|
||
414 | // TODO: A?adir POLIGONO lyrPolygons.addShape(new FShape(FConstant.SHAPE_TYPE_POLYGON, elShapeArc), auxRow);
|
||
415 | } |
||
416 | } |
||
417 | |||
418 | // System.err.println("Entra un Arco");
|
||
419 | break;
|
||
420 | |||
421 | case DGNFileHeader.DGNST_TEXT:
|
||
422 | |||
423 | DGNElemText psText = (DGNElemText) elemento; |
||
424 | |||
425 | // TODO: DEVOLVER UN TEXTO??
|
||
426 | |||
427 | /* FPoint2D elShapeTxt = new FPoint2D(
|
||
428 | psText.origin.x, psText.origin.y,psText.origin.z);
|
||
429 | |||
430 | auxRow[ID_FIELD_ID] = new Integer(elemento.element_id);
|
||
431 | auxRowTxt[ID_FIELD_ENTITY] = new String("Text");
|
||
432 | auxRowTxt[ID_FIELD_LAYER] = new Integer(elemento.level);
|
||
433 | auxRowTxt[ID_FIELD_COLOR] = new Integer(elemento.color);
|
||
434 | heightText = (float) psText.height_mult;
|
||
435 | auxRowTxt[ID_FIELD_HEIGHTTEXT] = new Double(heightText);
|
||
436 | auxRowTxt[ID_FIELD_ROTATIONTEXT] = new Double(psText.rotation);
|
||
437 | auxRowTxt[ID_FIELD_TEXT] = psText.string; // .trim();
|
||
438 | lyrTexts.addShape(new FShape(elShapeTxt,FConstant.SHAPE_TYPE_POINT),
|
||
439 | auxRowTxt);
|
||
440 | */
|
||
441 | break;
|
||
442 | |||
443 | /* default:
|
||
444 | m_DgnReader.DGNDumpElement(m_DgnReader.getInfo(), elemento, "");
|
||
445 | */
|
||
446 | } // switch
|
||
447 | } // if
|
||
448 | |||
449 | // } // for
|
||
450 | if (bElementoCompuesto) {
|
||
451 | if (bInsideCell) {
|
||
452 | auxRow = cellRow; |
||
453 | } else {
|
||
454 | auxRow = complexRow; |
||
455 | } |
||
456 | |||
457 | // System.err.println("Entidad compuesta. bInsideCell = " + bInsideCell + " auxRow = " + auxRow[ID_FIELD_ENTITY]);
|
||
458 | // TODO: LINEA lyrLines.addShape(new FShape(FConstant.SHAPE_TYPE_POLYLINE, elementoCompuesto), auxRow);
|
||
459 | if (bEsPoligono) {
|
||
460 | if (complex_index_fill_color != -1) { |
||
461 | auxRow[ID_FIELD_COLOR] = new Integer(complex_index_fill_color); |
||
462 | } |
||
463 | |||
464 | // TODO: POLIGONO lyrPolygons.addShape(new FShape(FConstant.SHAPE_TYPE_POLYGON, elementoCompuesto), auxRow);
|
||
465 | } |
||
466 | 378 | fjp | } |
467 | |||
468 | 1005 | vcaballero | return null; |
469 | 378 | fjp | } |
470 | 307 | vcaballero | |
471 | 1005 | vcaballero | /**
|
472 | * @see com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#getShapeCount()
|
||
473 | */
|
||
474 | public int getShapeCount() throws IOException { |
||
475 | return m_DgnReader.getNumEntities();
|
||
476 | } |
||
477 | 307 | vcaballero | |
478 | 1005 | vcaballero | /**
|
479 | * @see com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#getFullExtent()
|
||
480 | */
|
||
481 | public Rectangle2D getFullExtent() throws IOException { |
||
482 | return m_DgnReader.getBoundingBox();
|
||
483 | } |
||
484 | 307 | vcaballero | |
485 | 1005 | vcaballero | /**
|
486 | * @see com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#initialize()
|
||
487 | */
|
||
488 | public void initialize() throws IOException { |
||
489 | m_DgnReader = new DGNReader(m_Fich.getAbsolutePath());
|
||
490 | } |
||
491 | 307 | vcaballero | |
492 | 1005 | vcaballero | /**
|
493 | * @see com.iver.cit.gvsig.fmap.drivers.VectorialDriver#getShapeType()
|
||
494 | */
|
||
495 | public int getShapeType() { |
||
496 | return 15; |
||
497 | } |
||
498 | 307 | vcaballero | |
499 | 1005 | vcaballero | /**
|
500 | 408 | fernando | * @see com.hardcode.driverManager.Driver#getType()
|
501 | */
|
||
502 | public String getName() { |
||
503 | return "gvSIG DGN Driver"; |
||
504 | } |
||
505 | |||
506 | /**
|
||
507 | * @see com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#accept(java.io.File)
|
||
508 | */
|
||
509 | public boolean accept(File f) { |
||
510 | return f.getName().toUpperCase().endsWith("DGN"); |
||
511 | } |
||
512 | |||
513 | /**
|
||
514 | * @see com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#getDataDriverName()
|
||
515 | */
|
||
516 | public String getDataDriverName() { |
||
517 | //TODO implementar bien
|
||
518 | return null; |
||
519 | } |
||
520 | |||
521 | /**
|
||
522 | * @see com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#getDataFile(java.io.File)
|
||
523 | */
|
||
524 | public File getDataFile(File f) { |
||
525 | //TODO implementar bien
|
||
526 | return null; |
||
527 | } |
||
528 | 559 | fjp | |
529 | /* (non-Javadoc)
|
||
530 | * @see com.hardcode.gdbms.engine.data.FileDriver#fileAccepted(java.io.File)
|
||
531 | */
|
||
532 | public boolean fileAccepted(File f) { |
||
533 | return f.getName().toUpperCase().endsWith("DGN"); |
||
534 | } |
||
535 | |||
536 | /* (non-Javadoc)
|
||
537 | * @see com.hardcode.gdbms.engine.data.ReadDriver#getFieldValue(long, int)
|
||
538 | */
|
||
539 | 1005 | vcaballero | public Value getFieldValue(long rowIndex, int fieldId) |
540 | throws DriverException {
|
||
541 | 559 | fjp | // TODO Auto-generated method stub
|
542 | return null; |
||
543 | } |
||
544 | |||
545 | /* (non-Javadoc)
|
||
546 | * @see com.hardcode.gdbms.engine.data.ReadDriver#getFieldCount()
|
||
547 | */
|
||
548 | public int getFieldCount() throws DriverException { |
||
549 | // TODO Auto-generated method stub
|
||
550 | return 0; |
||
551 | } |
||
552 | |||
553 | /* (non-Javadoc)
|
||
554 | * @see com.hardcode.gdbms.engine.data.ReadDriver#getFieldName(int)
|
||
555 | */
|
||
556 | public String getFieldName(int fieldId) throws DriverException { |
||
557 | // TODO Auto-generated method stub
|
||
558 | return null; |
||
559 | } |
||
560 | |||
561 | /* (non-Javadoc)
|
||
562 | * @see com.hardcode.gdbms.engine.data.ReadDriver#getRowCount()
|
||
563 | */
|
||
564 | public long getRowCount() throws DriverException { |
||
565 | try {
|
||
566 | return getShapeCount();
|
||
567 | } catch (IOException e) { |
||
568 | e.printStackTrace(); |
||
569 | } |
||
570 | 1005 | vcaballero | |
571 | 559 | fjp | return -1; |
572 | } |
||
573 | 1233 | fjp | |
574 | /* (non-Javadoc)
|
||
575 | * @see com.iver.cit.gvsig.fmap.drivers.VectorialDriver#getDriverAttributes()
|
||
576 | */
|
||
577 | public DriverAttributes getDriverAttributes() {
|
||
578 | // TODO Auto-generated method stub
|
||
579 | return null; |
||
580 | } |
||
581 | 1658 | fjp | |
582 | /* (non-Javadoc)
|
||
583 | * @see com.hardcode.gdbms.engine.data.ReadDriver#getFieldType(int)
|
||
584 | */
|
||
585 | 1773 | fernando | public int getFieldType(int arg0) throws DriverException { |
586 | throw new RuntimeException("por implementar"); |
||
587 | 1658 | fjp | } |
588 | 307 | vcaballero | } |