|
@@ -5,12 +5,16 @@ import com.sysu.admin.controller.lz.area.LzAreaService;
|
|
import com.sysu.admin.utils.shape.GeoCastUtil;
|
|
import com.sysu.admin.utils.shape.GeoCastUtil;
|
|
import com.xiesx.fastboot.base.result.BaseResult;
|
|
import com.xiesx.fastboot.base.result.BaseResult;
|
|
import com.xiesx.fastboot.base.result.R;
|
|
import com.xiesx.fastboot.base.result.R;
|
|
|
|
+import org.geotools.geometry.jts.JTSFactoryFinder;
|
|
|
|
+import org.locationtech.jts.geom.GeometryFactory;
|
|
import org.locationtech.jts.geom.MultiPolygon;
|
|
import org.locationtech.jts.geom.MultiPolygon;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
@RequestMapping("/site/lz_area")
|
|
@RequestMapping("/site/lz_area")
|
|
@RestController
|
|
@RestController
|
|
public class LzAreaController {
|
|
public class LzAreaController {
|
|
@@ -20,12 +24,18 @@ public class LzAreaController {
|
|
|
|
|
|
@RequestMapping("/list")
|
|
@RequestMapping("/list")
|
|
public BaseResult list(){
|
|
public BaseResult list(){
|
|
- return R.succ(lzAreaService.findAll());
|
|
|
|
|
|
+ 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("/save")
|
|
@RequestMapping("/save")
|
|
public BaseResult save(@RequestBody LzArea bean){
|
|
public BaseResult save(@RequestBody LzArea bean){
|
|
bean.setGeom((MultiPolygon) GeoCastUtil.wktToGeom(bean.getWkt()));
|
|
bean.setGeom((MultiPolygon) GeoCastUtil.wktToGeom(bean.getWkt()));
|
|
|
|
+ bean.setPoint(bean.getGeom().getCentroid());
|
|
lzAreaService.save(bean);
|
|
lzAreaService.save(bean);
|
|
return R.succ();
|
|
return R.succ();
|
|
}
|
|
}
|