Ejemplo n.º 1
0
  private static FeatureCollection<?> buildFeatureUnionList() {

    try {
      type = createSimpleType2();
    } catch (NoSuchAuthorityCodeException ex) {
      Logger.getLogger(UnionTest.class.getName()).log(Level.SEVERE, null, ex);
    } catch (FactoryException ex) {
      Logger.getLogger(UnionTest.class.getName()).log(Level.SEVERE, null, ex);
    }

    final FeatureCollection<Feature> featureList = DataUtilities.collection("", type);

    Feature myFeature1;
    LinearRing ring =
        geometryFactory.createLinearRing(
            new Coordinate[] {
              new Coordinate(4.0, 4.0),
              new Coordinate(4.0, 8.0),
              new Coordinate(7.0, 8.0),
              new Coordinate(7.0, 4.0),
              new Coordinate(4.0, 4.0)
            });
    sfb = new SimpleFeatureBuilder(type);
    sfb.set("name", "feature11");
    sfb.set("color", "red");
    sfb.set("geom3", geometryFactory.createPolygon(ring, null));
    sfb.set("att", 20);
    myFeature1 = sfb.buildFeature("id-11");
    featureList.add(myFeature1);

    Feature myFeature2;
    ring =
        geometryFactory.createLinearRing(
            new Coordinate[] {
              new Coordinate(7.0, 4.0),
              new Coordinate(7.0, 8.0),
              new Coordinate(9.0, 8.0),
              new Coordinate(9.0, 4.0),
              new Coordinate(7.0, 4.0)
            });
    sfb = new SimpleFeatureBuilder(type);
    sfb.set("name", "feature12");
    sfb.set("color", "blue");
    sfb.set("geom3", geometryFactory.createPolygon(ring, null));
    sfb.set("att", 20);
    myFeature2 = sfb.buildFeature("id-12");
    featureList.add(myFeature2);

    Feature myFeature3;
    ring =
        geometryFactory.createLinearRing(
            new Coordinate[] {
              new Coordinate(6.0, 2.0),
              new Coordinate(6.0, 4.0),
              new Coordinate(9.0, 4.0),
              new Coordinate(9.0, 2.0),
              new Coordinate(6.0, 2.0)
            });
    sfb = new SimpleFeatureBuilder(type);
    sfb.set("name", "feature13");
    sfb.set("color", "grey");
    sfb.set("geom3", geometryFactory.createPolygon(ring, null));
    sfb.set("att", 10);
    myFeature3 = sfb.buildFeature("id-13");
    featureList.add(myFeature3);

    Feature myFeature4;
    ring =
        geometryFactory.createLinearRing(
            new Coordinate[] {
              new Coordinate(4.0, 2.0),
              new Coordinate(4.0, 3.0),
              new Coordinate(5.0, 3.0),
              new Coordinate(5.0, 2.0),
              new Coordinate(4.0, 2.0)
            });
    sfb = new SimpleFeatureBuilder(type);
    sfb.set("name", "feature14");
    sfb.set("color", "grey");
    sfb.set("geom3", geometryFactory.createPolygon(ring, null));
    sfb.set("att", 12);
    myFeature4 = sfb.buildFeature("id-14");
    featureList.add(myFeature4);

    Feature myFeature5;
    ring =
        geometryFactory.createLinearRing(
            new Coordinate[] {
              new Coordinate(2.0, 5.0),
              new Coordinate(2.0, 6.0),
              new Coordinate(3.0, 6.0),
              new Coordinate(3.0, 5.0),
              new Coordinate(2.0, 5.0)
            });
    sfb = new SimpleFeatureBuilder(type);
    sfb.set("name", "feature15");
    sfb.set("color", "grey");
    sfb.set("geom3", geometryFactory.createPolygon(ring, null));
    sfb.set("att", 12);
    myFeature5 = sfb.buildFeature("id-15");
    featureList.add(myFeature5);

    return featureList;
  }
