Пример #1
0
  /**
   * Round Trip test for a single MultiPolygon with lotsa points
   *
   * @throws SQLException
   */
  public void testSingleMultiPolygonManyPointsManyHolesRoundTrip() throws SQLException {

    PolygonGenerator pgc = new PolygonGenerator();
    pgc.setGeometryFactory(geometryFactory);
    pgc.setGenerationAlgorithm(PolygonGenerator.BOX);
    pgc.setNumberPoints(100);
    pgc.setNumberHoles(100);
    MultiGenerator pg = new MultiGenerator(pgc);
    pg.setBoundingBox(new Envelope(0, 10, 0, 10));
    pg.setNumberGeometries(3);
    pg.setGeometryFactory(geometryFactory);

    MultiPolygon pt = (MultiPolygon) pg.create();
    //		System.out.println((pt==null?"NULL":pt.toString()));

    OraWriter ow = new OraWriter();
    STRUCT st = ow.write(pt, getConnection());

    OraReader or = new OraReader();
    MultiPolygon pt2 = (MultiPolygon) or.read(st);

    //		System.out.println((pt==null?"NULL":pt.toString()));
    //		System.out.println((pt2==null?"NULL":pt2.toString()));
    assertTrue("The input MultiPolygon is not the same as the output MultiPolygon", pt.equals(pt2));
  }
Пример #2
0
  /**
   * Round Trip test for a 8 overlapping line MultiPolygons (4 distinct MultiPolygons)
   *
   * @throws SQLException
   */
  public void testOverlappingMultiPolygonsHolesRoundTrip() throws SQLException {
    GridGenerator grid = new GridGenerator();
    grid.setGeometryFactory(geometryFactory);
    grid.setBoundingBox(new Envelope(0, 10, 0, 10));
    grid.setNumberColumns(2);
    grid.setNumberRows(2);

    MultiPolygon[] pt = new MultiPolygon[4];
    STRUCT[] st = new STRUCT[8];

    PolygonGenerator pgc = new PolygonGenerator();
    pgc.setGeometryFactory(geometryFactory);
    pgc.setGenerationAlgorithm(PolygonGenerator.BOX);
    pgc.setNumberPoints(10);
    pgc.setNumberHoles(4);
    MultiGenerator pg = new MultiGenerator(pgc);
    pg.setBoundingBox(new Envelope(0, 10, 0, 10));
    pg.setNumberGeometries(3);
    pg.setGeometryFactory(geometryFactory);

    OraWriter ow = new OraWriter();

    int i = 0;
    while (grid.canCreate() && i < 8) {
      pg.setBoundingBox(grid.createEnv());
      pt[i] = (MultiPolygon) pg.create();
      st[i] = ow.write(pt[i], getConnection());
      i++;
    }
    for (int j = 0; j < 4; j++) {
      if (pt[j] != null) st[i++] = ow.write(pt[j], getConnection());
    }

    OraReader or = new OraReader();
    i = 0;
    while (i < 8 && pt[i % 4] != null) {
      MultiPolygon pt2 = (MultiPolygon) or.read(st[i]);
      //			System.out.println((pt==null?"NULL":pt[i%4].toString()));
      //			System.out.println((pt2==null?"NULL":pt2.toString()));
      assertTrue(
          "The input MultiPolygon is not the same as the output MultiPolygon",
          pt[i % 4].equals(pt2));
      i++;
    }
  }