コード例 #1
0
  @SuppressWarnings("unchecked")
  public void XtestSetFeatures() {
    FeatureCollection<SimpleFeatureType, SimpleFeature> newFeatures =
        FeatureCollections.newCollection();
    newFeatures.add(feature1);
    table.setFeatures(newFeatures);
    while (Display.getCurrent().readAndDispatch()) ;

    assertEquals(1, table.getViewer().getTable().getItemCount());
    TableItem item = table.getViewer().getTable().getItem(0);
    assertEquals(feature1, item.getData());

    newFeatures.add(feature2);
    while (Display.getCurrent().readAndDispatch()) ;
    assertEquals(2, table.getViewer().getTable().getItemCount());
    item = table.getViewer().getTable().getItem(0);
    assertEquals(feature1, item.getData());
    item = table.getViewer().getTable().getItem(1);
    assertEquals(feature2, item.getData());

    newFeatures.remove(feature1);
    while (Display.getCurrent().readAndDispatch()) ;
    assertEquals(1, table.getViewer().getTable().getItemCount());
    item = table.getViewer().getTable().getItem(0);
    assertEquals(feature2, item.getData());
  }
コード例 #2
0
  public SimpleFeatureCollection createLineCollection() throws Exception {
    SimpleFeatureCollection fc = FeatureCollections.newCollection();
    fc.add(createLine(-177, 0, -177, 10));
    fc.add(createLine(-177, 0, -200, 0));
    fc.add(createLine(-177, 0, -177, 100));

    return fc;
  }
コード例 #3
0
  private MapLayer createCrsLayer(Geometry geom, CoordinateReferenceSystem crs) {
    SimpleFeatureCollection collection = FeatureCollections.newCollection();
    collection.add(createCrsBoundsFeature(geom, crs));

    Style style = getStyle("crs.sld");

    DefaultMapLayer ml = new DefaultMapLayer(collection, style);
    return ml;
  }
コード例 #4
0
 @SuppressWarnings("unchecked") // $NON-NLS-1$
 public void javaToNative(Object object, TransferData transferData) {
   Feature feature = (Feature) object;
   FeatureCollection collection = FeatureCollections.newCollection();
   collection.add(feature);
   FeatureTransformer transformer = new FeatureTransformer();
   transformer.setIndentation(4);
   try {
     TextTransfer.getInstance().javaToNative(transformer.transform(collection), transferData);
   } catch (TransformerException e) {
     throw (RuntimeException) new RuntimeException().initCause(e);
   }
 }
コード例 #5
0
    @SuppressWarnings("deprecation")
    public Object nativeToJava(TransferData transferData) {
      String string = (String) TextTransfer.getInstance().nativeToJava(transferData);
      InputSource input = new InputSource(new StringReader(string));
      FeatureCollection collection = FeatureCollections.newCollection();
      GMLReceiver receiver = new GMLReceiver(collection);
      GMLFilterFeature filterFeature = new GMLFilterFeature(receiver);
      GMLFilterGeometry filterGeometry = new GMLFilterGeometry(filterFeature);
      GMLFilterDocument filterDocument = new GMLFilterDocument(filterGeometry);
      try {
        // parse xml
        XMLReader reader = XMLReaderFactory.createXMLReader();
        reader.setContentHandler(filterDocument);
        reader.parse(input);
      } catch (Exception e) {
        throw new RuntimeException(e);
      }

      return collection.features().next();
    }
  /**
   * ********************************************************************** Private function which
   * generetes izolines from triangle with defined elevated Step
   *
   * @param T - triangleDT
   * @param elevatedStep - int elevated step
   * @return linked list of extract izolines
   * @throws ParseException
   * @throws SchemaException
   */
  public static FeatureCollection getRangedIzoLines(
      DelaunayDataStore triangles,
      ArrayList<Double> elevatedDifference,
      String EPSG,
      int rangeLimit)
      throws ParseException, SchemaException {

    WKTReader wktReader = new WKTReader();

    FeatureCollection trianglesFC = FeatureCollections.newCollection();

    for (int i = 0; i < triangles.getNumberOfTriangles(); i++) {
      TriangleDT T = triangles.getTriangle(i);
      Double tt = T.A.z;

      if (T != null) {
        LinkedList contours = rangedIzoLines(T, elevatedDifference.get(0).intValue(), rangeLimit);
        Iterator iter = contours.iterator();
        while (iter.hasNext()) {
          Izolines L = (Izolines) iter.next();
          LineString geometry =
              (LineString)
                  wktReader.read(
                      "LINESTRING ("
                          + (L.A.x)
                          + " "
                          + (L.A.y)
                          + ","
                          + (L.B.x)
                          + " "
                          + (L.B.y)
                          + ")");
          SimpleFeature feature = BuildNewFeature(L, geometry);
          trianglesFC.add(feature);
        }
      }
    }

    return trianglesFC;
  }
