记录一下如何创建创建缓冲区并获取缓冲区内的要素,便于以后查找使用

     static SimpleFeatureSource featureSource = null;
static CoordinateReferenceSystem targetCRS;
   static String geometryPropertyName;
static FilterFactory2 ff;
public SimpleFeatureCollection grabFeaturesInBoundingBox(double x1, double y1, double x2, double y2)
throws Exception {
ShapefileDataStoreFactory dataStoreFactory = new ShapefileDataStoreFactory();
ShapefileDataStore sds = (ShapefileDataStore)dataStoreFactory.createDataStore
(new File("E://Merge_direction.shp").toURI().toURL()); Charset charset = Charset.forName("GBK");
sds.setCharset(charset);
String typeName = sds.getTypeNames()[0];
featureSource = sds.getFeatureSource (typeName);
FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
FeatureType schema = featureSource.getSchema(); geometryPropertyName = schema.getGeometryDescriptor().getLocalName();
targetCRS = schema.getGeometryDescriptor().getCoordinateReferenceSystem(); ReferencedEnvelope bbox = new ReferencedEnvelope(x1, y1, x2, y2, targetCRS); Filter filter = ff.bbox(ff.property(geometryPropertyName), bbox);
return featureSource.getFeatures(filter);
}

最新文章

  1. Double Checked Locking 模式
  2. 面试题目——《CC150》递归与动态规划
  3. Linux下rz命令使用的实例详解
  4. GCD学习之dispatch_barrier_async
  5. android - startActivity浅谈
  6. wpf 如何设置滚动条在超出范围的时候才显示?(转)
  7. 服务启动错误1053,一例解决方案(给用户添加NetworkService权限)
  8. 程序员如何巧用Excel提高工作效率
  9. Django12-ModelForm中创建局部钩子和全局钩子
  10. redis安装以及安全配置
  11. ArcPy批量计算Mean Center的两个实例
  12. Leetcode 1021. 最佳观光组合
  13. SQL创建删除索引
  14. TimeZone 时区 (JS .NET JSON MYSQL) + work week 闰年
  15. Java面试题整理1
  16. 【bzoj2006】【NOI2015】超级钢琴
  17. Git添加本地项目出现fatal: unable to get credential storage lock: File exists
  18. Spark性能优化的10大问题及其解决方案
  19. python学习之路 一 :编程语言介绍
  20. Openshift部署Zookeeper和Kafka

热门文章

  1. CSS面试题&知识点汇总
  2. 用两个栈实现一个队列(C++)
  3. Pivotal tc Server Integration for Eclipse
  4. JavaScript小数转百分比
  5. 使用iframe的好处与坏处详细比拼
  6. C 语言高效编程与代码优化
  7. Django环境的搭建以及最简示例
  8. python开发时小问题之端口占用
  9. Java IO: PipedOutputStream
  10. LINQ之路 6:延迟执行(Deferred Execution) 笔记