36 changed files with 471 additions and 186 deletions
@ -0,0 +1,70 @@ |
|||||||
|
package com.air.applets.convert; |
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil; |
||||||
|
import com.air.applets.dto.CoordinatePoint; |
||||||
|
import com.air.applets.dto.Feature; |
||||||
|
import com.air.applets.dto.LandLonLatDto; |
||||||
|
import com.air.applets.dto.LandProperties; |
||||||
|
import com.air.applets.entity.CityAreaLonLatBase; |
||||||
|
import com.air.entity.PolygonGeom; |
||||||
|
import com.air.land.entity.LandListedLonLat; |
||||||
|
import com.air.utils.GeomUtils; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 地块、经纬度转换 |
||||||
|
* |
||||||
|
* @author peihao |
||||||
|
* @date 2021-09-16 |
||||||
|
**/ |
||||||
|
public class LandLonLatConvert { |
||||||
|
|
||||||
|
public static List<LandLonLatDto> getCityAreaLonLat(List<CityAreaLonLatBase> list, Integer id){ |
||||||
|
if (CollectionUtil.isEmpty(list)){ |
||||||
|
return null; |
||||||
|
} |
||||||
|
List<LandLonLatDto> landLonLatDtos = new ArrayList<>(); |
||||||
|
list.forEach(e ->{ |
||||||
|
LandLonLatDto landLonLatDto = new LandLonLatDto(); |
||||||
|
|
||||||
|
CoordinatePoint coordinatePoint = GeomUtils.lonLatConvertPoint(e.getPos()); |
||||||
|
PolygonGeom polygonGeom = GeomUtils.computeGemo(coordinatePoint.getPolygonPoints(), e.getLineColor() |
||||||
|
, e.getLineOpaqueness(), e.getLineWidth(), e.getFillColor(), e.getFillOpaqueness()); |
||||||
|
polygonGeom.setId(id); |
||||||
|
landLonLatDto.setPolygon(polygonGeom); |
||||||
|
landLonLatDtos.add(landLonLatDto); |
||||||
|
}); |
||||||
|
return landLonLatDtos; |
||||||
|
} |
||||||
|
|
||||||
|
public static List<LandLonLatDto> getLandLonLatDto(List<LandListedLonLat> landList, Integer id){ |
||||||
|
if (CollectionUtil.isEmpty(landList)){ |
||||||
|
return null; |
||||||
|
} |
||||||
|
List<LandLonLatDto> landLonLatDtos = new ArrayList<>(); |
||||||
|
landList.forEach(e ->{ |
||||||
|
LandLonLatDto landLonLatDto = new LandLonLatDto(); |
||||||
|
|
||||||
|
Feature feature = new Feature(); |
||||||
|
LandProperties landProperties = new LandProperties(); |
||||||
|
landProperties.setLatId(e.getLatId()); |
||||||
|
landProperties.setLandId(e.getLandListedId()); |
||||||
|
feature.setProperties(landProperties); |
||||||
|
feature.setId(id); |
||||||
|
|
||||||
|
CoordinatePoint coordinatePoint = GeomUtils.lonLatConvertPoint(e.getLandLonLat()); |
||||||
|
feature.setCoordinates(coordinatePoint.getCoordinates()); |
||||||
|
landLonLatDto.setFeature(feature); |
||||||
|
landLonLatDto.setCenterPoint(coordinatePoint.getCenPoint()); |
||||||
|
|
||||||
|
PolygonGeom polygonGeom = GeomUtils.computeGemo(coordinatePoint.getPolygonPoints(), e.getLineColor(), Integer.valueOf(e.getLineOpaqueness()), |
||||||
|
Integer.valueOf(e.getLineWidth()), e.getFillColor(), Integer.valueOf(e.getFillOpaqueness())); |
||||||
|
polygonGeom.setId(id); |
||||||
|
landLonLatDto.setPolygon(polygonGeom); |
||||||
|
landLonLatDtos.add(landLonLatDto); |
||||||
|
}); |
||||||
|
return landLonLatDtos; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,21 @@ |
|||||||
|
package com.air.applets.dto; |
||||||
|
|
||||||
|
import com.air.entity.PolygonPoint; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author peihao |
||||||
|
* @date 2021-09-15 |
||||||
|
**/ |
||||||
|
@Data |
||||||
|
public class CoordinatePoint { |
||||||
|
|
||||||
|
private List<PolygonPoint> polygonPoints; |
||||||
|
|
||||||
|
private List<List<Double>> coordinates; |
||||||
|
|
||||||
|
private List<Double> cenPoint; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,23 @@ |
|||||||
|
package com.air.applets.dto; |
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author peihao |
||||||
|
* @date 2021-09-15 |
||||||
|
**/ |
||||||
|
@Data |
||||||
|
public class Feature { |
||||||
|
|
||||||
|
@ApiModelProperty(value = "地块,经纬度信息") |
||||||
|
private LandProperties properties; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "坐标点") |
||||||
|
private List<List<Double>> coordinates; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "id") |
||||||
|
private Integer id; |
||||||
|
} |
@ -0,0 +1,27 @@ |
|||||||
|
package com.air.applets.dto; |
||||||
|
|
||||||
|
import com.air.entity.PolygonGeom; |
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 小程序土地地块经纬度 |
||||||
|
* |
||||||
|
* @author peihao |
||||||
|
* @date 2021-09-15 |
||||||
|
**/ |
||||||
|
@ApiModel |
||||||
|
@Data |
||||||
|
public class LandLonLatDto { |
||||||
|
|
||||||
|
@ApiModelProperty(value = "图形坐标颜色等信息") |
||||||
|
private PolygonGeom polygon; |
||||||
|
@ApiModelProperty(value = "中间点位") |
||||||
|
private List<Double> centerPoint; |
||||||
|
@ApiModelProperty(value = "图形坐标颜色等信息") |
||||||
|
private Feature feature; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,21 @@ |
|||||||
|
package com.air.applets.dto; |
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
/** |
||||||
|
* 地块,经纬度信息 |
||||||
|
* |
||||||
|
* @author peihao |
||||||
|
* @date 2021-09-15 |
||||||
|
**/ |
||||||
|
@ApiModel |
||||||
|
@Data |
||||||
|
public class LandProperties { |
||||||
|
|
||||||
|
@ApiModelProperty(value = "地块id") |
||||||
|
private String landId; |
||||||
|
@ApiModelProperty(value = "经纬度id") |
||||||
|
private Long latId; |
||||||
|
} |
@ -0,0 +1,40 @@ |
|||||||
|
package com.air.applets.entity; |
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
/** |
||||||
|
* 行政区,大组团,小组团,环线通用 |
||||||
|
* |
||||||
|
* @author peihao |
||||||
|
* @date 2021-09-15 |
||||||
|
**/ |
||||||
|
@ApiModel |
||||||
|
@Data |
||||||
|
public class CityAreaLonLatBase { |
||||||
|
@ApiModelProperty(value="") |
||||||
|
private Integer id; |
||||||
|
@ApiModelProperty(value="") |
||||||
|
private String name; |
||||||
|
@ApiModelProperty(value="") |
||||||
|
private String pos; |
||||||
|
@ApiModelProperty(value="") |
||||||
|
private Integer lineWidth; |
||||||
|
@ApiModelProperty(value="") |
||||||
|
private String lineColor; |
||||||
|
@ApiModelProperty(value="") |
||||||
|
private Integer lineOpaqueness; |
||||||
|
@ApiModelProperty(value="") |
||||||
|
private String fillColor; |
||||||
|
@ApiModelProperty(value="") |
||||||
|
private Integer fillOpaqueness; |
||||||
|
@ApiModelProperty(value="") |
||||||
|
private Integer attr; |
||||||
|
@ApiModelProperty(value="") |
||||||
|
private String comment; |
||||||
|
@ApiModelProperty(value="") |
||||||
|
private String geom; |
||||||
|
@ApiModelProperty(value = "城市") |
||||||
|
private String city; |
||||||
|
} |
@ -0,0 +1,32 @@ |
|||||||
|
package com.air.entity; |
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 小程序坐标渲染对象 |
||||||
|
* |
||||||
|
* @author peihao |
||||||
|
* @date 2021-09-15 |
||||||
|
**/ |
||||||
|
@ApiModel("小程序坐标渲染对象") |
||||||
|
@Data |
||||||
|
public class PolygonGeom { |
||||||
|
|
||||||
|
@ApiModelProperty(value = "填充颜色") |
||||||
|
private String fillColor; |
||||||
|
@ApiModelProperty(value = "id") |
||||||
|
private Integer id; |
||||||
|
@ApiModelProperty(value = "线条颜色") |
||||||
|
private String strokeColor; |
||||||
|
@ApiModelProperty(value = "线条宽度") |
||||||
|
private Integer strokeWidth; |
||||||
|
@ApiModelProperty(value = "层级(默认1)") |
||||||
|
private int zIndex = 1; |
||||||
|
@ApiModelProperty(value = "坐标点位") |
||||||
|
private List<PolygonPoint> points; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,69 @@ |
|||||||
|
package com.air.utils; |
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil; |
||||||
|
import cn.hutool.json.JSONUtil; |
||||||
|
import com.air.applets.dto.CoordinatePoint; |
||||||
|
import com.air.entity.PolygonGeom; |
||||||
|
import com.air.entity.PolygonPoint; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.Arrays; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author peihao |
||||||
|
* @date 2021-09-14 |
||||||
|
**/ |
||||||
|
public class GeomUtils { |
||||||
|
|
||||||
|
public static PolygonGeom computeGemo(List<PolygonPoint> polygonPoints,String lineColor,Integer lineOpaqueness,Integer lineWidth,String fillColor,Integer fillOpaqueness){ |
||||||
|
PolygonGeom polygonGeom = new PolygonGeom(); |
||||||
|
polygonGeom.setStrokeColor(computeColor(lineColor,lineOpaqueness)); |
||||||
|
polygonGeom.setFillColor(computeColor(fillColor,fillOpaqueness)); |
||||||
|
polygonGeom.setStrokeWidth(Integer.valueOf(lineWidth)); |
||||||
|
polygonGeom.setPoints(polygonPoints); |
||||||
|
return polygonGeom; |
||||||
|
} |
||||||
|
|
||||||
|
public static CoordinatePoint lonLatConvertPoint(String lonLat){ |
||||||
|
List<String> lonLatList = Arrays.asList(lonLat.split(";")); |
||||||
|
|
||||||
|
CoordinatePoint coordinatePoint = new CoordinatePoint(); |
||||||
|
//绘图经纬度
|
||||||
|
List<PolygonPoint> polygonPoints = new ArrayList<>(); |
||||||
|
//坐标数组
|
||||||
|
List<List<Double>> coordinates = new ArrayList<>(); |
||||||
|
//导航中间点
|
||||||
|
List<Double> cenPoint = new ArrayList<>(2); |
||||||
|
for (int i = 0;i<lonLatList.size();i++){ |
||||||
|
String[] lntlat = lonLatList.get(i).split(","); |
||||||
|
double lon = Double.parseDouble(lntlat[0]); |
||||||
|
double lat = Double.parseDouble(lntlat[1]); |
||||||
|
if (i == 0){ |
||||||
|
cenPoint.add(lon); |
||||||
|
cenPoint.add(lat); |
||||||
|
} |
||||||
|
PolygonPoint point = new PolygonPoint(); |
||||||
|
point.setLongitude(lon); |
||||||
|
point.setLatitude(lat); |
||||||
|
List<Double> coordinate = new ArrayList<>(); |
||||||
|
coordinate.add(lon); |
||||||
|
coordinate.add(lat); |
||||||
|
polygonPoints.add(point); |
||||||
|
coordinates.add(coordinate); |
||||||
|
} |
||||||
|
coordinatePoint.setCoordinates(coordinates); |
||||||
|
coordinatePoint.setPolygonPoints(polygonPoints); |
||||||
|
coordinatePoint.setCenPoint(cenPoint); |
||||||
|
return coordinatePoint; |
||||||
|
} |
||||||
|
|
||||||
|
public static String computeColor(String color,Integer opaqueness){ |
||||||
|
if (StrUtil.isEmpty(color) || opaqueness == null){ |
||||||
|
return null; |
||||||
|
} |
||||||
|
String hex = Integer.toHexString(opaqueness); |
||||||
|
return color+hex; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue