Search in sources :

Example 1 with LBLFile

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

the class MapBuilder method processExit.

private void processExit(Map map, MapExitPoint mep) {
    LBLFile lbl = map.getLblFile();
    String ref = mep.getMotorwayRef();
    String OSMId = mep.getOSMId();
    if (ref != null) {
        Highway hw = highways.get(ref);
        if (hw == null)
            hw = makeHighway(map, ref);
        if (hw == null) {
            log.warn("Can't create exit", mep.getName(), "(OSM id", OSMId, ") on unknown highway", ref);
            return;
        }
        String exitName = mep.getName();
        String exitTo = mep.getTo();
        Exit exit = new Exit(hw);
        String facilityDescription = mep.getFacilityDescription();
        log.info("Creating", ref, "exit", exitName, "(OSM id", OSMId + ") to", exitTo, "with facility", ((facilityDescription == null) ? "(none)" : facilityDescription));
        if (facilityDescription != null) {
            // description is TYPE,DIR,FACILITIES,LABEL
            // (same as Polish Format)
            String[] atts = facilityDescription.split(",");
            int type = 0;
            if (atts.length > 0)
                type = Integer.decode(atts[0]);
            char direction = ' ';
            if (atts.length > 1) {
                direction = atts[1].charAt(0);
                if (direction == '\'' && atts[1].length() > 1)
                    direction = atts[1].charAt(1);
            }
            int facilities = 0x0;
            if (atts.length > 2)
                facilities = Integer.decode(atts[2]);
            String description = "";
            if (atts.length > 3)
                description = atts[3];
            // FIXME - handle multiple facilities?
            boolean last = true;
            ExitFacility ef = lbl.createExitFacility(type, direction, facilities, description, last);
            exit.addFacility(ef);
        }
        mep.setExit(exit);
        POIRecord r = lbl.createExitPOI(exitName, exit);
        if (exitTo != null) {
            Label ed = lbl.newLabel(exitTo);
            exit.setDescription(ed);
        }
        poimap.put(mep, r);
    // FIXME - set bottom bits of
    // type to reflect facilities available?
    }
}
Also used : Highway(uk.me.parabola.imgfmt.app.lbl.Highway) Label(uk.me.parabola.imgfmt.app.Label) POIRecord(uk.me.parabola.imgfmt.app.lbl.POIRecord) LBLFile(uk.me.parabola.imgfmt.app.lbl.LBLFile) MapPoint(uk.me.parabola.mkgmap.general.MapPoint) MapExitPoint(uk.me.parabola.mkgmap.general.MapExitPoint) Point(uk.me.parabola.imgfmt.app.trergn.Point) ExitFacility(uk.me.parabola.imgfmt.app.lbl.ExitFacility) Exit(uk.me.parabola.imgfmt.app.Exit)

Example 2 with LBLFile

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

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

the class MapBuilder method makeHighway.

Highway makeHighway(Map map, String ref) {
    if (getDefaultRegion(null) == null) {
        log.warn("Highway " + ref + " has no region (define a default region to zap this warning)");
    }
    Highway hw = highways.get(ref);
    if (hw == null) {
        LBLFile lblFile = map.getLblFile();
        log.info("creating highway " + ref);
        hw = lblFile.createHighway(getDefaultRegion(null), ref);
        highways.put(ref, hw);
    }
    return hw;
}
Also used : Highway(uk.me.parabola.imgfmt.app.lbl.Highway) LBLFile(uk.me.parabola.imgfmt.app.lbl.LBLFile)

Example 4 with LBLFile

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

the class MapBuilder method processRoads.

