| 
					
				 | 
			
			
				@@ -0,0 +1,57 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+package com.sysu.admin.controller.lz.air_route; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.sysu.admin.controller.lz.area.LzArea; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.sysu.admin.controller.lz.area.LzAreaService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.sysu.admin.site.CommonVo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.sysu.admin.utils.shape.GeoCastUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.xiesx.fastboot.base.result.BaseResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.xiesx.fastboot.base.result.R; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.locationtech.jts.geom.Coordinate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.locationtech.jts.geom.MultiPolygon; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.web.bind.annotation.RequestBody; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.web.bind.annotation.RequestMapping; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.web.bind.annotation.RestController; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@RequestMapping("/site/lz_area") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@RestController 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+public class AirRouteController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private LzAreaService lzAreaService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @RequestMapping("/list") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public BaseResult list(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<LzArea> list = lzAreaService.findAll(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        list.forEach(lzArea -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            lzArea.setWkt(GeoCastUtil.geomToWkt(lzArea.getGeom())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            lzArea.setPointWkt(GeoCastUtil.geomToWkt(lzArea.getPoint())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return R.succ(list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @RequestMapping("/air_route") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public BaseResult airRoute(@RequestBody CommonVo commonVo){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LzArea area = lzAreaService.findOne(commonVo.getId().intValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Coordinate[] coordinates  = area.getGeom().getCoordinates(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Double[][] res = new Double[coordinates.length - 1][]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for(int i=0; i < coordinates.length - 1; i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Double [] temp = new Double[2]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            temp[0] = coordinates[i].getX(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            temp[1] = coordinates[i].getY(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            res[i] = temp; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return R.succ(res); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @RequestMapping("/save") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public BaseResult save(@RequestBody LzArea bean){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        bean.setGeom((MultiPolygon) GeoCastUtil.wktToGeom(bean.getWkt())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        bean.setPoint(bean.getGeom().getCentroid()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        lzAreaService.save(bean); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return R.succ(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 |