| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package uk.me.parabola.imgfmt.app.lbl; |
| 18 |
|
| 19 |
import uk.me.parabola.imgfmt.app.ImgFileReader; |
| 20 |
import uk.me.parabola.imgfmt.app.ImgFileWriter; |
| 21 |
import uk.me.parabola.imgfmt.app.Section; |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
public class PlacesHeader { |
| 31 |
|
| 32 |
private static final char COUNTRY_REC_LEN = 3; |
| 33 |
private static final char REGION_REC_LEN = 5; |
| 34 |
private static final char CITY_REC_LEN = 5; |
| 35 |
private static final char POI_INDEX_REC_LEN = 4; |
| 36 |
private static final char POI_TYPE_INDEX_REC_LEN = 4; |
| 37 |
private static final char ZIP_REC_LEN = 3; |
| 38 |
private static final char HIGHWAY_REC_LEN = 6; |
| 39 |
private static final char EXIT_REC_LEN = 5; |
| 40 |
private static final char HIGHWAYDATA_REC_LEN = 3; |
| 41 |
|
| 42 |
private final Section country = new Section(COUNTRY_REC_LEN); |
| 43 |
private final Section region = new Section(country, REGION_REC_LEN); |
| 44 |
private final Section city = new Section(region, CITY_REC_LEN); |
| 45 |
private final Section poiIndex = new Section(city, POI_INDEX_REC_LEN); |
| 46 |
private final Section poiProperties = new Section(poiIndex); |
| 47 |
private final Section poiTypeIndex = new Section(poiProperties, POI_TYPE_INDEX_REC_LEN); |
| 48 |
private final Section zip = new Section(poiTypeIndex, ZIP_REC_LEN); |
| 49 |
private final Section highway = new Section(zip, HIGHWAY_REC_LEN); |
| 50 |
private final Section exitFacility = new Section(highway, EXIT_REC_LEN); |
| 51 |
private final Section highwayData = new Section(exitFacility, HIGHWAYDATA_REC_LEN); |
| 52 |
private int POIGlobalFlags ; |
| 53 |
|
| 54 |
void setPOIGlobalFlags(int flags) { |
| 55 |
this.POIGlobalFlags = flags; |
| 56 |
} |
| 57 |
|
| 58 |
int getPOIGlobalFlags() { |
| 59 |
return POIGlobalFlags; |
| 60 |
} |
| 61 |
|
| 62 |
void writeFileHeader(ImgFileWriter writer) { |
| 63 |
writer.put4(country.getPosition()); |
| 64 |
writer.put4(country.getSize()); |
| 65 |
writer.put2u(country.getItemSize()); |
| 66 |
writer.put4(0); |
| 67 |
|
| 68 |
writer.put4(region.getPosition()); |
| 69 |
writer.put4(region.getSize()); |
| 70 |
writer.put2u(region.getItemSize()); |
| 71 |
writer.put4(0); |
| 72 |
|
| 73 |
writer.put4(city.getPosition()); |
| 74 |
writer.put4(city.getSize()); |
| 75 |
writer.put2u(city.getItemSize()); |
| 76 |
writer.put4(0); |
| 77 |
|
| 78 |
writer.put4(poiIndex.getPosition()); |
| 79 |
writer.put4(poiIndex.getSize()); |
| 80 |
writer.put2u(poiIndex.getItemSize()); |
| 81 |
writer.put4(0); |
| 82 |
|
| 83 |
writer.put4(poiProperties.getPosition()); |
| 84 |
writer.put4(poiProperties.getSize()); |
| 85 |
writer.put1u(0); |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
writer.put1u(POIGlobalFlags); |
| 95 |
writer.put2u(0); |
| 96 |
writer.put1u(0); |
| 97 |
|
| 98 |
writer.put4(poiTypeIndex.getPosition()); |
| 99 |
writer.put4(poiTypeIndex.getSize()); |
| 100 |
writer.put2u(poiTypeIndex.getItemSize()); |
| 101 |
writer.put4(0); |
| 102 |
|
| 103 |
writer.put4(zip.getPosition()); |
| 104 |
writer.put4(zip.getSize()); |
| 105 |
writer.put2u(zip.getItemSize()); |
| 106 |
writer.put4(0); |
| 107 |
|
| 108 |
writer.put4(highway.getPosition()); |
| 109 |
writer.put4(highway.getSize()); |
| 110 |
writer.put2u(highway.getItemSize()); |
| 111 |
writer.put4(0); |
| 112 |
|
| 113 |
writer.put4(exitFacility.getPosition()); |
| 114 |
writer.put4(exitFacility.getSize()); |
| 115 |
writer.put2u(exitFacility.getItemSize()); |
| 116 |
writer.put4(0); |
| 117 |
|
| 118 |
writer.put4(highwayData.getPosition()); |
| 119 |
writer.put4(highwayData.getSize()); |
| 120 |
writer.put2u(highwayData.getItemSize()); |
| 121 |
writer.put4(0); |
| 122 |
} |
| 123 |
|
| 124 |
void readFileHeader(ImgFileReader reader) { |
| 125 |
reader.position(reader.getGMPOffset() + 0x1fL); |
| 126 |
|
| 127 |
country.readSectionInfo(reader, true, true); |
| 128 |
|
| 129 |
region.readSectionInfo(reader, true, true); |
| 130 |
|
| 131 |
city.readSectionInfo(reader, true, true); |
| 132 |
|
| 133 |
poiIndex.readSectionInfo(reader, true, true); |
| 134 |
|
| 135 |
poiProperties.readSectionInfo(reader, false); |
| 136 |
reader.get(); |
| 137 |
|
| 138 |
POIGlobalFlags = reader.get1u(); |
| 139 |
reader.get2u(); |
| 140 |
reader.get(); |
| 141 |
|
| 142 |
poiTypeIndex.readSectionInfo(reader, true, true); |
| 143 |
|
| 144 |
zip.readSectionInfo(reader, true, true); |
| 145 |
|
| 146 |
highway.readSectionInfo(reader, true, true); |
| 147 |
|
| 148 |
exitFacility.readSectionInfo(reader, true, true); |
| 149 |
|
| 150 |
highwayData.readSectionInfo(reader, true, true); |
| 151 |
} |
| 152 |
|
| 153 |
int getLastPos() { |
| 154 |
|
| 155 |
return highwayData.getEndPos(); |
| 156 |
} |
| 157 |
|
| 158 |
void setLabelEnd(int pos) { |
| 159 |
country.setPosition(pos); |
| 160 |
} |
| 161 |
|
| 162 |
void endCountries(int pos) { |
| 163 |
country.setSize(pos - country.getPosition()); |
| 164 |
} |
| 165 |
|
| 166 |
void endRegions(int pos) { |
| 167 |
region.setSize(pos - region.getPosition()); |
| 168 |
} |
| 169 |
|
| 170 |
void endCity(int pos) { |
| 171 |
city.setSize(pos - city.getPosition()); |
| 172 |
} |
| 173 |
|
| 174 |
void endPOI(int pos) { |
| 175 |
poiProperties.setSize(pos - poiProperties.getPosition()); |
| 176 |
} |
| 177 |
|
| 178 |
void endPOIIndex(int pos) { |
| 179 |
poiIndex.setSize(pos - poiIndex.getPosition()); |
| 180 |
} |
| 181 |
|
| 182 |
void endPOITypeIndex(int pos) { |
| 183 |
poiTypeIndex.setSize(pos - poiTypeIndex.getPosition()); |
| 184 |
} |
| 185 |
|
| 186 |
void endZip(int pos) { |
| 187 |
zip.setSize(pos - zip.getPosition()); |
| 188 |
} |
| 189 |
|
| 190 |
void endHighway(int pos) { |
| 191 |
highway.setSize(pos - highway.getPosition()); |
| 192 |
} |
| 193 |
|
| 194 |
void endExitFacility(int pos) { |
| 195 |
exitFacility.setSize(pos - exitFacility.getPosition()); |
| 196 |
} |
| 197 |
|
| 198 |
void endHighwayData(int pos) { |
| 199 |
highwayData.setSize(pos - highwayData.getPosition()); |
| 200 |
} |
| 201 |
|
| 202 |
public int getNumCities() { |
| 203 |
return city.getNumItems(); |
| 204 |
} |
| 205 |
|
| 206 |
public int getNumZips() { |
| 207 |
return zip.getNumItems(); |
| 208 |
} |
| 209 |
|
| 210 |
public int getPoiPropertiesStart() { |
| 211 |
return poiProperties.getPosition(); |
| 212 |
} |
| 213 |
public int getPoiPropertiesEnd() { |
| 214 |
return poiProperties.getEndPos(); |
| 215 |
} |
| 216 |
|
| 217 |
public Section getCitySection() { |
| 218 |
return city; |
| 219 |
} |
| 220 |
public int getNumExits() { |
| 221 |
return exitFacility.getNumItems(); |
| 222 |
} |
| 223 |
|
| 224 |
public Section getCountrySection() { |
| 225 |
return country; |
| 226 |
} |
| 227 |
|
| 228 |
public Section getRegionSection() { |
| 229 |
return region; |
| 230 |
} |
| 231 |
|
| 232 |
public int getNumHighways() { |
| 233 |
return highway.getNumItems(); |
| 234 |
} |
| 235 |
|
| 236 |
public Section getZipSection() { |
| 237 |
return zip; |
| 238 |
} |
| 239 |
} |