logo separator

[mkgmap-dev] Divide number in style file

From Felix Hartmann extremecarver at gmail.com on Fri May 7 13:50:09 BST 2021

Ah true, can use other conversion too, so it's doable...

On Fri, 7 May 2021, 18:47 Ticker Berkin <rwb-mkgmap at jagit.co.uk> wrote:

> ...|conv:"from=>to" does speed and weight conversions as well as length
>
> This is the table (from mkgmap/osmstyle/eval/UnitConversions.java)
>
>   static {
>         Map<String, Double> m = LENGTH_FACTORS;
>         m.put("m", 1.0);
>         m.put("km", 1000.0);
>         m.put("ft", 0.3048);
>         m.put("feet", 0.3048);
>         m.put("mi", 1_609.344);
>         CONVERSIONS.put(UnitType.LENGTH, LENGTH_FACTORS);
>
>         m = SPEED_FACTORS;
>         m.put("kmh", 1.0);
>         m.put("km/h", 1.0);
>         m.put("kmph", 1.0);
>         m.put("mph", 1.60934);
>         m.put("knots", 1.852);
>         CONVERSIONS.put(UnitType.SPEED, SPEED_FACTORS);
>
>         m = WEIGHT_FACTORS;
>         m.put("t", 1.0);
>         m.put("kg", 0.001);
>         m.put("lb", 0.00045359237);
>         m.put("lbs", 0.00045359237);
>         CONVERSIONS.put(UnitType.WEIGHT, WEIGHT_FACTORS);
>     }
>
> I see no reason why chaining conv| shouldn't work, but haven't tried
> it.
>
> Ticker
>
> On Fri, 2021-05-07 at 17:56 +0800, Felix Hartmann wrote:
> > yes I figured out the only current possible division would be to
> > convert ft to mt - that could be run against population number as
> > well of course.. Dividing the population number to get maps of India
> > or China a bit less cluttered without using a specific style would be
> > quite handy. Though yes - besides improving rules for cities not much
> > else use of a division factor for values that I can think of. So
> > right now only 3.28, 3.28^2, 3.28^3 and so on is possible (i did not
> > actually check if it is possible to convert twice, but think so).
> >
> > On Fri, 7 May 2021 at 16:56, Ticker Berkin <rwb-mkgmap at jagit.co.uk>
> > wrote:
> > > Hi Felix
> > >
> > > I don't think there is any way to do maths on tag values.
> > >
> > > It should not be too difficult to implement additional variable
> > > filters
> > > that do a simple maths op with a constant, eg:
> > >   {set population='${population|divide:"7"}'}
> > >
> > > Ticker
> > >
> > > On Wed, 2021-05-05 at 22:58 +0800, Felix Hartmann wrote:
> > > > Is it possible to divide a number by a factor in the style file?
> > > >
> > > > ( mkgmap:country=CHN | mkmgap:countrz=CN | mkgmap:country=IND |
> > >
> > >                                      ^^
> > > > mkgmap:country=IN ) & ( place=city | place=island | place=town |
> > > > place=village ) & population=* {set population='${population}/7'}
> > > >
> > > > Did not work. I intend to divide the population in cities in
> > > China
> > > > and India because otherwise cities clutter up the map there (also
> > > in
> > > > India they do not use admin level ... which could be an
> > > alternative).
> > > >
> > > > --
> > > > Felix Hartman - Openmtbmap.org & VeloMap.org
> > > >
> > > > _______________________________________________
> > > > mkgmap-dev mailing list
> > > > mkgmap-dev at lists.mkgmap.org.uk
> > > > https://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
> > > _______________________________________________
> > > mkgmap-dev mailing list
> > > mkgmap-dev at lists.mkgmap.org.uk
> > > https://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
> > >
> >
> > --
> > Felix Hartman - Openmtbmap.org & VeloMap.org
> >
> > _______________________________________________
> > mkgmap-dev mailing list
> > mkgmap-dev at lists.mkgmap.org.uk
> > https://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
> _______________________________________________
> mkgmap-dev mailing list
> mkgmap-dev at lists.mkgmap.org.uk
> https://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mkgmap.org.uk/pipermail/mkgmap-dev/attachments/20210507/f931bf33/attachment.html>


More information about the mkgmap-dev mailing list