Java Code Examples for org.geotools.data.DataUtilities#attributeNames()

The following examples show how to use org.geotools.data.DataUtilities#attributeNames() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BandFeatureIterator.java    From geowave with Apache License 2.0 6 votes vote down vote up
private void init(final Filter cqlFilter) throws NoSuchAuthorityCodeException, FactoryException {
  final SimpleFeatureTypeBuilder typeBuilder =
      sceneIterator.getProvider().bandFeatureTypeBuilder();
  final SimpleFeatureType bandType = typeBuilder.buildFeatureType();

  Iterator<SimpleFeature> featureIterator = new FeatureIteratorIterator<>(sceneIterator);
  featureIterator =
      Iterators.concat(
          Iterators.transform(featureIterator, new SceneToBandFeatureTransform(bandType)));

  if ((cqlFilter != null) && !cqlFilter.equals(Filter.INCLUDE)) {
    final String[] attributes = DataUtilities.attributeNames(cqlFilter, bandType);

    // we can rely on the scene filtering if we don't have to check any
    // specific band filters
    if (ArrayUtils.contains(attributes, BAND_ATTRIBUTE_NAME)) {
      featureIterator =
          Iterators.filter(
              featureIterator,
              new SceneFeatureIterator.CqlFilterPredicate(cqlFilter));
    }
  }
  iterator = featureIterator;
}
 
Example 2
Source File: SceneFeatureIterator.java    From geowave with Apache License 2.0 5 votes vote down vote up
private boolean hasOtherProperties(final Filter cqlFilter) {
  final String[] attributes = DataUtilities.attributeNames(cqlFilter, type);

  for (final String attribute : attributes) {
    if (type.getDescriptor(attribute) == null) {
      return true;
    }
  }
  return false;
}
 
Example 3
Source File: PropertyIgnoringFilterVisitor.java    From geowave with Apache License 2.0 5 votes vote down vote up
private boolean usesProperty(final Filter filter) {
  final String[] attributes = DataUtilities.attributeNames(filter, type);

  // rely on best scene aggregation at a higher level if the filter is
  // using attributes not contained in the scene

  for (final String attribute : attributes) {
    if (!ArrayUtils.contains(validPropertyNames, attribute)) {
      return false;
    }
  }
  return true;
}
 
Example 4
Source File: SceneFeatureIterator.java    From geowave with Apache License 2.0 5 votes vote down vote up
private boolean hasOtherProperties(final Filter cqlFilter) {
  final String[] attributes = DataUtilities.attributeNames(cqlFilter, type);
  for (final String attr : attributes) {
    if (!ArrayUtils.contains(SCENE_ATTRIBUTES, attr)) {
      return true;
    }
  }
  return false;
}
 
Example 5
Source File: BandFeatureIterator.java    From geowave with Apache License 2.0 5 votes vote down vote up
private void init(
    final boolean nBestScenesByPathRow,
    final int nBestBands,
    final Filter cqlFilter) {
  // wrap the iterator with a feature conversion and a filter (if
  // provided)
  final SimpleFeatureType bandType = createFeatureType(sceneIterator.getFeatureType());
  iterator =
      Iterators.concat(
          Iterators.transform(
              new FeatureIteratorIterator<>(sceneIterator),
              new SceneToBandFeatureTransform(bandType)));
  if (cqlFilter != null) {
    final String[] attributes = DataUtilities.attributeNames(cqlFilter, bandType);
    // we can rely on the scene filtering if we don't have to check any
    // specific band filters
    if (ArrayUtils.contains(attributes, BAND_ATTRIBUTE_NAME)
        || ArrayUtils.contains(attributes, SIZE_ATTRIBUTE_NAME)
        || ArrayUtils.contains(attributes, BAND_DOWNLOAD_ATTRIBUTE_NAME)) {
      // and rely on the band filter
      iterator = Iterators.filter(iterator, new CqlFilterPredicate(cqlFilter));
      if (nBestBands > 0) {
        iterator = SceneFeatureIterator.nBestScenes(this, nBestScenesByPathRow, nBestBands);
      }
    }
  }
}
 
Example 6
Source File: PropertyIgnoringFilterVisitor.java    From geowave with Apache License 2.0 5 votes vote down vote up
private boolean usesProperty(final Filter filter) {
  final String[] attributes = DataUtilities.attributeNames(filter, type);
  // rely on best scene aggregation at a higher level if the filter is
  // using attributes not contained in the scene

  for (final String attr : attributes) {
    if (!ArrayUtils.contains(validPropertyNames, attr)) {
      return false;
    }
  }
  return true;
}