コード例 #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();
    }
  }
コード例 #2
0
    /** Update the selection */
    protected void updateSelection() {
      if (!typeDefinitions.getSelection().isEmpty()) {
        TypeDefinition type =
            (TypeDefinition)
                ((IStructuredSelection) typeDefinitions.getSelection()).getFirstElement();

        filterField.setType(type);

        SchemaSpaceID space = getSchemaSpace();

        Integer max = (Integer) ((IStructuredSelection) count.getSelection()).getFirstElement();

        InstanceService is = PlatformUI.getWorkbench().getService(InstanceService.class);

        List<Instance> instanceList = new ArrayList<Instance>();
        DataSet dataset =
            (space == SchemaSpaceID.SOURCE) ? (DataSet.SOURCE) : (DataSet.TRANSFORMED);

        Filter filter = null;
        String filterExpression = filterField.getFilterExpression();
        /*
         * Custom filter handling.
         *
         * FIXME Ultimately this should be done by the filter field
         * instead, which should be able to handle all kinds of
         * registered filters (e.g. also Groovy).
         */
        if (filterExpression.startsWith("id:")) {
          // XXX meta ID "hack"
          String metaFilter = filterExpression.substring("id:".length());
          String[] values = metaFilter.split(",");

          filter =
              new MetaFilter(
                  type, InstanceMetadata.METADATA_ID, new HashSet<>(Arrays.asList(values)));
        } else if (filterExpression.startsWith("source:")) {
          // XXX meta source ID "hack"
          String metaFilter = filterExpression.substring("source:".length());
          String[] values = metaFilter.split(",");

          filter =
              new MetaFilter(
                  type, InstanceMetadata.METADATA_SOURCEID, new HashSet<>(Arrays.asList(values)));
        } else {
          filter = filterField.getFilter();
        }

        InstanceCollection instances = is.getInstances(dataset);
        if (filter != null) {
          instances = instances.select(filter);
        }

        ResourceIterator<Instance> it = instances.iterator();
        try {
          int num = 0;
          while (it.hasNext() && num < max) {
            Instance instance = it.next();
            if (instance.getDefinition().equals(type)) {
              instanceList.add(instance);
              num++;
            }
          }
        } finally {
          it.close();
        }

        selection = instanceList;
        selectedType = type;
      } else {
        selection = null;
        selectedType = null;

        filterField.setType(null);
      }

      for (InstanceSelectionListener listener : listeners) {
        listener.selectionChanged(selectedType, selection);
      }
    }