| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
package uk.me.parabola.imgfmt.app.mdr; |
| 15 |
|
| 16 |
import java.util.ArrayList; |
| 17 |
import java.util.Collections; |
| 18 |
import java.util.List; |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
public class Mdr22 extends Mdr2x { |
| 30 |
|
| 31 |
public Mdr22(MdrConfig config) { |
| 32 |
setConfig(config); |
| 33 |
} |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
public void buildFromStreets(List<Mdr7Record> inStreets) { |
| 45 |
ArrayList<Mdr7Record> sorted = new ArrayList<>(inStreets.size()); |
| 46 |
for (Mdr7Record street : inStreets) { |
| 47 |
if (street.getCity() != null) { |
| 48 |
assert street.getCity().getCountryName() != null; |
| 49 |
sorted.add(street); |
| 50 |
} |
| 51 |
} |
| 52 |
sorted.sort((o1, o2) -> { |
| 53 |
int d = Integer.compare(o1.getCity().getMdr22SortPos(), o2.getCity().getMdr22SortPos()); |
| 54 |
if (d != 0) |
| 55 |
return d; |
| 56 |
return Integer.compare(o1.getIndex(), o2.getIndex()); |
| 57 |
}); |
| 58 |
|
| 59 |
int lastIndex = -1; |
| 60 |
int record = 0; |
| 61 |
for (Mdr7Record street : sorted) { |
| 62 |
if (street.getIndex() != lastIndex) { |
| 63 |
record++; |
| 64 |
streets.add(street); |
| 65 |
|
| 66 |
|
| 67 |
Mdr14Record mdrCountry = street.getCity().getMdrCountry(); |
| 68 |
if (mdrCountry != null) { |
| 69 |
Mdr29Record mdr29 = mdrCountry.getMdr29(); |
| 70 |
mdr29.setMdr22(record); |
| 71 |
} |
| 72 |
|
| 73 |
lastIndex = street.getIndex(); |
| 74 |
} |
| 75 |
} |
| 76 |
} |
| 77 |
|
| 78 |
protected boolean sameGroup(Mdr7Record street1, Mdr7Record street2) { |
| 79 |
return true; |
| 80 |
} |
| 81 |
|
| 82 |
public List<Mdr7Record> getStreets() { |
| 83 |
return Collections.unmodifiableList(streets); |
| 84 |
} |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
public int getExtraValue() { |
| 90 |
int magic; |
| 91 |
if (isForDevice()) { |
| 92 |
magic = 0x0000e; |
| 93 |
if (!getConfig().getSort().isMulti()) |
| 94 |
magic |= 0xc0000; |
| 95 |
} else { |
| 96 |
magic = 0x11000; |
| 97 |
} |
| 98 |
return magic; |
| 99 |
} |
| 100 |
} |