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 <[email protected]> im Auftrag
> von Ticker Berkin <[email protected]>
> 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 <[email protected]> im Auftrag
> > von Gerd Petermann <[email protected]>
> > 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 <[email protected]> im Auftrag
> > von Ticker Berkin <[email protected]>
> > 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 <[email protected]> im
> > > Auftrag
> > > von Ticker Berkin <[email protected]>
> > > 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
> > > > [email protected]
> > > > http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
> > > _______________________________________________
> > > mkgmap-dev mailing list
> > > [email protected]
> > > http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
> > _______________________________________________
> > mkgmap-dev mailing list
> > [email protected]
> > http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
> > _______________________________________________
> > mkgmap-dev mailing list
> > [email protected]
> > http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
> > _______________________________________________
> > mkgmap-dev mailing list
> > [email protected]
> > http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-devIndex: src/test/display/MdrCheck.java
===================================================================
--- src/test/display/MdrCheck.java (revision 543)
+++ 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 543)
+++ src/test/display/MdrDisplay.java (working copy)
@@ -219,6 +219,8 @@
mdr28_29PointerSize = getSection(28).getBytesForRecords();
if (has28_29_offset && mdr20PointerSize == 0)
mdr28_29PointerSize = getSection(29).getBytesForRecords();
+ if (cityPtrSize < 2 || cityPtrSize > 3)
+ System.out.printf("MDR5 cityPtrSize: %d\n", cityPtrSize);
//boolean has44 = (s.getMagic() & 0x2000) != 0;
//int mdr44PointerSize = getSection(44).getBytesForRecords();
@@ -403,13 +405,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,17 +445,21 @@
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;
+ int mask = 0;
+ int c = 0;
switch (cityPtrSize) {
+ case 1: // There is supposed to be a min size of 2, but handle anyway & warn elsewhere
+ 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;
- break;
}
if (c > 0) {
if ((c & mask) == 0)
Index: src/test/files/RgnFile.java
===================================================================
--- src/test/files/RgnFile.java (revision 543)
+++ 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
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev