def test_encode_coordinate(config):

    O.init_osm_factory(config)

    # The following tests assume that the scale factor in use is 10^7.
    _sf = config.getint(C.DATASTORE, C.SCALE_FACTOR)
    assert _sf == 10000000

    #
    # Test encoding of strings.
    #
    inputlist = [ ('0', 0),                  # Zero.
                  ('0.00123456',      12345), # Tiny
                  ('0.12345678',    1234567), # Fraction only
                  ('1.23456789',   12345678), # Normal, small
                  ('12.3456789',  123456789), # Normal
                  ('123.456789', 1234567890), # Normal, large
                  ('1',            10000000), # Integral, small
                  ('12',          120000000), # Integral
                  ('123',        1230000000)  # Integral, large
                ]
    for (strval, refval) in inputlist:
        v = O.encode_coordinate(strval)
        assert refval == v


    #
    # Test encoding of floating point values.
    #
    inputlist = [ (0.0, 0),
                  (0.123456,    1234560),
                  (0.1234567,   1234567),
                  (1.0,        10000000),
                  (1.23456,    12345600),
                 (12.3455899, 123455899)
                ]
    for (flval, refval) in inputlist:
        v = O.encode_coordinate(flval)
        assert v == refval
Test encoding of a coordinate string.
dataset/ETHPy150Open MapQuest/mapquest-osm-server/src/python/tests/test_osmelement.py/test_encode_coordinate