|
@@ -1,6 +1,7 @@ |
|
|
package com.ruoyi.system.service.impl; |
|
|
package com.ruoyi.system.service.impl; |
|
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSON; |
|
|
import com.alibaba.fastjson2.JSON; |
|
|
|
|
|
import com.ruoyi.common.utils.space.SpaceUtils; |
|
|
import com.ruoyi.system.domain.SysGis; |
|
|
import com.ruoyi.system.domain.SysGis; |
|
|
import com.ruoyi.system.domain.gis.Point; |
|
|
import com.ruoyi.system.domain.gis.Point; |
|
|
import com.ruoyi.system.mapper.SysGisMapper; |
|
|
import com.ruoyi.system.mapper.SysGisMapper; |
|
@@ -33,64 +34,25 @@ public class SysGsiServiceImpl implements ISysGisService { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public int updateGeomByPolygon(SysGis gis) { |
|
|
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<Point> 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); |
|
|
return gisMapper.updateGeomByPolygon(gis); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public int updateGeomByPolygonPri(SysGis gis) { |
|
|
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<Point> 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); |
|
|
return gisMapper.updateGeomByPolygonPri(gis); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|