Search in sources :

Example 16 with MapFailedException

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

the class FileBackedImgFileWriter method putChar.

/**
 * Write out two bytes. Can't use writeChar() since need to reverse the byte
 * order.
 *
 * @param c The value to write.
 */
public void putChar(char c) {
    try {
        file.write(c);
        file.write(c >> 8);
    } catch (IOException e) {
        throw new MapFailedException("could not write char to mdr tmp file");
    }
}
Also used : MapFailedException(uk.me.parabola.imgfmt.MapFailedException) IOException(java.io.IOException)

Example 17 with MapFailedException

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

the class FileBackedImgFileWriter method putN.

/**
 * Write out 1-4 bytes.  Done in the correct byte order.
 *
 * @param nBytes The number of bytes to write.
 * @param val The value to write.
 */
public void putN(int nBytes, int val) {
    try {
        file.write(val);
        if (nBytes <= 1)
            return;
        file.write(val >> 8);
        if (nBytes <= 2)
            return;
        file.write(val >> 16);
        if (nBytes <= 3)
            return;
        file.write(val >> 24);
    } catch (IOException e) {
        throw new MapFailedException("could not write put3 to mdr tmp file");
    }
}
Also used : MapFailedException(uk.me.parabola.imgfmt.MapFailedException) IOException(java.io.IOException)

Example 18 with MapFailedException

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

the class FileBackedImgFileWriter method put.

/**
 * Write out a complete byte buffer.
 *
 * @param src The buffer to write.
 */
public void put(ByteBuffer src) {
    try {
        file.flush();
        tmpChannel.write(src);
    } catch (IOException e) {
        throw new MapFailedException("could not write buffer to mdr tmp file");
    }
}
Also used : MapFailedException(uk.me.parabola.imgfmt.MapFailedException) IOException(java.io.IOException)

Example 19 with MapFailedException

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

the class FileBackedImgFileWriter method put2.

/**
 * Write out int in range 0..65535 as two bytes in correct byte order.
 * Use instead of putChar() for unsigned for clarity.
 * @param val The value to write.
 */
public void put2(int val) {
    assert val >= 0 && val <= 65535 : val;
    try {
        file.write(val);
        file.write(val >> 8);
    } catch (IOException e) {
        throw new MapFailedException("could not write 2 bytes to mdr tmp file");
    }
}
Also used : MapFailedException(uk.me.parabola.imgfmt.MapFailedException) IOException(java.io.IOException)

Example 20 with MapFailedException

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

the class FileCopier method init.

public void init(CommandArgs args) {
    areaName = args.get("area-name", null);
    mapsetName = args.get("mapset-name", "OSM map set");
    overallDescription = args.getDescription();
    outputDir = args.getOutputDir();
    hideGmapsuppOnPC = args.get("hide-gmapsupp-on-pc", false);
    productVersion = args.get("product-version", 100);
    mdrConfig = new MdrConfig();
    mdrConfig.setIndexOptions(args);
    try {
        imgFs = createGmapsupp();
    } catch (FileNotWritableException e) {
        throw new MapFailedException("Could not create gmapsupp.img file");
    }
}
Also used : FileNotWritableException(uk.me.parabola.imgfmt.FileNotWritableException) MapFailedException(uk.me.parabola.imgfmt.MapFailedException) MdrConfig(uk.me.parabola.imgfmt.app.mdr.MdrConfig)

Aggregations

MapFailedException (uk.me.parabola.imgfmt.MapFailedException)22 IOException (java.io.IOException)11 File (java.io.File)4 FileNotFoundException (java.io.FileNotFoundException)4 TypData (uk.me.parabola.imgfmt.app.typ.TypData)3 SyntaxException (uk.me.parabola.mkgmap.scan.SyntaxException)3 FileInputStream (java.io.FileInputStream)2 OutOfMemoryError (java.lang.OutOfMemoryError)2 ExitException (uk.me.parabola.imgfmt.ExitException)2 FileNotWritableException (uk.me.parabola.imgfmt.FileNotWritableException)2 TYPFile (uk.me.parabola.imgfmt.app.typ.TYPFile)2 Path2D (java.awt.geom.Path2D)1 Rectangle2D (java.awt.geom.Rectangle2D)1 BufferedReader (java.io.BufferedReader)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MemoryPoolMXBean (java.lang.management.MemoryPoolMXBean)1 MemoryUsage (java.lang.management.MemoryUsage)1 ByteBuffer (java.nio.ByteBuffer)1