diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/resource/TResourceLandController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/resource/TResourceLandController.java index 957b949..5ddaa53 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/resource/TResourceLandController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/resource/TResourceLandController.java @@ -231,13 +231,6 @@ public class TResourceLandController extends BaseController @PostMapping("/update") public AjaxResult edit(@RequestBody TResourceLand tResourceLand) { - if (tResourceLand.getTheGeom() != null && tResourceLand.getTheGeom().substring(0, 1).equals("[")) { - //坐标转换 - String houseApplyProposedSituations = SpaceUtils.space(tResourceLand.getTheGeom()); - tResourceLand.setTheGeom(houseApplyProposedSituations); - } else { - tResourceLand.setTheGeom(null); - } return toAjax(tResourceLandService.updateTResourceLand(tResourceLand)); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysGsiServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysGsiServiceImpl.java index e9f6727..8598aab 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysGsiServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysGsiServiceImpl.java @@ -1,6 +1,7 @@ package com.ruoyi.system.service.impl; import com.alibaba.fastjson2.JSON; +import com.ruoyi.common.utils.space.SpaceUtils; import com.ruoyi.system.domain.SysGis; import com.ruoyi.system.domain.gis.Point; import com.ruoyi.system.mapper.SysGisMapper; @@ -33,64 +34,25 @@ public class SysGsiServiceImpl implements ISysGisService { @Override public int updateGeomByPolygon(SysGis gis) { - StringBuilder sb = new StringBuilder(); - sb.append("MULTIPOLYGON((("); - - //ObjectMapper mapper = new ObjectMapper(); - try { - String theGeom = gis.getTheGeom(); - //GeoPoint gp = mapper.readValue(theGeom, GeoPoint.class); - List pointList = JSON.parseArray(theGeom, Point.class); - //pointList.remove(pointList.size()-1); - // 检查第一个点和最后一个点是否相同 - if (!pointList.get(0).equals(pointList.get(pointList.size() - 1))) { - // 如果不相同,添加第一个点作为最后一个点来闭合多边形 - pointList.add(pointList.get(0)); - } - pointList.forEach(p -> { - sb.append(p.getLongitude()); - sb.append(" "); - sb.append(p.getLatitude()); - sb.append(","); - }); - sb.setLength(sb.length() - 1); - sb.append(")))"); - } catch (Exception e) { - e.printStackTrace(); + if (gis.getTheGeom() != null && gis.getTheGeom().substring(0, 1).equals("[")) { + //坐标转换 + String houseApplyProposedSituations = SpaceUtils.space(gis.getTheGeom()); + gis.setTheGeom(houseApplyProposedSituations); + } else { + gis.setTheGeom(null); } - gis.setTheGeom(sb.toString()); return gisMapper.updateGeomByPolygon(gis); } @Override public int updateGeomByPolygonPri(SysGis gis) { - - StringBuilder sb = new StringBuilder(); - sb.append("MULTIPOLYGON((("); - - //ObjectMapper mapper = new ObjectMapper(); - try { - String theGeom = gis.getTheGeom(); - //GeoPoint gp = mapper.readValue(theGeom, GeoPoint.class); - List pointList = JSON.parseArray(theGeom, Point.class); - //pointList.remove(pointList.size()-1); - // 检查第一个点和最后一个点是否相同 - if (!pointList.get(0).equals(pointList.get(pointList.size() - 1))) { - // 如果不相同,添加第一个点作为最后一个点来闭合多边形 - pointList.add(pointList.get(0)); - } - pointList.forEach(p -> { - sb.append(p.getLongitude()); - sb.append(" "); - sb.append(p.getLatitude()); - sb.append(","); - }); - sb.setLength(sb.length() - 1); - sb.append(")))"); - } catch (Exception e) { - e.printStackTrace(); + if (gis.getTheGeom() != null && gis.getTheGeom().substring(0, 1).equals("[")) { + //坐标转换 + String houseApplyProposedSituations = SpaceUtils.space(gis.getTheGeom()); + gis.setTheGeom(houseApplyProposedSituations); + } else { + gis.setTheGeom(null); } - gis.setTheGeom(sb.toString()); return gisMapper.updateGeomByPolygonPri(gis); }