use of uk.me.parabola.imgfmt.app.srt.SortKey in project mkgmap by openstreetmap.
the class Mdr24 method sortCountries.
/**
* Sort the countries by name. Duplicates are kept.
* @param list The full list of countries.
*/
public void sortCountries(List<Mdr14Record> list) {
Sort sort = getConfig().getSort();
List<SortKey<Mdr14Record>> keys = MdrUtils.sortList(sort, list);
Collections.sort(keys);
String lastName = null;
int lastMapIndex = 0;
int record = 0;
for (SortKey<Mdr14Record> key : keys) {
Mdr14Record c = key.getObject();
// If this is a new name, then we prepare a mdr29 record for it.
String name = c.getName();
if (lastMapIndex != c.getMapIndex() || !name.equals(lastName)) {
record++;
c.getMdr29().setMdr24(record);
countries.add(c);
lastName = name;
lastMapIndex = c.getMapIndex();
}
}
}
use of uk.me.parabola.imgfmt.app.srt.SortKey in project mkgmap by openstreetmap.
the class Mdr28 method buildFromRegions.
public void buildFromRegions(List<Mdr13Record> regions) {
Sort sort = getConfig().getSort();
List<SortKey<Mdr13Record>> keys = MdrUtils.sortList(sort, regions);
int record = 0;
Mdr28Record mdr28 = null;
String lastName = null;
for (SortKey<Mdr13Record> key : keys) {
Mdr13Record region = key.getObject();
String name = region.getName();
if (!name.equals(lastName)) {
record++;
mdr28 = new Mdr28Record();
mdr28.setIndex(record);
mdr28.setName(name);
mdr28.setStrOffset(region.getStrOffset());
mdr28.setMdr14(region.getMdr14());
index.add(mdr28);
lastName = name;
}
assert mdr28 != null;
region.setMdr28(mdr28);
}
}
use of uk.me.parabola.imgfmt.app.srt.SortKey in project mkgmap by openstreetmap.
the class Mdr29 method buildFromCountries.
public void buildFromCountries(List<Mdr14Record> countries) {
Sort sort = getConfig().getSort();
List<SortKey<Mdr14Record>> keys = MdrUtils.sortList(sort, countries);
// Sorted by name, for every new name we allocate a new 29 record and set the same one in every
// country with the same name.
String lastName = null;
Mdr29Record mdr29 = null;
for (SortKey<Mdr14Record> key : keys) {
Mdr14Record country = key.getObject();
String name = country.getName();
if (!name.equals(lastName)) {
mdr29 = new Mdr29Record();
mdr29.setName(name);
mdr29.setStrOffset(country.getStrOff());
index.add(mdr29);
lastName = name;
}
assert mdr29 != null;
country.setMdr29(mdr29);
}
}
Aggregations