开发者社区> 问答> 正文

OSM数据路网拓扑结构提取

已解决

请问各位大神 有什么方法能从open street map的OSM数据中提取路网的拓扑结构呀 或者有什么办法能过去路网的拓扑结构,还望各位大神支个招 急………

展开
收起
情人的眼淚 2019-01-11 20:47:33 4529 0
1 条回答
写回答
取消 提交回答
  • 采纳回答

    要看路网数据什么格式,例如扩展名是.shp的就应该是shapefile,对应shapefile我们可以在搜索引擎中搜索java shapefile查找相关库,例如GeoTools http://geotools.org/

    如果觉得官方文档比较难定位到相关用法,stackoverflow上也有shapefile解析的回答 https://stackoverflow.com/questions/2044876/does-anyone-know-of-a-library-in-java-that-can-parse-esri-shapefiles

    File file = new File("mayshapefile.shp");
    
    try {
      Map<String, String> connect = new HashMap();
      connect.put("url", file.toURI().toString());
    
      DataStore dataStore = DataStoreFinder.getDataStore(connect);
      String[] typeNames = dataStore.getTypeNames();
      String typeName = typeNames[0];
    
      System.out.println("Reading content " + typeName);
    
      FeatureSource featureSource = dataStore.getFeatureSource(typeName);
      FeatureCollection collection = featureSource.getFeatures();
      FeatureIterator iterator = collection.features();
    
    
      try {
        while (iterator.hasNext()) {
          Feature feature = iterator.next();
          GeometryAttribute sourceGeometry = feature.getDefaultGeometryProperty();
        }
      } finally {
        iterator.close();
      }
    
    } catch (Throwable e) {}
    2019-07-17 23:25:24
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载