记录一下如何创建DirectedGraph,便于以后查找使用

  

     static ShapefileDataStore sds= null;
    static DirectedGraph graph = null;
     ShapefileDataStoreFactory dataStoreFactory = new ShapefileDataStoreFactory();
try {
sds = (ShapefileDataStore)dataStoreFactory.createDataStore(new File("E://桌面//route_LI.shp").toURI().toURL());
} catch (IOException e) {
e.printStackTrace();
}
//设置编码
Charset charset = Charset.forName("GBK");
sds.setCharset(charset);
String typeName = null;
try {
typeName = sds.getTypeNames()[0];
} catch (IOException e) {
e.printStackTrace();
} FeatureSource featureSource = null;
try {
featureSource = sds.getFeatureSource (typeName);
} catch (IOException e) {
e.printStackTrace();
} SimpleFeatureCollection fCollection =null;
try {
fCollection = (SimpleFeatureCollection) featureSource.getFeatures();
} catch (IOException e1) {
e1.printStackTrace();
} DirectedLineStringGraphGenerator lineStringGen = new DirectedLineStringGraphGenerator();
FeatureGraphGenerator featureGen = new FeatureGraphGenerator(lineStringGen);
featureGen.setGraphBuilder(new BasicDirectedLineGraphBuilder());
SimpleFeatureIterator iterator = fCollection.features();
try {
while (iterator.hasNext()) {
SimpleFeature feature = iterator.next();
featureGen.add(feature);
}
} finally {
iterator.close();
}
sds.dispose();
graph = (DirectedGraph)featureGen.getGraph();

最新文章

  1. # Hawk:开源贡献计划,设计,反思
  2. [UCSD白板题] Maximum Pairwise Product
  3. linux笔记七---------管道
  4. Python 模块,数据类型,元组
  5. ubuntu + subversion + apache2 设置
  6. PHP中MySql函数收集
  7. struts1、 struts2所有版本jar包下载地址大全
  8. 犹记当年写出bug睡不着,回想今天只求睡好渡余生……
  9. 转:Spring与Mybatis整合的MapperScannerConfigurer处理过程源码分析
  10. Flatten Nested List Iterator
  11. 小黄人IP营销的四种玩法思维导图
  12. iOS--崩溃日志的格式化分析---格式化crash日志
  13. 返回值为 Record类型的函数 初始化 Result
  14. Controller与Switch建立连接
  15. 执行git命令出现 xcrun: error:
  16. C++调用Python脚本中的函数
  17. 通过管道传输快速将MySQL的数据导入Redis
  18. vim中多行注释和多行删除命令
  19. Servlet和SpringMVC补课
  20. 使用C# .NET 将结构数组绑定到 Windows 窗体的方法

热门文章

  1. jmeter接口压测的反思
  2. Tmux 速成教程:技巧和调整
  3. docker pull很慢解决办法
  4. [洛谷P4720] [模板] 扩展卢卡斯
  5. 千万不要在module里扩展较多逻辑,很容易引起项目异常。
  6. Python拾遗(2)
  7. POJ 2112 Optimal Milking 最短路 二分构图 网络流
  8. tips [ 18870 ]
  9. python中字符串操作--截取,查找,替换
  10. android应用程序源码结构分析