记录一下如何创建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();

Geotools中读取shapefile路网数据,并创建DirectedGraph的更多相关文章

  1. 从PCD文件中读取点云数据

    博客转载自:http://www.pclcn.org/study/shownews.php?lang=cn&id=84 在本小节我们学习如何从PCD文件中读取点云数据. 代码 章例1文件夹中, ...

  2. nodeks —— fs模块 —— 从流中 读取和写入数据

    Fs流读取和写入数据 使用文件流来读取大文件不会卡顿 1, 从流中读取数据 var fs = require("fs"); var data = ''; var count = 0 ...

  3. 一些常用的文本文件格式(TXT,JSON,CSV)以及如何从这些文件中读取和写入数据

    TXT文件: txt是微软在操作系统上附带的一种文本格式,文件以.txt为后缀. 从txt文件中读取数据: with open ('xxx.txt') as file: data=file.readl ...

  4. Geotools在shapefile路网数据中建立缓冲区,并获取缓冲区内的要素

    记录一下如何创建创建缓冲区并获取缓冲区内的要素,便于以后查找使用 static SimpleFeatureSource featureSource = null; static CoordinateR ...

  5. C#中Form窗体中读取EXCEL的数据

    使用OLEDB可以对excel文件进行读取,我们只要把该excel文件作为数据源即可 首先引用Microsoft.EXEL 代码如下: using System; using System.Colle ...

  6. js中读取解析json数据

    在数据传输流程中,json是以文本,即字符串的形式传递的,而JS操作的是JSON对象,所以,JSON对象和JSON字符串之间的相互转换是关键. JSON字符串:       'var str1 = ' ...

  7. c语言链表从本地文件中读取和写入数据

    1 typedef struct Data{ 2 40 char *name; 3 41 char *IDCARD; 4 42 char *job_id; 5 43 char *length; 6 4 ...

  8. pb中读取大文本数据

    string ls_FileName,lb_FileDatas,lb_FileData  long ll_FileLen,ll_Handle,ll_Loop,ll_Bytes,ll_Loops,ll_ ...

  9. Geotools求shapefile路网中任意两点之间最短路径的距离

    前言:之前在博问求助过这个问题.经过几天的思考,算是解决了(但仍有不足),另一方面对Geotools不是很熟,有些描述可能不正确,希望大家批评指正. 问题:作为一个新手,我并没有发现Geotools中 ...

随机推荐

  1. OpenCV 输入输出XML和YAML文件

    #include <opencv2/core/core.hpp> #include <iostream> #include <string> using names ...

  2. spring学习笔记一:spring介绍

    jar包下载地址:http://repo.spring.io/release/org/springframework/spring/ spring特点: 1.非侵入性 spring框架的API不会在业 ...

  3. input系统——android input系统

    AndroidInput系统--JNI NativeInputManager InputManger InputReader AndroidInput系统--InputReader AndroidIn ...

  4. 从又一家外卖被Uber收购,看美团打车未来

    别以为Uber在中国失利,连优步中国都被滴滴收购了,就认为Uber已经不行了.其实从全球范围内来看,Uber还是相当强势的--创始人的那些破事儿不算在内.此外,更重要的是Uber已经不单单是在打车业务 ...

  5. 编程语言十万个为什么之java web的基础概念

    1.什么是JAVA Java是一种可以撰写跨平台应用软件的面向对象的程序设计语言,是由SunMicrosystems公司于1995年5月推出的Java程序设计语言和Java平台(即JavaSE, Ja ...

  6. ubuntu采用apt方式安装多个版本php-fpm

    适用系统:Ubuntu 16.04 LTS / Ubuntu 14.04 LTS 安装 PHP Ondřej Surý 的 PHP PPA 为 Ubuntu 16.04/14.04 提供了 PHP7. ...

  7. 两篇很好的EPG相关文章

    两篇很好的EPG相关文章 原文地址:http://blog.sina.com.cn/s/blog_53220cef0100pi8j.html 1 基于DVB-SI的数字有线电视机顶盒节目指南的设计实现 ...

  8. 通过IE私有滤镜让IE6 7 8支持背景透明,内容不透明效果。

    CSS3已经支持背景rgba的rgba透明度,这一方法可以避免元素内容也随背景一起变透明(详情请阅http://www.cssha.com/css3-new-knowledge-student).但是 ...

  9. NIPS 2016:普及机器学习

    ​ 2016:普及机器学习" title="NIPS 2016:普及机器学习"> ​左起:微软研究员Robert Schapire,John Langford,Al ...

  10. GIT 使用(二):创建仓库并提交代码

    基本操作 所用命令使用 windows 下安装 git-bash 运行 Table of Contents 先决条件 已经安装了 GIT 客户端 已经设置用户信息 如果没做可以看安装和配置 获取 Gi ...