Hi Gerd
Here is modified patch that handles 4 byte cityPtr in mdr11 and renames
the variable for this to avoid having 2 variable of the same name in
scope. I've named it to be like the equivalent function in mkgmap
I've also got rid of the system.out.printf and fixed some bad
tabbing/indentation
Ticker
On Thu, 2019-11-07 at 11:56 +0000, Ticker Berkin wrote:
> Hi Gerd
>
> MdrDisplay/cityPtrSize:
>
> I didn't change any significant behaviour. Because it seemed
> inconsistent, I put in a diagnostic. I also made the switch stmt in
> printSec11_city like the similar instances that do have to handle
> 1/2/3
> byte objects rather than switch ... case 3: ... default: ...
>
> I should also have added handling cityPtrSize of 4. I fixed mkgmap to
> work correctly for this. However, when I get a tile that needs 4 byte
> pointers, the gmapsupp.img size jumps up, so I re-split the map with
> a
> different number of nodes until the city count reduces again.
>
> My preference here would be rename one of the cityPtrSize variables
> and
> keep/extend the switch statement. Happy to get rid of the
> test/system.out.printf
>
> MdrCheck/group/toType:
>
> The original code in check10() tried to re-constitute a type/subtype
> as
> per mkgmap from group/someBits data and it didn't do it fully or
> correctly.
>
> I agree that this tool should just display/validate the understanding
> of the Garmin IMG structure. However, in this case, because the
> fullType generated above is then validated against data from mdr11,
> it
> has to do this validation based on the grouping chosen by mkgmap.
> Similarly, if these mappings are changed in mkgmap, equivalent
> changes
> need to be made to Display (I put in a few comments to this effect in
> the relevant places)
>
> AllElements:
>
> On my Etrex device, it shows some points not in the correct place
> according to sequence with strange types or names. Some of these
> points
> are outside the map area! I can't quite remember the details, it has
> been a while since I last used it.
>
> So yes, I'm sure it is generating something it shouldn't and maybe
> the
> lower levels of mkgmap code should be checking/objecting as well. It
> might be related to indPoints sometimes having subtypes; I think
> there
> are assumptions that these are a fixed size items.
>
> I don't know if this will cause the problems you describe, but I'll
> have a look at it.
>
> Ticker
>
>
> On Thu, 2019-11-07 at 09:15 +0000, Gerd Petermann wrote:
> > Hi Ticker,
> >
> > I've not yet understood the changes regarding cityPtrSize. Do you
> > think that Garmin supports one-byte pointers when there are less
> > than
> > 128 cities?
> > The transalpin demo map contains only a few cities or regions but
> > uses two bytes.
> > I've attached a patch with my proposed changes.
> >
> > One more hint:
> > I don't like the description "Understands the same MDR groups as
> > generated by mkgmap so it can recreate the correct full type."
> > My understanding of display tool is this:
> > - The main purpose is to find out how the Garmin algos encode
> > things
> > in IMG format, so we should use maps produced by Garmin and
> > Mapsource/Basecamp to verify. The code in mkgmap should be the
> > results of those findings, not vice versa.
> > - I also use it to verify that changes made in mkgmap don't do
> > something unexpected.
> >
> > I've just learned that Mapsource doesn't like the map produced with
> > java -jar mkgmap.jar --index --gmapi test-map:all-elements
> > It crashes when you search for all POI and also when you search for
> > cities (both without giving a name)
> >
> > Gerd
> >
> > ________________________________________
> > Von: mkgmap-dev <mkgmap-dev-boun...@lists.mkgmap.org.uk> im Auftrag
> > von Ticker Berkin <rwb-mkg...@jagit.co.uk>
> > Gesendet: Dienstag, 5. November 2019 12:44
> > An: mkgmap development
> > Betreff: Re: [mkgmap-dev] type/subtype of points and cities
> >
> > Hi Gerd
> >
> > Here is patch for Display.
> >
> > Changes are:
> > Couple of extra diagnostics.
> > Handles 1 byte cities.
> > Moves a call of getSection(11).get... out of a loop.
> > Consistent handling/display of point type/subtype.
> > Understands the same MDR groups as generated by mkgmap so
> > it can recreate the correct full type.
> >
> > Ticker
> >
> > On Tue, 2019-11-05 at 09:43 +0000, Gerd Petermann wrote:
> > > Hi Ticker,
> > >
> > > okay, looks good to me. In an earlier post you mentioned that
> > > display
> > > tool needs changes, too. Please post that patch as well.
> > >
> > > Gerd
> > >
> > > ________________________________________
> > > Von: mkgmap-dev <mkgmap-dev-boun...@lists.mkgmap.org.uk> im
> > > Auftrag
> > > von Ticker Berkin <rwb-mkg...@jagit.co.uk>
> > > Gesendet: Montag, 4. November 2019 18:12
> > > An: Development list for mkgmap
> > > Betreff: Re: [mkgmap-dev] type/subtype of points and cities
> > >
> > > Hi Gerd
> > >
> > > To stay compatible with "Openfietsmap full" style, I've updated
> > > the
> > > patch to change the range of city to be:
> > > type >= 0x0100 && type < 0x1100;
> > > Release mkgmap had this as:
> > > type >= 0x0100 && type <= 0x1100;
> > >
> > > In release mkgmap, a point with value 0x1100 was added to the RGN
> > > as
> > > an
> > > indPoint, but not indexed as a city by MDR. Also 0x1100 is not
> > > findable
> > > as a nearby city, at least on Garmin eTrex. I couldn't detect any
> > > useful behaviour for this combination.
> > >
> > > Ticker
> > >
> > > On Tue, 2019-10-22 at 15:03 +0000, Gerd Petermann wrote:
> > > > Hi Minko,
> > > >
> > > > "(like you say)" should have been ... "(like Ticker wrote)"
> > > > ... (a small dot with the label) ...
> > > > sorry, I forgot to use the typ file, so 0x1101 is displayed
> > > > with
> > > > an
> > > > icon showing a bus and without the label.
> > > > But why do you use a type that is not indexed?
> > > >
> > > > Gerd
> > > >
> > > > ________________________________________
> > > > Von: mkgmap-dev <mkgmap-dev-boun...@lists.mkgmap.org.uk> im
> > > > Auftrag
> > > > von Gerd Petermann <gpetermann_muenc...@hotmail.com>
> > > > Gesendet: Dienstag, 22. Oktober 2019 16:52
> > > > An: Development list for mkgmap
> > > > Betreff: Re: [mkgmap-dev] type/subtype of points and cities
> > > >
> > > > Hi Ticker,
> > > >
> > > > thanks.
> > > >
> > > > @Minko:
> > > > I've created a small map with "Openfietsmap full" style and
> > > > trunk
> > > > r4315 , OSM data contains an amenity=bus_station.
> > > > The result is that this POI appears in the map (a small dot
> > > > with
> > > > the
> > > > label), but it is not in the mdr (like you say).
> > > > I found no older versions of mkgmap where this would have
> > > > worked
> > > > different, so it seems useless to me because normally I'd want
> > > > to
> > > > be
> > > > able to find the bus station under transport services.
> > > >
> > > > Why do you use 0x1101, 0x1102, or 0x1108 for POI?
> > > >
> > > > Gerd
> > > >
> > > > ________________________________________
> > > > Von: mkgmap-dev <mkgmap-dev-boun...@lists.mkgmap.org.uk> im
> > > > Auftrag
> > > > von Ticker Berkin <rwb-mkg...@jagit.co.uk>
> > > > Gesendet: Dienstag, 22. Oktober 2019 16:29
> > > > An: Development list for mkgmap
> > > > Betreff: Re: [mkgmap-dev] type/subtype of points and cities
> > > >
> > > > Hi Gerd
> > > >
> > > > The old reader/osm/Gtype:checkType() didn't diagnose cities
> > > > (however
> > > > they might be defined) with non-zero subtypes - this is where
> > > > the
> > > > new
> > > > message comes from.
> > > >
> > > > Old general/MapPoint:isCity[Type] defined city as:
> > > >
> > > > return type >= 0x0100 && type <= 0x1100
> > > >
> > > > ie 0x1100 is city, 0x1101 isn't, which I thought wasn't a good
> > > > definition, so I changed it to:
> > > >
> > > > return type >= 0x0100 && type < 0x1200;
> > > >
> > > > I chose all of 0x11XX to be considered cities so that 0x1100
> > > > processing
> > > > as a city didn't change (this and 0x1000 were put into RGN
> > > > indPoints,
> > > > but were not indexed as cities by MDR)
> > > >
> > > > Changing it to < 0x1100 would be reasonable, because the device
> > > > range
> > > > seems to be < 0x0e00 and MDR5 city indexing was for points <
> > > > 0x1000
> > > >
> > > > Ticker
> > > >
> > > > On Tue, 2019-10-22 at 12:32 +0000, Gerd Petermann wrote:
> > > > > Hi Ticker,
> > > > >
> > > > > I see some new warnings for Minkos popular Openfietsmap
> > > > > styles
> > > > > with
> > > > > this patch:
> > > > > checking style: Openfietsmap full
> > > > > Warning: invalid type 0x1101 for POINT in style file points,
> > > > > line
> > > > > 97
> > > > > Warning: invalid type 0x1102 for POINT in style file points,
> > > > > line
> > > > > 263
> > > > > Warning: invalid type 0x1102 for POINT in style file points,
> > > > > line
> > > > > 264
> > > > > Warning: invalid type 0x1108 for POINT in style file points,
> > > > > line
> > > > > 336
> > > > > Warning: invalid type 0x1108 for POINT in style file points,
> > > > > line
> > > > > 348
> > > > > Warning: invalid type 0x1108 for POINT in style file points,
> > > > > line
> > > > > 349
> > > > > Warning: invalid type 0x1108 for POINT in style file points,
> > > > > line
> > > > > 350
> > > > >
> > > > > The corresponding lines in the points file
> > > > > amenity=bus_station [0x1101 resolution 24 continue]
> > > > > railway=halt [0x1102 resolution 22]
> > > > > railway=station [0x1102 resolution 20-23 continue]
> > > > > (barrier=bollard | barrier=bus_trap | barrier=block) [0x1108
> > > > > resolution 23]
> > > > > access:conditional=* & access:conditional ~
> > > > > '!(sunset|sunrise|destination)' & bicycle!=no &
> > > > > bicycle!=permissive
> > > > > &
> > > > > vehicle!=no { name 'access=${access:conditional}' } [0x1108
> > > > > resolution 24]
> > > > > bicycle:conditional=* & bicycle:conditional ~
> > > > > '!(sunset|sunrise|destination)' { name
> > > > > 'bicycle=${bicycle:conditional}' } [0x1108 resolution 24]
> > > > > vehicle:conditional=* & vehicle:conditional ~
> > > > > '!(sunset|sunrise|destination)' { name
> > > > > 'vehicle=${vehicle:conditional}' } [0x1108 resolution 24]
> > > > >
> > > > > Can you explain what happened with those POI without the
> > > > > patch?
> > > > >
> > > > > Gerd
> > > > >
> > > > > ________________________________________
> > > > > Von: mkgmap-dev <mkgmap-dev-boun...@lists.mkgmap.org.uk> im
> > > > > Auftrag
> > > > > von Ticker Berkin <rwb-mkg...@jagit.co.uk>
> > > > > Gesendet: Dienstag, 22. Oktober 2019 13:07
> > > > > An: Development list for mkgmap
> > > > > Betreff: Re: [mkgmap-dev] type/subtype of points and cities
> > > > >
> > > > > Hi Gerd
> > > > >
> > > > > Here is the patch based on the current trunk
> > > > >
> > > > > Ticker
> > > > > On Tue, 2019-04-23 at 11:51 +0100, Ticker Berkin wrote:
> > > > > > Hi
> > > > > >
> > > > > > I think the mkgmap internal handling of types/subtypes of
> > > > > > points
> > > > > > is
> > > > > > obscure.
> > > > > >
> > > > > > In the points style file, the type code is always full, ie
> > > > > > type
> > > > > > <<
> > > > > > 8
> > > > > > >
> > > > > > subtype, but when the points are read back from the RGN
> > > > > > file
> > > > > > for
> > > > > > the
> > > > > > MDR processing, the representation is the same provided the
> > > > > > subtype
> > > > > > is
> > > > > > not zero, otherwise it is just type! Logic then decides
> > > > > > that
> > > > > > if
> > > > > > the
> > > > > > value is <= 0xff it is because the subtype is zero.
> > > > > >
> > > > > > It is simpler and much clearer to preserve the original
> > > > > > representation.
> > > > > > This also allows unambiguous use of type 0 with subtypes,
> > > > > > and,
> > > > > > possibly, city with subtypes.
> > > > > >
> > > > > > It also allows the same function to be used to test a type
> > > > > > for
> > > > > > being
> > > > > > in
> > > > > > the 'city' range, regardless of the context. mkgmap wasn't
> > > > > > consistent
> > > > > > the ranges for the isCity test.
> > > > > >
> > > > > > City POI are written in a different manner to the RGN file.
> > > > > > The
> > > > > > old
> > > > > > range for this was:
> > > > > > type >= 0x0100 && type <= 0x1100
> > > > > > which I've kept, except changing to: ...& type < 0x1200. A
> > > > > > similar
> > > > > > range was used for MDR5.
> > > > > >
> > > > > > However, city POI are held in group 1 of MDR 9/10. This is
> > > > > > used
> > > > > > in
> > > > > > Find
> > > > > > > City 'By Name'. The old range was: type <= 0xf, where, if
> > > > > > > the
> > > > > > > subtype
> > > > > > was zero, type is right shifted by 8 (see above), non-zero
> > > > > > subtypes
> > > > > > messed up the testing. Now it uses the same range as above.
> > > > > >
> > > > > > Actually neither of these ranges are correct for my Garmin
> > > > > > devices.
> > > > > > Find > City show nearby POI with types in the range
> > > > > > 0x0100..0x0d1f,
> > > > > > regardless of the img RGN or MDR. The eTrex Legend labels
> > > > > > POIs
> > > > > > in
> > > > > > this
> > > > > > range as {Large/Medium/Small} City/Town and points in the
> > > > > > range
> > > > > > 0x0e00..0x111f as "*".
> > > > > >
> > > > > > Find > City 'by-name' returns POI if in group 1 of MDR
> > > > > > 9/10.
> > > > > > I
> > > > > > find
> > > > > > it
> > > > > > a useful feature to have a POI that can be searched for but
> > > > > > doesn't
> > > > > > flood the list of nearby points.
> > > > > >
> > > > > > Generally, non-zero subtypes for cities cause problems in
> > > > > > the
> > > > > > RGN
> > > > > > structure and I've added a test for this to the style
> > > > > > validation.
> > > > > >
> > > > > > There is also a fix to --make-poi-index, but I can't detect
> > > > > > any
> > > > > > effect
> > > > > > of this option.
> > > > > >
> > > > > > This patch won't make any difference to the img output
> > > > > > unless
> > > > > > the
> > > > > > there
> > > > > > are points 0x1000, 0x1100.
> > > > > >
> > > > > > If this patch is accepted, I'll do the equivalent to the
> > > > > > img
> > > > > > display
> > > > > > system.
> > > > > >
> > > > > > Regards
> > > > > > Ticker
> > > > > > _______________________________________________
> > > > > > mkgmap-dev mailing list
> > > > > > mkgmap-dev@lists.mkgmap.org.uk
> > > > > > http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
> > > > > _______________________________________________
> > > > > mkgmap-dev mailing list
> > > > > mkgmap-dev@lists.mkgmap.org.uk
> > > > > http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
> > > > _______________________________________________
> > > > mkgmap-dev mailing list
> > > > mkgmap-dev@lists.mkgmap.org.uk
> > > > http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
> > > > _______________________________________________
> > > > mkgmap-dev mailing list
> > > > mkgmap-dev@lists.mkgmap.org.uk
> > > > http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
> > > > _______________________________________________
> > > > mkgmap-dev mailing list
> > > > mkgmap-dev@lists.mkgmap.org.uk
> > > > http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
> _______________________________________________
> mkgmap-dev mailing list
> mkgmap-dev@lists.mkgmap.org.uk
> http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
Index: src/test/display/MdrCheck.java
===================================================================
--- src/test/display/MdrCheck.java (revision 545)
+++ src/test/display/MdrCheck.java (working copy)
@@ -219,6 +219,7 @@
mdr28_29PointerSize = getSection(28).getBytesForRecords();
if (has28_29_offset && mdr20PointerSize == 0)
mdr28_29PointerSize = getSection(29).getBytesForRecords();
+ test("Sect5 flags %x %d %d %d", magic, cityPtrSize, mdr20PointerSize, mdr28_29PointerSize);
reader.position(start);
int citynum = 0;
@@ -559,8 +560,6 @@
info("%d: map%d; t=0x%04x subdiv/num=%d/%d %s %s", record, mapNumber, o.getType(), subdiv, num, kind, text);
int type = o.getType();
- if (type <= 0xff)
- type <<= 8;
poiType.put(record, type);
}
}
@@ -1949,19 +1948,21 @@
}
private static int toType(int group, int typeOrSubType) {
- if (group == 1 )
+ // see mkgmap imgfmt/app/mdr/MdrUtils.java:getGroupForPoi()
+ // and mkgmap imgfmt/app/mdr/Mdr10.java:addPoiType()
+ if (group == 1)
+ return typeOrSubType << 8;
+ if (group >= 64)
return typeOrSubType;
- if (group >= 64 )
- return typeOrSubType;
int t = -1;
if (group >= 2 && group <= 8)
- t = group + 0x28;
- if (group == 9)
- t = 0x28;
- if (group >= 11 && group <= 13)
- t = group + 0x59;
+ t = (group + 0x28) << 8;
+ else if (group == 9)
+ t = 0x28 << 8;
+ else if (group >= 11 && group <= 13)
+ t = (group + 0x59) << 8;
if (typeOrSubType != 0)
- t = (t << 8) | typeOrSubType;
+ t |= typeOrSubType;
return t;
}
Index: src/test/display/MdrDisplay.java
===================================================================
--- src/test/display/MdrDisplay.java (revision 545)
+++ src/test/display/MdrDisplay.java (working copy)
@@ -30,7 +30,7 @@
* knowledge of the file format.
*
* Can produce a massive file, so may take some time to write.
- *
+ *
* @author Steve Ratcliffe
*/
@SuppressWarnings({"UnusedDeclaration"})
@@ -43,7 +43,7 @@
private int numberOfMaps; // The number of maps
private boolean compressedStrings;
- private int cityPtrSize;
+ private int citySizeFlagged;
private Charset charSet;
private Map<Integer, String> stringTable;
private int start;
@@ -291,7 +291,7 @@
int zipPtrSize = (s.getMagic() & 0x3) + 1;
d.item().addText("Zip size: "+zipPtrSize);
- boolean hasString = (s.getMagic() & 0x4) != 0;
+ boolean hasString = (s.getMagic() & 0x4) != 0;
reader.position(s.getStart());
int zipnum = 0;
@@ -300,7 +300,7 @@
printMapIndex(d);
putValue(d, "the %d zip in the map", zipPtrSize);
if (hasString)
- printTextLabel(d);
+ printTextLabel(d);
}
d.print(outStream);
@@ -327,15 +327,15 @@
d.setSectStart(s.getStart());
int recsize = s.getRecordSize();
reader.position(s.getStart());
- int count = 1;
+ int count = 1;
while (reader.position() < s.getEnd()) {
- DisplayItem item = d.item();
- item.addText("Record %d", count++);
- long itemStart = reader.position();
+ DisplayItem item = d.item();
+ item.addText("Record %d", count++);
+ long itemStart = reader.position();
- printMapIndex(d);
+ printMapIndex(d);
- item = d.int3Item();
+ item = d.int3Item();
int off = item.getValue();
item.addText("Pointer back into LBL: %06x", off & ~0x800000);
if ((off & 0x800000) == 0)
@@ -363,11 +363,11 @@
private void printSect8() {
Displayer d = new Displayer(reader);
d.setTitle("MDR 8 (index into streets)");
- print8_12(d, 8);
+ print8_12(d, 8);
}
/**
- * POI / Polygon groups.
+ * POI / Polygon groups.
*/
private void printSect9() {
Displayer d = new Displayer(reader);
@@ -403,13 +403,12 @@
reader.position(s.getStart());
int count = 1;
+ // Calculate record size by determining how many points there are in MDR11
+ int nPoints = getSection(11).getNumberOfRecords();
while (reader.position() < s.getEnd()) {
- d.byteValue("type 0x%x");
+ d.byteValue("[sub]type 0x%x");
DisplayItem item = d.item();
- // Calculate record size by determining how many points there are in MDR11
- int nPoints = getSection(11).getNumberOfRecords();
-
int c;
boolean isRepeat = true;
@@ -444,16 +443,24 @@
private void printSect11_City(Displayer d) {
// if this is a city there is a reference to it.
DisplayItem item = d.item();
- int mask;
- int c;
- switch (cityPtrSize) {
+ int mask = 0;
+ int c = 0;
+ switch (citySizeFlagged) {
+ case 1: // There is supposed to be a min size of 2, but handle anyway
+ c = item.setBytes1(reader.get1u());
+ mask = 0x80;
+ break;
+ case 2:
+ c = item.setBytes2(reader.get2u());
+ mask = 0x8000;
+ break;
case 3:
c = item.setBytes3(reader.get3u());
mask = 0x800000;
break;
- default: // There is a min size of 2
- c = item.setBytes2(reader.get2u());
- mask = 0x8000;
+ case 4:
+ c = item.setBytes4(reader.get4());
+ mask = 0x80000000;
break;
}
if (c > 0) {
@@ -516,36 +523,36 @@
d.print(outStream);
}
- private void printSect12() {
+ private void printSect12() {
Displayer d = new Displayer(reader);
d.setTitle("MDR 12 (index into POI)");
- print8_12(d, 12);
+ print8_12(d, 12);
}
- private void print8_12(Displayer d, int sectNumber) {
+ private void print8_12(Displayer d, int sectNumber) {
// Get the number of records in the previous section
- Section s = getSection(sectNumber-1);
+ Section s = getSection(sectNumber-1);
int sizePrev = s.getBytesForRecords();
s = getSection(sectNumber);
- d.setSectStart(s.getStart());
- int recsize = s.getRecordSize();
+ d.setSectStart(s.getStart());
+ int recsize = s.getRecordSize();
int flags = s.getMagic();
- reader.position(s.getStart());
- while (reader.position() < s.getEnd()) {
+ reader.position(s.getStart());
+ while (reader.position() < s.getEnd()) {
long start = reader.position();
- d.stringValue((flags>>8), "Prefix:%s");
+ d.stringValue((flags>>8), "Prefix:%s");
d.intValue(sizePrev, "record %d");
d.rawValue((int) (recsize - (reader.position() - start)));
- }
+ }
- d.print(outStream);
- }
+ d.print(outStream);
+ }
- /**
+ /**
* This is an ordered list containing pointers into the text strings,
* probably for regions, arranged per map.
*/
@@ -654,13 +661,11 @@
int peek = 0xff & (int) d.byteValue("Peek");
DisplayItem item = d.item();
int partlength = 0;
- if ((peek & 1) == 1)
- {
+ if ((peek & 1) == 1) {
partlength = peek;
partlength >>= 1;
}
- if ((peek & 3) == 2)
- {
+ if ((peek & 3) == 2) {
partlength = reader.get1u();
item.setBytes1(partlength);
partlength <<= 8;
@@ -667,8 +672,7 @@
partlength += peek;
partlength >>= 2;
}
- if ((peek & 7) == 4)
- {
+ if ((peek & 7) == 4) {
partlength = reader.get2u();
item.setBytes2(partlength);
partlength <<= 8;
@@ -679,8 +683,8 @@
int sectHeader = -1;
if (partlength > 2) {
- item = d.charItem();
- sectHeader = item.getValue();
+ item = d.charItem();
+ sectHeader = item.getValue();
item.addText("Some header: 0x%04x", sectHeader);
partlength -= 2;
}
@@ -689,21 +693,21 @@
d.rawValue(s.getLen(),"please implement");
break;
}
- // This can't be the whole story. Header flags from other sections help determine?
- int strLen = (sectHeader >> 8) + 1;
- int indLen = sectHeader & 0xff;
- if (strLen == 4)
- indLen -= 0x10;
- indLen = (indLen-9)/10 + 1;
+ // This can't be the whole story. Header flags from other sections help determine?
+ int strLen = (sectHeader >> 8) + 1;
+ int indLen = sectHeader & 0xff;
+ if (strLen == 4)
+ indLen -= 0x10;
+ indLen = (indLen-9)/10 + 1;
- item.addText("str len %d, index len %d", strLen, indLen);
- partlength /= strLen + indLen;
- int record = 0;
- for (int i = 0; i < partlength; i++) {
- record++;
- d.stringValue(strLen, String.format("[%d] str: %%s", record));
- d.intValue(indLen, "Index? %d");
- }
+ item.addText("str len %d, index len %d", strLen, indLen);
+ partlength /= strLen + indLen;
+ int record = 0;
+ for (int i = 0; i < partlength; i++) {
+ record++;
+ d.stringValue(strLen, String.format("[%d] str: %%s", record));
+ d.intValue(indLen, "Index? %d");
+ }
}
d.print(outStream);
@@ -719,15 +723,15 @@
Section s = getSection(18);
d.setSectStart(s.getStart());
- int size19 = getSection(19).getBytesForRecords();
+ int size19 = getSection(19).getBytesForRecords();
reader.position(s.getStart());
while (reader.position() < s.getEnd()) {
- DisplayItem item = d.charItem();
- int type = item.getValue();
- if (type == 0xffff)
- break;
- item.addText("Type: %02x/%02x", (type>>5) & 0xff, type & 0x1f);
+ DisplayItem item = d.charItem();
+ int type = item.getValue();
+ if (type == 0xffff)
+ break;
+ item.addText("Type: %02x/%02x", (type>>5) & 0xff, type & 0x1f);
d.intValue(size19, "Idx into MDR 19: %d");
}
@@ -740,19 +744,19 @@
Section s = getSection(19);
d.setSectStart(s.getStart());
- int poiSize = getSection(11).getBytesForRecords();
- int mask = 0;
- if (poiSize == 1)
- mask = 0x80 - 1;
- else if (poiSize == 2)
- mask = 0x8000 - 1;
- else if (poiSize == 3)
- mask = 0x800000 - 1;
+ int poiSize = getSection(11).getBytesForRecords();
+ int mask = 0;
+ if (poiSize == 1)
+ mask = 0x80 - 1;
+ else if (poiSize == 2)
+ mask = 0x8000 - 1;
+ else if (poiSize == 3)
+ mask = 0x800000 - 1;
reader.position(s.getStart());
int count = 1;
while (reader.position() < s.getEnd()) {
DisplayItem item = d.intItem(poiSize);
- int val = item.getValue();
+ int val = item.getValue();
item.addText("record %d: poi index %d", count++, val & mask);
}
@@ -774,7 +778,6 @@
return;
}
-
int count = 1;
int record = 1;
int lastid = -1;
@@ -801,7 +804,7 @@
item = d.intItem(flgSize);
val = item.getValue();
- // item.addText("%ssplitInfo=%d", (val & 1) == 0 ? "[r] " : "", val >> 1);
+ // item.addText("%ssplitInfo=%d", (val & 1) == 0 ? "[r] " : "", val >> 1);
item.addText("%s sort seq p=%-3d s=%-3d", (val & 1) == 1 ? "N" : "R",
(val >> 1) & splitMask,
(val >>> (unk2split + 1)));
@@ -831,7 +834,7 @@
if (id < lastid)
item.addText("# New group %d", count++);
lastid = id;
- item.addText("street %d %s", id, (val & 1) == 1 ? "" : "R");
+ item.addText("street %d %s", id, (val & 1) == 1 ? "" : "R");
}
printRemainder(d, recsize, start);
@@ -971,7 +974,6 @@
d.print(outStream);
}
-
private void printSect27() {
Displayer d = new Displayer(reader);
d.setTitle("MDR 27 (cities by region?)");
@@ -1057,13 +1059,13 @@
boolean hasStr = (magic & 0x1) != 0; // guessed
boolean has17 = (magic & 0x30) != 0;
- boolean has26 = (magic & 0x8) != 0;
+ boolean has26 = (magic & 0x8) != 0;
- int size24 = getSection(24).getBytesForRecords();
+ int size24 = getSection(24).getBytesForRecords();
int size22 = getSection(22).getBytesForRecords();
int size25 = getSection(5).getBytesForRecords(); // NB appears to be size of 5, not 25 (they are related of course).
- int size26 = (has26)? getSection(26).getBytesForRecords() : 0;
- int size17 = (has17)? (magic & 0x30) >> 4 : 0;
+ int size26 = (has26)? getSection(26).getBytesForRecords() : 0;
+ int size17 = (has17)? (magic & 0x30) >> 4 : 0;
reader.position(s.getStart());
int count = 1;
@@ -1087,15 +1089,15 @@
m = d.intValue(size25, "mdr25 record %d");
if (m > max[3]) max[3] = m;
- if (has26) {
- m = d.intValue(size26, "mdr26 record %d");
- if (m > max[4]) max[4] = m;
- }
+ if (has26) {
+ m = d.intValue(size26, "mdr26 record %d");
+ if (m > max[4]) max[4] = m;
+ }
- if (has17) {
- m = d.intValue(size17, "mdr17 record %d");
- if (m > max[4]) max[4] = m;
- }
+ if (has17) {
+ m = d.intValue(size17, "mdr17 record %d");
+ if (m > max[4]) max[4] = m;
+ }
printRemainder(d, recsize, start);
}
@@ -1347,10 +1349,12 @@
// The city field in mdr11 appears to have a minimum of 2
int ncities = getSection(5).getNumberOfRecords();
- if (ncities > 0x7fff)
- cityPtrSize = 3;
+ if (ncities > 0x7fffff)
+ citySizeFlagged = 4;
+ else if (ncities > 0x7fff)
+ citySizeFlagged = 3;
else
- cityPtrSize = 2;
+ citySizeFlagged = 2;
d.print(outStream);
outStream.flush();
Index: src/test/files/RgnFile.java
===================================================================
--- src/test/files/RgnFile.java (revision 545)
+++ src/test/files/RgnFile.java (working copy)
@@ -128,7 +128,7 @@
p.setType(((t & 0xff) << 8) | (st & 0xff));
//p.setHasSubtype(true);
} else {
- p.setType(t & 0xff);
+ p.setType((t & 0xff) << 8);
}
p.setNumber(number++);
_______________________________________________
mkgmap-dev mailing list
mkgmap-dev@lists.mkgmap.org.uk
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev