logo separator

[mkgmap-dev] Branch is_in ready for a first test

From Gerd Petermann GPetermann_muenchen at hotmail.com on Thu Jan 9 11:43:42 GMT 2020

Hi all,

the branch version r4408 implements the style function is_in with three parameters tag-key,tag-value,method
- tag-key can be something like landuse or natural or amenity
- tag-value would be the expected value for that tag-key 
- method has to be "any" or "all". 

Example usage in lines:
# no cycling within a cemetery
highway=* & bicycle!=* & is_in(landuse,cemetery,all) {add bicycle=dismount}

Before any style rule is evaluated the function evaluates the list of all ways found in the input file. When a way matches the given tag (key+value) and is closed and complete the shape geometry is stored in a spatial index. 
With the current implementation this index is created for appearance of the is_in function in a style rule (subject to optimization)

When the style function is called it retrieves the stored shape(s) which intersect the boundary of the element. 
If none is found "false" is returned.
If there are multiple such shapes the are merged where possible, so that overlapping or touching shapes are combined to a single shape which may include holes. 
The list of (outer) shapes is then tested one after the other until one shape is found which either contains the element completely or - when "any" is used as method - partially. If none is found the value "false" is returned.
If a match is found  and the combined shapes have holes, a final test is done to find out if the element is within the hole.
If method "any" is used and the shape is completey within one hole "false" is returned.
If method "all" is used and the shape is partly within one hole "false" is returned.
If we get here true is "returned"

I've also slightly changed the behaviour of the LocationHook and the ResidentialHook. The results should be a bit more predictable now as searches are done with higher precsion. Still, both try to find a nearby boundary(shape) if none is found at the exact position.
The ResidentialHook is now automatically disabled when the style doesn't use mkgmap:residential anywhere.

TODO:
- various possible special cases need more testing
- maybe add more methods for cases where parts of the tested element touch the boundary of the shape.
- tuning
- unit tests

As always with branch version the binary can be found at the bottom of the download page.
http://www.mkgmap.org.uk/download/mkgmap.html

I've tested this with the example file posted before, accept for b18 all cases work as expected.

Gerd


More information about the mkgmap-dev mailing list