Package org.onebusaway.geospatial.model

Examples of org.onebusaway.geospatial.model.EncodedPolygonBean


    checkBounds(grid.get(3), new CoordinateBounds(5.1, 4.1, 5.2, 4.2), DELTA);

    List<EncodedPolygonBean> boundary = factory.getBoundary();
    assertEquals(1, boundary.size());

    EncodedPolygonBean polygon = boundary.get(0);
    assertTrue(polygon.getInnerRings().isEmpty());

    List<CoordinatePoint> points = PolylineEncoder.decode(polygon.getOuterRing());
    points = shiftPoints(points);

    assertEquals(8, points.size());

    assertEqualsPoints(new CoordinatePoint(5.0, 4.0), points.get(0), DELTA);
    assertEqualsPoints(new CoordinatePoint(5.1, 4.0), points.get(1), DELTA);
    assertEqualsPoints(new CoordinatePoint(5.2, 4.0), points.get(2), DELTA);
    assertEqualsPoints(new CoordinatePoint(5.2, 4.1), points.get(3), DELTA);
    assertEqualsPoints(new CoordinatePoint(5.2, 4.2), points.get(4), DELTA);
    assertEqualsPoints(new CoordinatePoint(5.1, 4.2), points.get(5), DELTA);
    assertEqualsPoints(new CoordinatePoint(5.0, 4.2), points.get(6), DELTA);
    assertEqualsPoints(new CoordinatePoint(5.0, 4.1), points.get(7), DELTA);

    factory.addBounds(new CoordinateBounds(5.15, 4.05, 5.26, 4.19));

    grid = factory.getGrid();

    assertEquals(6, grid.size());

    Collections.sort(grid, BOUNDS_COMPARATOR);

    checkBounds(grid.get(0), new CoordinateBounds(5.0, 4.0, 5.1, 4.1), DELTA);
    checkBounds(grid.get(1), new CoordinateBounds(5.0, 4.1, 5.1, 4.2), DELTA);
    checkBounds(grid.get(2), new CoordinateBounds(5.1, 4.0, 5.2, 4.1), DELTA);
    checkBounds(grid.get(3), new CoordinateBounds(5.1, 4.1, 5.2, 4.2), DELTA);
    checkBounds(grid.get(4), new CoordinateBounds(5.2, 4.0, 5.3, 4.1), DELTA);
    checkBounds(grid.get(5), new CoordinateBounds(5.2, 4.1, 5.3, 4.2), DELTA);

    boundary = factory.getBoundary();
    assertEquals(1, boundary.size());

    polygon = boundary.get(0);
    assertTrue(polygon.getInnerRings().isEmpty());

    points = PolylineEncoder.decode(polygon.getOuterRing());
    points = shiftPoints(points);

    assertEquals(10, points.size());

    assertEqualsPoints(new CoordinatePoint(5.0, 4.0), points.get(0), DELTA);
View Full Code Here


  protected List<EncodedPolygonBean> getBoundariesAsBeans(
      List<Boundary> boundaries) {
    List<EncodedPolygonBean> beans = new ArrayList<EncodedPolygonBean>(
        boundaries.size());
    for (Boundary boundary : boundaries) {
      EncodedPolygonBean bean = getBoundaryAsPolygonBean(boundary);
      beans.add(bean);
    }
    return beans;
  }
View Full Code Here

    }
    return beans;
  }

  protected EncodedPolygonBean getBoundaryAsPolygonBean(Boundary boundary) {
    EncodedPolygonBean bean = new EncodedPolygonBean();
    EncodedPolylineBean outerRing = getPathAsEncodedPath(boundary.getOuterBoundary());
    bean.setOuterRing(outerRing);
    for (BoundaryPath path : boundary.getInnerBoundaries()) {
      EncodedPolylineBean innerRing = getPathAsEncodedPath(path);
      bean.addInnerRing(innerRing);
    }
    return bean;
  }
