Search in sources :

Example 16 with Label

use of uk.me.parabola.imgfmt.app.Label 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 17 with Label

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

the class MdrBuilder method addPoints.

/**
 * Read points from this map and add them to the index.
 * @param mr The currently open map.
 * @param maps Maps of regions, cities countries etc.
 */
private void addPoints(MapReader mr, AreaMaps maps) {
    List<Point> list = mr.pointsForLevel(0, MapReader.WITHOUT_EXT_TYPE_DATA);
    for (Point p : list) {
        Label label = p.getLabel();
        if (p.getNumber() > 256) {
            continue;
        }
        Mdr5Record mdrCity = null;
        boolean isCity;
        if (p.getType() >= 0x1 && p.getType() <= 0x11) {
            // This is itself a city, it gets a reference to its own MDR 5 record.
            // and we also use it to set the name of the city.
            mdrCity = maps.cities.get((p.getSubdiv().getNumber() << 8) + p.getNumber());
            if (mdrCity != null) {
                mdrCity.setLblOffset(label.getOffset());
                mdrCity.setName(label.getText());
            }
            isCity = true;
        } else {
            // This is not a city, but we have information about which city
            // it is in.  If so then add the mdr5 record number of the city.
            POIRecord poi = p.getPOIRecord();
            City c = poi.getCity();
            if (c != null)
                mdrCity = getMdr5FromCity(maps, c);
            isCity = false;
        }
        if (label != null && !label.getText().trim().isEmpty())
            mdrFile.addPoint(p, mdrCity, isCity);
    }
}
Also used : Mdr5Record(uk.me.parabola.imgfmt.app.mdr.Mdr5Record) Label(uk.me.parabola.imgfmt.app.Label) POIRecord(uk.me.parabola.imgfmt.app.lbl.POIRecord) Point(uk.me.parabola.imgfmt.app.trergn.Point) City(uk.me.parabola.imgfmt.app.lbl.City)

Example 18 with Label

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

the class LBLFile method newLabel.

/**
 * Add a new label with the given text.  Labels are shared, so that identical
 * text is always represented by the same label.
 *
 * @param text The text of the label, it will be in uppercase.
 * @return A reference to the created label.
 */
public Label newLabel(String text) {
    EncodedText encodedText = textEncoder.encodeText(text);
    Label l = labelCache.get(encodedText);
    if (l == null) {
        l = new Label(encodedText.getChars());
        labelCache.put(encodedText, l);
        l.setOffset(getNextLabelOffset());
        if (encodedText.getLength() > 0)
            getWriter().put(encodedText.getCtext(), 0, encodedText.getLength());
        alignForNext();
        if (l.getOffset() > 0x3fffff)
            throw new MapFailedException("Overflow of LBL section");
    }
    return l;
}
Also used : MapFailedException(uk.me.parabola.imgfmt.MapFailedException) EncodedText(uk.me.parabola.imgfmt.app.labelenc.EncodedText) Label(uk.me.parabola.imgfmt.app.Label)

Example 19 with Label

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

the class LBLFileReader method readCities.

/**
 * Read in the city section and cache the results here.  They are needed
 * to read in the POI properties section.
 */
private void readCities() {
    PlacesHeader placeHeader = header.getPlaceHeader();
    int start = placeHeader.getCitiesStart();
    int end = placeHeader.getCitiesEnd();
    ImgFileReader reader = getReader();
    // Since cities are indexed starting from 1, we add a null one at index 0
    reader.position(start);
    int index = 1;
    while (reader.position() < end) {
        // First is either a label offset or a point/subdiv combo, we
        // don't know until we have read further
        int label = reader.getu3();
        int info = reader.getChar();
        City city;
        if ((info & 0x4000) == 0) {
            Region region = regions.get(info & 0x3fff);
            city = new City(region);
        } else {
            Country country = countries.get(info & 0x3fff);
            city = new City(country);
        }
        city.setIndex(index);
        if ((info & 0x8000) == 0) {
            city.setSubdivision(Subdivision.createEmptySubdivision(1));
            Label label1 = labels.get(label & 0x3fffff);
            city.setLabel(label1);
        } else {
            // Has subdiv/point index
            int pointIndex = label & 0xff;
            int subdiv = (label >> 8) & 0xffff;
            city.setPointIndex((byte) pointIndex);
            city.setSubdivision(Subdivision.createEmptySubdivision(subdiv));
        }
        cities.add(city);
        index++;
    }
}
Also used : Label(uk.me.parabola.imgfmt.app.Label) ImgFileReader(uk.me.parabola.imgfmt.app.ImgFileReader) BufferedImgFileReader(uk.me.parabola.imgfmt.app.BufferedImgFileReader)

Example 20 with Label

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

the class LBLFileReader method readCountries.

/**
 * Read a cache the countries. These are used when reading cities.
 */
private void readCountries() {
    ImgFileReader reader = getReader();
    PlacesHeader placeHeader = header.getPlaceHeader();
    // 1 based indexes
    countries.add(null);
    int start = placeHeader.getCountriesStart();
    int end = placeHeader.getCountriesEnd();
    reader.position(start);
    int index = 1;
    while (reader.position() < end) {
        int offset = reader.getu3();
        Label label = fetchLabel(offset);
        if (label != null) {
            Country country = new Country(index);
            country.setLabel(label);
            countries.add(country);
        }
        index++;
    }
}
Also used : Label(uk.me.parabola.imgfmt.app.Label) ImgFileReader(uk.me.parabola.imgfmt.app.ImgFileReader) BufferedImgFileReader(uk.me.parabola.imgfmt.app.BufferedImgFileReader)

Aggregations

Label (uk.me.parabola.imgfmt.app.Label)35 BufferedImgFileReader (uk.me.parabola.imgfmt.app.BufferedImgFileReader)7 ImgFileReader (uk.me.parabola.imgfmt.app.ImgFileReader)7 POIRecord (uk.me.parabola.imgfmt.app.lbl.POIRecord)5 Point (uk.me.parabola.imgfmt.app.trergn.Point)4 ArrayList (java.util.ArrayList)2 BitReader (uk.me.parabola.imgfmt.app.BitReader)2 City (uk.me.parabola.imgfmt.app.lbl.City)2 LBLFile (uk.me.parabola.imgfmt.app.lbl.LBLFile)2 RoadDef (uk.me.parabola.imgfmt.app.net.RoadDef)2 MapPoint (uk.me.parabola.mkgmap.general.MapPoint)2 HashMap (java.util.HashMap)1 Random (java.util.Random)1 MapFailedException (uk.me.parabola.imgfmt.MapFailedException)1 BitWriter (uk.me.parabola.imgfmt.app.BitWriter)1 BufferedImgFileWriter (uk.me.parabola.imgfmt.app.BufferedImgFileWriter)1 Exit (uk.me.parabola.imgfmt.app.Exit)1 ImgFileWriter (uk.me.parabola.imgfmt.app.ImgFileWriter)1 Section (uk.me.parabola.imgfmt.app.Section)1 DecodedText (uk.me.parabola.imgfmt.app.labelenc.DecodedText)1