Section.java
2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package com.bsth.entity;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.LineString;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 路段信息
* Created by panzhao on 2017/4/5.
*/
public class Section {
public static List<Section> craete(List<Map<String, Object>> mapList){
List<Section> list = JSONObject.parseArray(JSON.toJSONString(mapList), Section.class);
//处理路段坐标
String polygonStr;
String[] coords;
int i, len;
String[] temps;//1, temps2;
List<Coordinate> cds;
GeometryFactory geometryFactory = new GeometryFactory();
for(Section road : list){
polygonStr = road.getGROAD_VECTOR();
coords = polygonStr.substring(11, polygonStr.length() - 1).split(",");
len = coords.length;
cds = new ArrayList<>();
//每2个点连一条线
for(i = 0; i < len; i ++){
temps = coords[i].split(" ");
cds.add(new Coordinate(Float.parseFloat(temps[1]), Float.parseFloat(temps[0])));
}
Coordinate[] cdsArray = new Coordinate[cds.size()];
road.setLineStr(geometryFactory.createLineString(cds.toArray(cdsArray)));
}
return list;
}
private long ID;
@JsonIgnore
private String GROAD_VECTOR;
private String ROAD_CODE;
private String ROAD_NAME;
private double SPEED;
@JsonIgnore
private LineString lineStr;
public long getID() {
return ID;
}
public void setID(long ID) {
this.ID = ID;
}
public String getGROAD_VECTOR() {
return GROAD_VECTOR;
}
public void setGROAD_VECTOR(String GROAD_VECTOR) {
this.GROAD_VECTOR = GROAD_VECTOR;
}
public String getROAD_CODE() {
return ROAD_CODE;
}
public void setROAD_CODE(String ROAD_CODE) {
this.ROAD_CODE = ROAD_CODE;
}
public String getROAD_NAME() {
return ROAD_NAME;
}
public void setROAD_NAME(String ROAD_NAME) {
this.ROAD_NAME = ROAD_NAME;
}
public double getSPEED() {
return SPEED;
}
public void setSPEED(double SPEED) {
this.SPEED = SPEED;
}
public LineString getLineStr() {
return lineStr;
}
public void setLineStr(LineString lineStr) {
this.lineStr = lineStr;
}
}