Search in sources :

Example 1 with Mdr13Record

use of uk.me.parabola.imgfmt.app.mdr.Mdr13Record in project mkgmap by openstreetmap.

the class MdrBuilder method addRegions.

private Map<Integer, Mdr13Record> addRegions(MapReader mr, AreaMaps maps) {
    Map<Integer, Mdr13Record> regionMap = new HashMap<>();
    List<Region> regions = mr.getRegions();
    for (Region region : regions) {
        if (region != null) {
            Mdr14Record mdr14 = maps.countries.get((int) region.getCountry().getIndex());
            Mdr13Record record = mdrFile.addRegion(region, mdr14);
            regionMap.put((int) region.getIndex(), record);
        }
    }
    return regionMap;
}
Also used : Mdr14Record(uk.me.parabola.imgfmt.app.mdr.Mdr14Record) HashMap(java.util.HashMap) Mdr13Record(uk.me.parabola.imgfmt.app.mdr.Mdr13Record) Region(uk.me.parabola.imgfmt.app.lbl.Region)

Example 2 with Mdr13Record

use of uk.me.parabola.imgfmt.app.mdr.Mdr13Record in project mkgmap by openstreetmap.

the class MdrBuilder method fetchCities.

/**
 * There is not complete information that we need about a city in the city
 * section, it has to be completed from the points section. So we fetch
 * and create the mdr5s first before points.
 */
private List<Mdr5Record> fetchCities(MapReader mr, AreaMaps maps) {
    Map<Integer, Mdr5Record> cityMap = maps.cities;
    List<Mdr5Record> cityList = new ArrayList<>();
    List<City> cities = mr.getCities();
    for (City c : cities) {
        int regionCountryNumber = c.getRegionCountryNumber();
        Mdr13Record mdrRegion = null;
        Mdr14Record mdrCountry;
        if ((regionCountryNumber & 0x4000) == 0) {
            mdrRegion = maps.regions.get(regionCountryNumber);
            mdrCountry = mdrRegion.getMdr14();
        } else {
            mdrCountry = maps.countries.get(regionCountryNumber & 0x3fff);
        }
        Mdr5Record mdrCity = new Mdr5Record();
        mdrCity.setCityIndex(c.getIndex());
        mdrCity.setRegionIndex(c.getRegionCountryNumber());
        mdrCity.setMdrRegion(mdrRegion);
        mdrCity.setMdrCountry(mdrCountry);
        mdrCity.setLblOffset(c.getLblOffset());
        mdrCity.setName(c.getName());
        int key = (c.getSubdivNumber() << 8) + (c.getPointIndex() & 0xff);
        assert key < 0xffffff;
        cityMap.put(key, mdrCity);
        cityList.add(mdrCity);
    }
    return cityList;
}
Also used : Mdr14Record(uk.me.parabola.imgfmt.app.mdr.Mdr14Record) Mdr5Record(uk.me.parabola.imgfmt.app.mdr.Mdr5Record) ArrayList(java.util.ArrayList) Mdr13Record(uk.me.parabola.imgfmt.app.mdr.Mdr13Record) City(uk.me.parabola.imgfmt.app.lbl.City) Point(uk.me.parabola.imgfmt.app.trergn.Point)

Aggregations

Mdr13Record (uk.me.parabola.imgfmt.app.mdr.Mdr13Record)2 Mdr14Record (uk.me.parabola.imgfmt.app.mdr.Mdr14Record)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 City (uk.me.parabola.imgfmt.app.lbl.City)1 Region (uk.me.parabola.imgfmt.app.lbl.Region)1 Mdr5Record (uk.me.parabola.imgfmt.app.mdr.Mdr5Record)1 Point (uk.me.parabola.imgfmt.app.trergn.Point)1