Exemplo n.º 1
0
  /**
   * Test multi polygon geometries read from a GML 3.1 file
   *
   * @throws Exception if an error occurs
   */
  @Test
  public void testMultiPolygonGml31() throws Exception {
    InstanceCollection instances =
        AbstractHandlerTest.loadXMLInstances(
            getClass().getResource("/data/gml/geom-gml31.xsd").toURI(),
            getClass().getResource("/data/polygon/sample-multipolygon-gml31.xml").toURI());

    // one instance expected
    ResourceIterator<Instance> it = instances.iterator();
    try {
      // MultiPolygonProperty with LinearRings defined through coordinates
      assertTrue("First sample feature missing", it.hasNext());
      Instance instance = it.next();
      checkPolygonPropertyInstance(instance);
    } finally {
      it.close();
    }
  }
Exemplo n.º 2
0
  @Override
  public void init() {
    super.init();

    LinearRing shell =
        geomFactory.createLinearRing(
            new Coordinate[] {
              new Coordinate(0.01, 3.2),
              new Coordinate(3.33, 3.33),
              new Coordinate(0.01, -3.2),
              new Coordinate(-3.33, -3.2),
              new Coordinate(0.01, 3.2)
            });

    LinearRing[] holes = new LinearRing[2];
    LinearRing hole1 =
        geomFactory.createLinearRing(
            new Coordinate[] {
              new Coordinate(0, 1),
              new Coordinate(1, 1),
              new Coordinate(0, -1),
              new Coordinate(-1, -1),
              new Coordinate(0, 1)
            });
    LinearRing hole2 =
        geomFactory.createLinearRing(
            new Coordinate[] {
              new Coordinate(0, 2),
              new Coordinate(2, 2),
              new Coordinate(0, -2),
              new Coordinate(-2, -2),
              new Coordinate(0, 2)
            });
    holes[0] = hole1;
    holes[1] = hole2;

    Polygon polygon1 = geomFactory.createPolygon(shell, holes);

    shell =
        geomFactory.createLinearRing(
            new Coordinate[] {
              new Coordinate(6.01, 9.2),
              new Coordinate(9.33, 9.33),
              new Coordinate(6.01, -9.2),
              new Coordinate(-9.33, -9.2),
              new Coordinate(6.01, 9.2)
            });

    holes = new LinearRing[2];
    hole1 =
        geomFactory.createLinearRing(
            new Coordinate[] {
              new Coordinate(2, 3),
              new Coordinate(3, 3),
              new Coordinate(2, -3),
              new Coordinate(-3, -3),
              new Coordinate(2, 3)
            });
    hole2 =
        geomFactory.createLinearRing(
            new Coordinate[] {
              new Coordinate(2, 4),
              new Coordinate(4, 4),
              new Coordinate(2, -4),
              new Coordinate(-4, -4),
              new Coordinate(2, 4)
            });
    holes[0] = hole1;
    holes[1] = hole2;

    Polygon polygon2 = geomFactory.createPolygon(shell, holes);

    Polygon[] polygons = new Polygon[] {polygon1, polygon2};

    reference = geomFactory.createMultiPolygon(polygons);
  }