Search in sources :

Example 6 with ZipCodeInfo

use of uk.me.parabola.mkgmap.general.ZipCodeInfo in project mkgmap by openstreetmap.

the class CityZipWriter method compile.

public boolean compile(List<Numbers> numbers) {
    try {
        // left and right entry in zip or city table
        // current num
        int[] indexes = { defaultIndex, defaultIndex };
        // previous num
        int[] refIndexes = { defaultIndex, defaultIndex };
        int lastEncodedNodeIndex = -1;
        boolean needsWrite = false;
        for (Numbers num : numbers) {
            for (int side = 0; side < 2; side++) {
                indexes[side] = defaultIndex;
                boolean left = (side == 0);
                switch(type) {
                    case "zip":
                        ZipCodeInfo zipInfo = num.getZipCodeInfo(left);
                        if (zipInfo != null) {
                            if (zipInfo.getImgZip() != null) {
                                indexes[side] = zipInfo.getImgZip().getIndex();
                            }
                        }
                        break;
                    case "city":
                        CityInfo cityInfo = num.getCityInfo(left);
                        if (cityInfo != null) {
                            if (cityInfo.getImgCity() != null) {
                                indexes[side] = cityInfo.getImgCity().getIndex();
                            }
                        }
                        break;
                    default:
                        break;
                }
            }
            if (indexes[0] == refIndexes[0] && indexes[1] == refIndexes[1])
                continue;
            needsWrite = true;
            if (num.getIndex() > 0) {
                int range = num.getIndex() - 1;
                if (lastEncodedNodeIndex > 0)
                    range -= lastEncodedNodeIndex;
                encode(range, refIndexes);
            }
            refIndexes[0] = indexes[0];
            refIndexes[1] = indexes[1];
            lastEncodedNodeIndex = num.getIndex();
        }
        if (needsWrite) {
            int lastIndexWithNumbers = numbers.get(numbers.size() - 1).getIndex();
            int range = lastIndexWithNumbers - lastEncodedNodeIndex;
            encode(range, indexes);
        } else {
            // probably not needed
            buf.reset();
        }
    } catch (Abandon e) {
        return false;
    }
    return true;
}
Also used : CityInfo(uk.me.parabola.mkgmap.general.CityInfo) ZipCodeInfo(uk.me.parabola.mkgmap.general.ZipCodeInfo)

Example 7 with ZipCodeInfo

use of uk.me.parabola.mkgmap.general.ZipCodeInfo in project mkgmap by openstreetmap.

the class RoadDef method resetImgData.

public void resetImgData() {
    zipList = null;
    cityList = null;
    if (numbersList != null) {
        for (Numbers num : numbersList) {
            for (int side = 0; side < 2; side++) {
                boolean left = side == 0;
                CityInfo ci = num.getCityInfo(left);
                if (ci != null)
                    ci.setImgCity(null);
                ZipCodeInfo z = num.getZipCodeInfo(left);
                if (z != null)
                    z.setImgZip(null);
            }
        }
    }
}
Also used : CityInfo(uk.me.parabola.mkgmap.general.CityInfo) ZipCodeInfo(uk.me.parabola.mkgmap.general.ZipCodeInfo)

Aggregations

ZipCodeInfo (uk.me.parabola.mkgmap.general.ZipCodeInfo)7 CityInfo (uk.me.parabola.mkgmap.general.CityInfo)6 Int2IntOpenHashMap (it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Coord (uk.me.parabola.imgfmt.app.Coord)1 City (uk.me.parabola.imgfmt.app.lbl.City)1 LBLFile (uk.me.parabola.imgfmt.app.lbl.LBLFile)1 Zip (uk.me.parabola.imgfmt.app.lbl.Zip)1 NumberStyle (uk.me.parabola.imgfmt.app.net.NumberStyle)1 Numbers (uk.me.parabola.imgfmt.app.net.Numbers)1 Point (uk.me.parabola.imgfmt.app.trergn.Point)1 MapExitPoint (uk.me.parabola.mkgmap.general.MapExitPoint)1 MapLine (uk.me.parabola.mkgmap.general.MapLine)1 MapPoint (uk.me.parabola.mkgmap.general.MapPoint)1 MapRoad (uk.me.parabola.mkgmap.general.MapRoad)1 Node (uk.me.parabola.mkgmap.reader.osm.Node)1