private void processRoads(Map map, MapDataSource src) {
    LBLFile lbl = map.getLblFile();
    MapPoint searchPoint = new MapPoint();
    for (MapLine line : src.getLines()) {
        if (line.isRoad()) {
            String cityName = line.getCity();
            String cityCountryName = line.getCountry();
            String cityRegionName = line.getRegion();
            String zipStr = line.getZip();
            if (cityName == null && locationAutofill.contains("nearest")) {
                // Get name of next city if untagged
                searchPoint.setLocation(line.getLocation());
                MapPoint nextCity = locator.findNextPoint(searchPoint);
                if (nextCity != null) {
                    cityName = nextCity.getCity();
                    // city/region/country fields should match to the found city
                    cityCountryName = nextCity.getCountry();
                    cityRegionName = nextCity.getRegion();
                    // use the zip code only if no zip code is known
                    if (zipStr == null)
                        zipStr = nextCity.getZip();
                }
            }
            MapRoad road = (MapRoad) line;
            road.resetImgData();
            City roadCity = calcCity(lbl, cityName, cityRegionName, cityCountryName);
            if (roadCity != null)
                road.addRoadCity(roadCity);
            if (zipStr != null) {
                road.addRoadZip(lbl.createZip(zipStr));
            }
            List<Numbers> numbers = road.getRoadDef().getNumbersList();
            if (numbers != null) {
                for (Numbers num : numbers) {
                    for (int i = 0; i < 2; i++) {
                        boolean left = (i == 0);
                        ZipCodeInfo zipInfo = num.getZipCodeInfo(left);
                        if (zipInfo != null && zipInfo.getZipCode() != null) {
                            Zip zip = zipInfo.getImgZip();
                            if (zipInfo.getImgZip() == null) {
                                zip = lbl.createZip(zipInfo.getZipCode());
                                zipInfo.setImgZip(zip);
                            }
                            if (zip != null)
                                road.addRoadZip(zip);
                        }
                        CityInfo cityInfo = num.getCityInfo(left);
                        if (cityInfo != null) {
                            City city = cityInfo.getImgCity();
                            if (city == null) {
                                city = calcCity(lbl, cityInfo.getCity(), cityInfo.getRegion(), cityInfo.getCountry());
                                cityInfo.setImgCity(city);
                            }
                            if (city != null)
                                road.addRoadCity(city);
                        }
                    }
                }
            }
        }
    }
}
Also used : Zip(uk.me.parabola.imgfmt.app.lbl.Zip) CityInfo(uk.me.parabola.mkgmap.general.CityInfo) MapLine(uk.me.parabola.mkgmap.general.MapLine) MapPoint(uk.me.parabola.mkgmap.general.MapPoint) MapRoad(uk.me.parabola.mkgmap.general.MapRoad) City(uk.me.parabola.imgfmt.app.lbl.City) MapPoint(uk.me.parabola.mkgmap.general.MapPoint) MapExitPoint(uk.me.parabola.mkgmap.general.MapExitPoint) Point(uk.me.parabola.imgfmt.app.trergn.Point) Numbers(uk.me.parabola.imgfmt.app.net.Numbers) ZipCodeInfo(uk.me.parabola.mkgmap.general.ZipCodeInfo) LBLFile(uk.me.parabola.imgfmt.app.lbl.LBLFile)

Example 5 with LBLFile

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

the class Map method createMap.

/**
 * Create a complete map.  This consists of (at least) three
 * files that all have the same basename and different extensions.
 *
 * @param mapname The name of the map.  This is an 8 digit number as a
 * string.
 * @param params Parameters that describe the file system that the map
 * will be created in.
 * @return A map object that holds together all the files that make it up.
 * @throws FileExistsException If the file already exists and we do not
 * want to overwrite it.
 * @throws FileNotWritableException If the file cannot
 * be opened for write.
 */
public static Map createMap(String mapname, String outputdir, FileSystemParam params, String mapnumber, Sort sort) throws FileExistsException, FileNotWritableException {
    Map m = new Map();
    m.mapName = mapname;
    String outFilename = Utils.joinPath(outputdir, mapname, "img");
    FileSystem fs = ImgFS.createFs(outFilename, params);
    m.filename = outFilename;
    m.fileSystem = fs;
    m.rgnFile = new RGNFile(m.fileSystem.create(mapnumber + ".RGN"));
    m.treFile = new TREFile(m.fileSystem.create(mapnumber + ".TRE"));
    m.lblFile = new LBLFile(m.fileSystem.create(mapnumber + ".LBL"), sort);
    int mapid;
    try {
        mapid = Integer.parseInt(mapnumber);
    } catch (NumberFormatException e) {
        mapid = 0;
    }
    m.mapId = mapid;
    m.treFile.setMapId(mapid);
    m.fileSystem = fs;
    return m;
}
Also used : TREFile(uk.me.parabola.imgfmt.app.trergn.TREFile) RGNFile(uk.me.parabola.imgfmt.app.trergn.RGNFile) FileSystem(uk.me.parabola.imgfmt.fs.FileSystem) LBLFile(uk.me.parabola.imgfmt.app.lbl.LBLFile)

Aggregations

LBLFile (uk.me.parabola.imgfmt.app.lbl.LBLFile)7 MapPoint (uk.me.parabola.mkgmap.general.MapPoint)5 City (uk.me.parabola.imgfmt.app.lbl.City)3 POIRecord (uk.me.parabola.imgfmt.app.lbl.POIRecord)3 Point (uk.me.parabola.imgfmt.app.trergn.Point)3 MapExitPoint (uk.me.parabola.mkgmap.general.MapExitPoint)3 Exit (uk.me.parabola.imgfmt.app.Exit)2 Label (uk.me.parabola.imgfmt.app.Label)2 Highway (uk.me.parabola.imgfmt.app.lbl.Highway)2 Zip (uk.me.parabola.imgfmt.app.lbl.Zip)2 Coord (uk.me.parabola.imgfmt.app.Coord)1 Country (uk.me.parabola.imgfmt.app.lbl.Country)1 ExitFacility (uk.me.parabola.imgfmt.app.lbl.ExitFacility)1 Region (uk.me.parabola.imgfmt.app.lbl.Region)1 Numbers (uk.me.parabola.imgfmt.app.net.Numbers)1 ExtTypeAttributes (uk.me.parabola.imgfmt.app.trergn.ExtTypeAttributes)1 RGNFile (uk.me.parabola.imgfmt.app.trergn.RGNFile)1 TREFile (uk.me.parabola.imgfmt.app.trergn.TREFile)1 FileSystem (uk.me.parabola.imgfmt.fs.FileSystem)1 CityInfo (uk.me.parabola.mkgmap.general.CityInfo)1