コード例 #7
0
  @SuppressWarnings("unchecked")
  protected void setUp() throws Exception {
    super.setUp();
    Display display = Display.getCurrent();
    shell = new Shell(display.getActiveShell());
    shell.setLayout(new FillLayout());

    SimpleFeatureType ft =
        DataUtilities.createType("type", "name:String,id:int"); // $NON-NLS-1$//$NON-NLS-2$
    feature1 =
        SimpleFeatureBuilder.build(
            ft, new Object[] {"feature1", 1}, "feature1"); // $NON-NLS-1$ //$NON-NLS-2$
    feature2 =
        SimpleFeatureBuilder.build(
            ft, new Object[] {"feature2", 2}, "feature2"); // $NON-NLS-1$ //$NON-NLS-2$
    feature3 =
        SimpleFeatureBuilder.build(
            ft, new Object[] {"feature3", 3}, "feature3"); // $NON-NLS-1$ //$NON-NLS-2$
    feature4 =
        SimpleFeatureBuilder.build(
            ft, new Object[] {"feature4", 4}, "feature4"); // $NON-NLS-1$ //$NON-NLS-2$

    features = FeatureCollections.newCollection();

    features.add(feature1);
    features.add(feature2);
    features.add(feature3);
    features.add(feature4);

    UiPlugin.getDefault().getPreferenceStore().setValue(FeatureTableControl.CACHING_WARNING, true);

    table =
        new FeatureTableControl(
            new StaticProvider<IProgressMonitor>(new NullProgressMonitor()), shell, features);
    shell.open();
    shell.redraw();

    while (Display.getCurrent().readAndDispatch()) ;
  }
コード例 #8
0
  @SuppressWarnings("unchecked")
  public void testUpdateFeatureCollection() throws Exception {
    SimpleFeatureType ft =
        DataUtilities.createType("type", "name:String,id:int"); // $NON-NLS-1$//$NON-NLS-2$
    SimpleFeature f1 =
        SimpleFeatureBuilder.build(
            ft, new Object[] {"feature1", 10}, "feature1"); // $NON-NLS-1$ //$NON-NLS-2$
    SimpleFeature f2 =
        SimpleFeatureBuilder.build(
            ft, new Object[] {"feature5", 5}, "feature5"); // $NON-NLS-1$ //$NON-NLS-2$

    FeatureCollection<SimpleFeatureType, SimpleFeature> newFeatures =
        FeatureCollections.newCollection();

    newFeatures.add(f1);
    newFeatures.add(f2);

    table.update(newFeatures);

    UDIGTestUtil.inDisplayThreadWait(
        100000000,
        new WaitCondition() {

          public boolean isTrue() {
            SimpleFeature feature =
                (SimpleFeature) table.getViewer().getTable().getItem(0).getData();
            return table.getViewer().getTable().getItemCount() == 5
                && ((Integer) feature.getAttribute("id")).intValue() == 10; // $NON-NLS-1$
          }
        },
        false);

    SimpleFeature feature = (SimpleFeature) table.getViewer().getTable().getItem(0).getData();

    assertEquals(5, table.getViewer().getTable().getItemCount());
    assertEquals(10, ((Integer) feature.getAttribute("id")).intValue()); // $NON-NLS-1$
    table.assertInternallyConsistent();
  }
コード例 #9
0
 public void testGetName() {
   Function qInt = ff.function("Quantile", ff.literal(FeatureCollections.newCollection()));
   assertEquals("Quantile", qInt.getName());
 }
コード例 #10
0
 public void testInstance() {
   Function equInt = ff.function("Quantile", ff.literal(FeatureCollections.newCollection()));
   assertNotNull(equInt);
 }