Search in sources :

Example 1 with Label

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

the class POIRecord method write.

void write(ImgFileWriter writer, byte POIGlobalFlags, int realofs, long numCities, long numZips, long numHighways, long numExitFacilities) {
    assert offset == realofs : "offset = " + offset + " realofs = " + realofs;
    int ptr = poiName.getOffset();
    if (POIGlobalFlags != getPOIFlags())
        ptr |= 0x800000;
    writer.put3(ptr);
    if (POIGlobalFlags != getPOIFlags())
        writer.put(getWrittenPOIFlags(POIGlobalFlags));
    if (streetNumberName != null) {
        int labOff = streetNumberName.getOffset();
        writer.put((byte) ((labOff & 0x7F0000) >> 16));
        writer.putChar((char) (labOff & 0xFFFF));
    } else if (simpleStreetNumber.isUsed())
        simpleStreetNumber.write(writer);
    if (streetName != null)
        writer.put3(streetName.getOffset());
    if (city != null) {
        char cityIndex = (char) city.getIndex();
        writer.putN(Utils.numberToPointerSize((int) numCities), cityIndex);
    }
    if (zip != null) {
        char zipIndex = (char) zip.getIndex();
        writer.putN(Utils.numberToPointerSize((int) numZips), zipIndex);
    }
    if (complexPhoneNumber != null) {
        int labOff = complexPhoneNumber.getOffset();
        writer.put((byte) ((labOff & 0x7F0000) >> 16));
        writer.putChar((char) (labOff & 0xFFFF));
    } else if (simplePhoneNumber.isUsed())
        simplePhoneNumber.write(writer);
    if (exit != null) {
        Label description = exit.getDescription();
        int val = 0;
        if (description != null) {
            val = description.getOffset();
            assert val < 0x400000 : "Exit description label offset too large";
        }
        if (exit.getOvernightParking())
            val |= 0x400000;
        List<ExitFacility> facilites = exit.getFacilities();
        ExitFacility ef = null;
        if (!facilites.isEmpty())
            ef = facilites.get(0);
        if (ef != null)
            // exit facilities defined
            val |= 0x800000;
        writer.put3(val);
        char highwayIndex = (char) exit.getHighway().getIndex();
        writer.putN(Utils.numberToPointerSize((int) numHighways), highwayIndex);
        if (ef != null) {
            char exitFacilityIndex = (char) ef.getIndex();
            writer.putN(Utils.numberToPointerSize((int) numExitFacilities), exitFacilityIndex);
        }
    }
}
Also used : Label(uk.me.parabola.imgfmt.app.Label)

Example 2 with Label

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

the class PlacesFile method createPOI.

POIRecord createPOI(String name) {
    assert !poisClosed;
    // TODO...
    POIRecord p = new POIRecord();
    Label l = lblFile.newLabel(name);
    p.setLabel(l);
    pois.add(p);
    return p;
}
Also used : Label(uk.me.parabola.imgfmt.app.Label)

Example 3 with Label

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

the class PlacesFile method createCountry.

Country createCountry(String name, String abbr) {
    String s = abbr != null ? name + (char) 0x1d + abbr : name;
    Country c = countries.get(s);
    if (c == null) {
        c = new Country(countries.size() + 1);
        Label l = lblFile.newLabel(s);
        c.setLabel(l);
        countries.put(s, c);
    }
    return c;
}
Also used : Label(uk.me.parabola.imgfmt.app.Label)

Example 4 with Label

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

the class PlacesFile method createCity.

City createCity(Country country, String name, boolean unique) {
    String uniqueCityName = name.toUpperCase() + "_C" + country.getLabel().getOffset();
    // if unique is true, make sure that the name really is unique
    if (unique && cities.get(uniqueCityName) != null) {
        do {
            // add random suffix
            uniqueCityName += "_" + new Random().nextInt(0x10000);
        } while (cities.get(uniqueCityName) != null);
    }
    City c = null;
    if (!unique)
        c = cities.get(uniqueCityName);
    if (c == null) {
        c = new City(country);
        Label l = lblFile.newLabel(name);
        c.setLabel(l);
        cityList.add(c);
        cities.put(uniqueCityName, c);
        assert cityList.size() == cities.size() : " cityList and cities are different lengths after inserting " + name + " and " + uniqueCityName;
    }
    return c;
}
Also used : Random(java.util.Random) Label(uk.me.parabola.imgfmt.app.Label)

Example 5 with Label

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

the class PlacesFile method createHighway.

Highway createHighway(Region region, String name) {
    Highway h = new Highway(region, highways.size() + 1);
    Label l = lblFile.newLabel(name);
    h.setLabel(l);
    highways.add(h);
    return h;
}
Also used : Label(uk.me.parabola.imgfmt.app.Label)

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