⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 totalcountry.java

📁 基于Java的地图数据管理软件。使用MySQL数据库管理系统。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
			n = 0;
			for (int k = 0; allXianRoad != null && k < allXianRoad.size(); k++) {
				lxNumber = ((LdRow) allXianRoad.get(k)).getLxNumber();
				lxNumber = lxNumber.substring(0, 4) + ".gps";
				if (file.getName().equalsIgnoreCase(lxNumber))
					n++;
			}
			if (n > 0) {
				allTrack = ItemValue.getTracks();
				for (int j = 0; allTrack != null && j < allTrack.length; j++) {
					liCheng = ItemValue.getTracksStringDistance(allTrack[j]);
					roadValue += Double.parseDouble(liCheng);
				}
			}
			fo.reset();
			fo.dispose();
			// System.err.println("====FileName====="+file.getName()+"=========LiCheng========"+roadValue);
			roadCountValue += roadValue;
		}

		System.err.println("===============" + shiName);
		return roadCountValue;
	}

	// 找出行政村与符合通达情况的航迹的关系
	public String [] getCountryAndTrack(String filePath) {
		String [] temp = new String [2];
		Vector countryList = new Vector();
		File[] allFiles = getAllGPSFiles(filePath);// 读取所有村道GPS文件
		Vector countryNode = new Vector();
		File file = null;
		String fileName = "";
		ItemValue.setShowDialogMessage(false);
		FrameOur fo = new FrameOur();
		String luMian = "0.0";
		String leiXing = "";
		double luMianWidth = 0.0;
		Node pointNode = null;
		Node tempNode = null;
		// String pointName="";
		double pointDistance = 0.0;
		double minDistance = 99999.0;
		Node[] allTrack = null;
		LoadWaypointAndTrack lwat = null;
		WptTrackDistance wd = new WptTrackDistance();
		boolean isCount = true;
		Node wayPointNode = null;
		double liCheng = 0.0;
		int villageCount = 0;
		countryNode = getAllPointNode(filePath);
		List traks = new ArrayList();
		Vector allTrackList = getAllTrackByXian(filePath);
		
		int trackType = 0;
		
		//count licheng and village suliang
		for (int j = 0; countryNode != null && j < countryNode.size(); j++) {
			    wayPointNode = (Node)countryNode.get(j);
			    pointDistance = getNearTrack(wayPointNode,allTrackList);
			    if (pointDistance > 0.0){
			    	liCheng += pointDistance;
			    	villageCount += 1;
				
			}
	
		}
		
		temp[0]=""+liCheng;
		temp[1]=""+villageCount;
		 System.err.println("=================="+countryNode.size());
		 System.err.println(liCheng + "\t" + villageCount );
       return temp;
	}
		public double getNearTrack(Node pointNode , Vector allTrackList){
			int trackType = 0;
			Node [] allTrack = null;
			double minValue = 9999.0;
			double tempValue = 0.0;
			double[] value1 = null;
			double[] value2 = null;
			double liCheng = 0.0;
			int place = 0;
			int n = 0;
		  for (int i = 0; allTrackList != null && i < allTrackList.size(); i++) {
		          trackType = ((LoadTrack)allTrackList.get(i)).getTrackType();
		          allTrack = ((LoadTrack)allTrackList.get(i)).getAllTrack();
		          n = 0;
		          if (trackType == 1 ) {   //当航迹在县道或乡道上时
		        	  if (isLess35(allTrack) || isTuLuor(allTrack)){
		        		  //System.err.println("==================0k!");
		        		  value1 = getNodeAndTrackMinDistance(pointNode,allTrack);
		        		  tempValue = value1[0];
		        		  if (tempValue < 0.1){
		        			 
		        			  if ( minValue > tempValue) {
		    		        	  minValue = tempValue;
		    		        	  place = i;
		    	   			    liCheng = value1[1];
		        			  }
		        		  }else  {
		        			  //System.err.println("==================0k!");
		        			  continue; 
		        		  }
		        	  }
		          }else {
		        	     value2 = getNodeAndVillageTrackMin(pointNode,allTrack);
		        	     tempValue = value2[0];
		        	     System.err.println("==================================="+tempValue);
		        	     if (tempValue < 0.1){
		        	    	 System.err.println("==================HHHHHHH0k!");
		        	    	 if ( minValue > tempValue) {
		    		        	  minValue = tempValue;
		    		        	  place = i;
		    	   			    liCheng = value2[1];
		        			  }
		        		  }else  continue; 
		           }
		          
		          
		     }
		         return liCheng;
		  
		}
		//得到与航迹最近的距离
		public double [] getNodeAndTrackMinDistance (Node pointNode, Node [] allTrack){
			double minValue = 9999.0;
			WptTrackDistance wtd = new WptTrackDistance();
			double liCheng = 0;
			double[] temp = new double[2];
			for (int i=0; allTrack !=null && i<allTrack.length;i++){
				if (minValue < wtd.getWptToTrackDis(pointNode,allTrack[i]))
					minValue = wtd.getWptToTrackDis(pointNode,allTrack[i]);
				liCheng += ItemValue.getTracksDistance(allTrack[i]);
			}
			
			temp[0]=minValue;
			temp[1]=liCheng;
			return temp;
		}
		//
		public double[] getNodeAndVillageTrackMin (Node pointNode, Node[] allTrack){
			  String luMian = "";
        	  double luMianWidth = 0.0; 
        	  int n = 0;
        	  boolean resultLM = true;
        	  double minValue = 9999.0;
        	  int place = 0;
        	  double [] temp = new double[2];
        	  double liCheng = 0.0;
  			  WptTrackDistance wtd = new WptTrackDistance();
        	  for (int i = 0; allTrack !=null && i < allTrack.length ; i++ ){
        		   luMian = ItemValue.getTracksType(allTrack[i]);
        		  System.err.println("===========LuMian====="+luMian);
        			if ((luMian.indexOf("土路") != -1 || luMian.indexOf("无路面") != -1 
        					|| luMian.length() == 0 || luMianWidth < 3.5)){
        				
        				if (minValue < wtd.getWptToTrackDis(pointNode,allTrack[i]))
        					{
        					minValue = wtd.getWptToTrackDis(pointNode,allTrack[i]);
        					liCheng = ItemValue.getTracksDistance(allTrack[i]);
        					}
        				
        			}else continue;
        	  }
        	  temp[0]=minValue;
        	  temp[1]=liCheng;
        	  return temp;		
		}
	public Vector getAllTrackByXian(String filePath){
		Vector allNodeList = new Vector();
		ItemValue.setShowDialogMessage(false);
		FrameOur fo = new FrameOur();
		File [] allFiles =  getAllGPSFiles (filePath);
		String keyName = "";
		int trackType =0;
		for ( int i = 0; allFiles != null && i < allFiles.length ;i++ ){
			File myFile = allFiles[i];
			String fileName = myFile.getName();
			trackType = 0;
			fo.openFile(myFile);
			Node[] allTrack = ItemValue.getTracks();
			LoadTrack lt = new LoadTrack();
			if (myFile.getParent().indexOf("\\县") != -1 || myFile.getParent().indexOf("\\乡") != -1 )
				 trackType = 1;
			 lt.setAllTrack(allTrack);
			 lt.setTrackType(trackType);
			  allNodeList.add(lt);
			  
			  fo.reset();
			}
			
		
		
		return allNodeList;
	}
	
	public boolean isTongDaTulurLess35(Node  pointNode,Node[] allTrack){
		// pointName=ItemValue.getWaypointName(pointNode);
		WptTrackDistance wtd = new WptTrackDistance();
		Node tempNode = null;
        boolean isTongDa = true;
		for (int k = 0; allTrack != null && k < allTrack.length; k++) {
//			leiXing = ItemValue.getTracksType(allTrack[k]); // 路面类型
	//		luMian = ItemValue.getTracksWidth(allTrack[k]); // 路面宽度
		    if( ( wtd.getWptToTrackDis(pointNode,allTrack[k]) < 0.1) && isTongDa && (isTuLuor(allTrack) || isLess35(allTrack)))
		      isTongDa = true;
		     else
		      isTongDa = false;	
		    	
		}
		return isTongDa;
	}

	public int tongDaTrack(Node  pointNode, List allFiles){
		//Node[] tongDaRoad = null;
		File file = null;
		FrameOur fo = new FrameOur();
		Node[] allTrack = null;	
//		WptTrackDistance wtd = new WptTrackDistance();
		double temp = 999.0;
		int place = 0;
		if(isTongDaTulurLess35(pointNode,allTrack)){
			for( int i = 0 ;  i < allFiles.size() ; i++){
          			
				if(temp < getDistanct(pointNode,(Node[])allFiles.get(i))){
					temp = getDistanct(pointNode,(Node[])allFiles.get(i));
				    place = i;
				}
			}
			
		}
		//tongDaRoad[0] = allTrack[place];
		return place;
	}
	
	private double getDistanct(Node pointNode,Node[] allTrack){
		double distanct = 99999.0;
		WptTrackDistance wtd = new WptTrackDistance();	
		for(int i = 0; i < allTrack.length; i++){
			if(distanct > wtd.getWptToTrackDis(pointNode,allTrack[i]))
				distanct = wtd.getWptToTrackDis(pointNode,allTrack[i]);
		}
     return distanct; 
		
	}
	
	// 统计通达行政村道路的里程数
	public double CountCountryRoad(Vector countryList) {
		double countValue = 0.000;
		Vector cunList = new Vector();
		Vector tempCountry = countryList;
		ItemValue.setShowDialogMessage(false);
		// System.err.println("===========countryCount======="+tempCountry.size());
		int n = 0;
		Node trackNode1 = null;
		Node trackNode2 = null;
		String roadName = "";
		String roadName1 = "";
		String liCheng = "";
		for (int i = 0; i < tempCountry.size(); i++) {
			n = 0;
			trackNode1 = ((LoadWaypointAndTrack) tempCountry.get(i))
					.getTrackNode();
			roadName = ItemValue.getTracksName(trackNode1);
			for (int j = 0; cunList != null && j < cunList.size(); j++) {
				trackNode2 = ((LoadWaypointAndTrack) cunList.get(j))
						.getTrackNode();
				roadName1 = ItemValue.getTracksName(trackNode2);
				if (roadName1.equals(roadName)) {
					n++;
				}
			}
			if (n == 0)
				cunList.add((LoadWaypointAndTrack) tempCountry.get(i));

		}

		for (int i = 0; i < cunList.size(); i++) {
			trackNode1 = ((LoadWaypointAndTrack) cunList.get(i)).getTrackNode();
			roadName = ItemValue.getTracksName(trackNode1);
			liCheng = ItemValue.getTracksStringDistance(trackNode1);
			countValue += Double.parseDouble(liCheng);
			// System.err.println("=============="+roadName);
		}

		return countValue;
	}

	public void ShowTotalCountry(String filePath) {
		File allFile = new File(filePath);
		File[] files = allFile.listFiles();// 获取所有县(区)列表
		String quXianPath = ""; // 县(区)文件路径
		int sumCountry = 0; // 行政村总数
		double sumLiCheng = 0.0; // 里程总数
		ItemValue.setShowDialogMessage(false);
	
		double distance = 0.0; // 距离
		String liCheng = ""; // 里程
		String [] countryInfo = null; 
		
	
	
		for (int f = 0; files != null && f < files.length; f++) {
			quXianPath = files[f].getPath();
			String tempPath = quXianPath.replace('\\', ',');
			String[] paths = tempPath.split(",");
			int lenInt = paths.length - 1;
			String quXianName = paths[lenInt]; // 区县名
			System.err.println("=======path="+quXianPath);
			countryInfo = getCountryAndTrack(quXianPath);
			sumLiCheng += Double.parseDouble(countryInfo[0]);
			sumCountry += Integer.parseInt(countryInfo[1]);
		
			System.err.println(quXianName + ":  行政村总数=" + countryInfo[1]
					+ "    拟建村道里程=" + countryInfo[0]);
		}

		System.err.println("===========行政村总数===" + sumCountry);
		System.err.println("===========拟建村道里程===" + sumLiCheng);

	}

	public static void main(String[] args) {
		TotalCountry tc = new TotalCountry();
		  tc.ShowTotalCountry("D:\\安徽省通达数据\\合肥市");
		  //tc.countCountryData("D:\\安徽省通达数据\\亳州市");
		//tc.ShowTotalCountry("D:\\安徽省通达数据\\合肥市");
		// double
		// roadCount=tc.getAllXianorXiangRoadCount("D:\\安徽省通达数据\\亳州市","乡道");
		// System.err.println("===========CountValue===="+roadCount);

	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -