logo separator

[mkgmap-dev] [PATCH] apply_local action (variable substitution in relation members)

From Marko Mäkelä marko.makela at iki.fi on Mon Dec 14 21:41:05 GMT 2009

On the Finnish forum, the senior mapper alv pointed out that the left:*,
right:* names for boundary=administrative ways are being made obsolete by
boundary relations.  I agree with him that boundary relations are the better
option, especially with regards to localization.  mkgmap can replace name
with some other tag, such as name:sv for Swedish, but it would be difficult
to have it replace a family of left:*, right:* tags with left:*:sv, right:*:sv.

So, I tried to define a relations rule that would generate a space-separated
list of names for a boundary line.  For example, the boundary=administrative
line http://www.openstreetmap.org/browse/way/38589207
that belongs to the relations of the city borders Vantaa and Helsinki
and to the Helsinki suburban borders Tapulikaupunki and Suutarila should
get all these names, "Vantaa/Helsinki/Tapulikaupunki/Suutarila", in some
order.  What happens is that it will get just one of the names, "Suutarila"
in my test run:

In the relations file, I had this, trying to append each relation name
to the mkgmap:boundary_name attribute of each relation member:

(type=boundary | type=multipolygon) & boundary=administrative & name=*
{ echo '${name}';
  apply {
  set mkgmap:boundary_name='${mkgmap:boundary_name}/${name}' | '${name}';
  echo '${mkgmap:boundary_name}'
  }
}

The problem is that within apply{}, the variable substitutions on the
right-hand-side of the "set" and "add" action always refer to the tags of
the relation, not to the relation member.  Thus, mkgmap:boundary_name
will always be empty, and only one relation name will be copied to it.

One possible solution is to have a special form of apply{} where
SubAction.performOnSubElements(Relation rel) does not invoke
addTagAction.setValueTags(rel).  A patch that introduces the action
apply_local{} is attached.

An alternative solution would be to have a special form of variable
substitution that refers to the tags of the element itself.  One simple
way of implementing that could be to introduce the keywords set_local
and add_local and add another boolean parameter to AddTagAction that
would imply valueTags == null.

Yet another solution would be to have a special syntax of variable
substitution that would bypass the valueTags, say, $(var) instead of ${var}:

(type=boundary | type=multipolygon) & boundary=administrative & name=*
{ apply
  {
    set mkgmap:boundary_name='$(mkgmap:boundary_name)/${name}' | '${name}';
  }
}

Best regards,

	Marko
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mm-apply_local-boundary.patch
Type: text/x-diff
Size: 4667 bytes
Desc: not available
Url : http://lists.mkgmap.org.uk/pipermail/mkgmap-dev/attachments/20091214/d5e90be0/attachment.bin 


More information about the mkgmap-dev mailing list