コード例 #1
0
  @Test
  public void populateAlternateNames_nameWithCommaOrSemiColumn() {
    String RawAlternateNames =
        "Karl-Franzens-Universität Graz___Cheka Jedid,Chekia Atiq:Chekia Jedide;Chekia Jedidé";
    OpenStreetMapSimpleImporter importer = new OpenStreetMapSimpleImporter();
    OpenStreetMap street = new OpenStreetMap();
    street = importer.populateAlternateNames(street, RawAlternateNames);
    Assert.assertEquals(5, street.getAlternateNames().size());
    Assert.assertTrue(
        alternateOsmNameContains(street.getAlternateNames(), "Karl-Franzens-Universität Graz"));
    Assert.assertTrue(alternateOsmNameContains(street.getAlternateNames(), "Cheka Jedid"));
    Assert.assertTrue(alternateOsmNameContains(street.getAlternateNames(), "Chekia Atiq"));
    Assert.assertTrue(alternateOsmNameContains(street.getAlternateNames(), "Chekia Jedide"));
    Assert.assertTrue(alternateOsmNameContains(street.getAlternateNames(), "Chekia Jedidé"));

    Iterator<AlternateOsmName> iterator = street.getAlternateNames().iterator();
    while (iterator.hasNext()) {
      Assert.assertEquals(AlternateNameSource.OPENSTREETMAP, iterator.next().getSource());
    }
  }
コード例 #2
0
  @Test
  public void testImporterShouldImport() throws InterruptedException {
    System.out.println(openStreetMapImporter.getClass());
    openStreetMapImporter.process();
    /*if (openStreetMapImporter.getClass() != OpenStreetMapImporter.class){
        Thread.sleep(10000L);
    }*/
    assertEquals(4L, openStreetMapDao.count());
    openStreetMapDao.getAll();
    Long firstIdAssigned = (idGenerator.getGid() - 4 + 1);
    OpenStreetMap openStreetMap = openStreetMapDao.getByGid(firstIdAssigned);
    assertTrue("The oneWay attribute is not correct", openStreetMap.isOneWay());
    assertEquals("The countryCode is not correct ", "FR", openStreetMap.getCountryCode());
    assertEquals("The is_in is not correct ", "a city", openStreetMap.getIsIn());
    assertEquals(
        "The openstreetmapId is not correct ", new Long(11), openStreetMap.getOpenstreetmapId());
    assertEquals(
        "The streetType is not correct", StreetType.RESIDENTIAL, openStreetMap.getStreetType());
    assertEquals("The name is not correct", "Bachlettenstrasse", openStreetMap.getName());
    assertEquals(
        "The location->X is not correct ",
        ((Point)
                GeolocHelper.convertFromHEXEWKBToGeometry(
                    "010100000006C82291A0521E4054CC39B16BC64740"))
            .getX(),
        openStreetMap.getLocation().getX());
    assertEquals(
        "The location->Y is not correct ",
        ((Point)
                GeolocHelper.convertFromHEXEWKBToGeometry(
                    "010100000006C82291A0521E4054CC39B16BC64740"))
            .getY(),
        openStreetMap.getLocation().getY());
    assertEquals("The length is not correct", 0.00142246604529, openStreetMap.getLength());
    assertEquals(
        "The shape is not correct ",
        GeolocHelper.convertFromHEXEWKBToGeometry(
                "01020000000200000009B254CD6218024038E22428D9EF484075C93846B217024090A8AB96CFEF4840")
            .toString(),
        openStreetMap.getShape().toString());

    // check alternate names when there is 2
    Assert.assertEquals(2, openStreetMap.getAlternateNames().size());
    Assert.assertTrue(
        alternateNamesContain(openStreetMap.getAlternateNames(), "Rue de Bachlettenstrasse"));
    Assert.assertTrue(
        alternateNamesContain(openStreetMap.getAlternateNames(), "Bachletten strasse"));

    // check alternate names when there is no name but alternate
    openStreetMap = openStreetMapDao.getByGid(firstIdAssigned + 1);
    Assert.assertEquals(1, openStreetMap.getAlternateNames().size());
    Assert.assertEquals(
        "When there is no name and some alternatename, the first alternatename is set to name ",
        "noName BUT an alternate",
        openStreetMap.getName());
    Assert.assertTrue(alternateNamesContain(openStreetMap.getAlternateNames(), "other an"));

    // one alternate name
    openStreetMap = openStreetMapDao.getByGid(firstIdAssigned + 2);
    Assert.assertEquals(1, openStreetMap.getAlternateNames().size());
    Assert.assertTrue(alternateNamesContain(openStreetMap.getAlternateNames(), "Friedhof"));

    // no alternate names
    openStreetMap = openStreetMapDao.getByGid(firstIdAssigned + 3);
    Assert.assertEquals(0, openStreetMap.getAlternateNames().size());
  }