zoukankan      html  css  js  c++  java
  • [转]World Wind Java开发之五——读取本地shp文件

    World Wind Java 使用IconLayer图层类表现点和多点数据,使用RenderableLayer图层表现线和面数据,一个图层只能对应一组shape文件。World Wind Java首先使用ShapefileLoader类完成对shape文件的读取和加载,再通过createLayerFromSource方法创建RenderableLayer,最后将创建的Layer加在layers上。源码如下:

    /**
    	 * 
    	 * 方法名称: AddShapeData ;
    	 * 方法描述:  添加本地shape文件 ;
    	 * 参数 :@param filePath :文件路径 
    	 * 参数 :@param fileName :文件名
    	 * 参数 :@param layerTitle :图层名称
    	 * 参数 :@param maxActiveAltitude :图层可见最高视点
    	 * 参数 :@param minActiveAltitude :图层可见最低视点
    	 * 参数 :@return 
    	 * 返回类型: boolean ;
    	 * 创建人:James;
    	 * 创建时间:2014-11-25 下午5:19:48;
    	 * @throws
    	 */
    	public boolean AddShapeData(String filePath, String fileName,
    			String layerTitle, double maxActiveAltitude,
    			double minActiveAltitude)
    	{
    		boolean result = false;
    		try
    		{
    
    			ShapefileLoader pShapefileLoader = new ShapefileLoader();
    			pShapeLayer = pShapefileLoader.createLayerFromSource(filePath
    					+ fileName + ".shp");
    			pShapeLayer.setName(layerTitle);// 设置图层名称
    			pShapeLayer.setMaxActiveAltitude(maxActiveAltitude);
    			pShapeLayer.setMinActiveAltitude(minActiveAltitude);
    			
    			worldWindowGLCanvas.getModel().getLayers().add(pShapeLayer);
    			//添加图层树节点
    			pVectorNode.add(new DefaultMutableTreeNode(layerTitle));
    			pLayerTree.updateUI();
    			result = true;
    
    		}
    
    		catch (Exception e)
    		{
    			// TODO: handle exception
    			System.out.println(e.getMessage());
    
    		}
    		return result;
    	}

    效果图如下图所示:

    作者:liushuo_whu 发表于2014-11-25 18:42:13 原文链接

  • 相关阅读:
    mui-app 拍照、视频、图片选择,自动上传
    vue table大屏自动刷新滚动效果
    ant-design vue table表格高亮某一行 某一格
    vue-cli@3 ht 引入使用
    JAVA匿名内部类
    JAVA基本类型和引用类型
    引用 IO流学习详细教程
    JAVA多态
    JAVA数据类型能串门不?
    JAVA基本数据类型
  • 原文地址:https://www.cnblogs.com/rainbow70626/p/5267604.html
Copyright © 2011-2022 走看看