~ubuntu-branches/ubuntu/oneiric/mkgmap/oneiric

« back to all changes in this revision

Viewing changes to src/uk/me/parabola/imgfmt/app/trergn/RGNFile.java

  • Committer: Bazaar Package Importer
  • Author(s): Francesco Paolo Lovergine, Andreas Putzo, Francesco Paolo Lovergine
  • Date: 2009-07-16 11:10:16 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090716111016-yycxqya1f26xmti7
Tags: 0.0.0+svn1067-1
[ Andreas Putzo ]
* New upstream snapshot.
* Added ${misc:Depends} among dependencies to fix a lintian warning.
* Bumped debhelper compatibility level to 7.
* Updated long description.
* Updated Homepage in debian/control, debian/copyright, debian/watch.
* Added numerous files from /doc to debian/docs.
* Mentioned Bernhard Heibler in debian/copyright and updated copyright
  year of software and packaging.
* Bumped policy to 3.8.2, without changes.
* Added DM-Upload-Allowed to debian/control.

[ Francesco Paolo Lovergine ]
* Added me as Uploader to avoid possible inappropriate NMU notices.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 */
17
17
package uk.me.parabola.imgfmt.app.trergn;
18
18
 
19
 
import uk.me.parabola.imgfmt.app.BufferedWriteStrategy;
 
19
import uk.me.parabola.imgfmt.app.BufferedImgFileWriter;
20
20
import uk.me.parabola.imgfmt.app.ImgFile;
 
21
import uk.me.parabola.imgfmt.app.ImgFileWriter;
21
22
import uk.me.parabola.imgfmt.fs.ImgChannel;
22
23
import uk.me.parabola.log.Logger;
23
24
 
24
 
import java.io.IOException;
25
 
 
26
25
/**
27
26
 * The region file.  Holds actual details of points and lines etc.
28
27
 *
52
51
        public RGNFile(ImgChannel chan) {
53
52
                setHeader(header);
54
53
 
55
 
                setWriter(new BufferedWriteStrategy(chan));
 
54
                setWriter(new BufferedImgFileWriter(chan));
56
55
 
57
56
                // Position at the start of the writable area.
58
57
                position(HEADER_LEN);
59
 
        }
60
 
 
61
 
        public void sync() throws IOException {
 
58
        } 
 
59
 
 
60
        public void write() {
 
61
                if (!isWritable())
 
62
                        throw new IllegalStateException("File not writable");
 
63
 
62
64
                header.setDataSize(position() - HEADER_LEN);
63
65
 
64
66
                getHeader().writeHeader(getWriter());
65
 
 
66
 
                getWriter().sync();
67
67
        }
68
68
 
69
69
        public void startDivision(Subdivision sd) {
129
129
                if (currentDivision.needsPolygonPtr()) {
130
130
                        long currPos = position();
131
131
                        long off = currPos - currentDivision.getRgnPointer() - HEADER_LEN;
132
 
                        log.debug("currpos=" + currPos + ", off=" + off);
 
132
                        log.debug("currpos=", currPos, ", off=", off);
133
133
                        if (off > 0xffff)
134
134
                                throw new IllegalStateException("Too many items in the polygon section");
135
135
 
140
140
                        position(currPos);
141
141
                }
142
142
        }
 
143
 
 
144
        public ImgFileWriter getWriter() {
 
145
                return super.getWriter();
 
146
        }
143
147
}