Ejemplo n.º 2
0
  private static FeatureCollection<?> buildResultList() {

    try {
      type = createSimpleResultType();
    } catch (NoSuchAuthorityCodeException ex) {
      Logger.getLogger(UnionTest.class.getName()).log(Level.SEVERE, null, ex);
    } catch (FactoryException ex) {
      Logger.getLogger(UnionTest.class.getName()).log(Level.SEVERE, null, ex);
    }

    final FeatureCollection<Feature> featureList = DataUtilities.collection("", type);

    Feature myFeature;
    LinearRing ring =
        geometryFactory.createLinearRing(
            new Coordinate[] {
              new Coordinate(4, 7),
              new Coordinate(6, 7),
              new Coordinate(6, 5),
              new Coordinate(4, 5),
              new Coordinate(4, 7)
            });
    sfb = new SimpleFeatureBuilder(type);
    sfb.set("name", "feature1");
    sfb.set("color", "red");
    sfb.set("geom1", geometryFactory.createPolygon(ring, null));
    sfb.set("att", 20);
    myFeature = sfb.buildFeature("id-01-id-11");
    featureList.add(myFeature);

    LineString str =
        geometryFactory.createLineString(
            new Coordinate[] {new Coordinate(3, 5), new Coordinate(3, 6)});
    sfb = new SimpleFeatureBuilder(type);
    sfb.set("name", "feature1");
    sfb.set("color", "grey");
    sfb.set("geom1", str);
    sfb.set("att", 12);
    myFeature = sfb.buildFeature("id-01-id-15");
    featureList.add(myFeature);

    ring =
        geometryFactory.createLinearRing(
            new Coordinate[] {
              new Coordinate(3, 5),
              new Coordinate(3, 6),
              new Coordinate(3, 7),
              new Coordinate(4, 7),
              new Coordinate(4, 5),
              new Coordinate(3, 5)
            });
    sfb = new SimpleFeatureBuilder(type);
    sfb.set("name", "feature1");
    sfb.set("color", null);
    sfb.set("att", null);
    sfb.set("geom1", geometryFactory.createPolygon(ring, null));
    myFeature = sfb.buildFeature("id-01");
    featureList.add(myFeature);

    ring =
        geometryFactory.createLinearRing(
            new Coordinate[] {
              new Coordinate(7, 5),
              new Coordinate(8, 5),
              new Coordinate(8, 4),
              new Coordinate(7, 4),
              new Coordinate(7, 5)
            });
    sfb = new SimpleFeatureBuilder(type);
    sfb.set("name", "feature3");
    sfb.set("color", "blue");
    sfb.set("att", 20);
    sfb.set("geom1", geometryFactory.createPolygon(ring, null));
    myFeature = sfb.buildFeature("id-03-id-12");
    featureList.add(myFeature);

    ring =
        geometryFactory.createLinearRing(
            new Coordinate[] {
              new Coordinate(6, 4),
              new Coordinate(6, 5),
              new Coordinate(7, 5),
              new Coordinate(7, 4),
              new Coordinate(6, 4)
            });
    sfb = new SimpleFeatureBuilder(type);
    sfb.set("name", "feature3");
    sfb.set("color", "red");
    sfb.set("att", 20);
    sfb.set("geom1", geometryFactory.createPolygon(ring, null));
    myFeature = sfb.buildFeature("id-03-id-11");
    featureList.add(myFeature);

    ring =
        geometryFactory.createLinearRing(
            new Coordinate[] {
              new Coordinate(6, 2),
              new Coordinate(6, 4),
              new Coordinate(8, 4),
              new Coordinate(8, 2),
              new Coordinate(6, 2)
            });
    sfb = new SimpleFeatureBuilder(type);
    sfb.set("name", "feature3");
    sfb.set("color", "grey");
    sfb.set("att", 10);
    sfb.set("geom1", geometryFactory.createPolygon(ring, null));
    myFeature = sfb.buildFeature("id-03-id-13");
    featureList.add(myFeature);

    ring =
        geometryFactory.createLinearRing(
            new Coordinate[] {
              new Coordinate(7, 7),
              new Coordinate(8, 7),
              new Coordinate(8, 5),
              new Coordinate(7, 5),
              new Coordinate(7, 7)
            });
    sfb = new SimpleFeatureBuilder(type);
    sfb.set("name", "feature2");
    sfb.set("color", "blue");
    sfb.set("att", 20);
    sfb.set("geom1", geometryFactory.createPolygon(ring, null));
    myFeature = sfb.buildFeature("id-02-id-12");
    featureList.add(myFeature);

    ring =
        geometryFactory.createLinearRing(
            new Coordinate[] {
              new Coordinate(6, 5),
              new Coordinate(6, 7),
              new Coordinate(7, 7),
              new Coordinate(7, 5),
              new Coordinate(6, 5)
            });
    sfb = new SimpleFeatureBuilder(type);
    sfb.set("name", "feature2");
    sfb.set("color", "red");
    sfb.set("att", 20);
    sfb.set("geom1", geometryFactory.createPolygon(ring, null));
    myFeature = sfb.buildFeature("id-02-id-11");
    featureList.add(myFeature);

    ring =
        geometryFactory.createLinearRing(
            new Coordinate[] {
              new Coordinate(2, 3),
              new Coordinate(2, 4),
              new Coordinate(3, 4),
              new Coordinate(3, 3),
              new Coordinate(2, 3)
            });
    sfb = new SimpleFeatureBuilder(type);
    sfb.set("name", "feature4");
    sfb.set("color", null);
    sfb.set("att", null);
    sfb.set("geom1", geometryFactory.createPolygon(ring, null));
    myFeature = sfb.buildFeature("id-04");
    featureList.add(myFeature);

    ring =
        geometryFactory.createLinearRing(
            new Coordinate[] {
              new Coordinate(7, 7),
              new Coordinate(7, 8),
              new Coordinate(9, 8),
              new Coordinate(9, 4),
              new Coordinate(8, 4),
              new Coordinate(8, 5),
              new Coordinate(8, 7),
              new Coordinate(7, 7)
            });
    sfb = new SimpleFeatureBuilder(type);
    sfb.set("name", "feature12");
    sfb.set("color", "blue");
    sfb.set("att", 20);
    sfb.set("geom1", geometryFactory.createPolygon(ring, null));
    myFeature = sfb.buildFeature("id-12");
    featureList.add(myFeature);

    ring =
        geometryFactory.createLinearRing(
            new Coordinate[] {
              new Coordinate(8, 4),
              new Coordinate(9, 4),
              new Coordinate(9, 2),
              new Coordinate(8, 2),
              new Coordinate(8, 4)
            });
    sfb = new SimpleFeatureBuilder(type);
    sfb.set("name", "feature13");
    sfb.set("color", "grey");
    sfb.set("att", 10);
    sfb.set("geom1", geometryFactory.createPolygon(ring, null));
    myFeature = sfb.buildFeature("id-13");
    featureList.add(myFeature);

    ring =
        geometryFactory.createLinearRing(
            new Coordinate[] {
              new Coordinate(4, 2),
              new Coordinate(4, 3),
              new Coordinate(5, 3),
              new Coordinate(5, 2),
              new Coordinate(4, 2)
            });
    sfb = new SimpleFeatureBuilder(type);
    sfb.set("name", "feature14");
    sfb.set("color", "grey");
    sfb.set("att", 12);
    sfb.set("geom1", geometryFactory.createPolygon(ring, null));
    myFeature = sfb.buildFeature("id-14");
    featureList.add(myFeature);

    ring =
        geometryFactory.createLinearRing(
            new Coordinate[] {
              new Coordinate(4, 4),
              new Coordinate(4, 5),
              new Coordinate(6, 5),
              new Coordinate(6, 4),
              new Coordinate(4, 4)
            });
    LinearRing ring2 =
        geometryFactory.createLinearRing(
            new Coordinate[] {
              new Coordinate(6, 7),
              new Coordinate(4, 7),
              new Coordinate(4, 8),
              new Coordinate(7, 8),
              new Coordinate(7, 7),
              new Coordinate(6, 7)
            });
    Polygon poly1 = geometryFactory.createPolygon(ring, null);
    Polygon poly2 = geometryFactory.createPolygon(ring2, null);
    sfb = new SimpleFeatureBuilder(type);
    sfb.set("name", "feature11");
    sfb.set("color", "red");
    sfb.set("att", 20);
    sfb.set("geom1", geometryFactory.createMultiPolygon(new Polygon[] {poly1, poly2}));
    myFeature = sfb.buildFeature("id-11");
    featureList.add(myFeature);

    Feature myFeature5;
    ring =
        geometryFactory.createLinearRing(
            new Coordinate[] {
              new Coordinate(2.0, 5.0),
              new Coordinate(2.0, 6.0),
              new Coordinate(3.0, 6.0),
              new Coordinate(3.0, 5.0),
              new Coordinate(2.0, 5.0)
            });
    sfb = new SimpleFeatureBuilder(type);
    sfb.set("name", "feature15");
    sfb.set("color", "grey");
    sfb.set("geom1", geometryFactory.createPolygon(ring, null));
    sfb.set("att", 12);
    myFeature5 = sfb.buildFeature("id-15");
    featureList.add(myFeature5);

    return featureList;
  }
