org.geotools.data.Query.getPropertyNames()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(183)

本文整理了Java中org.geotools.data.Query.getPropertyNames方法的一些代码示例,展示了Query.getPropertyNames的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.getPropertyNames方法的具体详情如下:
包路径:org.geotools.data.Query
类名称:Query
方法名:getPropertyNames

Query.getPropertyNames介绍

[英]Get the names of the properties that this Query will retrieve as part of the returned org.geotools.feature.FeatureCollection.
[中]获取此查询将作为返回组织的一部分检索的属性的名称。地理工具。特色特色系列。

代码示例

代码示例来源:origin: geoserver/geoserver

String[] queriedAtts = query.getPropertyNames();
int queriedAttCount = queriedAtts.length;
List allowedAtts = new LinkedList();

代码示例来源:origin: geoserver/geoserver

((SimpleFeatureStore) storeDelegate).modifyFeatures(names, values, filter);
} else if (writeQuery.getFilter() == Filter.EXCLUDE
    || writeQuery.getPropertyNames() == Query.NO_NAMES) {
  throw unsupportedOperation();
Query mixed = mixQueries(local, writeQuery);
if (writeQuery.getPropertyNames() == Query.ALL_NAMES) {
      new HashSet<String>(Arrays.asList(writeQuery.getPropertyNames()));

代码示例来源:origin: geoserver/geoserver

return;
} else if (writeQuery.getFilter() == Filter.EXCLUDE
    || writeQuery.getPropertyNames() == Query.NO_NAMES) {
  throw unsupportedOperation();
Query mixed = mixQueries(local, writeQuery);
if (writeQuery.getPropertyNames() == Query.ALL_NAMES) {
      new HashSet<String>(Arrays.asList(writeQuery.getPropertyNames()));

代码示例来源:origin: geoserver/geoserver

/**
 * * Takes into account eventual joins
 *
 * @param query
 * @return
 */
public SimpleFeatureType getFeatureType(Query query) {
  SimpleFeatureType result;
  if (query.getPropertyNames() != Query.ALL_NAMES) {
    result = SimpleFeatureTypeBuilder.retype(featureType, query.getPropertyNames());
  } else {
    result = featureType;
  }
  // add back the joined features in case of join
  if (!query.getJoins().isEmpty()) {
    SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder();
    tb.init(result);
    for (Join join : query.getJoins()) {
      String joinedFeatureAttribute = join.getAlias();
      if (joinedFeatureAttribute == null) {
        joinedFeatureAttribute = join.getTypeName();
      }
      tb.add(joinedFeatureAttribute, SimpleFeature.class);
    }
    result = tb.buildFeatureType();
  }
  return result;
}

代码示例来源:origin: geoserver/geoserver

return;
} else if (writeQuery.getFilter() == Filter.EXCLUDE
    || writeQuery.getPropertyNames() == Query.NO_NAMES) {
  throw unsupportedOperation();
Query mixed = mixQueries(local, writeQuery);
if (writeQuery.getPropertyNames() == Query.ALL_NAMES) {
      new HashSet<String>(Arrays.asList(writeQuery.getPropertyNames()));

代码示例来源:origin: geoserver/geoserver

if (query.getPropertyNames() == Query.ALL_NAMES) {
  return ft;
  SimpleFeatureType sft = (SimpleFeatureType) ft;
  Set<String> properties =
      new HashSet<String>(Arrays.asList(query.getPropertyNames()));
  SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder();
  tb.init(sft);

代码示例来源:origin: geoserver/geoserver

public void removeFeatures(Filter filter) throws IOException {
  // are we limiting anything?
  Query writeQuery = getWriteQuery(policy);
  if (writeQuery == Query.ALL) {
    storeDelegate.removeFeatures(filter);
  } else if (writeQuery.getFilter() == Filter.EXCLUDE
      || writeQuery.getPropertyNames() == Query.NO_NAMES) {
    throw unsupportedOperation();
  }
  // get the mixed filter
  final Query local = new Query(null, filter);
  Query mixed = mixQueries(local, writeQuery);
  storeDelegate.removeFeatures(mixed.getFilter());
}

代码示例来源:origin: geoserver/geoserver

|| writeQuery.getPropertyNames() == Query.NO_NAMES) {
  throw unsupportedOperation();
} else if (writeQuery == Query.ALL) {
  if (writeQuery.getPropertyNames() == Query.ALL_NAMES) {
    return storeDelegate.addFeatures(collection);
  } else {
      List<String> writableAttributes = Arrays.asList(writeQuery.getPropertyNames());
      CheckAttributesFeatureCollection checker =
          new CheckAttributesFeatureCollection(

代码示例来源:origin: geoserver/geoserver

SimpleFeatureType target =
    SimpleFeatureTypeBuilder.retype(
        sfc.getSchema(), mixed.getPropertyNames());
ReTypingFeatureCollection retyped = new ReTypingFeatureCollection(sfc, target);
return (FeatureCollection) SecuredObjects.secure(retyped, policy);

代码示例来源:origin: geotools/geotools

/**
 * Creates a sub-schema with only the selected attributes
 *
 * @param schema
 * @param query
 * @return
 */
static SimpleFeatureType retypeSchema(SimpleFeatureType schema, Query query) {
  if (query.getPropertyNames() == Query.ALL_NAMES) {
    return schema;
  } else {
    return SimpleFeatureTypeBuilder.retype(schema, query.getPropertyNames());
  }
}

代码示例来源:origin: geotools/geotools

SimpleFeatureType getResultSchema(Query q) {
  if (q.getPropertyNames() == null) {
    return getSchema();
  } else {
    return SimpleFeatureTypeBuilder.retype(getSchema(), q.getPropertyNames());
  }
}

代码示例来源:origin: geotools/geotools

boolean isSubQuery(Query query) {
  // no cached data?
  if (cachedQuery == null) return false;
  // do we miss some properties?
  String[] cachedPropNames = cachedQuery.getPropertyNames();
  String[] propNames = query.getPropertyNames();
  if (cachedPropNames != Query.ALL_NAMES
      && (propNames == Query.ALL_NAMES
          || !Arrays.asList(cachedPropNames).containsAll(Arrays.asList(propNames))))
    return false;
  Filter[] filters = splitFilters(query);
  Filter[] cachedFilters = splitFilters(cachedQuery);
  if (!filters[0].equals(cachedFilters[0])) return false;
  Envelope envelope = getEnvelope(filters[1]);
  return cachedBounds.contains(envelope);
}

代码示例来源:origin: geotools/geotools

@Override
public SimpleFeatureCollection getGranules(Query q) throws IOException {
  Query renamed = renameQuery(q);
  SimpleFeatureCollection granules = delegate.getGranules(renamed);
  SimpleFeatureType targetSchema = this.schema;
  if (q.getPropertyNames() != Query.ALL_NAMES) {
    targetSchema = SimpleFeatureTypeBuilder.retype(schema, q.getPropertyNames());
  }
  return new ReTypingFeatureCollection(granules, targetSchema);
}

代码示例来源:origin: geotools/geotools

private SimpleFeatureCollection getFeatureCollection(Query query, Envelope bounds)
    throws IOException {
  try {
    SimpleFeatureType base = wrapped.getSchema();
    SimpleFeatureType alternate = base;
    if (query.getPropertyNames() != Query.ALL_NAMES) {
      alternate = SimpleFeatureTypeBuilder.retype(base, query.getPropertyNames());
      if (alternate.equals(base)) alternate = base;
    }
    return new CachingFeatureCollection(bounds, base, alternate, query);
  } catch (Exception e) {
    throw new DataSourceException(
        "Error occurred extracting features from the spatial index", e);
  }
}

代码示例来源:origin: geotools/geotools

SimpleFeatureType getReadSchema(Query q) {
  if (q.getPropertyNames() == Query.ALL_NAMES) {
    return getSchema();
  }
  // Step 1: start with requested property names
  LinkedHashSet<String> attributes = new LinkedHashSet<String>();
  attributes.addAll(Arrays.asList(q.getPropertyNames()));
  Filter filter = q.getFilter();
  if (filter != null && !Filter.INCLUDE.equals(filter)) {
    // Step 2: Add query attributes (if needed)
    // Step 3: Fill empty XPath with appropriate property names
    FilterAttributeExtractor fat = new AbsoluteAttributeExtractor(getSchema());
    filter.accept(fat, null);
    attributes.addAll(fat.getAttributeNameSet());
  }
  return SimpleFeatureTypeBuilder.retype(getSchema(), new ArrayList<String>(attributes));
}

代码示例来源:origin: geotools/geotools

private SimpleFeatureSource getFeatureSourceFor(Query query) throws IOException {
  Double distance = getRequestedDistance(query);
  String geomPropertyName = info.getGeomPropertyName(); // the geometry for which we have
  // generalizations
  String[] queryProperyNames = query.getPropertyNames();
  if (queryProperyNames != null) {
    for (String prop : queryProperyNames) { // check if geom property name was specified in
      // the query
      if (prop.equals(geomPropertyName)) return getFeatureSourceFor(distance);
    }
  } else { // we have Query.ALL
    return getFeatureSourceFor(distance);
  }
  // no geometry in the query for which generalizations are present.
  return getBaseFeatureSource();
}

代码示例来源:origin: geotools/geotools

/**
 * Hashcode based on all parameters other than the handle.
 *
 * @return hascode for this Query
 */
@Override
public int hashCode() {
  String[] n = getPropertyNames();
  return ((n == null) ? (-1) : ((n.length == 0) ? 0 : (n.length | n[0].hashCode())))
      | getMaxFeatures()
      | ((getFilter() == null) ? 0 : getFilter().hashCode())
      | ((getTypeName() == null) ? 0 : getTypeName().hashCode())
      | ((getVersion() == null) ? 0 : getVersion().hashCode())
      | ((getCoordinateSystem() == null) ? 0 : getCoordinateSystem().hashCode())
      | ((getCoordinateSystemReproject() == null)
          ? 0
          : getCoordinateSystemReproject().hashCode())
      | getStartIndex();
}

代码示例来源:origin: geotools/geotools

/**
 * Configure expected
 *
 * @param origional
 * @param query
 * @return
 */
public static SimpleFeatureType retype(SimpleFeatureType origional, Query query) {
  CoordinateReferenceSystem crs = null;
  if (query.getCoordinateSystem() != null) {
    crs = query.getCoordinateSystem();
  }
  if (query.getCoordinateSystemReproject() != null) {
    crs = query.getCoordinateSystemReproject();
  }
  return retype(origional, query.getPropertyNames(), crs);
}

代码示例来源:origin: geotools/geotools

public SimpleFeatureType getQueryType(Query query) throws IOException {
  final String typeName = query.getTypeName();
  final String propertyNames[] = query.getPropertyNames();
  final FeatureTypeInfo typeInfo = typeInfoCache.getFeatureTypeInfo(typeName);
  final SimpleFeatureType completeSchema = typeInfo.getFeatureType();
  SimpleFeatureType featureType = completeSchema;
  if (!query.retrieveAllProperties() || query.getCoordinateSystem() != null) {
    try {
      featureType =
          DataUtilities.createSubType(
              featureType, propertyNames, query.getCoordinateSystem());
    } catch (SchemaException e) {
      LOGGER.log(Level.FINEST, e.getMessage(), e);
      throw new DataSourceException("Could not create Feature Type for query", e);
    }
  }
  return featureType;
}

代码示例来源:origin: geotools/geotools

/** Get features based on the query specified. */
@Override
public FeatureCollection<FeatureType, Feature> getFeatures(Query query) throws IOException {
  GetFeatureRequest request = client.createGetFeatureRequest();
  FeatureType schema = dataAccess.getSchema(typeName);
  QName name = dataAccess.getRemoteTypeName(typeName);
  request.setTypeName(new QName(query.getTypeName()));
  request.setFullType(schema);
  request.setFilter(query.getFilter());
  request.setPropertyNames(query.getPropertyNames());
  request.setSortBy(query.getSortBy());
  String srsName = null;
  request.setSrsName(srsName);
  return new WFSContentComplexFeatureCollection(request, schema, name);
}

相关文章