View Full Code Here

    checkBounds(grid.get(3), new CoordinateBounds(2.0, 3.0, 3.0, 4.0), DELTA);

    List<EncodedPolygonBean> boundary = factory.getBoundary();
    assertEquals(1, boundary.size());

    EncodedPolygonBean polygon = boundary.get(0);
    assertTrue(polygon.getInnerRings().isEmpty());

    List<CoordinatePoint> points = PolylineEncoder.decode(polygon.getOuterRing());
    points = shiftPoints(points);

    assertEquals(8, points.size());

    assertEqualsPoints(new CoordinatePoint(1.0, 2.0), points.get(0), DELTA);
    assertEqualsPoints(new CoordinatePoint(2.0, 2.0), points.get(1), DELTA);
    assertEqualsPoints(new CoordinatePoint(3.0, 2.0), points.get(2), DELTA);
    assertEqualsPoints(new CoordinatePoint(3.0, 3.0), points.get(3), DELTA);
    assertEqualsPoints(new CoordinatePoint(3.0, 4.0), points.get(4), DELTA);
    assertEqualsPoints(new CoordinatePoint(2.0, 4.0), points.get(5), DELTA);
    assertEqualsPoints(new CoordinatePoint(1.0, 4.0), points.get(6), DELTA);
    assertEqualsPoints(new CoordinatePoint(1.0, 3.0), points.get(7), DELTA);

    factory.addBounds(new CoordinateBounds(5.5, 4.5, 5.6, 4.6));

    grid = factory.getGrid();

    assertEquals(5, grid.size());

    Collections.sort(grid, BOUNDS_COMPARATOR);

    checkBounds(grid.get(0), new CoordinateBounds(1.0, 2.0, 2.0, 3.0), DELTA);
    checkBounds(grid.get(1), new CoordinateBounds(1.0, 3.0, 2.0, 4.0), DELTA);
    checkBounds(grid.get(2), new CoordinateBounds(2.0, 2.0, 3.0, 3.0), DELTA);
    checkBounds(grid.get(3), new CoordinateBounds(2.0, 3.0, 3.0, 4.0), DELTA);
    checkBounds(grid.get(4), new CoordinateBounds(5.0, 4.0, 6.0, 5.0), DELTA);

    boundary = factory.getBoundary();

    assertEquals(2, boundary.size());

    Collections.sort(boundary, POLYGON_COMPARATOR);
   
    polygon = boundary.get(0);
    assertTrue(polygon.getInnerRings().isEmpty());

    points = PolylineEncoder.decode(polygon.getOuterRing());
    points = shiftPoints(points);

    assertEquals(8, points.size());

    assertEqualsPoints(new CoordinatePoint(1.0, 2.0), points.get(0), DELTA);
    assertEqualsPoints(new CoordinatePoint(2.0, 2.0), points.get(1), DELTA);
    assertEqualsPoints(new CoordinatePoint(3.0, 2.0), points.get(2), DELTA);
    assertEqualsPoints(new CoordinatePoint(3.0, 3.0), points.get(3), DELTA);
    assertEqualsPoints(new CoordinatePoint(3.0, 4.0), points.get(4), DELTA);
    assertEqualsPoints(new CoordinatePoint(2.0, 4.0), points.get(5), DELTA);
    assertEqualsPoints(new CoordinatePoint(1.0, 4.0), points.get(6), DELTA);
    assertEqualsPoints(new CoordinatePoint(1.0, 3.0), points.get(7), DELTA);

    polygon = boundary.get(1);
    assertTrue(polygon.getInnerRings().isEmpty());

    points = PolylineEncoder.decode(polygon.getOuterRing());
    points = shiftPoints(points);

    assertEquals(4, points.size());

    assertEqualsPoints(new CoordinatePoint(5.0, 4.0), points.get(0), DELTA);
View Full Code Here

    _maxTime = 0;
    _complete = complete;

    for (int i = 0; i < polygons.size(); i++) {

      EncodedPolygonBean bean = polygons.get(i);
      List<EncodedPolylineBean> inner = bean.getInnerRings();

      EncodedPolyline[] lines = new EncodedPolyline[1 + inner.size()];

      lines[0] = createPolyline(bean.getOuterRing());

      for (int x = 0; x < inner.size(); x++)
        lines[1 + x] = createPolyline(inner.get(x));

      int time = times.get(i);
View Full Code Here

TOP

Related Classes of org.onebusaway.geospatial.model.EncodedPolygonBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.