logo separator

[mkgmap-dev] gmapi reader?

From Steve Ratcliffe steve at parabola.me.uk on Mon Jan 29 11:30:07 GMT 2018

Hi Gerd

Is this something that needs to be done before the merge?

> the DEM header structures are quite special, the headers of the sections are written at the very end of the DEM file,
> and they point to data that follows the main header. This is probably not mandantory but it's the way Garmin does it,
> and also DemDisplay uses it to determine the length of the last bitstream.
> So, to do the needed checks we have to read main header and the DEM Section headers at the end of the file.

OK so that is more than I thought, but still not the whole file?  If
you do have to read the whole file, then you might as well use it and
the following may not make sense.

> Not sure where to place this if not in DEMFile. Where would you implement that?

I meant to move everything in DEMFile.tryCopy().

I guess it goes back to Map.addDem().  If possible you want to do
things there or in the code that calls addDem().

You may not have all the required information there, in which case I 
don't know
how to proceed.

Currently addDem() is:

	demFile = new DEMFile(fileSystem.create(mapId + ".DEM"), true);

But you want either a DEMFile or a FileCopier,
you only want the demFile when you need to create it.

	handle = fileSystem.create(mapId + ".DEM");

	if (checkExistingDem()) {
		// Can copy existing one

		// Just a rough idea, many details to be filled in...
		fc = FileCopier(fileContainingDem);
		cl = fc.add(demFilename, handle)
		handle.link(() -> demSize, cl);

		// Probably would create a new constructor:
		// fc = FileCopier(handle, fileContainingDem);
		// fc.add(demFilename);
		// When the img file is closed then the copy will happen
		// automatically.

		// demFile = null
	} else {
		// Need to create it
		demFile = new DEMFile(handle, true);
	}

Hope that makes some kind of sense.
There are probably a lot of details missing.

> reg. FileCopier: I don't see how I can use that class outside of GmapsuppBuilder. Maybe you can extract it?
> 
> I've already thought about using FileBackedImgWriter. I'll do some tests to find out how it influences performance.

Yes it will need to be moved to a top level class and maybe some
changes as well.

..Steve


More information about the mkgmap-dev mailing list