本文整理汇总了Java中org.opengis.feature.type.GeometryDescriptor.getCoordinateReferenceSystem方法的典型用法代码示例。如果您正苦于以下问题:Java GeometryDescriptor.getCoordinateReferenceSystem方法的具体用法?Java GeometryDescriptor.getCoordinateReferenceSystem怎么用?Java GeometryDescriptor.getCoordinateReferenceSystem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opengis.feature.type.GeometryDescriptor
的用法示例。
在下文中一共展示了GeometryDescriptor.getCoordinateReferenceSystem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findDescription
import org.opengis.feature.type.GeometryDescriptor; //导入方法依赖的package包/类
public static ShapeFileDesc findDescription(File file) throws IOException {
FileDataStore store = FileDataStoreFinder.getDataStore(file);
SimpleFeatureType schema = store.getSchema();
GeometryDescriptor geometryDescriptor = schema.getGeometryDescriptor();
GeometryType type = geometryDescriptor.getType();
CoordinateReferenceSystem coordinateReferenceSystem = geometryDescriptor.getCoordinateReferenceSystem();
List<AttributeDescriptor> attributeDescriptors = schema.getAttributeDescriptors();
List<String> labels = new ArrayList();
for (AttributeDescriptor a : attributeDescriptors) {
labels.add(a.getLocalName());
//labels
System.out.println(a.getLocalName());
}
//projection system
// System.out.println(coordinateReferenceSystem.getCoordinateSystem().getName().toString());
//type
System.out.println(parseGeometry(type));
double w = store.getFeatureSource().getBounds().getWidth();
double h = store.getFeatureSource().getBounds().getHeight();
return new ShapeFileDesc(coordinateReferenceSystem == null ? null : coordinateReferenceSystem.getCoordinateSystem().getName().toString(),
parseGeometry(type), labels, Math.sqrt(w * w + h * h));
}
示例2: reprojectFilter
import org.opengis.feature.type.GeometryDescriptor; //导入方法依赖的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);
}
}
示例3: getSRS
import org.opengis.feature.type.GeometryDescriptor; //导入方法依赖的package包/类
public static SRS getSRS(GeometryDescriptor gd) throws KettleException {
return new SRS(gd.getCoordinateReferenceSystem());
}