当前位置: 首页>>代码示例>>Java>>正文


Java Query.getFilter方法代码示例

本文整理汇总了Java中org.geotools.data.Query.getFilter方法的典型用法代码示例。如果您正苦于以下问题:Java Query.getFilter方法的具体用法?Java Query.getFilter怎么用?Java Query.getFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.geotools.data.Query的用法示例。


在下文中一共展示了Query.getFilter方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: makeDefinitionQuery

import org.geotools.data.Query; //导入方法依赖的package包/类
/**
 * Takes a query and adapts it to match re definitionQuery filter
 * configured for a feature type.
 *
 * @param query Query against this DataStore
 * @param schema TODO
 *
 * @return Query restricted to the limits of definitionQuery
 *
 * @throws IOException See DataSourceException
 * @throws DataSourceException If query could not meet the restrictions of
 *         definitionQuery
 */
protected Query makeDefinitionQuery(Query query, SimpleFeatureType schema) throws IOException {
    if ((query == Query.ALL) || query.equals(Query.ALL)) {
        return query;
    }

    try {
        String[] propNames = extractAllowedAttributes(query, schema);
        Filter filter = query.getFilter();
        filter = makeDefinitionFilter(filter);

        Query defQuery = new Query(query);
        defQuery.setFilter(filter);
        defQuery.setPropertyNames(propNames);

        // set sort by
        if (query.getSortBy() != null) {
            defQuery.setSortBy(query.getSortBy());
        }

        // tell the data sources about the default linearization tolerance for curved
        // geometries they might be reading
        if (linearizationTolerance != null) {
            query.getHints().put(Hints.LINEARIZATION_TOLERANCE, linearizationTolerance);
        }

        return defQuery;
    } catch (Exception ex) {
        throw new DataSourceException(
            "Could not restrict the query to the definition criteria: " + ex.getMessage(), ex);
    }
}
 
开发者ID:STEMLab,项目名称:geoserver-3d-extension,代码行数:45,代码来源:ISOGeoServerFeatureSource.java

示例2: getReaderInternal

