コード例 #1
0
  /*
  copied from TestUtils because test classes can't be shared easily
  */
  private static City createDefaultTestCityInstance(IdGenerator idGenerator) {

    BaseCoordinate referencePoint = new BaseCoordinate(52.516667, 13.4);
    BasePolygon referenceArea =
        new BasePolygon(
            idGenerator.getNextId(),
            GeoToolsBootstrapping.getGeometryFactory()
                .createPolygon(
                    new LinkedList<Coordinate>(
                            Arrays.asList(
                                new BaseCoordinate(
                                    referencePoint.getX() - 1, referencePoint.getY() - 1),
                                new BaseCoordinate(
                                    referencePoint.getX() - 1, referencePoint.getY() + 1),
                                new BaseCoordinate(
                                    referencePoint.getX() + 1, referencePoint.getY() + 1),
                                new BaseCoordinate(
                                    referencePoint.getX() + 1, referencePoint.getY() - 1),
                                new BaseCoordinate(
                                    referencePoint.getX() - 1, referencePoint.getY() - 1)))
                        .toArray(new Coordinate[5])));
    City city =
        new City(
            idGenerator.getNextId(),
            "Berlin",
            3375222,
            80,
            true,
            true,
            new BaseBoundary(idGenerator.getNextId(), referencePoint, referenceArea));
    return city;
  }
コード例 #2
0
 /** Test of retrieveCenterPoint method, of class BaseBoundary. */
 @Test
 public void testRetrieveCenterPoint() {
   City testCity = createDefaultTestCityInstance(idGenerator);
   BaseBoundary instance =
       new BaseBoundary(
           idGenerator.getNextId(),
           testCity.getBoundary().getReferencePoint(),
           testCity.getBoundary().getBoundary());
   Coordinate expResult =
       GeoToolsBootstrapping.getGeometryFactory()
           .createMultiPoint(testCity.getBoundary().getBoundary().getCoordinates())
           .getCentroid()
           .getCoordinate();
   Coordinate result = instance.retrieveCenterPoint();
   assertEquals(expResult.x, result.x, 0.5);
   assertEquals(expResult.y, result.y, 0.5);
 }