| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package uk.me.parabola.imgfmt.app.net; |
| 18 |
|
| 19 |
import java.io.ByteArrayOutputStream; |
| 20 |
import java.util.ArrayList; |
| 21 |
import java.util.BitSet; |
| 22 |
import java.util.Collections; |
| 23 |
import java.util.HashSet; |
| 24 |
import java.util.List; |
| 25 |
import java.util.Set; |
| 26 |
import java.util.SortedMap; |
| 27 |
import java.util.TreeMap; |
| 28 |
|
| 29 |
import uk.me.parabola.imgfmt.MapFailedException; |
| 30 |
import uk.me.parabola.imgfmt.Utils; |
| 31 |
import uk.me.parabola.imgfmt.app.BitWriter; |
| 32 |
import uk.me.parabola.imgfmt.app.ImgFileWriter; |
| 33 |
import uk.me.parabola.imgfmt.app.Label; |
| 34 |
import uk.me.parabola.imgfmt.app.lbl.City; |
| 35 |
import uk.me.parabola.imgfmt.app.lbl.Zip; |
| 36 |
import uk.me.parabola.imgfmt.app.trergn.Polyline; |
| 37 |
import uk.me.parabola.log.Logger; |
| 38 |
import uk.me.parabola.mkgmap.general.CityInfo; |
| 39 |
import uk.me.parabola.mkgmap.general.ZipCodeInfo; |
| 40 |
import uk.me.parabola.mkgmap.reader.osm.FakeIdGenerator; |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
public class RoadDef { |
| 64 |
private static final Logger log = Logger.getLogger(RoadDef.class); |
| 65 |
public static final int MAX_NUMBER_NODES = 0x3ff; |
| 66 |
public static final int MAX_NUMBER_POLYLINES = 0x7f; |
| 67 |
|
| 68 |
public static final int NET_FLAG_NODINFO = 0x40; |
| 69 |
public static final int NET_FLAG_ADDRINFO = 0x10; |
| 70 |
private static final int NET_FLAG_UNK1 = 0x04; |
| 71 |
private static final int NET_FLAG_ONEWAY = 0x02; |
| 72 |
|
| 73 |
private static final int NOD2_FLAG_UNK = 0x01; |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
private static final int TABA_FLAG_TOLL = 0x80; |
| 78 |
|
| 79 |
private static final int TABA_FLAG_ONEWAY = 0x08; |
| 80 |
|
| 81 |
|
| 82 |
private static final int TABAACCESS_FLAG_CARPOOL = 0x0008; |
| 83 |
private static final int TABAACCESS_FLAG_NOTHROUGHROUTE = 0x0080; |
| 84 |
|
| 85 |
|
| 86 |
private static final int TABAACCESS_FLAG_NO_EMERGENCY = 0x8000; |
| 87 |
private static final int TABAACCESS_FLAG_NO_DELIVERY = 0x4000; |
| 88 |
private static final int TABAACCESS_FLAG_NO_CAR = 0x0001; |
| 89 |
private static final int TABAACCESS_FLAG_NO_BUS = 0x0002; |
| 90 |
private static final int TABAACCESS_FLAG_NO_TAXI = 0x0004; |
| 91 |
private static final int TABAACCESS_FLAG_NO_FOOT = 0x0010; |
| 92 |
private static final int TABAACCESS_FLAG_NO_BIKE = 0x0020; |
| 93 |
private static final int TABAACCESS_FLAG_NO_TRUCK = 0x0040; |
| 94 |
|
| 95 |
|
| 96 |
private boolean skipAddToNOD; |
| 97 |
|
| 98 |
|
| 99 |
private int offsetNod2; |
| 100 |
|
| 101 |
|
| 102 |
private int offsetNet1; |
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
private int netFlags = NET_FLAG_UNK1; |
| 108 |
|
| 109 |
|
| 110 |
private byte mkgmapAccess; |
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
private int roadLength; |
| 115 |
|
| 116 |
|
| 117 |
private static final int MAX_LABELS = 4; |
| 118 |
|
| 119 |
private final Label[] labels = new Label[MAX_LABELS]; |
| 120 |
private int numlabels; |
| 121 |
|
| 122 |
private final SortedMap<Integer,List<RoadIndex>> roadIndexes = new TreeMap<>(); |
| 123 |
|
| 124 |
private boolean paved = true; |
| 125 |
private boolean ferry; |
| 126 |
private boolean roundabout; |
| 127 |
private boolean synthesised; |
| 128 |
private boolean flareCheck; |
| 129 |
private Set<String> messageIssued; |
| 130 |
|
| 131 |
private final List<Offset> rgnOffsets = new ArrayList<>(); |
| 132 |
|
| 133 |
private BitSet nod2BitSet; |
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
private RouteNode node; |
| 142 |
|
| 143 |
|
| 144 |
private boolean startsWithNode = true; |
| 145 |
|
| 146 |
private int nnodes = -1; |
| 147 |
|
| 148 |
|
| 149 |
private int nod2Flags = NOD2_FLAG_UNK; |
| 150 |
|
| 151 |
|
| 152 |
private int tabAInfo; |
| 153 |
private int tabAAccess; |
| 154 |
|
| 155 |
|
| 156 |
private final long id; |
| 157 |
private final String name; |
| 158 |
|
| 159 |
|
| 160 |
private List<Numbers> numbersList; |
| 161 |
private List<City> cityList; |
| 162 |
private List<Zip> zipList; |
| 163 |
|
| 164 |
|
| 165 |
private int nodeCountInner; |
| 166 |
|
| 167 |
private int lenInMeter; |
| 168 |
|
| 169 |
public RoadDef(long id, String name) { |
| 170 |
this.id = id; |
| 171 |
this.name = name; |
| 172 |
} |
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
public RoadDef(long id, int net1offset, String name) { |
| 182 |
this.id = id; |
| 183 |
this.offsetNet1 = net1offset; |
| 184 |
this.name = name; |
| 185 |
} |
| 186 |
|
| 187 |
|
| 188 |
public String toString() { |
| 189 |
if (FakeIdGenerator.isFakeId(id)) |
| 190 |
return "(generated way)"; |
| 191 |
|
| 192 |
|
| 193 |
return "(" + "http://www.openstreetmap.org/way/" + id + ")"; |
| 194 |
} |
| 195 |
|
| 196 |
public String getName() { |
| 197 |
if (name != null) |
| 198 |
return name; |
| 199 |
if (labels[0] != null) |
| 200 |
return labels[0].toString(); |
| 201 |
return null; |
| 202 |
} |
| 203 |
|
| 204 |
public long getId() { |
| 205 |
return id; |
| 206 |
} |
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
void writeNet1(ImgFileWriter writer, int numCities, int numZips) { |
| 213 |
if (numlabels == 0) |
| 214 |
return; |
| 215 |
assert numlabels > 0; |
| 216 |
Zip zip = getZips().isEmpty() ? null : getZips().get(0); |
| 217 |
City city = getCities().isEmpty() ? null: getCities().get(0); |
| 218 |
offsetNet1 = writer.position(); |
| 219 |
NumberPreparer numbers = null; |
| 220 |
if (numbersList != null) { |
| 221 |
numbers = new NumberPreparer(numbersList, zip, city, numCities, numZips); |
| 222 |
if (!numbers.prepare()){ |
| 223 |
numbers = null; |
| 224 |
log.warn("Invalid housenumbers in",this.toString()); |
| 225 |
} |
| 226 |
} |
| 227 |
|
| 228 |
writeLabels(writer); |
| 229 |
if (numbers != null && numbers.getSwapped()) { |
| 230 |
netFlags |= 0x20; |
| 231 |
} |
| 232 |
writer.put1u(netFlags); |
| 233 |
writer.put3u(roadLength); |
| 234 |
|
| 235 |
int maxlevel = writeLevelCount(writer); |
| 236 |
|
| 237 |
writeLevelDivs(writer, maxlevel); |
| 238 |
|
| 239 |
if((netFlags & NET_FLAG_ADDRINFO) != 0) { |
| 240 |
if (!hasHouseNumbers() && skipAddToNOD()) { |
| 241 |
|
| 242 |
nodeCountInner = 0; |
| 243 |
} |
| 244 |
writer.put1u(nodeCountInner & 0xff); |
| 245 |
|
| 246 |
int code = (nodeCountInner >> 8) & 0x3; |
| 247 |
int len, flag; |
| 248 |
|
| 249 |
ByteArrayOutputStream zipBuf = null, cityBuf = null; |
| 250 |
len = (numbers == null) ? 0: numbers.zipWriter.getBuffer().size(); |
| 251 |
if (len > 0){ |
| 252 |
zipBuf = numbers.zipWriter.getBuffer(); |
| 253 |
flag = Utils.numberToPointerSize(len) - 1; |
| 254 |
} else { |
| 255 |
flag = (zip == null) ? 3 : 2; |
| 256 |
} |
| 257 |
code |= flag << 2; |
| 258 |
|
| 259 |
len = (numbers == null) ? 0: numbers.cityWriter.getBuffer().size(); |
| 260 |
if (len > 0){ |
| 261 |
cityBuf = numbers.cityWriter.getBuffer(); |
| 262 |
flag = Utils.numberToPointerSize(len) - 1; |
| 263 |
} else { |
| 264 |
flag = (city == null) ? 3 : 2; |
| 265 |
} |
| 266 |
code |= flag << 4; |
| 267 |
|
| 268 |
len = (numbers == null) ? 0 : numbers.fetchBitStream().getLength(); |
| 269 |
if (len > 0){ |
| 270 |
flag = Utils.numberToPointerSize(len) - 1; |
| 271 |
} else { |
| 272 |
flag = 3; |
| 273 |
} |
| 274 |
code |= flag << 6; |
| 275 |
|
| 276 |
writer.put1u(code); |
| 277 |
|
| 278 |
if (zipBuf != null){ |
| 279 |
len = zipBuf.size(); |
| 280 |
writer.putNu(Utils.numberToPointerSize(len), len); |
| 281 |
writer.put(zipBuf.toByteArray()); |
| 282 |
} else { |
| 283 |
if(zip != null) { |
| 284 |
int zipIndex = zip.getIndex(); |
| 285 |
writer.putNu(Utils.numberToPointerSize(numZips), zipIndex); |
| 286 |
} |
| 287 |
} |
| 288 |
if (cityBuf != null){ |
| 289 |
len = cityBuf.size(); |
| 290 |
writer.putNu(Utils.numberToPointerSize(len), len); |
| 291 |
writer.put(cityBuf.toByteArray()); |
| 292 |
} else { |
| 293 |
if(city != null) { |
| 294 |
int cityIndex = city.getIndex(); |
| 295 |
writer.putNu(Utils.numberToPointerSize(numCities), cityIndex); |
| 296 |
} |
| 297 |
} |
| 298 |
if (numbers != null) { |
| 299 |
BitWriter bw = numbers.fetchBitStream(); |
| 300 |
writer.putNu(Utils.numberToPointerSize(bw.getLength()), bw.getLength()); |
| 301 |
writer.put(bw.getBytes(), 0, bw.getLength()); |
| 302 |
} |
| 303 |
} |
| 304 |
|
| 305 |
if (hasNodInfo()) { |
| 306 |
|
| 307 |
int val = offsetNod2; |
| 308 |
if (val < 0x7fff) { |
| 309 |
writer.put1u(1); |
| 310 |
writer.put2u(val); |
| 311 |
} else { |
| 312 |
writer.put1u(2); |
| 313 |
writer.put3u(val); |
| 314 |
} |
| 315 |
} |
| 316 |
} |
| 317 |
|
| 318 |
private void writeLabels(ImgFileWriter writer) { |
| 319 |
for (int i = 0; i < numlabels; i++) { |
| 320 |
Label l = labels[i]; |
| 321 |
int ptr = l.getOffset(); |
| 322 |
if (i == (numlabels-1)) |
| 323 |
ptr |= 0x800000; |
| 324 |
writer.put3u(ptr); |
| 325 |
} |
| 326 |
} |
| 327 |
|
| 328 |
public void putSortedRoadEntry(ImgFileWriter writer, Label label) { |
| 329 |
for(int i = 0; i < labels.length && labels[i] != null; ++i) { |
| 330 |
if(labels[i].equals(label)) { |
| 331 |
writer.put3u((i << 22) | offsetNet1); |
| 332 |
return; |
| 333 |
} |
| 334 |
} |
| 335 |
} |
| 336 |
|
| 337 |
private int writeLevelCount(ImgFileWriter writer) { |
| 338 |
int maxlevel = getMaxZoomLevel(); |
| 339 |
for (int i = 0; i <= maxlevel; i++) { |
| 340 |
List<RoadIndex> l = roadIndexes.get(i); |
| 341 |
int b = (l == null) ? 0 : l.size(); |
| 342 |
if (b > MAX_NUMBER_POLYLINES) |
| 343 |
throw new MapFailedException("Too many polylines for road " + this + " at level " + i); |
| 344 |
if (i == maxlevel) |
| 345 |
b |= 0x80; |
| 346 |
writer.put1u(b); |
| 347 |
} |
| 348 |
return maxlevel; |
| 349 |
} |
| 350 |
|
| 351 |
private void writeLevelDivs(ImgFileWriter writer, int maxlevel) { |
| 352 |
for (int i = 0; i <= maxlevel; i++) { |
| 353 |
List<RoadIndex> l = roadIndexes.get(i); |
| 354 |
if (l != null) { |
| 355 |
for (RoadIndex ri : l) |
| 356 |
ri.write(writer); |
| 357 |
} |
| 358 |
} |
| 359 |
} |
| 360 |
|
| 361 |
public void addLabel(Label l) { |
| 362 |
int i; |
| 363 |
for (i = 0; i < MAX_LABELS && labels[i] != null; ++i) { |
| 364 |
if (l.equals(labels[i])) { |
| 365 |
|
| 366 |
return; |
| 367 |
} |
| 368 |
} |
| 369 |
|
| 370 |
if (i < MAX_LABELS) { |
| 371 |
labels[i] = l; |
| 372 |
++numlabels; |
| 373 |
} |
| 374 |
else |
| 375 |
log.warn(this.toString() + " discarding extra label (already have " + MAX_LABELS + ")"); |
| 376 |
} |
| 377 |
|
| 378 |
public Label[] getLabels() { |
| 379 |
return labels; |
| 380 |
} |
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
public void addPolylineRef(Polyline pl) { |
| 391 |
if(log.isDebugEnabled()) |
| 392 |
log.debug("adding polyline ref", this, pl.getSubdiv()); |
| 393 |
int level = pl.getSubdiv().getZoom().getLevel(); |
| 394 |
roadIndexes.computeIfAbsent(level, k -> new ArrayList<>()).add(new RoadIndex(pl)); |
| 395 |
|
| 396 |
if (level == 0) { |
| 397 |
nodeCountInner += pl.getNodeCount(hasHouseNumbers()); |
| 398 |
} |
| 399 |
} |
| 400 |
|
| 401 |
private int getMaxZoomLevel() { |
| 402 |
return roadIndexes.lastKey(); |
| 403 |
} |
| 404 |
|
| 405 |
public boolean connectedTo(RoadDef other) { |
| 406 |
List<RoadIndex> l = roadIndexes.get(0); |
| 407 |
if(l == null) |
| 408 |
return false; |
| 409 |
|
| 410 |
List<RoadIndex> ol = other.roadIndexes.get(0); |
| 411 |
if(ol == null) |
| 412 |
return false; |
| 413 |
|
| 414 |
for(RoadIndex ri : l) |
| 415 |
for(RoadIndex ori : ol) |
| 416 |
if(ri.getLine().sharesNodeWith(ori.getLine())) |
| 417 |
return true; |
| 418 |
return false; |
| 419 |
} |
| 420 |
|
| 421 |
public boolean sameDiv(RoadDef other) { |
| 422 |
return getStartSubdivNumber() == other.getStartSubdivNumber(); |
| 423 |
} |
| 424 |
|
| 425 |
public int getStartSubdivNumber() { |
| 426 |
Integer key = roadIndexes.firstKey(); |
| 427 |
return roadIndexes.get(key).get(0).getLine().getSubdiv().getNumber(); |
| 428 |
} |
| 429 |
|
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
public void setLength(double lenInMeter) { |
| 434 |
this.lenInMeter = (int) Math.round(lenInMeter); |
| 435 |
roadLength = NODHeader.metersToRaw(lenInMeter); |
| 436 |
} |
| 437 |
|
| 438 |
public boolean hasHouseNumbers() { |
| 439 |
return numbersList != null && !numbersList.isEmpty(); |
| 440 |
} |
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
class Offset { |
| 446 |
final int position; |
| 447 |
final int flags; |
| 448 |
|
| 449 |
Offset(int position, int flags) { |
| 450 |
this.position = position; |
| 451 |
this.flags = flags; |
| 452 |
} |
| 453 |
|
| 454 |
int getPosition() { |
| 455 |
return position; |
| 456 |
} |
| 457 |
|
| 458 |
int getFlags() { |
| 459 |
return flags; |
| 460 |
} |
| 461 |
} |
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
|
| 468 |
|
| 469 |
|
| 470 |
|
| 471 |
public void addOffsetTarget(int position, int flags) { |
| 472 |
rgnOffsets.add(new Offset(position, flags)); |
| 473 |
} |
| 474 |
|
| 475 |
|
| 476 |
|
| 477 |
|
| 478 |
|
| 479 |
void writeRgnOffsets(ImgFileWriter rgn) { |
| 480 |
if (offsetNet1 >= 0x400000) |
| 481 |
throw new MapFailedException("Overflow of the NET1. The tile (" |
| 482 |
+ log.threadTag() |
| 483 |
+ ") must be split so that there are fewer roads in it"); |
| 484 |
|
| 485 |
for (Offset off : rgnOffsets) { |
| 486 |
rgn.position(off.getPosition()); |
| 487 |
rgn.put3u(offsetNet1 | off.getFlags()); |
| 488 |
} |
| 489 |
} |
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
public void setNode(RouteNode node) { |
| 498 |
if (skipAddToNOD) |
| 499 |
return; |
| 500 |
netFlags |= NET_FLAG_NODINFO; |
| 501 |
this.node = node; |
| 502 |
} |
| 503 |
|
| 504 |
public RouteNode getNode(){ |
| 505 |
return node; |
| 506 |
} |
| 507 |
|
| 508 |
private boolean hasNodInfo() { |
| 509 |
return (netFlags & NET_FLAG_NODINFO) != 0; |
| 510 |
} |
| 511 |
|
| 512 |
public void setStartsWithNode(boolean s) { |
| 513 |
startsWithNode = s; |
| 514 |
} |
| 515 |
|
| 516 |
public void setNumNodes(int n) { |
| 517 |
if (n-2 > MAX_NUMBER_NODES) { |
| 518 |
throw new MapFailedException("Too many special nodes: " + n + " is > " + MAX_NUMBER_NODES + " " + this); |
| 519 |
} |
| 520 |
nnodes = n; |
| 521 |
} |
| 522 |
|
| 523 |
public void setNumbersList(List<Numbers> numbersList) { |
| 524 |
if (numbersList != null && !numbersList.isEmpty()) { |
| 525 |
this.numbersList = numbersList; |
| 526 |
netFlags |= NET_FLAG_ADDRINFO; |
| 527 |
} |
| 528 |
} |
| 529 |
|
| 530 |
public List<Numbers> getNumbersList() { |
| 531 |
return numbersList; |
| 532 |
} |
| 533 |
|
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
public void writeNod2(ImgFileWriter writer) { |
| 544 |
if (!hasNodInfo()) |
| 545 |
return; |
| 546 |
if (skipAddToNOD){ |
| 547 |
|
| 548 |
log.error("internal error: writeNod2 called for roaddef with skipAddToNOD=true"); |
| 549 |
return; |
| 550 |
} |
| 551 |
|
| 552 |
log.debug("writing nod2"); |
| 553 |
|
| 554 |
offsetNod2 = writer.position(); |
| 555 |
|
| 556 |
writer.put1u(nod2Flags); |
| 557 |
writer.put3u(node.getOffsetNod1()); |
| 558 |
|
| 559 |
|
| 560 |
|
| 561 |
|
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
int nbits = nnodes; |
| 566 |
if (!startsWithNode && !hasHouseNumbers()) |
| 567 |
nbits++; |
| 568 |
writer.put2u(nbits); |
| 569 |
boolean[] bits = new boolean[nbits]; |
| 570 |
|
| 571 |
if (hasHouseNumbers()){ |
| 572 |
for (int i = 0; i < bits.length; i++){ |
| 573 |
if (nod2BitSet.get(i)) |
| 574 |
bits[i] = true; |
| 575 |
} |
| 576 |
} else { |
| 577 |
for (int i = 0; i < bits.length; i++) |
| 578 |
bits[i] = true; |
| 579 |
if (!startsWithNode) |
| 580 |
bits[0] = false; |
| 581 |
} |
| 582 |
for (int i = 0; i < bits.length; i += 8) { |
| 583 |
int b = 0; |
| 584 |
for (int j = 0; j < 8 && j < bits.length - i; j++) { |
| 585 |
if (bits[i+j]) |
| 586 |
b |= 1 << j; |
| 587 |
} |
| 588 |
writer.put1u(b); |
| 589 |
} |
| 590 |
} |
| 591 |
|
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
|
| 603 |
|
| 604 |
|
| 605 |
|
| 606 |
public int getOffsetNet1() { |
| 607 |
return offsetNet1; |
| 608 |
} |
| 609 |
|
| 610 |
|
| 611 |
|
| 612 |
|
| 613 |
public void setToll() { |
| 614 |
tabAInfo |= TABA_FLAG_TOLL; |
| 615 |
} |
| 616 |
|
| 617 |
|
| 618 |
|
| 619 |
|
| 620 |
|
| 621 |
|
| 622 |
public void setCarpoolLane() { |
| 623 |
tabAAccess |= TABAACCESS_FLAG_CARPOOL; |
| 624 |
} |
| 625 |
|
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
|
| 630 |
public void setNoThroughRouting() { |
| 631 |
tabAAccess |= TABAACCESS_FLAG_NOTHROUGHROUTE; |
| 632 |
} |
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
public byte getAccess() { |
| 638 |
return mkgmapAccess; |
| 639 |
} |
| 640 |
|
| 641 |
|
| 642 |
|
| 643 |
|
| 644 |
|
| 645 |
public void setAccess(byte mkgmapAccess) { |
| 646 |
this.mkgmapAccess = mkgmapAccess; |
| 647 |
|
| 648 |
|
| 649 |
tabAAccess &= ~(0xc077); |
| 650 |
if (mkgmapAccess == (byte) 0xff) |
| 651 |
return; |
| 652 |
|
| 653 |
if ((mkgmapAccess & AccessTagsAndBits.FOOT) == 0) |
| 654 |
tabAAccess |= TABAACCESS_FLAG_NO_FOOT; |
| 655 |
if ((mkgmapAccess & AccessTagsAndBits.BIKE) == 0) |
| 656 |
tabAAccess |=TABAACCESS_FLAG_NO_BIKE; |
| 657 |
if ((mkgmapAccess & AccessTagsAndBits.CAR) == 0) |
| 658 |
tabAAccess |=TABAACCESS_FLAG_NO_CAR; |
| 659 |
if ((mkgmapAccess & AccessTagsAndBits.DELIVERY) == 0) |
| 660 |
tabAAccess |=TABAACCESS_FLAG_NO_DELIVERY; |
| 661 |
if ((mkgmapAccess & AccessTagsAndBits.TRUCK) == 0) |
| 662 |
tabAAccess |=TABAACCESS_FLAG_NO_TRUCK; |
| 663 |
if ((mkgmapAccess & AccessTagsAndBits.BUS) == 0) |
| 664 |
tabAAccess |=TABAACCESS_FLAG_NO_BUS; |
| 665 |
if ((mkgmapAccess & AccessTagsAndBits.TAXI) == 0) |
| 666 |
tabAAccess |=TABAACCESS_FLAG_NO_TAXI; |
| 667 |
if ((mkgmapAccess & AccessTagsAndBits.EMERGENCY) == 0) |
| 668 |
tabAAccess |=TABAACCESS_FLAG_NO_EMERGENCY; |
| 669 |
} |
| 670 |
|
| 671 |
public int getTabAInfo() { |
| 672 |
return tabAInfo; |
| 673 |
} |
| 674 |
|
| 675 |
public int getTabAAccess() { |
| 676 |
return tabAAccess; |
| 677 |
} |
| 678 |
|
| 679 |
|
| 680 |
|
| 681 |
|
| 682 |
|
| 683 |
private int roadClass = -1; |
| 684 |
|
| 685 |
|
| 686 |
|
| 687 |
public void setRoadClass(int roadClass) { |
| 688 |
assert roadClass < 0x08; |
| 689 |
|
| 690 |
|
| 691 |
this.roadClass = roadClass; |
| 692 |
|
| 693 |
|
| 694 |
int shifted = (roadClass << 4) & 0xff; |
| 695 |
tabAInfo |= shifted; |
| 696 |
|
| 697 |
|
| 698 |
nod2Flags |= shifted; |
| 699 |
} |
| 700 |
|
| 701 |
public int getRoadClass() { |
| 702 |
assert roadClass >= 0 : "roadClass not set"; |
| 703 |
return roadClass; |
| 704 |
} |
| 705 |
|
| 706 |
public void setSpeed(int speed) { |
| 707 |
assert speed < 0x08; |
| 708 |
|
| 709 |
|
| 710 |
tabAInfo |= speed; |
| 711 |
|
| 712 |
|
| 713 |
nod2Flags |= (speed << 1); |
| 714 |
} |
| 715 |
|
| 716 |
public int getRoadSpeed() { |
| 717 |
return tabAInfo & 7; |
| 718 |
} |
| 719 |
|
| 720 |
public void setOneway() { |
| 721 |
tabAInfo |= TABA_FLAG_ONEWAY; |
| 722 |
netFlags |= NET_FLAG_ONEWAY; |
| 723 |
} |
| 724 |
|
| 725 |
public boolean isOneway() { |
| 726 |
return (netFlags & NET_FLAG_ONEWAY) != 0; |
| 727 |
} |
| 728 |
|
| 729 |
public void addCityIfNotPresent(City city) { |
| 730 |
if (city == null){ |
| 731 |
log.error("trying to add null value to city list in road",this); |
| 732 |
return; |
| 733 |
} |
| 734 |
netFlags |= NET_FLAG_ADDRINFO; |
| 735 |
if (cityList == null){ |
| 736 |
cityList = new ArrayList<>(2); |
| 737 |
} |
| 738 |
if (!cityList.contains(city)) |
| 739 |
cityList.add(city); |
| 740 |
} |
| 741 |
|
| 742 |
public void addZipIfNotPresent(Zip zip) { |
| 743 |
if (zip == null){ |
| 744 |
log.error("trying to add null value to zip list in road",this); |
| 745 |
return; |
| 746 |
} |
| 747 |
netFlags |= NET_FLAG_ADDRINFO; |
| 748 |
if (zipList == null){ |
| 749 |
zipList = new ArrayList<>(2); |
| 750 |
} |
| 751 |
if (!zipList.contains(zip)) |
| 752 |
zipList.add(zip); |
| 753 |
} |
| 754 |
|
| 755 |
|
| 756 |
public List<City> getCities(){ |
| 757 |
if (cityList == null) |
| 758 |
return Collections.emptyList(); |
| 759 |
return cityList; |
| 760 |
} |
| 761 |
|
| 762 |
public List<Zip> getZips(){ |
| 763 |
if (zipList == null) |
| 764 |
return Collections.emptyList(); |
| 765 |
return zipList; |
| 766 |
} |
| 767 |
|
| 768 |
public boolean paved() { |
| 769 |
return paved; |
| 770 |
} |
| 771 |
|
| 772 |
public void paved(boolean p) { |
| 773 |
paved = p; |
| 774 |
} |
| 775 |
|
| 776 |
public void ferry(boolean f) { |
| 777 |
ferry = f; |
| 778 |
} |
| 779 |
|
| 780 |
public boolean ferry() { |
| 781 |
return ferry; |
| 782 |
} |
| 783 |
|
| 784 |
public void setRoundabout(boolean r) { |
| 785 |
roundabout = r; |
| 786 |
} |
| 787 |
|
| 788 |
public boolean isRoundabout() { |
| 789 |
return roundabout; |
| 790 |
} |
| 791 |
|
| 792 |
public void setSynthesised(boolean s) { |
| 793 |
synthesised = s; |
| 794 |
} |
| 795 |
|
| 796 |
public boolean isSynthesised() { |
| 797 |
return synthesised; |
| 798 |
} |
| 799 |
|
| 800 |
public void doFlareCheck(boolean fc) { |
| 801 |
flareCheck = fc; |
| 802 |
} |
| 803 |
|
| 804 |
public boolean doFlareCheck() { |
| 805 |
return flareCheck; |
| 806 |
} |
| 807 |
|
| 808 |
public boolean messagePreviouslyIssued(String key) { |
| 809 |
if(messageIssued == null) |
| 810 |
messageIssued = new HashSet<>(); |
| 811 |
boolean previouslyIssued = messageIssued.contains(key); |
| 812 |
messageIssued.add(key); |
| 813 |
return previouslyIssued; |
| 814 |
} |
| 815 |
|
| 816 |
public void setNod2BitSet(BitSet bs) { |
| 817 |
if (skipAddToNOD) |
| 818 |
return; |
| 819 |
nod2BitSet = bs; |
| 820 |
} |
| 821 |
|
| 822 |
public boolean skipAddToNOD() { |
| 823 |
return skipAddToNOD; |
| 824 |
} |
| 825 |
|
| 826 |
public void skipAddToNOD(boolean skip) { |
| 827 |
this.skipAddToNOD = skip; |
| 828 |
if (hasNodInfo()) { |
| 829 |
log.info("road", this, "is removed from NOD, length:", lenInMeter, "m"); |
| 830 |
netFlags &= ~NET_FLAG_NODINFO; |
| 831 |
} |
| 832 |
} |
| 833 |
|
| 834 |
public void resetImgData() { |
| 835 |
zipList = null; |
| 836 |
cityList = null; |
| 837 |
if (numbersList != null){ |
| 838 |
for (Numbers num : numbersList){ |
| 839 |
for (int side = 0; side < 2; side++){ |
| 840 |
boolean left = side == 0; |
| 841 |
CityInfo ci = num.getCityInfo(left); |
| 842 |
if (ci != null) |
| 843 |
ci.setImgCity(null); |
| 844 |
ZipCodeInfo z = num.getZipCodeInfo(left); |
| 845 |
if (z != null) |
| 846 |
z.setImgZip(null); |
| 847 |
} |
| 848 |
} |
| 849 |
} |
| 850 |
} |
| 851 |
|
| 852 |
public double getLenInMeter() { |
| 853 |
return lenInMeter; |
| 854 |
} |
| 855 |
|
| 856 |
} |