Statistics
| Revision:

svn-gvsig-desktop / tags / v1_0_2_Build_904 / libraries / libFMap / src / com / iver / cit / gvsig / fmap / drivers / AbstractCadMemoryDriver.java @ 10724

History | View | Annotate | Download (4.85 KB)

1
/*
2
 * Created on 26-oct-2006
3
 *
4
 * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
21
 *
22
 * For more information, contact:
23
 *
24
 *  Generalitat Valenciana
25
 *   Conselleria d'Infraestructures i Transport
26
 *   Av. Blasco Ib??ez, 50
27
 *   46010 VALENCIA
28
 *   SPAIN
29
 *
30
 *      +34 963862235
31
 *   gvsig@gva.es
32
 *      www.gvsig.gva.es
33
 *
34
 *    or
35
 *
36
 *   IVER T.I. S.A
37
 *   Salamanca 50
38
 *   46005 Valencia
39
 *   Spain
40
 *
41
 *   +34 963163400
42
 *   dac@iver.es
43
 */
44
/* CVS MESSAGES:
45
*
46
* $Id: AbstractCadMemoryDriver.java 10724 2007-03-13 09:15:05Z  $
47
* $Log$
48
* Revision 1.1.2.1  2006-11-15 04:11:12  jjdelcerro
49
* *** empty log message ***
50
*
51
* Revision 1.1  2006/10/26 17:05:30  azabala
52
* *** empty log message ***
53
*
54
*
55
*/
56
package com.iver.cit.gvsig.fmap.drivers;
57

    
58
import java.sql.Types;
59

    
60
import com.hardcode.gdbms.engine.data.driver.DriverException;
61

    
62
/**
63
 * Abstract base class for CAD drivers (dxf, dwg) memory drivers.
64
 * 
65
 * Features readed with these drivers share the same schema
66
 * (static FieldDescription[])
67
 * 
68
 * 
69
 * */
70
public abstract class AbstractCadMemoryDriver extends MemoryDriver {
71
        
72
        protected final static int ID_FIELD_ID = 0;
73

    
74
        protected final static int ID_FIELD_FSHAPE = 1;
75

    
76
        protected final static int ID_FIELD_ENTITY = 2;
77

    
78
        protected final static int ID_FIELD_LAYER = 3;
79

    
80
        protected final static int ID_FIELD_COLOR = 4;
81

    
82
        protected final static int ID_FIELD_ELEVATION = 5;
83

    
84
        protected final static int ID_FIELD_THICKNESS = 6;
85

    
86
        protected final static int ID_FIELD_TEXT = 7;
87

    
88
        protected final static int ID_FIELD_HEIGHTTEXT = 8;
89

    
90
        protected final static int ID_FIELD_ROTATIONTEXT = 9;
91

    
92
        protected final static FieldDescription[] fields = new FieldDescription[10];
93
        static{
94
                FieldDescription fieldDesc = new FieldDescription();
95
                fieldDesc.setFieldName("ID");
96
                fieldDesc.setFieldType(Types.INTEGER);
97
                fieldDesc.setFieldLength(20);
98
                fieldDesc.setFieldDecimalCount(0);
99
                fields[0] = fieldDesc;
100

    
101
                fieldDesc = new FieldDescription();
102
                fieldDesc.setFieldName("FShape");
103
                fieldDesc.setFieldType(Types.VARCHAR);
104
                fieldDesc.setFieldLength(254);
105
                fieldDesc.setFieldDecimalCount(0);
106
                fields[1] = fieldDesc;
107

    
108
                fieldDesc = new FieldDescription();
109
                fieldDesc.setFieldName("Entity");
110
                fieldDesc.setFieldType(Types.VARCHAR);
111
                fieldDesc.setFieldLength(254);
112
                fieldDesc.setFieldDecimalCount(0);
113
                fields[2] = fieldDesc;
114

    
115
                fieldDesc = new FieldDescription();
116
                fieldDesc.setFieldName("Layer");
117
                fieldDesc.setFieldType(Types.VARCHAR);
118
                fieldDesc.setFieldLength(254);
119
                fieldDesc.setFieldDecimalCount(0);
120
                fields[3] = fieldDesc;
121

    
122
                fieldDesc = new FieldDescription();
123
                fieldDesc.setFieldName("Color");
124
                fieldDesc.setFieldType(Types.DOUBLE);
125
                fieldDesc.setFieldLength(20);
126
                fieldDesc.setFieldDecimalCount(5);
127
                fields[4] = fieldDesc;
128

    
129
                fieldDesc = new FieldDescription();
130
                fieldDesc.setFieldName("Elevation");
131
                fieldDesc.setFieldType(Types.DOUBLE);
132
                fieldDesc.setFieldLength(20);
133
                fieldDesc.setFieldDecimalCount(5);
134
                fields[5] = fieldDesc;
135

    
136
                fieldDesc = new FieldDescription();
137
                fieldDesc.setFieldName("Thickness");
138
                fieldDesc.setFieldType(Types.DOUBLE);
139
                fieldDesc.setFieldLength(20);
140
                fieldDesc.setFieldDecimalCount(5);
141
                fields[6] = fieldDesc;
142

    
143
                fieldDesc = new FieldDescription();
144
                fieldDesc.setFieldName("Text");
145
                fieldDesc.setFieldType(Types.VARCHAR);
146
                fieldDesc.setFieldLength(254);
147
                fieldDesc.setFieldDecimalCount(0);
148
                fields[7] = fieldDesc;
149

    
150
                fieldDesc = new FieldDescription();
151
                fieldDesc.setFieldName("Height");
152
                fieldDesc.setFieldType(Types.DOUBLE);
153
                fieldDesc.setFieldLength(20);
154
                fieldDesc.setFieldDecimalCount(5);
155
                fields[8] = fieldDesc;
156

    
157
                fieldDesc = new FieldDescription();
158
                fieldDesc.setFieldName("Rotation");
159
                fieldDesc.setFieldType(Types.DOUBLE);
160
                fieldDesc.setFieldLength(20);
161
                fieldDesc.setFieldDecimalCount(5);
162
                fields[9] = fieldDesc;
163

    
164
        }
165
        
166
        /**
167
         * Returns de field type of the specified field index.
168
         * @return field type of i field
169
         */
170
        public int getFieldType(int i) throws DriverException {
171
          //azabala: we overwrite MemoryDriver because type resolution
172
          //is based in first register value (it could be null)
173
      if(i >= fields.length)
174
              throw new DriverException("Excedido el numero de campos del dxf");
175
      return fields[i].getFieldType();
176
        }
177
}
178