Debian Codegraph @

src/uk/me/parabola/imgfmt/app/mdr/Mdr21.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2011.
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 3 or
6 * version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 */
13 package uk.me.parabola.imgfmt.app.mdr;
14
15 import java.util.ArrayList;
16 import java.util.List;
17
18 /**
19 * This section contains the streets sorted by region.
20 * There is no pointer from region, unlike in the case with cities.
21 *
22 * @author Steve Ratcliffe
23 * @author Gerd Petermann
24 */
25 public class Mdr21 extends Mdr2x {
26
27 public Mdr21(MdrConfig config) {
28 setConfig(config);
29 }
30
31 /**
32 * We need to sort the streets by the name of their region. Within a region
33 * group the streets are ordered by their own index.
34 *
35 * @param inStreets The list of streets from mdr7.
36 */
37 public void buildFromStreets(List<Mdr7Record> inStreets) {
38 ArrayList<Mdr7Record> sorted = new ArrayList<>(inStreets.size());
39 for (Mdr7Record street : inStreets) {
40 if (street.getCity() != null && street.getCity().getMdrRegion() != null)
41 sorted.add(street);
42 }
43 sorted.sort((o1, o2) -> {
44 int d = Integer.compare(o1.getCity().getMdr21SortPos(), o2.getCity().getMdr21SortPos());
45 if (d != 0)
46 return d;
47 return Integer.compare(o1.getIndex(), o2.getIndex());
48 });
49
50 int lastIndex = -1;
51 int record = 0;
52 for (Mdr7Record street : sorted) {
53 if (lastIndex != street.getIndex()) {
54 record++;
55 streets.add(street);
56
57 Mdr13Record mdrRegion = street.getCity().getMdrRegion();
58 if (mdrRegion != null) {
59 Mdr28Record mdr28 = mdrRegion.getMdr28();
60 mdr28.setMdr21(record);
61 }
62
63 lastIndex = street.getIndex();
64 }
65 }
66 }
67
68 protected boolean sameGroup(Mdr7Record street1, Mdr7Record street2) {
69 return true;
70 }
71
72 /**
73 * Not known what these flags signify.
74 */
75 public int getExtraValue() {
76 return 0x11800;
77 }
78 }