logo separator

[mkgmap-dev] methods to write signed / unsigned integers

From Gerd Petermann gpetermann_muenchen at hotmail.com on Fri Mar 16 08:22:50 GMT 2018

Hi Ticker,

yes, I think display tool needs more work. You commented a
I think the method names in Displayer.java should be changed so that they are similar to the corresponding reader methods.
Example:
        public int int3Value(String text)
would be
        public int int3uValue(String text)

I see some places where you replaced
                item.setBytes(reader.getChar());
by
                item.setBytes((char)reader.get2u());
I think the cast to char should be removed.

I also see code like this:
                                c = item.setBytes(reader.get2u()) & 0xffff;
I think the & 0xffff is obsolete and confusing.

I am pretty sure that some lines in MdrDisplay are wrong (not because of your patch).
I think all places where get3s() is used need a closer look. We might have to change them to get3u().
For example:
 int record = reader.get3s();
off = item.setBytes3(reader.get3s());
Record numbers and offsets are normally not negative. I'll have a closer look today.

I also agree that this snippet from NodConvert looks wrong:
		} else if (restrbytes == 3) {
			size = reader.get2u() & 0xffffff;  // %%% think mistake

I've not used NodConvert for a long time, it might well be behind the last findings reg. NOD.

Gerd


________________________________________
Von: mkgmap-dev <mkgmap-dev-bounces at lists.mkgmap.org.uk> im Auftrag von Ticker Berkin <ticker at jagIT.co.uk>
Gesendet: Donnerstag, 15. März 2018 15:21:25
An: mkgmap-dev at lists.mkgmap.org.uk
Betreff: Re: [mkgmap-dev] methods to write signed / unsigned integers

Hi Gerd

I've attached the Display patch - this was a quick hack global edit and
could be improved by using the relevant signed/unsigned get methods
instead of masking...  I'm happy to do this - let me know.

Yes to DEM changes. Also the nearby asserts can go now because put2s()
will check the range.

  // don't think needed:
could be changed to
  // not needed at moment:
but I think it is worth leaving these methods (getNs()/putNs())
commented in the ImgFile interface source.

Ticker


On Thu, 2018-03-15 at 10:12 +0000, Gerd Petermann wrote:
> Hi Ticker,
>
> sorry, did not find the time to look at it until now.
> At least for DEM this would not be correct, some values should be
> written with the signed put versions.
> I've attached a corrected version of the patch.
> Besides that I'd prefer not to see comments like
> // don't think needed:
>
> For further testing I'd need the patch for display tool as well.
>
> Gerd


More information about the mkgmap-dev mailing list