Search in sources :

Example 1 with Country

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

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

the class MdrBuilder method addCountries.

private Map<Integer, Mdr14Record> addCountries(MapReader mr) {
    Map<Integer, Mdr14Record> countryMap = new HashMap<>();
    List<Country> countries = mr.getCountries();
    for (Country c : countries) {
        if (c != null) {
            Mdr14Record record = mdrFile.addCountry(c);
            countryMap.put((int) c.getIndex(), record);
        }
    }
    return countryMap;
}
Also used : Mdr14Record(uk.me.parabola.imgfmt.app.mdr.Mdr14Record) HashMap(java.util.HashMap) Country(uk.me.parabola.imgfmt.app.lbl.Country)

Example 3 with Country

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

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