Debian Codegraph @

src/uk/me/parabola/imgfmt/app/net/RoadDef.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2007 Steve Ratcliffe
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 *
14 * Author: Steve Ratcliffe
15 * Create date: Jan 5, 2008
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 * A road definition. This ties together all segments of a single road
44 * and provides street address information.
45 *
46 * This corresponds to an entry in NET1, which is linked with the
47 * polylines making up this road in RGN. Links to RGN are written
48 * via RoadIndex, while writing links from RGN to NET1 is delayed
49 * via setOffsetWriter.
50 *
51 * If the map includes routing, the NET1 record also points to
52 * a NOD2 record, written by writeNod2.
53 *
54 * Edges in the routing graph ("arcs") link to the corresponding
55 * road via the RoadDef, storing the NET1 offset via TableA,
56 * which also includes some road information.
57 *
58 * @author Elrond
59 * @author Steve Ratcliffe
60 * @author Robert Vollmert
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; // lock on road?
71 private static final int NET_FLAG_ONEWAY = 0x02;
72
73 private static final int NOD2_FLAG_UNK = 0x01;
74 // private static final int NOD2_FLAG_EXTRA_DATA = 0x80; just documentation
75
76 // first byte of Table A info in NOD 1
77 private static final int TABA_FLAG_TOLL = 0x80;
78 // private static final int TABA_MASK_CLASS = 0x70; just documentation
79 private static final int TABA_FLAG_ONEWAY = 0x08;
80 // private static final int TABA_MASK_SPEED = 0x07; just documentation
81
82 private static final int TABAACCESS_FLAG_CARPOOL = 0x0008;
83 private static final int TABAACCESS_FLAG_NOTHROUGHROUTE = 0x0080;
84
85 // second byte: access flags, bits 0x08, 0x80 are set separately
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 // true if road should not be added to NOD
96 private boolean skipAddToNOD;
97
98 // the offset in Nod2 of our Nod2 record
99 private int offsetNod2;
100
101 // the offset in Net1 of our Net1 record
102 private int offsetNet1;
103
104 /*
105 * Everything that's relevant for writing to NET1.
106 */
107 private int netFlags = NET_FLAG_UNK1;
108
109 // the allowed vehicles in mkgmap internal format
110 private byte mkgmapAccess;
111
112 // The road length units may be affected by other flags in the header as
113 // there is doubt as to the formula.
114 private int roadLength;
115
116 // There can be up to 4 labels for the same road.
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 // for the NOD2 bit stream
133 private BitSet nod2BitSet;
134
135 /*
136 * Everything that's relevant for writing out Nod 2.
137 */
138 // This is the node associated with the road. I'm not certain about how
139 // this works, but in NOD2 each road has a reference to only one node.
140 // This is that node.
141 private RouteNode node;
142
143 // the first point in the road is a node (the above routing node)
144 private boolean startsWithNode = true;
145 // number of nodes in the road
146 private int nnodes = -1;
147
148 // always appears to be set
149 private int nod2Flags = NOD2_FLAG_UNK;
150
151 // The data for Table A
152 private int tabAInfo;
153 private int tabAAccess;
154
155 // for diagnostic purposes
156 private final long id;
157 private final String name;
158
159 // road/address search data from (house) numbers
160 private List<Numbers> numbersList;
161 private List<City> cityList;
162 private List<Zip> zipList;
163
164 /** cumulative number of special nodes between first and last node of line segments */
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 * A constructor that is used when reading a file and you know the NET1 offset. When writing
176 * the offsetNet1 field is filled in during the writing process.
177 * @param id Road id
178 * @param net1offset The offset in the road defs section of the NET file.
179 * @param name The main of the road.
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 // for diagnostic purposes
188 public String toString() {
189 if (FakeIdGenerator.isFakeId(id))
190 return "(generated way)";
191
192 // assumes id is an OSM id
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 * This is for writing to NET1.
210 * @param writer A writer that is positioned within NET1.
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; // swapped default; left=even, right=odd
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 // no need to write node info (decreases bitstream length)
242 nodeCountInner = 0;
243 }
244 writer.put1u(nodeCountInner & 0xff); // lo bits of node count
245
246 int code = (nodeCountInner >> 8) & 0x3; // top bits of node count
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 // This is the offset of an entry in NOD2
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 // label already present
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 * Add a polyline to this road.
384 *
385 * References to these are written to NET. At a given zoom
386 * level, we're writing these in the order we get them,
387 * which must(!) be the order the segments have
388 * in the road.
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 * Set the road length (in meters).
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 * Everything that's relevant for writing to RGN.
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 * Add a target location in the RGN section where we should write the
466 * offset of this road def when it is written to NET.
467 *
468 * @param position The offset in RGN.
469 * @param flags The flags that should be set.
470 */
471 public void addOffsetTarget(int position, int flags) {
472 rgnOffsets.add(new Offset(position, flags));
473 }
474
475 /**
476 * Write into the RGN the offset in net1 of this road.
477 * @param rgn A writer for the rgn file.
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 * Set the routing node associated with this road.
493 *
494 * This implies that the road has an entry in NOD 2
495 * which will be pointed at from NET 1.
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 * Write this road's NOD2 entry.
537 *
538 * Stores the writing position to be able to link here
539 * from NET 1 later.
540 *
541 * @param writer A writer positioned in NOD2.
542 */
543 public void writeNod2(ImgFileWriter writer) {
544 if (!hasNodInfo())
545 return;
546 if (skipAddToNOD){
547 // should not happen
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()); // offset in nod1
558
559 // this is related to the number of nodes, but there
560 // is more to it...
561 // For now, shift by one if the first node is not a
562 // routing node.
563 // If the road has house numbers, we count also
564 // the number nodes, and these get a 0 in the bit stream.
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 * Everything that's relevant for writing out Table A.
594 *
595 * Storing this info in the RoadDef means that each
596 * arc gets the same version of the below info, which
597 * makes sense for the moment considering polish format
598 * doesn't provide for different speeds and restrictions
599 * for segments of roads.
600 */
601
602 /**
603 * Return the offset of this road's NET1 entry. Assumes
604 * writeNet1() has been called.
605 */
606 public int getOffsetNet1() {
607 return offsetNet1;
608 }
609
610 /**
611 * Flag that a toll must be payed when using this road.
612 */
613 public void setToll() {
614 tabAInfo |= TABA_FLAG_TOLL;
615 }
616
617 /**
618 * Flag that the road has a carpool lane.<br>
619 * Warning: This bit does not seem to work. Maybe it does not control
620 * the carpool flag.
621 */
622 public void setCarpoolLane() {
623 tabAAccess |= TABAACCESS_FLAG_CARPOOL;
624 }
625
626 /**
627 * Sets the flag that routing is allowed only if the route starts or
628 * end on this road.
629 */
630 public void setNoThroughRouting() {
631 tabAAccess |= TABAACCESS_FLAG_NOTHROUGHROUTE;
632 }
633
634 /**
635 * @return allowed vehicles in mkgmap format
636 */
637 public byte getAccess() {
638 return mkgmapAccess;
639 }
640
641 /**
642 * Set allowed vehicles
643 * @param mkgmapAccess bit mask in mkgmap format
644 */
645 public void setAccess(byte mkgmapAccess) {
646 this.mkgmapAccess = mkgmapAccess;
647 // translate internal format to that used in TableA
648 //clear the corresponding bits
649 tabAAccess &= ~(0xc077);
650 if (mkgmapAccess == (byte) 0xff)
651 return; // all vehicles allowed
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 * These affect various parts.
681 */
682
683 private int roadClass = -1;
684
685
686 // road class that goes in various places (really?)
687 public void setRoadClass(int roadClass) {
688 assert roadClass < 0x08;
689
690 /* for RouteArcs to get as their "destination class" */
691 this.roadClass = roadClass;
692
693 /* for Table A */
694 int shifted = (roadClass << 4) & 0xff;
695 tabAInfo |= shifted;
696
697 /* for NOD 2 */
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 /* for Table A */
710 tabAInfo |= speed;
711
712 /* for NOD 2 */
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 }