/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package usda.weru.util.gis;

import java.io.DataInputStream;
import java.io.IOException;

/**
 *
 * @author wjr
 */
public class FileHeader {

    int fileCode = 0;
    int fileLength = 0;
    int version = 0;
    int shapeType = 0;
    double mbrMinX = 0;         // mbr -- minimum bounding rectangle
    double mbrMinY = 0;
    double mbrMaxX = 0;
    double mbrMaxY = 0;

	/**
	 *
	 * @return
	 */
	@Override
    public String toString() {
        return fileCode + " " + fileLength + " " + version + " " + shapeType + " " + mbrMinX + " " + mbrMinY + " " + mbrMaxX + " " + mbrMaxY;
    }

    void read(DataInputStream in) throws IOException {
        fileCode = in.readInt();
        for (int idx = 0; idx < 5; idx++) {
            in.readInt();
        }
        fileLength = in.readInt() * 2;
        version = Swab.swab(in.readInt());
        shapeType = Swab.swab(in.readInt());
        mbrMinX = Swab.swab(in.readDouble());
        mbrMinY = Swab.swab(in.readDouble());
        mbrMaxX = Swab.swab(in.readDouble());
        mbrMaxY = Swab.swab(in.readDouble());
        for (int idx = 0; idx < 4; idx++) {
            in.readDouble();
        }
    }
}