Subversion Repositories display

Rev

Rev 538 | Blame | Compare with Previous | Last modification | View Log | RSS feed

/*
 * Copyright (C) 2007 Steve Ratcliffe
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 2 as
 *  published by the Free Software Foundation.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *
 * Author: Steve Ratcliffe
 * Create date: Jan 22, 2008
 */

package test.display;

import java.util.ArrayList;
import java.util.List;

import uk.me.parabola.imgfmt.app.ImgFileReader;

/**
 * Read in just enough of tables A and B to provide the address links.
 *
 * @author Steve Ratcliffe
 */

public class TableHeader {
    private int lon;
        private int lat;
        private long position;
    private final List<Integer> links = new ArrayList<>();
        private final List<Integer> roads = new ArrayList<>();

        public TableHeader(ImgFileReader reader, int offset, int tabAReclen) {
                this.position = offset;

        long orig = reader.position();
        reader.position(offset);
        reader.get();

                lon = reader.get3s();
                lat = reader.get3s();

        int na = reader.get1u();
        int nb = reader.get1u();

                // Read in Table A
            for (int i = 0; i < na; i++) {
                        roads.add(reader.get3u() & 0x3fffff);
                    reader.get(tabAReclen - 3);
            }

                // Read in Table B
        for (int i = 0; i < nb; i++)
                        links.add(reader.get3u());

        reader.position(orig);
    }

    public int getLink(int i) {
        if (i >= links.size())
            return -1;
        return links.get(i);
    }

        public int getRoad(int ri) {
                if (ri >= roads.size())
                        return -1;
                return roads.get(ri);
        }

        public void setLong(int lon) {
                this.lon = lon;
        }

        public void setLat(int lat) {
                this.lat = lat;
        }

        public int getLat() {
                return lat;
        }

        public int getLon() {
                return lon;
        }

        public void setPosition(long position) {
                this.position = position;
        }

        public long getPosition() {
                return position;
        }
}