示例#1
0
  @Test
  public void testDecode() throws Exception {
    PointList list = WebHelper.decodePolyline("_p~iF~ps|U", 1);
    assertEquals(Helper.createPointList(38.5, -120.2), list);

    list = WebHelper.decodePolyline("_p~iF~ps|U_ulLnnqC_mqNvxq`@", 3);
    assertEquals(Helper.createPointList(38.5, -120.2, 40.7, -120.95, 43.252, -126.453), list);
  }
示例#2
0
  @Test
  public void testEncode() throws Exception {
    assertEquals("_p~iF~ps|U", WebHelper.encodePolyline(Helper.createPointList(38.5, -120.2)));

    assertEquals(
        "_p~iF~ps|U_ulLnnqC_mqNvxq`@",
        WebHelper.encodePolyline(
            Helper.createPointList(38.5, -120.2, 40.7, -120.95, 43.252, -126.453)));
  }
示例#3
0
  @Test
  public void testBoth() throws Exception {
    PointList list =
        Helper.createPointList(
            38.5, -120.2, 43.252, -126.453, 40.7, -120.95, 50.3139, 10.612793, 50.04303, 9.497681);
    String str = WebHelper.encodePolyline(list);
    assertEquals(list, WebHelper.decodePolyline(str, list.size()));

    list =
        Helper.createPointList(38.5, -120.2, 43.252, -126.453, 40.7, -120.95, 40.70001, -120.95001);
    str = WebHelper.encodePolyline(list);
    assertEquals(list, WebHelper.decodePolyline(str, list.size()));
  }