當前位置: 首頁>>代碼示例>>Java>>正文


Java SimpleFeatureType.getGeometryDescriptor方法代碼示例

本文整理匯總了Java中org.opengis.feature.simple.SimpleFeatureType.getGeometryDescriptor方法的典型用法代碼示例。如果您正苦於以下問題:Java SimpleFeatureType.getGeometryDescriptor方法的具體用法?Java SimpleFeatureType.getGeometryDescriptor怎麽用?Java SimpleFeatureType.getGeometryDescriptor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.opengis.feature.simple.SimpleFeatureType的用法示例。


在下文中一共展示了SimpleFeatureType.getGeometryDescriptor方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: reprojectFilter

import org.opengis.feature.simple.SimpleFeatureType; //導入方法依賴的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.opengis.feature.simple.SimpleFeatureType.getGeometryDescriptor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。