svn-gvsig-desktop / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / drivers / dgn / DGNDriver.java @ 1233
History | View | Annotate | Download (19 KB)
1 |
/* 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 |
package com.iver.cit.gvsig.fmap.drivers.dgn; |
42 |
|
43 |
import com.hardcode.gdbms.engine.data.DriverException; |
44 |
import com.hardcode.gdbms.engine.data.FileDriver; |
45 |
import com.hardcode.gdbms.engine.values.Value; |
46 |
|
47 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
48 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
49 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
50 |
import com.iver.cit.gvsig.fmap.drivers.DriverAttributes; |
51 |
import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver; |
52 |
|
53 |
import java.awt.geom.AffineTransform; |
54 |
import java.awt.geom.Arc2D; |
55 |
import java.awt.geom.Rectangle2D; |
56 |
|
57 |
import java.io.File; |
58 |
import java.io.IOException; |
59 |
|
60 |
import java.util.ArrayList; |
61 |
|
62 |
|
63 |
/**
|
64 |
* Driver DGN.
|
65 |
*
|
66 |
* @author Vicente Caballero Navarro
|
67 |
*/
|
68 |
public class DGNDriver implements VectorialFileDriver, FileDriver { |
69 |
DGNReader m_DgnReader; |
70 |
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 |
private String path; |
78 |
private File m_Fich; |
79 |
|
80 |
// Campos del registro en cache:
|
81 |
Object[] auxRow = new Object[7]; |
82 |
Object[] cellRow = new Object[7]; |
83 |
Object[] complexRow = new Object[7]; |
84 |
|
85 |
/**
|
86 |
* 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 |
*/
|
90 |
private int[] m_posShapes; |
91 |
|
92 |
/**
|
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 |
|
99 |
/**
|
100 |
* @see com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#close()
|
101 |
*/
|
102 |
public void close() throws IOException { |
103 |
} |
104 |
|
105 |
/**
|
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 |
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 |
|
115 |
// int contadorSubElementos =0, numSubElementos = 0;
|
116 |
int complex_index_fill_color = -1; |
117 |
int nClass; // Para filtrar los elementos de construcci?n, etc. |
118 |
|
119 |
ArrayList arrayFields = new ArrayList(); |
120 |
arrayFields.add("ID");
|
121 |
arrayFields.add("Entity");
|
122 |
arrayFields.add("Layer");
|
123 |
arrayFields.add("Color");
|
124 |
arrayFields.add("HeightText");
|
125 |
arrayFields.add("RotationText");
|
126 |
arrayFields.add("Text");
|
127 |
|
128 |
IGeometry aux; |
129 |
GeneralPathX elementoCompuesto = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD);
|
130 |
|
131 |
m_DgnReader.DGNGotoElement(index); |
132 |
|
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 |
auxRow[ID_FIELD_COLOR] = new Integer(complex_index_fill_color); |
166 |
} |
167 |
|
168 |
// 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 |
case DGNFileHeader.DGNST_SHARED_CELL_DEFN:
|
186 |
bInsideCell = true;
|
187 |
cellRow[ID_FIELD_ID] = new Integer(elemento.element_id); |
188 |
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 |
break;
|
193 |
|
194 |
case DGNFileHeader.DGNST_CELL_HEADER:
|
195 |
bInsideCell = true;
|
196 |
|
197 |
DGNElemCellHeader psCellHeader = (DGNElemCellHeader) elemento; |
198 |
cellRow[ID_FIELD_ID] = new Integer(elemento.element_id); |
199 |
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 |
break;
|
206 |
|
207 |
case DGNFileHeader.DGNST_COMPLEX_HEADER:
|
208 |
|
209 |
// bElementoCompuesto = true;
|
210 |
// System.err.println("Complex Header");
|
211 |
// contadorSubElementos = 0;
|
212 |
DGNElemComplexHeader psComplexHeader = (DGNElemComplexHeader) elemento; |
213 |
|
214 |
// numSubElementos = psComplexHeader.numelems;
|
215 |
complexRow[ID_FIELD_ID] = new Integer(elemento.element_id); |
216 |
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 |
bEsPoligono = true;
|
222 |
|
223 |
// Si es un agujero, no conectamos con el anterior
|
224 |
if ((psComplexHeader.properties & 0x8000) != 0) { |
225 |
bFirstHoleEntity = true;
|
226 |
} else {
|
227 |
// Miramos si tiene color de relleno
|
228 |
// complex_index_fill_color = -1;
|
229 |
// if (elemento.attr_bytes > 0) {
|
230 |
complex_index_fill_color = m_DgnReader.DGNGetShapeFillInfo(elemento); |
231 |
|
232 |
// System.err.println("complex shape fill color = " + elemento.color);
|
233 |
// }
|
234 |
} |
235 |
|
236 |
bConnect = true;
|
237 |
} else {
|
238 |
bEsPoligono = false;
|
239 |
bConnect = false;
|
240 |
} |
241 |
|
242 |
break;
|
243 |
|
244 |
case DGNFileHeader.DGNST_MULTIPOINT:
|
245 |
|
246 |
// 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 |
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 |
// Miramos si tiene color de relleno
|
308 |
if (elemento.attr_bytes > 0) { |
309 |
elemento.color = m_DgnReader.DGNGetShapeFillInfo(elemento); |
310 |
|
311 |
// System.err.println("fill color = " + elemento.color);
|
312 |
if (elemento.color != -1) { |
313 |
auxRow[ID_FIELD_COLOR] = new Integer(elemento.color); |
314 |
} |
315 |
} |
316 |
|
317 |
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 |
|
323 |
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 |
|
340 |
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 |
} |
467 |
|
468 |
return null; |
469 |
} |
470 |
|
471 |
/**
|
472 |
* @see com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#getShapeCount()
|
473 |
*/
|
474 |
public int getShapeCount() throws IOException { |
475 |
return m_DgnReader.getNumEntities();
|
476 |
} |
477 |
|
478 |
/**
|
479 |
* @see com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#getFullExtent()
|
480 |
*/
|
481 |
public Rectangle2D getFullExtent() throws IOException { |
482 |
return m_DgnReader.getBoundingBox();
|
483 |
} |
484 |
|
485 |
/**
|
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 |
|
492 |
/**
|
493 |
* @see com.iver.cit.gvsig.fmap.drivers.VectorialDriver#getShapeType()
|
494 |
*/
|
495 |
public int getShapeType() { |
496 |
return 15; |
497 |
} |
498 |
|
499 |
/**
|
500 |
* @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 |
|
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 |
public Value getFieldValue(long rowIndex, int fieldId) |
540 |
throws DriverException {
|
541 |
// 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 |
|
571 |
return -1; |
572 |
} |
573 |
|
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 |
} |