Revision 1005 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/dgn/DGNFileHeader.java

View differences:

DGNFileHeader.java
16 16

  
17 17

  
18 18
/**
19
 * DOCUMENT ME!
19
 * Clase Header del DGN.
20 20
 *
21
 * @author VCN To change the template for this generated type comment go to
22
 *         Window>Preferences>Java>Code Generation>Code and Comments
21
 * @author Vicente Caballero Navarro
23 22
 */
24 23
public class DGNFileHeader {
25 24
	/** DGNElemCore style: Element uses DGNElemCore structure */
26
	 public static final int DGNST_CORE = 1;
25
	public static final int DGNST_CORE = 1;
27 26

  
28
	 /** DGNElemCore style: Element uses DGNElemMultiPoint structure */
29
	 public static final int DGNST_MULTIPOINT = 2;
27
	/** DGNElemCore style: Element uses DGNElemMultiPoint structure */
28
	public static final int DGNST_MULTIPOINT = 2;
30 29

  
31
	 /** DGNElemCore style: Element uses DGNElemColorTable structure */
32
	 public static final int DGNST_COLORTABLE = 3;
30
	/** DGNElemCore style: Element uses DGNElemColorTable structure */
31
	public static final int DGNST_COLORTABLE = 3;
33 32

  
34
	 /** DGNElemCore style: Element uses DGNElemTCB structure */
35
	 public static final int DGNST_TCB = 4;
33
	/** DGNElemCore style: Element uses DGNElemTCB structure */
34
	public static final int DGNST_TCB = 4;
36 35

  
37
	 /** DGNElemCore style: Element uses DGNElemArc structure */
38
	 public static final int DGNST_ARC = 5;
39
	 
40
	 /** DGNElemCore style: Element uses DGNElemText structure */
41
	 public static final int DGNST_TEXT = 6;
36
	/** DGNElemCore style: Element uses DGNElemArc structure */
37
	public static final int DGNST_ARC = 5;
42 38

  
43
	 /** DGNElemCore style: Element uses DGNElemComplexHeader structure */
44
	 public static final int DGNST_COMPLEX_HEADER = 7;
39
	/** DGNElemCore style: Element uses DGNElemText structure */
40
	public static final int DGNST_TEXT = 6;
45 41

  
46
	 /** DGNElemCore style: Element uses DGNElemCellHeader structure */
47
	 public static final int DGNST_CELL_HEADER = 8;
42
	/** DGNElemCore style: Element uses DGNElemComplexHeader structure */
43
	public static final int DGNST_COMPLEX_HEADER = 7;
48 44

  
49
	 /** DGNElemCore style: Element uses DGNElemTagValue structure */
50
	 public static final int DGNST_TAG_VALUE = 9;
45
	/** DGNElemCore style: Element uses DGNElemCellHeader structure */
46
	public static final int DGNST_CELL_HEADER = 8;
51 47

  
52
	 /** DGNElemCore style: Element uses DGNElemTagSet structure */
53
	 public static final int DGNST_TAG_SET = 10;
48
	/** DGNElemCore style: Element uses DGNElemTagValue structure */
49
	public static final int DGNST_TAG_VALUE = 9;
54 50

  
55
	 /** DGNElemCore style: Element uses DGNElemCellLibrary structure */
56
	 public static final int DGNST_CELL_LIBRARY = 11;
57
	 
58
	 /** DGNElemCore style: Element uses DGNElemGroup structure */
59
	 public static final int DGNST_GROUP_DATA = 12;
60
	 
61
	 public static final int DGNST_SHARED_CELL_DEFN = 13;
51
	/** DGNElemCore style: Element uses DGNElemTagSet structure */
52
	public static final int DGNST_TAG_SET = 10;
62 53

  
63
	 /* -------------------------------------------------------------------- */
64
	 /*      Element types                                                   */
65
	 /* -------------------------------------------------------------------- */
66
	 public static final int DGNT_NULL = 0;
67
	 public static final int DGNT_CELL_LIBRARY = 1;
68
	 public static final int DGNT_CELL_HEADER = 2;
69
	 public static final int DGNT_LINE = 3;
70
	 public static final int DGNT_LINE_STRING = 4;
71
	 public static final int DGNT_GROUP_DATA = 5;
72
	 public static final int DGNT_SHAPE = 6;
73
	 public static final int DGNT_TEXT_NODE = 7;
74
	 public static final int DGNT_DIGITIZER_SETUP = 8;
75
	 public static final int DGNT_TCB = 9;
76
	 public static final int DGNT_LEVEL_SYMBOLOGY = 10;
77
	 public static final int DGNT_CURVE = 11;
78
	 public static final int DGNT_COMPLEX_CHAIN_HEADER = 12;
79
	 public static final int DGNT_COMPLEX_SHAPE_HEADER = 14;
80
	 public static final int DGNT_ELLIPSE = 15;
81
	 public static final int DGNT_ARC = 16;
82
	 public static final int DGNT_TEXT = 17;
83
	 public static final int DGNT_BSPLINE = 21;
84
	 public static final int DGNT_SHARED_CELL_DEFN = 34;
85
	 public static final int DGNT_SHARED_CELL_ELEM = 35; // REVISAR
86
	 public static final int DGNT_TAG_VALUE = 37;
87
	 public static final int DGNT_APPLICATION_ELEM = 66;
54
	/** DGNElemCore style: Element uses DGNElemCellLibrary structure */
55
	public static final int DGNST_CELL_LIBRARY = 11;
88 56

  
89
	 /* -------------------------------------------------------------------- */
90
	 /*      Line Styles                                                     */
91
	 /* -------------------------------------------------------------------- */
92
	 public static final int DGNS_SOLID = 0;
93
	 public static final int DGNS_DOTTED = 1;
94
	 public static final int DGNS_MEDIUM_DASH = 2;
95
	 public static final int DGNS_LONG_DASH = 3;
96
	 public static final int DGNS_DOT_DASH = 4;
97
	 public static final int DGNS_SHORT_DASH = 5;
98
	 public static final int DGNS_DASH_DOUBLE_DOT = 6;
99
	 public static final int DGNS_LONG_DASH_SHORT_DASH = 7;
57
	/** DGNElemCore style: Element uses DGNElemGroup structure */
58
	public static final int DGNST_GROUP_DATA = 12;
59
	public static final int DGNST_SHARED_CELL_DEFN = 13;
100 60

  
101
	 /* -------------------------------------------------------------------- */
102
	 /*      Class                                                           */
103
	 /* -------------------------------------------------------------------- */
104
	 public static final int DGNC_PRIMARY = 0;
105
	 public static final int DGNC_PATTERN_COMPONENT = 1;
106
	 public static final int DGNC_CONSTRUCTION_ELEMENT = 2;
107
	 public static final int DGNC_DIMENSION_ELEMENT = 3;
108
	 public static final int DGNC_PRIMARY_RULE_ELEMENT = 4;
109
	 public static final int DGNC_LINEAR_PATTERNED_ELEMENT = 5;
110
	 public static final int DGNC_CONSTRUCTION_RULE_ELEMENT = 6;
61
	/* -------------------------------------------------------------------- */
62
	/*      Element types                                                   */
63
	/* -------------------------------------------------------------------- */
64
	public static final int DGNT_NULL = 0;
65
	public static final int DGNT_CELL_LIBRARY = 1;
66
	public static final int DGNT_CELL_HEADER = 2;
67
	public static final int DGNT_LINE = 3;
68
	public static final int DGNT_LINE_STRING = 4;
69
	public static final int DGNT_GROUP_DATA = 5;
70
	public static final int DGNT_SHAPE = 6;
71
	public static final int DGNT_TEXT_NODE = 7;
72
	public static final int DGNT_DIGITIZER_SETUP = 8;
73
	public static final int DGNT_TCB = 9;
74
	public static final int DGNT_LEVEL_SYMBOLOGY = 10;
75
	public static final int DGNT_CURVE = 11;
76
	public static final int DGNT_COMPLEX_CHAIN_HEADER = 12;
77
	public static final int DGNT_COMPLEX_SHAPE_HEADER = 14;
78
	public static final int DGNT_ELLIPSE = 15;
79
	public static final int DGNT_ARC = 16;
80
	public static final int DGNT_TEXT = 17;
81
	public static final int DGNT_BSPLINE = 21;
82
	public static final int DGNT_SHARED_CELL_DEFN = 34;
83
	public static final int DGNT_SHARED_CELL_ELEM = 35; // REVISAR
84
	public static final int DGNT_TAG_VALUE = 37;
85
	public static final int DGNT_APPLICATION_ELEM = 66;
111 86

  
112
	 /* -------------------------------------------------------------------- */
113
	 /*      Group Data level numbers.                                       */
114
	 /*                                                                      */
115
	 /*      These are symbolic values for the typ 5 (DGNT_GROUP_DATA)       */
116
	 /*      level values that have special meanings.                        */
117
	 /* -------------------------------------------------------------------- */
118
	 public static final int DGN_GDL_COLOR_TABLE = 1;
119
	 public static final int DGN_GDL_NAMED_VIEW = 3;
120
	 public static final int DGN_GDL_REF_FILE = 9;
87
	/* -------------------------------------------------------------------- */
88
	/*      Line Styles                                                     */
89
	/* -------------------------------------------------------------------- */
90
	public static final int DGNS_SOLID = 0;
91
	public static final int DGNS_DOTTED = 1;
92
	public static final int DGNS_MEDIUM_DASH = 2;
93
	public static final int DGNS_LONG_DASH = 3;
94
	public static final int DGNS_DOT_DASH = 4;
95
	public static final int DGNS_SHORT_DASH = 5;
96
	public static final int DGNS_DASH_DOUBLE_DOT = 6;
97
	public static final int DGNS_LONG_DASH_SHORT_DASH = 7;
121 98

  
122
	 /* -------------------------------------------------------------------- */
123
	 /*      Word 17 property flags.                                         */
124
	 /* -------------------------------------------------------------------- */
125
	 public static final int DGNPF_HOLE = 0x8000;
126
	 public static final int DGNPF_SNAPPABLE = 0x4000;
127
	 public static final int DGNPF_PLANAR = 0x2000;
128
	 public static final int DGNPF_ORIENTATION = 0x1000;
129
	 public static final int DGNPF_ATTRIBUTES = 0x0800;
130
	 public static final int DGNPF_MODIFIED = 0x0400;
131
	 public static final int DGNPF_NEW = 0x0200;
132
	 public static final int DGNPF_LOCKED = 0x0100;
133
	 public static final int DGNPF_CLASS = 0x000f;
99
	/* -------------------------------------------------------------------- */
100
	/*      Class                                                           */
101
	/* -------------------------------------------------------------------- */
102
	public static final int DGNC_PRIMARY = 0;
103
	public static final int DGNC_PATTERN_COMPONENT = 1;
104
	public static final int DGNC_CONSTRUCTION_ELEMENT = 2;
105
	public static final int DGNC_DIMENSION_ELEMENT = 3;
106
	public static final int DGNC_PRIMARY_RULE_ELEMENT = 4;
107
	public static final int DGNC_LINEAR_PATTERNED_ELEMENT = 5;
108
	public static final int DGNC_CONSTRUCTION_RULE_ELEMENT = 6;
134 109

  
135
	 /* -------------------------------------------------------------------- */
136
	 /*      DGNElementInfo flag values.                                     */
137
	 /* -------------------------------------------------------------------- */
138
	 public static final int DGNEIF_DELETED = 0x01;
139
	 public static final int DGNEIF_COMPLEX = 0x02;
110
	/* -------------------------------------------------------------------- */
111
	/*      Group Data level numbers.                                       */
112
	/*                                                                      */
113
	/*      These are symbolic values for the typ 5 (DGNT_GROUP_DATA)       */
114
	/*      level values that have special meanings.                        */
115
	/* -------------------------------------------------------------------- */
116
	public static final int DGN_GDL_COLOR_TABLE = 1;
117
	public static final int DGN_GDL_NAMED_VIEW = 3;
118
	public static final int DGN_GDL_REF_FILE = 9;
140 119

  
141
	 /* -------------------------------------------------------------------- */
142
	 /*      Justifications                                                  */
143
	 /* -------------------------------------------------------------------- */
144
	 public static final int DGNJ_LEFT_TOP = 0;
145
	 public static final int DGNJ_LEFT_CENTER = 1;
146
	 public static final int DGNJ_LEFT_BOTTOM = 2;
147
	 public static final int DGNJ_LEFTMARGIN_TOP = 3;
120
	/* -------------------------------------------------------------------- */
121
	/*      Word 17 property flags.                                         */
122
	/* -------------------------------------------------------------------- */
123
	public static final int DGNPF_HOLE = 0x8000;
124
	public static final int DGNPF_SNAPPABLE = 0x4000;
125
	public static final int DGNPF_PLANAR = 0x2000;
126
	public static final int DGNPF_ORIENTATION = 0x1000;
127
	public static final int DGNPF_ATTRIBUTES = 0x0800;
128
	public static final int DGNPF_MODIFIED = 0x0400;
129
	public static final int DGNPF_NEW = 0x0200;
130
	public static final int DGNPF_LOCKED = 0x0100;
131
	public static final int DGNPF_CLASS = 0x000f;
148 132

  
149
	 /* text node header only */
150
	 public static final int DGNJ_LEFTMARGIN_CENTER = 4;
133
	/* -------------------------------------------------------------------- */
134
	/*      DGNElementInfo flag values.                                     */
135
	/* -------------------------------------------------------------------- */
136
	public static final int DGNEIF_DELETED = 0x01;
137
	public static final int DGNEIF_COMPLEX = 0x02;
151 138

  
152
	 /* text node header only */
153
	 public static final int DGNJ_LEFTMARGIN_BOTTOM = 5;
139
	/* -------------------------------------------------------------------- */
140
	/*      Justifications                                                  */
141
	/* -------------------------------------------------------------------- */
142
	public static final int DGNJ_LEFT_TOP = 0;
143
	public static final int DGNJ_LEFT_CENTER = 1;
144
	public static final int DGNJ_LEFT_BOTTOM = 2;
145
	public static final int DGNJ_LEFTMARGIN_TOP = 3;
154 146

  
155
	 /* text node header only */
156
	 public static final int DGNJ_CENTER_TOP = 6;
157
	 public static final int DGNJ_CENTER_CENTER = 6;
158
	 public static final int DGNJ_CENTER_BOTTOM = 8;
159
	 public static final int DGNJ_RIGHTMARGIN_TOP = 9;
147
	/* text node header only */
148
	public static final int DGNJ_LEFTMARGIN_CENTER = 4;
160 149

  
161
	 /* text node header only */
162
	 public static final int DGNJ_RIGHTMARGIN_CENTER = 10;
150
	/* text node header only */
151
	public static final int DGNJ_LEFTMARGIN_BOTTOM = 5;
163 152

  
164
	 /* text node header only */
165
	 public static final int DGNJ_RIGHTMARGIN_BOTTOM = 11;
153
	/* text node header only */
154
	public static final int DGNJ_CENTER_TOP = 6;
155
	public static final int DGNJ_CENTER_CENTER = 6;
156
	public static final int DGNJ_CENTER_BOTTOM = 8;
157
	public static final int DGNJ_RIGHTMARGIN_TOP = 9;
166 158

  
167
	 /* text node header only */
168
	 public static final int DGNJ_RIGHT_TOP = 12;
169
	 public static final int DGNJ_RIGHT_CENTER = 13;
170
	 public static final int DGNJ_RIGHT_BOTTOM = 14;
159
	/* text node header only */
160
	public static final int DGNJ_RIGHTMARGIN_CENTER = 10;
171 161

  
172
	 /* -------------------------------------------------------------------- */
173
	 /*      DGN file reading options.                                       */
174
	 /* -------------------------------------------------------------------- */
175
	 public static final int DGNO_CAPTURE_RAW_DATA = 0x01;
162
	/* text node header only */
163
	public static final int DGNJ_RIGHTMARGIN_BOTTOM = 11;
176 164

  
177
	 /* -------------------------------------------------------------------- */
178
	 /*      Known attribute linkage types, including my synthetic ones.     */
179
	 /* -------------------------------------------------------------------- */
180
	 public static final int DGNLT_DMRS = 0x0000;
181
	 public static final int DGNLT_INFORMIX = 0x3848;
182
	 public static final int DGNLT_ODBC = 0x5e62;
183
	 public static final int DGNLT_ORACLE = 0x6091;
184
	 public static final int DGNLT_RIS = 0x71FB;
185
	 public static final int DGNLT_SYBASE = 0x4f58;
186
	 public static final int DGNLT_XBASE = 0x1971;
187
	 public static final int DGNLT_SHAPE_FILL = 0x0041;
188
	 public static final int DGNLT_ASSOC_ID = 0x7D2F;
165
	/* text node header only */
166
	public static final int DGNJ_RIGHT_TOP = 12;
167
	public static final int DGNJ_RIGHT_CENTER = 13;
168
	public static final int DGNJ_RIGHT_BOTTOM = 14;
189 169

  
190
	 /* -------------------------------------------------------------------- */
191
	 /*      File creation options.                                          */
192
	 /* -------------------------------------------------------------------- */
193
	 public static final int DGNCF_USE_SEED_UNITS = 0x01;
194
	 public static final int DGNCF_USE_SEED_ORIGIN = 0x02;
195
	 public static final int DGNCF_COPY_SEED_FILE_COLOR_TABLE = 0x04;
196
	 public static final int DGNCF_COPY_WHOLE_SEED_FILE = 0x08;
197
	 public static final int SIZE_LONG = 4;
170
	/* -------------------------------------------------------------------- */
171
	/*      DGN file reading options.                                       */
172
	/* -------------------------------------------------------------------- */
173
	public static final int DGNO_CAPTURE_RAW_DATA = 0x01;
198 174

  
199
    /*
175
	/* -------------------------------------------------------------------- */
176
	/*      Known attribute linkage types, including my synthetic ones.     */
177
	/* -------------------------------------------------------------------- */
178
	public static final int DGNLT_DMRS = 0x0000;
179
	public static final int DGNLT_INFORMIX = 0x3848;
180
	public static final int DGNLT_ODBC = 0x5e62;
181
	public static final int DGNLT_ORACLE = 0x6091;
182
	public static final int DGNLT_RIS = 0x71FB;
183
	public static final int DGNLT_SYBASE = 0x4f58;
184
	public static final int DGNLT_XBASE = 0x1971;
185
	public static final int DGNLT_SHAPE_FILL = 0x0041;
186
	public static final int DGNLT_ASSOC_ID = 0x7D2F;
200 187

  
201
            int         offset;
202
            int         size;
188
	/* -------------------------------------------------------------------- */
189
	/*      File creation options.                                          */
190
	/* -------------------------------------------------------------------- */
191
	public static final int DGNCF_USE_SEED_UNITS = 0x01;
192
	public static final int DGNCF_USE_SEED_ORIGIN = 0x02;
193
	public static final int DGNCF_COPY_SEED_FILE_COLOR_TABLE = 0x04;
194
	public static final int DGNCF_COPY_WHOLE_SEED_FILE = 0x08;
195
	public static final int SIZE_LONG = 4;
203 196

  
204
            int         element_id;
205
            int         stype;
206
            int                level;
207
            int                type;
208
            int                complex;
209
            int                deleted;
197
	/*
198
	   int         offset;
199
	   int         size;
200
	   int         element_id;
201
	   int         stype;
202
	   int                level;
203
	   int                type;
204
	   int                complex;
205
	   int                deleted;
206
	   int                graphic_group;
207
	   int                properties;
208
	   int         color;
209
	   int         weight;
210
	   int         style;
211
	   int                attr_bytes;
212
	   byte attr_data;
213
	   int         raw_bytes;
214
	   byte raw_data;
215
	   //} DGNElemCore;
216
	 */
210 217

  
211
            int                graphic_group;
212
            int                properties;
213
            int         color;
214
            int         weight;
215
            int         style;
218
	/** File Length; */
219
	int myFileLength = 0;
216 220

  
217
            int                attr_bytes;
218
            byte attr_data;
221
	/** Version of the file. */
222
	int myVersion = 1000;
219 223

  
220
            int         raw_bytes;
221
            byte raw_data;
222
    //} DGNElemCore;
223
    */
224
	/*
225
	   public static final int SHAPE_NULL = 0;
226
	    public static final int SHAPE_POINT = 1;
227
	    public static final int SHAPE_POLYLINE = 3;
228
	    public static final int SHAPE_POLYGON = 5;
229
	    public static final int SHAPE_MULTIPOINT = 8;
230
	    public static final int SHAPE_POINTZ = 11;
231
	    public static final int SHAPE_POLYLINEZ = 13;
232
	    public static final int SHAPE_POLYGONZ = 15;
233
	    public static final int SHAPE_MULTIPOINTZ = 18;
234
	    public static final int SHAPE_POINTM = 21;
235
	    public static final int SHAPE_POLYLINEM = 23;
236
	    public static final int SHAPE_POLYGONM = 25;
237
	    public static final int SHAPE_MULTIPOINTM = 28;
238
	    public static final int SHAPE_MULTIPATCH = 31;
239
	 */
240
	int myDGNType = 0;
241
	double myXmin = 0;
242
	double myYmin = 0;
243
	double myXmax = 0;
244
	double myYmax = 0;
245
	double myZmin = 0;
246
	double myZmax = 0;
247
	double myMmin = 0;
248
	double myMmax = 0;
224 249

  
225
    /** File Length; */
226
    int myFileLength = 0;
250
	// notify about warnings.
251
	private boolean myWarning = true;
227 252

  
228
    /** Version of the file. */
229
    int myVersion = 1000;
253
	/**
254
	 * ShapeFileHeader constructor comment.
255
	 */
256
	public DGNFileHeader() {
257
		super();
258
	}
230 259

  
231
    /*
232
             public static final int SHAPE_NULL = 0;
233
              public static final int SHAPE_POINT = 1;
234
              public static final int SHAPE_POLYLINE = 3;
235
              public static final int SHAPE_POLYGON = 5;
236
              public static final int SHAPE_MULTIPOINT = 8;
237
              public static final int SHAPE_POINTZ = 11;
238
              public static final int SHAPE_POLYLINEZ = 13;
239
              public static final int SHAPE_POLYGONZ = 15;
240
              public static final int SHAPE_MULTIPOINTZ = 18;
241
              public static final int SHAPE_POINTM = 21;
242
              public static final int SHAPE_POLYLINEM = 23;
243
              public static final int SHAPE_POLYGONM = 25;
244
              public static final int SHAPE_MULTIPOINTM = 28;
245
              public static final int SHAPE_MULTIPATCH = 31;
246
        */
247
    int myDGNType = 0;
248
    double myXmin = 0;
249
    double myYmin = 0;
250
    double myXmax = 0;
251
    double myYmax = 0;
252
    double myZmin = 0;
253
    double myZmax = 0;
254
    double myMmin = 0;
255
    double myMmax = 0;
260
	/**
261
	 * Return the version of the file.
262
	 *
263
	 * @return DOCUMENT ME!
264
	 */
265
	public int getVersion() {
266
		return myVersion;
267
	}
256 268

  
257
    // notify about warnings.
258
    private boolean myWarning = true;
269
	/**
270
	 * Devuelve el rect?ngulo del fichero.
271
	 *
272
	 * @return DOCUMENT ME!
273
	 */
274
	public java.awt.geom.Rectangle2D.Double getFileExtents() {
275
		return new java.awt.geom.Rectangle2D.Double(myXmin, myYmin,
276
			myXmax - myXmin, myYmax - myYmin);
277
	}
259 278

  
260
    /**
261
     * ShapeFileHeader constructor comment.
262
     */
263
    public DGNFileHeader() {
264
        super();
265
    }
279
	/**
280
	 * Print warnings to system.out.
281
	 *
282
	 * @param inWarning DOCUMENT ME!
283
	 */
284
	public void setWarnings(boolean inWarning) {
285
		myWarning = inWarning;
286
	}
266 287

  
267
    /**
268
     * Return the version of the file.
269
     *
270
     * @return DOCUMENT ME!
271
     */
272
    public int getVersion() {
273
        return myVersion;
274
    }
288
	/**
289
	 * Return the length of the header in 16 bit words..
290
	 *
291
	 * @return DOCUMENT ME!
292
	 */
293
	public int getHeaderLength() {
294
		return 50;
295
	}
275 296

  
276
    /**
277
     * DOCUMENT ME!
278
     *
279
     * @return DOCUMENT ME!
280
     */
281
    public java.awt.geom.Rectangle2D.Double getFileExtents() {
282
        return new java.awt.geom.Rectangle2D.Double(myXmin, myYmin,
283
            myXmax - myXmin, myYmax - myYmin);
284
    }
297
	/**
298
	 * Return the number of 16 bit words in the shape file as recorded in the
299
	 * header
300
	 *
301
	 * @return DOCUMENT ME!
302
	 */
303
	public int getFileLength() {
304
		return myFileLength;
305
	}
285 306

  
286
    /**
287
     * Print warnings to system.out.
288
     *
289
     * @param inWarning DOCUMENT ME!
290
     */
291
    public void setWarnings(boolean inWarning) {
292
        myWarning = inWarning;
293
    }
307
	/**
308
	 * Read the header from the shape file.
309
	 *
310
	 * @param in DOCUMENT ME!
311
	 */
312
	public void readHeader(MappedByteBuffer in) {
313
		//in.order(ByteOrder.BIG_ENDIAN);
294 314

  
295
    /**
296
     * Return the length of the header in 16 bit words..
297
     *
298
     * @return DOCUMENT ME!
299
     */
300
    public int getHeaderLength() {
301
        return 50;
302
    }
315
		/*
316
		   offset=in.getInt();
317
		   System.out.println("offset     "+offset);
318
		   size=in.getInt();
319
		   System.out.println("size        "+size);
320
		                   element_id=in.getInt();
321
		   System.out.println("element_id          "+element_id);
322
		                   stype=in.getInt();
323
		   System.out.println("stype        "+stype);
324
		                   level=in.getInt();
325
		   System.out.println("level          "+level);
326
		                   type=in.getInt();
327
		   System.out.println("type          "+type);
328
		                   complex=in.getInt();
329
		   System.out.println("complex          "+complex);
330
		                   deleted=in.getInt();
331
		   System.out.println("deleted          "+deleted);
332
		                   graphic_group=in.getInt();
333
		   System.out.println("graphic_group          "+graphic_group);
334
		                   properties=in.getInt();
335
		   System.out.println("properties          "+properties);
336
		                   color=in.getInt();
337
		   System.out.println("color          "+color);
338
		                   weight=in.getInt();
339
		   System.out.println("weight          "+weight);
340
		                   style=in.getInt();
341
		   System.out.println("style          "+style);
342
		                   attr_bytes=in.getInt();
343
		   System.out.println("attr_bytes          "+attr_bytes);
344
		                   //attr_data=in.get(attr_bytes);
345
		   //System.out.println("attr_data          "+attr_data);
346
		                   raw_bytes=in.getInt();
347
		   System.out.println("raw_bytes          "+raw_bytes);
348
		                   //raw_data=in.get(raw_bytes);
349
		   //System.out.println("raw_data          "+raw_data);
350
		 */
303 351

  
304
    /**
305
     * Return the number of 16 bit words in the shape file as recorded in the
306
     * header
307
     *
308
     * @return DOCUMENT ME!
309
     */
310
    public int getFileLength() {
311
        return myFileLength;
312
    }
352
		// the first four bytes are integers
353
		// in.setLittleEndianMode(false);
313 354

  
314
    /**
315
     * Read the header from the shape file.
316
     *
317
     * @param in DOCUMENT ME!
318
     */
319
    public void readHeader(MappedByteBuffer in) {
320
        //in.order(ByteOrder.BIG_ENDIAN);
355
		/*  in.order(ByteOrder.BIG_ENDIAN);
356
		   myFileCode = in.getInt();
357
		   if (myFileCode != 9994) warn("File Code = "+myFileCode+" Not equal to 9994");
358
		   // From 4 to 8 are unused.
359
		   myUnused1 = in.getInt();
360
		   // From 8 to 12 are unused.
361
		   myUnused2 = in.getInt();
362
		   // From 12 to 16 are unused.
363
		   myUnused3 = in.getInt();
364
		   // From 16 to 20 are unused.
365
		   myUnused4 = in.getInt();
366
		   // From 20 to 24 are unused.
367
		   myUnused5 = in.getInt();
368
		   // From 24 to 28 are the file length.
369
		   myFileLength = in.getInt();
370
		   // From 28 to 32 are the File Version.
371
		   in.order(ByteOrder.LITTLE_ENDIAN);
372
		   myVersion = in.getInt();
373
		   // From 32 to 36 are the Shape Type.
374
		   myShapeType = in.getInt();
375
		   // From 36 to 44 are Xmin.
376
		   myXmin = in.getDouble(); // Double.longBitsToDouble(in.getLong());
377
		   // From 44 to 52 are Ymin.
378
		   myYmin = in.getDouble();
379
		   // From 52 to 60 are Xmax.
380
		   myXmax = in.getDouble();
381
		   // From 60 to 68 are Ymax.
382
		   myYmax = in.getDouble();
383
		   // From 68 to 76 are Zmin.
384
		   myZmin = in.getDouble();
385
		   // From 76 to 84 are Zmax.
386
		   myZmax = in.getDouble();
387
		   // From 84 to 92 are Mmin.
388
		   myMmin = in.getDouble();
389
		   // From 92 to 100 are Mmax.
390
		   myMmax = in.getDouble();
391
		   // that is all 100 bytes of the header.
392
		 */
393
	}
321 394

  
322
        /*
323
                        offset=in.getInt();
324
                        System.out.println("offset     "+offset);
325
                        size=in.getInt();
326
        System.out.println("size        "+size);
327
                        element_id=in.getInt();
328
        System.out.println("element_id          "+element_id);
329
                        stype=in.getInt();
330
        System.out.println("stype        "+stype);
331
                        level=in.getInt();
332
        System.out.println("level          "+level);
333
                        type=in.getInt();
334
        System.out.println("type          "+type);
335
                        complex=in.getInt();
336
        System.out.println("complex          "+complex);
337
                        deleted=in.getInt();
338
        System.out.println("deleted          "+deleted);
339
                        graphic_group=in.getInt();
340
        System.out.println("graphic_group          "+graphic_group);
341
                        properties=in.getInt();
342
        System.out.println("properties          "+properties);
343
                        color=in.getInt();
344
        System.out.println("color          "+color);
345
                        weight=in.getInt();
346
        System.out.println("weight          "+weight);
347
                        style=in.getInt();
348
        System.out.println("style          "+style);
349
                        attr_bytes=in.getInt();
350
        System.out.println("attr_bytes          "+attr_bytes);
351
                        //attr_data=in.get(attr_bytes);
352
        //System.out.println("attr_data          "+attr_data);
353
                        raw_bytes=in.getInt();
354
        System.out.println("raw_bytes          "+raw_bytes);
355
                        //raw_data=in.get(raw_bytes);
356
        //System.out.println("raw_data          "+raw_data);
357

  
358
        */
359

  
360
        // the first four bytes are integers
361
        // in.setLittleEndianMode(false);
362

  
363
        /*  in.order(ByteOrder.BIG_ENDIAN);
364
          myFileCode = in.getInt();
365
          if (myFileCode != 9994) warn("File Code = "+myFileCode+" Not equal to 9994");
366

  
367
          // From 4 to 8 are unused.
368

  
369
          myUnused1 = in.getInt();
370

  
371
          // From 8 to 12 are unused.
372
          myUnused2 = in.getInt();
373

  
374
          // From 12 to 16 are unused.
375
          myUnused3 = in.getInt();
376

  
377
          // From 16 to 20 are unused.
378
          myUnused4 = in.getInt();
379

  
380
          // From 20 to 24 are unused.
381
          myUnused5 = in.getInt();
382

  
383
          // From 24 to 28 are the file length.
384
          myFileLength = in.getInt();
385

  
386
          // From 28 to 32 are the File Version.
387
          in.order(ByteOrder.LITTLE_ENDIAN);
388
          myVersion = in.getInt();
389

  
390
          // From 32 to 36 are the Shape Type.
391
          myShapeType = in.getInt();
392

  
393
          // From 36 to 44 are Xmin.
394
          myXmin = in.getDouble(); // Double.longBitsToDouble(in.getLong());
395

  
396
          // From 44 to 52 are Ymin.
397
          myYmin = in.getDouble();
398

  
399
          // From 52 to 60 are Xmax.
400
          myXmax = in.getDouble();
401

  
402
          // From 60 to 68 are Ymax.
403
          myYmax = in.getDouble();
404

  
405
          // From 68 to 76 are Zmin.
406
          myZmin = in.getDouble();
407

  
408
          // From 76 to 84 are Zmax.
409
          myZmax = in.getDouble();
410

  
411
          // From 84 to 92 are Mmin.
412
          myMmin = in.getDouble();
413

  
414
          // From 92 to 100 are Mmax.
415
          myMmax = in.getDouble();
416

  
417
          // that is all 100 bytes of the header.
418
        */
419
    }
420

  
421
    /**
422
     * DOCUMENT ME!
423
     *
424
     * @param inWarn DOCUMENT ME!
425
     */
426
    private void warn(String inWarn) {
427
        if (myWarning) {
428
            System.out.print("WARNING: ");
429
            System.out.println(inWarn);
430
        }
431
    }
395
	/**
396
	 * Muestra por consola el warning.
397
	 *
398
	 * @param inWarn DOCUMENT ME!
399
	 */
400
	private void warn(String inWarn) {
401
		if (myWarning) {
402
			System.out.print("WARNING: ");
403
			System.out.println(inWarn);
404
		}
405
	}
432 406
}

Also available in: Unified diff