Ejemplo n.º 3
0
  private static FeatureCollection<?> buildFeatureList() {

    try {
      type = createSimpleType();
    } catch (NoSuchAuthorityCodeException ex) {
      Logger.getLogger(UnionTest.class.getName()).log(Level.SEVERE, null, ex);
    } catch (FactoryException ex) {
      Logger.getLogger(UnionTest.class.getName()).log(Level.SEVERE, null, ex);
    }

    final FeatureCollection<Feature> featureList = DataUtilities.collection("", type);

    Feature myFeature1;
    LinearRing ring =
        geometryFactory.createLinearRing(
            new Coordinate[] {
              new Coordinate(3.0, 5.0),
              new Coordinate(3.0, 7.0),
              new Coordinate(6.0, 7.0),
              new Coordinate(6.0, 5.0),
              new Coordinate(3.0, 5.0)
            });
    sfb = new SimpleFeatureBuilder(type);
    sfb.set("name", "feature1");
    sfb.set("geom1", geometryFactory.createPolygon(ring, null));
    myFeature1 = sfb.buildFeature("id-01");
    featureList.add(myFeature1);

    Feature myFeature2;
    ring =
        geometryFactory.createLinearRing(
            new Coordinate[] {
              new Coordinate(6.0, 5.0),
              new Coordinate(6.0, 7.0),
              new Coordinate(8.0, 7.0),
              new Coordinate(8.0, 5.0),
              new Coordinate(6.0, 5.0)
            });
    sfb = new SimpleFeatureBuilder(type);
    sfb.set("name", "feature2");
    sfb.set("geom1", geometryFactory.createPolygon(ring, null));
    myFeature2 = sfb.buildFeature("id-02");
    featureList.add(myFeature2);

    Feature myFeature3;
    ring =
        geometryFactory.createLinearRing(
            new Coordinate[] {
              new Coordinate(6.0, 2.0),
              new Coordinate(6.0, 5.0),
              new Coordinate(8.0, 5.0),
              new Coordinate(8.0, 2.0),
              new Coordinate(6.0, 2.0)
            });
    sfb = new SimpleFeatureBuilder(type);
    sfb.set("name", "feature3");
    sfb.set("geom1", geometryFactory.createPolygon(ring, null));
    // sfb.set("geom2", line);
    myFeature3 = sfb.buildFeature("id-03");
    featureList.add(myFeature3);

    Feature myFeature4;
    ring =
        geometryFactory.createLinearRing(
            new Coordinate[] {
              new Coordinate(2.0, 3.0),
              new Coordinate(2.0, 4.0),
              new Coordinate(3.0, 4.0),
              new Coordinate(3.0, 3.0),
              new Coordinate(2.0, 3.0)
            });
    sfb = new SimpleFeatureBuilder(type);
    sfb.set("name", "feature4");
    sfb.set("geom1", geometryFactory.createPolygon(ring, null));
    myFeature4 = sfb.buildFeature("id-04");
    featureList.add(myFeature4);

    return featureList;
  }