Search in sources :

Example 21 with Label

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

the class LBLFileReader method readPoiInfo.

/**
 * Read all the POI information.
 * This will create a POIRecord, but we just get the name at the minute.
 *
 * TODO: not finished
 */
private void readPoiInfo() {
    ImgFileReader reader = getReader();
    PlacesHeader placeHeader = header.getPlaceHeader();
    int poiGlobalFlags = placeHeader.getPOIGlobalFlags();
    int start = placeHeader.getPoiPropertiesStart();
    int end = placeHeader.getPoiPropertiesEnd();
    reader.position(start);
    PoiMasks localMask = makeLocalMask(placeHeader);
    while (reader.position() < end) {
        int poiOffset = position() - start;
        int val = reader.getu3();
        int labelOffset = val & 0x3fffff;
        boolean override = (val & 0x800000) != 0;
        POIRecord poi = new POIRecord();
        poi.setLabel(fetchLabel(labelOffset));
        // We have what we want, but now have to find the start of the
        // next record as they are not fixed length.
        int flags;
        boolean hasStreet;
        boolean hasStreetNum;
        boolean hasCity;
        boolean hasZip;
        boolean hasPhone;
        boolean hasHighwayExit;
        boolean hasTides;
        if (override) {
            flags = reader.get();
            hasStreetNum = (flags & localMask.streetNumMask) != 0;
            hasStreet = (flags & localMask.streetMask) != 0;
            hasCity = (flags & localMask.cityMask) != 0;
            hasZip = (flags & localMask.zipMask) != 0;
            hasPhone = (flags & localMask.phoneMask) != 0;
            hasHighwayExit = (flags & localMask.highwayExitMask) != 0;
            hasTides = (flags & localMask.tidesMask) != 0;
        } else {
            flags = poiGlobalFlags;
            hasStreetNum = (flags & POIRecord.HAS_STREET_NUM) != 0;
            hasStreet = (flags & POIRecord.HAS_STREET) != 0;
            hasCity = (flags & POIRecord.HAS_CITY) != 0;
            hasZip = (flags & POIRecord.HAS_ZIP) != 0;
            hasPhone = (flags & POIRecord.HAS_PHONE) != 0;
            hasHighwayExit = (flags & POIRecord.HAS_EXIT) != 0;
            hasTides = (flags & POIRecord.HAS_TIDE_PREDICTION) != 0;
        }
        if (hasStreetNum) {
            byte b = reader.get();
            if ((b & 0x80) == 0) {
                int mpoffset = (b << 16) & 0xff0000;
                mpoffset |= reader.getChar() & 0xffff;
                poi.setComplexStreetNumber(fetchLabel(mpoffset));
            } else {
                poi.setSimpleStreetNumber(reader.getBase11str(b, '-'));
            }
        }
        if (hasStreet) {
            // label for street
            int streetNameOffset = reader.getu3();
            Label label = fetchLabel(streetNameOffset);
            poi.setStreetName(label);
        }
        if (hasCity) {
            int cityIndex = reader.getUint(Utils.numberToPointerSize(placeHeader.getNumCities()));
            poi.setCity(cities.get(cityIndex - 1));
        }
        if (hasZip) {
            int zipIndex = reader.getUint(Utils.numberToPointerSize(placeHeader.getNumZips()));
            poi.setZip(zips.get(zipIndex - 1));
        }
        if (hasPhone) {
            byte b = reader.get();
            if ((b & 0x80) == 0) {
                // Yes this is a bit strange it is a byte followed by a char
                int mpoffset = (b << 16) & 0xff0000;
                mpoffset |= reader.getChar() & 0xffff;
                poi.setComplexPhoneNumber(fetchLabel(mpoffset));
            } else {
                poi.setSimplePhoneNumber(reader.getBase11str(b, '-'));
            }
        }
        if (hasHighwayExit) {
            int lblinfo = reader.getu3();
            int highwayLabelOffset = lblinfo & 0x3FFFF;
            boolean indexed = (lblinfo & 0x800000) != 0;
            boolean overnightParking = (lblinfo & 0x400000) != 0;
            int highwayIndex = reader.getUint(Utils.numberToPointerSize(placeHeader.getNumHighways()));
            if (indexed) {
                int eidx = reader.getUint(Utils.numberToPointerSize(placeHeader.getNumExits()));
            }
        }
        if (hasTides) {
            System.out.println("Map has tide prediction, please implement!");
        }
        pois.put(poiOffset, poi);
    }
}
Also used : Label(uk.me.parabola.imgfmt.app.Label) ImgFileReader(uk.me.parabola.imgfmt.app.ImgFileReader) BufferedImgFileReader(uk.me.parabola.imgfmt.app.BufferedImgFileReader)

Example 22 with Label

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

the class LBLFileReader method readRegions.

/**
 * Read an cache the regions.  These are used when reading cities.
 */
private void readRegions() {
    ImgFileReader reader = getReader();
    PlacesHeader placeHeader = header.getPlaceHeader();
    int start = placeHeader.getRegionsStart();
    int end = placeHeader.getRegionsEnd();
    regions.add(null);
    reader.position(start);
    int index = 1;
    while (reader.position() < end) {
        int country = reader.getChar();
        int offset = reader.getu3();
        Label label = fetchLabel(offset);
        if (label != null) {
            Region region = new Region(countries.get(country));
            region.setIndex(index);
            region.setLabel(label);
            regions.add(region);
        }
        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 23 with Label

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

the class PlacesFile method createExitPOI.

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

Example 24 with Label

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

the class PlacesFile method createCity.

City createCity(Region region, String name, boolean unique) {
    String uniqueCityName = name.toUpperCase() + "_R" + region.getLabel().getOffset();
    // if unique is true, make sure that the name really is unique
    if (unique && cities.get(uniqueCityName) != null) {
        do {
            // add semi-random suffix.
            uniqueCityName += "_" + random.nextInt(0x10000);
        } while (cities.get(uniqueCityName) != null);
    }
    City c = null;
    if (!unique)
        c = cities.get(uniqueCityName);
    if (c == null) {
        c = new City(region);
        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 : Label(uk.me.parabola.imgfmt.app.Label)

Example 25 with Label

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

the class PlacesFile method createExitFacility.

public ExitFacility createExitFacility(int type, char direction, int facilities, String description, boolean last) {
    Label d = lblFile.newLabel(description);
    ExitFacility ef = new ExitFacility(type, direction, facilities, d, last, exitFacilities.size() + 1);
    exitFacilities.add(ef);
    return ef;
}
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