import org.geotools.data.Query; //导入方法依赖的package包/类
@Override
protected FeatureReader<SimpleFeatureType, SimpleFeature> getReaderInternal(Query query) throws IOException {
    LOGGER.fine("getReaderInternal");
    FeatureReader<SimpleFeatureType, SimpleFeature> reader = null;
    try {
        final ElasticDataStore dataStore = getDataStore();
        final String docType = dataStore.getDocType(entry.getName());
        final boolean scroll = !useSortOrPagination(query) && dataStore.getScrollEnabled();
        final ElasticRequest searchRequest = prepareSearchRequest(query, scroll);
        final ElasticResponse sr = dataStore.getClient().search(dataStore.getIndexName(), docType, searchRequest);
        if (LOGGER.isLoggable(Level.FINE)) {
            LOGGER.fine("Search response: " + sr);
        }
        if (!scroll) {
            reader = new ElasticFeatureReader(getState(), sr);
        } else {
            reader = new ElasticFeatureReaderScroll(getState(), sr, getSize(query));
        }
        if (!filterFullySupported) {
            reader = new FilteringFeatureReader<SimpleFeatureType, SimpleFeature>(reader, query.getFilter());
        }
    } catch (Exception e) {
        LOGGER.log(Level.SEVERE, e.getMessage(), e);
        throw new IOException("Error executing query search", e);
    }
    return reader;
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:28,代码来源:ElasticFeatureSource.java

示例3: equals

import org.geotools.data.Query; //导入方法依赖的package包/类
/**
 * Equality based on propertyNames, maxFeatures, filter, typeName and
 * version.
 * 
 * <p>
 * Changing the handle does not change the meaning of the Query.
 * </p>
 * 
 * @param obj
 *            Other object to compare against
 * 
 * @return <code>true</code> if <code>obj</code> matches this filter
 */
@Override
public boolean equals(final Object obj) {
	if ((obj == null) || !(obj instanceof Query)) {
		return false;
	}

	if (this == obj) {
		return true;
	}

	final Query other = (Query) obj;

	return Arrays.equals(getPropertyNames(), other.getPropertyNames())
			&& (retrieveAllProperties() == other.retrieveAllProperties())
			&& (getMaxFeatures() == other.getMaxFeatures())
			&& ((getFilter() == null) ? (other.getFilter() == null)
					: getFilter().equals(other.getFilter()))
			&& ((getTypeName() == null) ? (other.getTypeName() == null)
					: getTypeName().equals(other.getTypeName()))
			&& ((getVersion() == null) ? (other.getVersion() == null)
					: getVersion().equals(other.getVersion()))
			&& ((getCoordinateSystem() == null) ? (other
					.getCoordinateSystem() == null) : getCoordinateSystem()
					.equals(other.getCoordinateSystem()))
			&& ((getCoordinateSystemReproject() == null) ? (other
					.getCoordinateSystemReproject() == null)
					: getCoordinateSystemReproject().equals(
							other.getCoordinateSystemReproject()));
}
 
开发者ID:52North,项目名称:uDig-SOS-plugin,代码行数:43,代码来源:ExampleAccessSOSProgramaticly.java

示例4: getCountInternal

import org.geotools.data.Query; //导入方法依赖的package包/类
@Override
protected int getCountInternal(Query query) throws IOException {
    // TODO: support query filter
    Filter filter = query.getFilter();
    if (filter != null) {
        //LOGGER.severe("Unhandled filter in getCountInternal" + query.getFilter());
        LOGGER.warning("Unable handler filter in getCountInternal" + query.getFilter().getClass().getName());
    }
    
    int count = -1;
    try {
        Statement q = getDataStore().getConnection().createStatement();
        ResultSet res = q.executeQuery("SELECT COUNT(*) FROM " + typeName);

        count = res.getInt(1);

        res.close();
        q.close();
    } catch (SQLException e) {
        throw new IOException(e);
    }
    
    if (checkLimitOffset(query)) {
        final int limit = query.getMaxFeatures();
        
        if (limit > count) {
            count = limit;
        }
    }
    
    System.out.println("FeatureCount: " + count);
    
    return count;
}
 
开发者ID:DennisPallett,项目名称:gt-jdbc-monetdb-simple,代码行数:35,代码来源:SimpleMonetDBFeatureSource.java

示例5: buildSqlQuery

import org.geotools.data.Query; //导入方法依赖的package包/类
protected String buildSqlQuery(Query query) throws IOException {
    StringBuilder sql = new StringBuilder("SELECT ");
    
    //column names
    selectColumns(getSchema(), null, query, sql);
    sql.setLength(sql.length() - 1);
    
    // from
    sql.append(" FROM ");
    sql.append(typeName);
    
    //filtering
    Filter filter = query.getFilter();
    if (filter != null && !Filter.INCLUDE.equals(filter)) {            
        sql.append(" WHERE ");
        
        //encode filter
        CoordinateReferenceSystem queryCrs = (query.getCoordinateSystem() != null) ? query.getCoordinateSystem() : query.getCoordinateSystemReproject();
        filter(getSchema(), filter, sql, queryCrs);
    }

    //sorting
    sort(getSchema(), query.getSortBy(), null, sql);
    
    // finally encode limit/offset, if necessary
    applyLimitOffset(sql, query);
    
    return sql.toString();
}
 
开发者ID:DennisPallett,项目名称:gt-jdbc-monetdb-simple,代码行数:30,代码来源:SimpleMonetDBFeatureSource.java

示例6: getFilter

import org.geotools.data.Query; //导入方法依赖的package包/类
private Filter getFilter(
		final Query query ) {
	final Filter filter = query.getFilter();
	if (filter instanceof BBOXImpl) {
		final BBOXImpl bbox = ((BBOXImpl) filter);
		final String propName = bbox.getPropertyName();
		if ((propName == null) || propName.isEmpty()) {
			bbox.setPropertyName(getSchema(
					reader,
					query).getGeometryDescriptor().getLocalName());
		}
	}
	return filter;
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:15,代码来源:GeoWaveFeatureCollection.java

示例7: reprojectFilter

import org.geotools.data.Query; //导入方法依赖的package包/类
private Query reprojectFilter(Query query) throws IOException {
    SimpleFeatureType nativeFeatureType = source.getSchema();
    final GeometryDescriptor geom = nativeFeatureType.getGeometryDescriptor();
    // if no geometry involved, no reprojection needed
    if(geom == null)
        return query;
    
    try {
        // default CRS: the CRS we can assume geometry and bbox elements in filter are
        // that is, usually the declared one, but the native one in the leave case
        CoordinateReferenceSystem defaultCRS = null;
        // we need to reproject all bbox and geometries to a target crs, which is
        // the native one usually, but it's the declared on in the force case (since in
        // that case we completely ignore the native one)
        CoordinateReferenceSystem targetCRS = null;
        CoordinateReferenceSystem nativeCRS = geom.getCoordinateReferenceSystem();
        if(srsHandling == ProjectionPolicy.FORCE_DECLARED) {
            defaultCRS = declaredCRS;
            targetCRS = declaredCRS;
            nativeFeatureType = FeatureTypes.transform(nativeFeatureType, declaredCRS);
        } else if(srsHandling == ProjectionPolicy.REPROJECT_TO_DECLARED) {
            defaultCRS = declaredCRS;
            targetCRS = nativeCRS;
        } else { // FeatureTypeInfo.LEAVE
            defaultCRS = nativeCRS;
            targetCRS = nativeCRS;
        }
        
        // now we apply a default to all geometries and bbox in the filter
        ISODefaultCRSFilterVisitor defaultCRSVisitor = new ISODefaultCRSFilterVisitor(ff, defaultCRS);
        Filter filter = query.getFilter() != null ? query.getFilter() : Filter.INCLUDE;
        Filter defaultedFilter = (Filter) filter.accept(defaultCRSVisitor, null);
        
        // and then we reproject all geometries so that the datastore receives
        // them in the native projection system (or the forced one, in case of force) 
        ISOReprojectingFilterVisitor reprojectingVisitor = new ISOReprojectingFilterVisitor(ff, nativeFeatureType);
        Filter reprojectedFilter = (Filter) defaultedFilter.accept(reprojectingVisitor, null);
        
        Query reprojectedQuery = new Query(query);
        reprojectedQuery.setFilter(reprojectedFilter);
        return reprojectedQuery;
    } catch(Exception e) {
        throw new DataSourceException("Had troubles handling filter reprojection...", e);
    }
}
 
开发者ID:STEMLab,项目名称:geoserver-3d-extension,代码行数:46,代码来源:ISOGeoServerFeatureSource.java


注:本文中的org.geotools.data.Query.getFilter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。