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 原文链接

  • 相关阅读:
    【英语天天读】Places and People
    【OpenCV学习】错误处理机制
    【英语天天读】Heart of a stranger 陌生的心灵
    【英语天天读】第一场雪
    【OpenCV学习】角点检测
    【英语天天读】Life is What We Make It
    【英语天天读】培养自信
    【英语天天读】Perseverance
    【OpenCV学习】cvseqpartition序列分类
    【英语天天读】自然
  • 原文地址:https://www.cnblogs.com/rainbow70626/p/5267604.html
Copyright © 2011-2022 走看看