Search in sources :

Example 1 with Region

use of uk.me.parabola.imgfmt.app.lbl.Region in project mkgmap by openstreetmap.

the class MapBuilder method processCities.

/**
 * Processing of Cities
 *
 * Fills the city list in lbl block that is required for find by name
 * It also builds up information that is required to get address info
 * for the POIs
 *
 * @param map The map.
 * @param src The map data.
 */
private void processCities(Map map, MapDataSource src) {
    LBLFile lbl = map.getLblFile();
    if (locationAutofill.isEmpty() == false) {
        // collect the names of the cities
        for (MapPoint p : src.getPoints()) {
            if (p.isCity() && p.getName() != null)
                // Put the city info the map for missing info
                locator.addCityOrPlace(p);
        }
        // Try to fill missing information that include search of next city
        locator.autofillCities();
    }
    for (MapPoint p : src.getPoints()) {
        if (p.isCity() && p.getName() != null) {
            String countryStr = p.getCountry();
            Country thisCountry;
            if (countryStr != null) {
                thisCountry = lbl.createCountry(countryStr, locator.getCountryISOCode(countryStr));
            } else
                thisCountry = getDefaultCountry();
            String regionStr = p.getRegion();
            Region thisRegion;
            if (regionStr != null) {
                thisRegion = lbl.createRegion(thisCountry, regionStr, null);
            } else
                thisRegion = getDefaultRegion(thisCountry);
            City thisCity;
            if (thisRegion != null)
                thisCity = lbl.createCity(thisRegion, p.getName(), true);
            else
                thisCity = lbl.createCity(thisCountry, p.getName(), true);
            cityMap.put(p, thisCity);
        }
    }
}
Also used : MapPoint(uk.me.parabola.mkgmap.general.MapPoint) Country(uk.me.parabola.imgfmt.app.lbl.Country) Region(uk.me.parabola.imgfmt.app.lbl.Region) LBLFile(uk.me.parabola.imgfmt.app.lbl.LBLFile) City(uk.me.parabola.imgfmt.app.lbl.City)

Example 2 with Region

use of uk.me.parabola.imgfmt.app.lbl.Region 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 3 with Region

use of uk.me.parabola.imgfmt.app.lbl.Region in project mkgmap by openstreetmap.

the class MapBuilder method calcCity.

private City calcCity(LBLFile lbl, String city, String region, String country) {
    if (city == null && region == null && country == null)
        return null;
    Country cc = (country == null) ? getDefaultCountry() : lbl.createCountry(locator.normalizeCountry(country), locator.getCountryISOCode(country));
    Region cr = (region == null) ? getDefaultRegion(cc) : lbl.createRegion(cc, region, null);
    if (city == null && (country != null || region != null)) {
        // if city name is unknown and region and/or country is known
        // use empty name for the city
        city = UNKNOWN_CITY_NAME;
    }
    if (city == null)
        return null;
    if (cr != null) {
        return lbl.createCity(cr, city, false);
    } else {
        return lbl.createCity(cc, city, false);
    }
}
Also used : Country(uk.me.parabola.imgfmt.app.lbl.Country) Region(uk.me.parabola.imgfmt.app.lbl.Region)

Aggregations

Region (uk.me.parabola.imgfmt.app.lbl.Region)3 Country (uk.me.parabola.imgfmt.app.lbl.Country)2 HashMap (java.util.HashMap)1 City (uk.me.parabola.imgfmt.app.lbl.City)1 LBLFile (uk.me.parabola.imgfmt.app.lbl.LBLFile)1 Mdr13Record (uk.me.parabola.imgfmt.app.mdr.Mdr13Record)1 Mdr14Record (uk.me.parabola.imgfmt.app.mdr.Mdr14Record)1 MapPoint (uk.me.parabola.mkgmap.general.MapPoint)1