Updated to worldwind release 20070817
[worldwind-tracker.git] / gov / nasa / worldwind / formats / rpf / RpfLocationSection.java
blob89837ec099a12267bdc033a02ffba65aef18c3d9
1 package gov.nasa.worldwind.formats.rpf;
3 import gov.nasa.worldwind.formats.nitfs.*;
4 /*
5 Copyright (C) 2001, 2007 United States Government
6 as represented by the Administrator of the
7 National Aeronautics and Space Administration.
8 All Rights Reserved.
9 */
11 /**
12 * @author Lado Garakanidze
13 * @version $Id: RpfLocationSection Apr 4, 2007 5:57:23 PM lado
15 public class RpfLocationSection
17 private java.util.Hashtable<Integer, ComponentLocationRecord> table =
18 new java.util.Hashtable<Integer, ComponentLocationRecord>();
20 public int getHeaderComponentLocation()
22 return this.getLocation(128);
24 public int getHeaderComponentLength()
26 return this.getLength(128);
28 public int getLocationComponentLocation()
30 return this.getLocation(129);
32 public int getLocationComponentLength()
34 return this.getLength(129);
36 public int getCoverageSectionSubheaderLocation()
38 return this.getLocation(130);
40 public int getCoverageSectionSubheaderLength()
42 return this.getLength(130);
44 public int getCompressionSectionSubheaderLocation()
46 return this.getLocation(131);
48 public int getCompressionSectionSubheaderLength()
50 return this.getLength(131);
52 public int getCompressionLookupSubsectionLocation()
54 return this.getLocation(132);
56 public int getCompressionLookupSubsectionLength()
58 return this.getLength(132);
60 public int getCompressionParameterSubsectionLocation()
62 return this.getLocation(133);
64 public int getCompressionParameterSubsectionLength()
66 return this.getLength(133);
68 public int getColorGrayscaleSectionSubheaderLocation()
70 return this.getLocation(134);
72 public int getColorGrayscaleSectionSubheaderLength()
74 return this.getLength(134);
76 public int getColormapSubsectionLocation()
78 return this.getLocation(135);
80 public int getColormapSubsectionLength()
82 return this.getLength(135);
84 public int getImageDescriptionSubheaderLocation()
86 return this.getLocation(136);
88 public int getImageDescriptionSubheaderLength()
90 return this.getLength(136);
92 public int getImageDisplayParametersSubheaderLocation()
94 return this.getLocation(137);
96 public int getImageDisplayParametersSubheaderLength()
98 return this.getLength(137);
100 public int getMaskSubsectionLocation()
102 return this.getLocation(138);
104 public int getMaskSubsectionLength()
106 return this.getLength(138);
108 public int getColorConverterSubsectionLocation()
110 return this.getLocation(139);
112 public int getColorConverterSubsectionLength()
114 return this.getLength(139);
117 public int getSpatialDataSubsectionLocation()
119 return this.getLocation(140);
121 public int getSpatialDataSubsectionLength()
123 return this.getLength(140);
125 public int getAttributeSectionSubheaderLocation()
127 return this.getLocation(141);
129 public int getAttributeSectionSubheaderLength()
131 return this.getLength(141);
133 public int getAttributeSubsectionLocation()
135 return this.getLocation(142);
137 public int getAttributeSubsectionLength()
139 return this.getLength(142);
141 public int getExplicitArealCoverageTableLocation()
143 return this.getLocation(143);
145 public int getExplicitArealCoverageTableLength()
147 return this.getLength(143);
149 public int getRelatedImagesSectionSubheaderLocation()
151 return this.getLocation(144);
153 public int getRelatedImagesSectionSubheaderLength()
155 return this.getLength(144);
157 public int getRelatedImagesSubsectionLocation()
159 return this.getLocation(145);
161 public int getRelatedImagesSubsectionLength()
163 return this.getLength(145);
165 public int getReplaceUpdateSectionSubheaderLocation()
167 return this.getLocation(146);
169 public int getReplaceUpdateSectionSubheaderLength()
171 return this.getLength(146);
173 public int getReplaceUpdateTableLocation()
175 return this.getLocation(147);
177 public int getReplaceUpdateTableLength()
179 return this.getLength(147);
181 public int getBoundaryRectangleSectionSubheaderLocation()
183 return this.getLocation(148);
185 public int getBoundaryRectangleSectionSubheaderLength()
187 return this.getLength(148);
189 public int getBoundaryRectangleTableLocation()
191 return this.getLocation(149);
193 public int getBoundaryRectangleTableLength()
195 return this.getLength(149);
197 public int getFrameFileIndexSectionSubheaderLocation()
199 return this.getLocation(150);
201 public int getFrameFileIndexSectionSubheaderLength()
203 return this.getLength(150);
205 public int getFrameFileIndexSubsectionLocation()
207 return this.getLocation(151);
209 public int getFrameFileIndexSubsectionLength()
211 return this.getLength(151);
213 public int getColorTableIndexSectionSubheaderLocation()
215 return this.getLocation(152);
217 public int getColorTableIndexSectionSubheaderLength()
219 return this.getLength(152);
221 public int getColorTableIndexRecordLocation()
223 return this.getLocation(153);
225 public int getColorTableIndexRecordLength()
227 return this.getLength(153);
229 // because of lack of "unsigned" in java, we store UINT as int, and UINT as long
230 public int locationSectionLength;
231 public long componentLocationTableOffset;
232 public int numOfComponentLocationRecords;
233 public int componentLocationRecordLength;
234 public long componentAggregateLength;
236 public RpfLocationSection(java.nio.ByteBuffer buffer)
238 this.locationSectionLength = NitfsUtil.getUShort(buffer);
239 this.componentLocationTableOffset = NitfsUtil.getUInt(buffer);
240 this.numOfComponentLocationRecords = NitfsUtil.getUShort(buffer);
241 this.componentLocationRecordLength = NitfsUtil.getUShort(buffer);
242 this.componentAggregateLength = NitfsUtil.getUInt(buffer);
244 if (this.numOfComponentLocationRecords < 2)
245 throw new NitfsRuntimeException("NitfsReader:InvalidNumberOfComponentLocationRecords");
247 for (int i = 0; i < this.numOfComponentLocationRecords; i++)
249 int id = NitfsUtil.getUShort(buffer);
250 table.put(id, new ComponentLocationRecord(id,
251 NitfsUtil.getUInt(buffer), // read uint:4 as "length"
252 NitfsUtil.getUInt(buffer) // read uint:4 as "location"
257 private int getLocation(int componentID)
259 ComponentLocationRecord rec = this.getRecord(componentID);
260 return (int) ((null != rec) ? (0xFFFFFFFFL & rec.getLocation()) : 0);
262 private int getLength(int componentID)
264 ComponentLocationRecord rec = this.getRecord(componentID);
265 return (int) ((null != rec) ? (0xFFFFFFFFL & rec.getLength()) : 0);
267 private ComponentLocationRecord getRecord(int componentID)
269 if(table.containsKey(componentID))
270 return table.get(componentID);
271 return null;
274 public class ComponentLocationRecord
276 private int id;
277 private long length;
278 private long location;
280 public int getId()
282 return id;
285 public long getLength()
287 return length;
290 public long getLocation()
292 return location;
295 public ComponentLocationRecord(int id, long length, long location)
297 this.id = id;
298 this.length = length;
299 this.location = location;