| 
					
				 | 
			
			
				@@ -16,12 +16,13 @@ import org.springframework.test.context.junit4.SpringRunner; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import javax.persistence.EntityManager; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.io.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-@RunWith(SpringRunner.class) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-@SpringBootTest(classes = MarkApplication.class) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-public class PostGisUtilTest extends BaseTest { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//@RunWith(SpringRunner.class) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//@SpringBootTest(classes = MarkApplication.class) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+public class PostGisUtilTest { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    static String sourceDir = "D:\\BaiduNetdiskDownload\\merge\\merge"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    static String sourceDir = "D:\\BaiduNetdiskDownload\\merge\\leizhou"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     static String outputDir = "D:"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     static String tablesString = "banan,beibei,bishan,changshou,chengkou,dadukou,dazu,dianjiang,fengdu,fengjie,fuling,hechuan,jiangbei,jiangjin,jiulongpo,kaizhou,liangping,nanan,nanchuan,pengshui,qianjiang,qijiang,qiuyang,rongchang,shapingba,shizhu,tongliang,tongnan,wanzhou,wulong,wushan,wuxi,xiushan,yongchuan,yubei,yunyang,yuzhong,zhong"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -117,6 +118,72 @@ public class PostGisUtilTest extends BaseTest { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Test 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void testInsertShpLeizhou() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        File shpDir = new File(sourceDir); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        File[] shpList = shpDir.listFiles((dir, name) -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(name.endsWith("shp")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            FileWriter fileWriter = new FileWriter(new File(outputDir,"insert.sql")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for(File shp : shpList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                List<Map<String,Object>> list = ShapeReader.getShapeFileLeizhou(shp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                System.out.println("数据准备:"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                System.out.println(list.size()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                getInsertSqlsLeizhou(fileWriter, "leizhou_parcel_out0209", list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            fileWriter.flush(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            fileWriter.close(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @SneakyThrows 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void getInsertSqlsLeizhou(FileWriter fileWriter,String typeName, List<Map<String, Object>> list){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int i=0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int c = 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        while(i < list.size()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(i % c == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                fileWriter.append("insert into " + typeName + "(inpoly_f_1,area,simpgnflag,toc,quxian,shengdao,hupo,gdp_pop,slope,aspect,name,id_card,crop_type,area_ha,value,majority,geom) values"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Map<String, Object> map = list.get(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            fileWriter.append(" ('"+map.get("inpoly_f_1")+"',"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            fileWriter.append("'"+map.get("area")+"',"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            fileWriter.append("'"+map.get("simpgnflag")+"',"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            fileWriter.append("'"+map.get("toc")+"',"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            fileWriter.append("'"+map.get("quxian")+"',"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            fileWriter.append("'"+map.get("shengdao")+"',"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            fileWriter.append("'"+map.get("hupo")+"',"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            fileWriter.append("'"+map.get("gdp_pop")+"',"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            fileWriter.append("'"+map.get("slope")+"',"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            fileWriter.append("'"+map.get("aspect")+"',"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            fileWriter.append("'"+map.get("name")+"',"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            fileWriter.append("'"+map.get("id_card")+"',"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            fileWriter.append("'"+map.get("crop_type")+"',"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            fileWriter.append("'"+map.get("area_ha")+"',"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            fileWriter.append("'"+map.get("value")+"',"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            fileWriter.append("'"+map.get("majority")+"',"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            fileWriter.append("st_geomfromtext('"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            fileWriter.append(map.get("geom").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            fileWriter.append("',4326))"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(i % c < (c-1) && i < list.size() - 1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                fileWriter.append(","); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                fileWriter.append(";"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                fileWriter.append("\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            i++; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public void updateCity(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for(String tableName : getTableNames()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             System.out.println("update "+ tableName + " t1 set province =500000,city = 500100, district = t2.code from p_land_range_index t2 where t2.table_name = '"+tableName+"';"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -177,4 +244,4 @@ public class PostGisUtilTest extends BaseTest { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 |