Search in sources :

Example 31 with Label

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

the class RGNFileReader method readLineCommon.

/**
 * Since polygons are pretty much like polylines in the img format the
 * reading code can be shared.
 *
 * @param reader The reader for the img file.
 * @param div The subdivision.
 * @param line The line or shape that is to be populated.
 */
private void readLineCommon(ImgFileReader reader, Subdivision div, Polyline line) {
    byte type = reader.get();
    if (line instanceof Polygon)
        line.setType(type & 0x7f);
    else {
        line.setType(type & 0x3f);
        line.setDirection((type & 0x40) != 0);
    }
    int labelOffset = reader.getu3();
    // Extra bit (for bit stream)
    boolean extra = (labelOffset & 0x400000) != 0;
    Label label;
    if ((labelOffset & 0x800000) == 0) {
        label = lblFile.fetchLabel(labelOffset & 0x7fffff);
    } else {
        int netoff = labelOffset & 0x3fffff;
        labelOffset = netFile.getLabelOffset(netoff);
        label = lblFile.fetchLabel(labelOffset);
        RoadDef roadDef = new RoadDef(0, netoff, label.getText());
        line.setRoadDef(roadDef);
    }
    line.setLabel(label);
    line.setDeltaLong((short) reader.getChar());
    line.setDeltaLat((short) reader.getChar());
    int len;
    if ((type & 0x80) == 0)
        len = reader.get() & 0xff;
    else
        len = reader.getChar();
    int base = reader.get();
    byte[] bitstream = reader.get(len);
    BitReader br = new BitReader(bitstream);
    // This reads the bit stream and adds all the points found
    readBitStream(br, div, line, extra, len, base);
}
Also used : Label(uk.me.parabola.imgfmt.app.Label) RoadDef(uk.me.parabola.imgfmt.app.net.RoadDef) BitReader(uk.me.parabola.imgfmt.app.BitReader)

Example 32 with Label

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

the class RGNFileReader method fetchPointsCommon.

/**
 * The indexed points and the points sections are both read just the same.
 */
private void fetchPointsCommon(Subdivision sd, long start, long end, List<Point> points) {
    position(start);
    ImgFileReader reader = getReader();
    int number = points.size() + 1;
    while (position() < end) {
        Point p = new Point(sd);
        byte t = reader.get();
        int val = reader.getu3();
        boolean hasSubtype = false;
        if ((val & 0x800000) != 0)
            hasSubtype = true;
        boolean hasPoi = false;
        if ((val & 0x400000) != 0)
            hasPoi = true;
        Label l;
        int labelOffset = val & 0x3fffff;
        if (hasPoi) {
            POIRecord record = lblFile.fetchPoi(labelOffset);
            if (record != null) {
                l = record.getNameLabel();
                p.setPOIRecord(record);
            } else
                l = lblFile.fetchLabel(0);
        } else {
            l = lblFile.fetchLabel(labelOffset);
        }
        p.setLabel(l);
        p.setDeltaLong((short) reader.getChar());
        p.setDeltaLat((short) reader.getChar());
        if (hasSubtype) {
            byte st = reader.get();
            p.setType(((t & 0xff) << 8) | (st & 0xff));
        // p.setHasSubtype(true);
        } else {
            p.setType(t & 0xff);
        }
        p.setNumber(number++);
        points.add(p);
    }
}
Also used : Label(uk.me.parabola.imgfmt.app.Label) POIRecord(uk.me.parabola.imgfmt.app.lbl.POIRecord) ImgFileReader(uk.me.parabola.imgfmt.app.ImgFileReader) BufferedImgFileReader(uk.me.parabola.imgfmt.app.BufferedImgFileReader)

Example 33 with Label

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

the class Subdivision method createPoint.

public Point createPoint(String name) {
    Point p = new Point(this);
    Label label = lblFile.newLabel(name);
    p.setLabel(label);
    return p;
}
Also used : Label(uk.me.parabola.imgfmt.app.Label)

Example 34 with Label

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

the class Subdivision method createLine.

public Polyline createLine(String[] labels) {
    // don't be tempted to "trim()" the name as it zaps the highway shields
    Label label = lblFile.newLabel(labels[0]);
    String nameSansGC = Label.stripGarminCodes(labels[0]);
    Polyline pl = new Polyline(this);
    pl.setLabel(label);
    if (labels[1] != null) {
        // ref may contain multiple ids separated by ";"
        int maxSetIdx = 3;
        if (labels[3] == null) {
            if (labels[2] == null) {
                maxSetIdx = 1;
            } else {
                maxSetIdx = 2;
            }
        }
        String[] refs = Arrays.copyOfRange(labels, 1, maxSetIdx + 1);
        if (refs.length == 1) {
            // don't bother to add a single ref that looks the
            // same as the name (sans shield) because it doesn't
            // change the routing directions
            String tr = refs[0].trim();
            String trSansGC = Label.stripGarminCodes(tr);
            if (trSansGC.length() > 0 && !trSansGC.equalsIgnoreCase(nameSansGC)) {
                pl.addRefLabel(lblFile.newLabel(tr));
            }
        } else if (refs.length > 1) {
            // multiple refs, always add the first so that it will
            // be used in routing instructions when the name has a
            // shield prefix
            pl.addRefLabel(lblFile.newLabel(refs[0].trim()));
            // name (sans shield)
            for (int i = 1; i < refs.length; ++i) {
                String tr = refs[i].trim();
                String trSansGC = Label.stripGarminCodes(tr);
                if (trSansGC.length() > 0 && !trSansGC.equalsIgnoreCase(nameSansGC)) {
                    pl.addRefLabel(lblFile.newLabel(tr));
                }
            }
        }
    }
    return pl;
}
Also used : Label(uk.me.parabola.imgfmt.app.Label)

Example 35 with Label

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

the class MapBuilder method processPOIs.

private void processPOIs(Map map, MapDataSource src) {
    LBLFile lbl = map.getLblFile();
    boolean checkedForPoiDispFlag = false;
    for (MapPoint p : src.getPoints()) {
        // special handling for highway exits
        if (p.isExit()) {
            processExit(map, (MapExitPoint) p);
        } else // * all POIs except roads in case the no-poi-address option is set
        if (!p.isCity() && !p.hasExtendedType() && poiAddresses) {
            String countryStr = p.getCountry();
            String regionStr = p.getRegion();
            String zipStr = p.getZip();
            String cityStr = p.getCity();
            if (locationAutofill.contains("nearest") && (countryStr == null || regionStr == null || (zipStr == null && cityStr == null))) {
                MapPoint nextCity = locator.findNearbyCityByName(p);
                if (nextCity == null)
                    nextCity = locator.findNextPoint(p);
                if (nextCity != null) {
                    if (countryStr == null)
                        countryStr = nextCity.getCountry();
                    if (regionStr == null)
                        regionStr = nextCity.getRegion();
                    if (zipStr == null) {
                        String cityZipStr = nextCity.getZip();
                        if (cityZipStr != null && cityZipStr.indexOf(',') < 0)
                            zipStr = cityZipStr;
                    }
                    if (cityStr == null)
                        cityStr = nextCity.getCity();
                }
            }
            if (countryStr != null && !checkedForPoiDispFlag) {
                // Different countries require different address notation
                poiDisplayFlags = locator.getPOIDispFlag(countryStr);
                checkedForPoiDispFlag = true;
            }
            POIRecord r = lbl.createPOI(p.getName());
            if (cityStr != null || regionStr != null || countryStr != null) {
                r.setCity(calcCity(lbl, cityStr, regionStr, countryStr));
            }
            if (zipStr != null) {
                Zip zip = lbl.createZip(zipStr);
                r.setZip(zip);
            }
            if (p.getStreet() != null) {
                Label streetName = lbl.newLabel(p.getStreet());
                r.setStreetName(streetName);
            }
            String houseNumber = p.getHouseNumber();
            if (houseNumber != null && !houseNumber.isEmpty()) {
                if (!r.setSimpleStreetNumber(houseNumber))
                    r.setComplexStreetNumber(lbl.newLabel(houseNumber));
            }
            String phone = p.getPhone();
            if (phone != null && !phone.isEmpty()) {
                if (!r.setSimplePhoneNumber(phone))
                    r.setComplexPhoneNumber(lbl.newLabel(phone));
            }
            poimap.put(p, r);
        }
    }
    lbl.allPOIsDone();
}
Also used : Zip(uk.me.parabola.imgfmt.app.lbl.Zip) MapPoint(uk.me.parabola.mkgmap.general.MapPoint) Label(uk.me.parabola.imgfmt.app.Label) POIRecord(uk.me.parabola.imgfmt.app.lbl.POIRecord) LBLFile(uk.me.parabola.imgfmt.app.lbl.LBLFile)

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