LsStationRouteServiceImpl.java
25.3 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
package com.bsth.service.impl;
import com.bsth.annotation.BusinessDescription;
import com.bsth.data.gpsdata_v2.utils.GeoUtils;
import com.bsth.entity.*;
import com.bsth.entity.search.CustomerSpecs;
import com.bsth.repository.*;
import com.bsth.service.LsStationRouteService;
import com.bsth.util.CustomBeanUtils;
import com.bsth.util.GeoConverter;
import org.geolatte.geom.LineString;
import org.geolatte.geom.Polygon;
import org.geolatte.geom.codec.Wkt;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.jdbc.core.BatchPreparedStatementSetter;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.*;
/**
* @author Hill
*/
@Service
public class LsStationRouteServiceImpl extends BaseServiceImpl<LsStationRoute, Integer> implements LsStationRouteService {
private final static Logger log = LoggerFactory.getLogger(LsStationRouteServiceImpl.class);
@Autowired
private LsStationRouteRepository lsStationRouteRepository;
@Autowired
private StationRouteRepository stationRouteRepository;
@Autowired
private StationRepository stationRepository;
@Autowired
private LsSectionRouteRepository lsSectionRouteRepository;
@Autowired
private SectionRouteRepository sectionRouteRepository;
@Autowired
private SectionRepository sectionRepository;
@Autowired
private LineRepository lineRepository;
@Autowired
private LineVersionsRepository lineVersionsRepository;
@Autowired
private JdbcTemplate jdbcTemplate;
@Autowired
private DetourRepository detourRepository;
@Override
public Iterable<LsStationRoute> findAllByParams(Map<String, Object> map) {
List<Sort.Order> orders = new ArrayList<>();
orders.add(new Sort.Order(Sort.Direction.ASC, "directions"));
orders.add(new Sort.Order(Sort.Direction.ASC, "stationRouteCode"));
return lsStationRouteRepository.findAll(new CustomerSpecs<>(map), Sort.by(orders));
}
/**
* 获取历史站点和路段路由
* @param map
* @return
*/
@Override
public Map<String, Object> findRoutes(Map<String, Object> map) {
Map<String, Object> result = new HashMap<>();
List<LsStationRoute> stationList = lsStationRouteRepository.findAll(new CustomerSpecs<>(map), Sort.by(Sort.Direction.ASC, "directions", "stationRouteCode"));
List<LsSectionRoute> sectionList = lsSectionRouteRepository.findAll(new CustomerSpecs<>(map), Sort.by(Sort.Direction.ASC, "directions", "sectionrouteCode"));
result.put("stationRoutes", stationList);
result.put("sectionRoutes", sectionList);
return result;
}
/**
* 获取历史站点路由
* @param map
* @return
*/
public List<LsStationRoute> findStationRoutes(Map<String, Object> map) {
return lsStationRouteRepository.findAll(new CustomerSpecs<>(map), Sort.by(Sort.Direction.ASC, "directions", "stationRouteCode"));
}
/**
* 获取当前站点以及下一站点路由
* @param id
* @return
*/
@Override
public List<LsStationRoute> findCurrentAndNext(Integer id) {
if (id == null) {
throw new IllegalArgumentException("需正确传入站点路由ID参数");
}
List<LsStationRoute> stationRoutes = new ArrayList<>();
LsStationRoute stationRoute = lsStationRouteRepository.findById(id).get();
Map<String, Object> params = new HashMap<>();
params.put("line.id_eq", stationRoute.getLine().getId());
params.put("versions_eq", stationRoute.getVersions());
params.put("directions_eq", stationRoute.getDirections());
params.put("destroy_eq", 0);
params.put("stationRouteCode_gt", stationRoute.getStationRouteCode());
List<LsStationRoute> stationRoutes1 = lsStationRouteRepository.findAll(new CustomerSpecs<>(params), Sort.by(Sort.Order.asc("stationRouteCode")));
stationRoutes.add(stationRoute);
if (stationRoutes1.size() > 0) {
stationRoutes.add(stationRoutes1.get(0));
}
return stationRoutes;
}
/**
* 批量撤销站点路由
* @param ids
*/
@BusinessDescription(value = "批量撤销站点路由")
@Transactional(rollbackFor = RuntimeException.class)
@Override
public void batchDestroy(List<Integer> ids) {
if (ids.size() > 0) {
Integer id = ids.get(0);
LsStationRoute stationRoute = lsStationRouteRepository.findById(id).get();
Integer lineId = stationRoute.getLine().getId();
Integer currentVersion = lineVersionsRepository.findCurrentVersion(lineId);
if (stationRoute.getVersions() < currentVersion) {
throw new IllegalArgumentException("历史版本不可变更");
}
lsStationRouteRepository.batchDestroy(ids);
remark(stationRoute);
if (stationRoute.getVersions().equals(currentVersion)) {
refreshCurrent(lineId, currentVersion);
}
}
}
/**
* 批量恢复撤销站点路由
* @param ids
*/
@BusinessDescription(value = "批量恢复撤销站点路由")
@Transactional(rollbackFor = RuntimeException.class)
@Override
public void batchRecover(List<Integer> ids) {
if (ids.size() > 0) {
Integer id = ids.get(0);
LsStationRoute stationRoute = lsStationRouteRepository.findById(id).get();
Integer lineId = stationRoute.getLine().getId();
Integer currentVersion = lineVersionsRepository.findCurrentVersion(lineId);
if (stationRoute.getVersions() < currentVersion) {
throw new IllegalArgumentException("历史版本不可变更");
}
lsStationRouteRepository.batchRecover(ids);
remark(stationRoute);
if (stationRoute.getVersions().equals(currentVersion)) {
refreshCurrent(lineId, currentVersion);
}
}
}
@Transactional
@Override
public Map<String, Object> addRoutes(Integer lineId, Integer versions, Integer directions, List<LsStationRoute> stationRoutes, List<LsSectionRoute> sectionRoutes) {
Map<String, Object> result = new HashMap<>();
Line line = lineRepository.findById(lineId).get();
Integer version = lineVersionsRepository.findCurrentVersion(lineId);
if (line == null) {
throw new RuntimeException(String.format("未找到ID为%d的线路信息", lineId));
}
List<Station> stations = stationRoutesHandle(line, versions, directions, stationRoutes);
List<Section> sections = sectionRoutesHandle(line, versions, directions, sectionRoutes);
stationRepository.saveAll(stations);
sectionRepository.saveAll(sections);
lsStationRouteRepository.saveAll(stationRoutes);
lsSectionRouteRepository.saveAll(sectionRoutes);
if (versions.equals(version)) {
refreshCurrent(lineId, version);
}
return result;
}
private List<Station> stationRoutesHandle(Line line, Integer versions, Integer directions, List<LsStationRoute> stationRoutes) {
List<Station> stations = new ArrayList<>();
int currentId = stationRepository.findLatestStationId(), count = 0;
for (int len = stationRoutes.size();count < len;) {
LsStationRoute stationRoute = stationRoutes.get(count);
stationRoute.setStationMark(count == 0 ? "B" : count == len - 1 ? "E" : "Z");
count++;
stationRoute.setLine(line);
stationRoute.setVersions(versions);
stationRoute.setDirections(directions);
stationRoute.setLineCode(line.getLineCode());
stationRoute.setStationRouteCode(100 * count);
stationRoute.setStationCode(stationRoute.getStation().getStationCode());
Station station = stationRoute.getStation();
stationRoute.setCenterPointWkt(station.getCenterPointWkt());
if (!StringUtils.isEmpty(stationRoute.getCenterPointWkt())) {
centerPoint(stationRoute);
}
if (station.getId() == null) {
station.setId(currentId + count);
station.setStationCode(station.getId().toString());
stationRoute.setStationCode(station.getStationCode());
centerPoint(station);
stations.add(station);
}
}
return stations;
}
private List<Section> sectionRoutesHandle(Line line, Integer versions, Integer directions, List<LsSectionRoute> sectionRoutes) {
List<Section> sections = new ArrayList<>();
int currentId = sectionRepository.findLatestSectionId(), count = 0;
for (int len = sectionRoutes.size();count < len;) {
LsSectionRoute sectionRoute = sectionRoutes.get(count++);
sectionRoute.setLine(line);
sectionRoute.setVersions(versions);
sectionRoute.setDirections(directions);
sectionRoute.setLineCode(line.getLineCode());
sectionRoute.setSectionrouteCode(100 * count);
String wkt = sectionRoute.getSection().getBsectionVectorWkt();
Section section = sectionRoute.getSection();
section.setBsectionVector((LineString) Wkt.fromWkt(wkt));
section.setGsectionVector(GeoConverter.lineStringBd2wgs(wkt));
section.setId(currentId + count);
section.setSectionCode(section.getId().toString());
sectionRoute.setSectionCode(section.getSectionCode());
sections.add(section);
}
return sections;
}
@BusinessDescription(value = "添加站点路由")
@Transactional
@Override
public Map<String, Object> add(LsStationRoute stationRoute) {
Station station = stationRoute.getStation();
Line line = lineRepository.findById(stationRoute.getLine().getId()).get();
Integer currentVersion = lineVersionsRepository.findCurrentVersion(line.getId());
boolean isPresent = stationRepository.findById(station.getId()).isPresent();
stationRoute.setLineCode(line.getLineCode());
stationRoute.setCenterPointWkt(station.getCenterPointWkt());
if (stationRoute.getVersions() < currentVersion) {
throw new IllegalArgumentException("历史版本不可变更");
}
if (!StringUtils.isEmpty(stationRoute.getCenterPointWkt())) {
centerPoint(stationRoute);
}
// 中心点坐标信息
if (!isPresent) {
centerPoint(station);
stationRoute.setCenterPoint(station.getCenterPoint());
stationRoute.setCenterPointWgs(station.getCenterPointWgs());
}
// 多边形缓冲区
if ("d".equals(stationRoute.getShapedType())) {
bufferPolygon(stationRoute);
}
lsStationRouteRepository.updateStatiouRouteCode(stationRoute);
if (!isPresent) {
stationRepository.save(station);
}
lsStationRouteRepository.save(stationRoute);
remark(stationRoute);
if (stationRoute.getVersions().equals(currentVersion)) {
refreshCurrent(line.getId(), currentVersion);
}
return new HashMap<>();
}
@Transactional
@Override
public Map<String, Object> modify(LsStationRoute stationRoute) {
LsStationRoute stationRoute1 = lsStationRouteRepository.findById(stationRoute.getId()).get();
Integer currentVersion = lineVersionsRepository.findCurrentVersion(stationRoute1.getLine().getId());
if (stationRoute1.getVersions() < currentVersion) {
throw new IllegalArgumentException("历史版本不可变更");
}
if (!StringUtils.isEmpty(stationRoute.getCenterPointWkt())) {
centerPoint(stationRoute);
}
// 多边形缓冲区
if ("d".equals(stationRoute.getShapedType())) {
bufferPolygon(stationRoute);
}
lsStationRouteRepository.updateStatiouRouteCode(stationRoute);
CustomBeanUtils.copyPropertiesIgnoredNull(stationRoute, stationRoute1);
lsStationRouteRepository.save(stationRoute1);
remark(stationRoute1);
if (stationRoute.getVersions().equals(currentVersion)) {
refreshCurrent(stationRoute1.getLine().getId(), currentVersion);
}
// 处理绕改道逻辑
handleDetour(stationRoute1);
return new HashMap<>();
}
private void handleDetour(LsStationRoute stationRoute) {
Integer detourStationRouteId = stationRoute.getDetourStationRoute();
if (detourStationRouteId == null) {
return;
}
// 获取终点站点路由
LsStationRoute endStationRoute = lsStationRouteRepository.findById(detourStationRouteId)
.orElseThrow(() -> new IllegalArgumentException("未找到对应的终点站点路由,ID:" + detourStationRouteId));
// 获取起点和终点的WGS坐标
org.geolatte.geom.Point startPoint = stationRoute.getCenterPointWgs();
org.geolatte.geom.Point endPoint = endStationRoute.getCenterPointWgs();
if (startPoint == null || endPoint == null) {
throw new IllegalArgumentException("起点或终点站点坐标信息不完整");
}
// 转换为内部Geo.Point
com.bsth.util.Geo.Point startGeoPoint = toGeoPoint(startPoint);
com.bsth.util.Geo.Point endGeoPoint = toGeoPoint(endPoint);
// 获取线路、版本号、上下行信息
Integer lineId = Optional.ofNullable(stationRoute.getLine())
.map(Line::getId)
.orElseThrow(() -> new IllegalArgumentException("站点路由关联的线路信息缺失"));
Integer versions = stationRoute.getVersions();
Integer directions = stationRoute.getDirections();
// 查询所有路段路由(按路段编码升序)
Map<String, Object> params = new HashMap<>();
params.put("line.id_eq", lineId);
params.put("versions_eq", versions);
params.put("directions_eq", directions);
params.put("destroy_eq", 0);
List<LsSectionRoute> sectionRoutes = lsSectionRouteRepository.findAll(
new CustomerSpecs<>(params),
Sort.by(Sort.Direction.ASC, "sectionrouteCode")
);
// 第一步:找到起点和终点所在的路段及索引
LsSectionRoute startSection = null;
LsSectionRoute endSection = null;
int startIndex = -1;
int endIndex = -1;
double minStartDistance = Double.MAX_VALUE;
double minEndDistance = Double.MAX_VALUE;
for (int i = 0; i < sectionRoutes.size(); i++) {
LsSectionRoute sectionRoute = sectionRoutes.get(i);
Section section = sectionRoute.getSection();
if (section == null || section.getGsectionVector() == null) {
continue;
}
LineString lineString = section.getGsectionVector();
// 计算起点到当前路段的最小距离
double startDist = calcMinDistanceToLine(lineString, startGeoPoint);
if (startDist < minStartDistance) {
minStartDistance = startDist;
startSection = sectionRoute;
startIndex = i;
}
// 计算终点到当前路段的最小距离
double endDist = calcMinDistanceToLine(lineString, endGeoPoint);
if (endDist < minEndDistance) {
minEndDistance = endDist;
endSection = sectionRoute;
endIndex = i;
}
}
if (startSection == null || endSection == null) {
log.warn("未能找到起点或终点所在的路段,起点ID:{},终点ID:{}",
stationRoute.getId(), endStationRoute.getId());
return;
}
// 第二步:确定中间经过的路段(排除起点和终点路段)
List<LsSectionRoute> passingSections = new ArrayList<>();
if (startIndex >= 0 && endIndex >= 0) {
int low = Math.min(startIndex, endIndex);
int high = Math.max(startIndex, endIndex);
// 只添加严格介于两者之间的路段
for (int i = low + 1; i < high; i++) {
passingSections.add(sectionRoutes.get(i));
}
}
// 检查路段数(超过15视为异常)
if (passingSections.size() > 13) {
log.error("绕改道路径过长,起点路段:{},终点路段:{},中间路段数:{}",
startSection.getId(), endSection.getId(), passingSections.size());
throw new RuntimeException("过长的绕改道路径(超过13个中间路段)");
}
// 构建绕改道路径
Detour detour = new Detour();
detour.setLine(lineId);
detour.setVersions(versions);
detour.setDirection(directions);
detour.setStartStationCode(stationRoute.getStationCode());
detour.setTerminalStationCode(endStationRoute.getStationCode());
String points = buildPoints(startPoint, passingSections, endPoint);
try {
detour.setPoints(points);
detourRepository.save(detour);
log.info("绕改道路径保存成功,线路:{},版本:{},方向:{}", lineId, versions, directions);
} catch (Exception e) {
log.error("保存绕改道失败,points:{}", points, e);
throw new RuntimeException("保存绕改道路径失败", e);
}
}
/**
* 将org.geolatte.geom.Point转换为内部Geo.Point
*/
private com.bsth.util.Geo.Point toGeoPoint(org.geolatte.geom.Point point) {
return new com.bsth.util.Geo.Point(
point.getPosition().getCoordinate(0),
point.getPosition().getCoordinate(1)
);
}
/**
* 将org.geolatte.geom.Position转换为内部Geo.Point
*/
private com.bsth.util.Geo.Point toGeoPoint(org.geolatte.geom.Position position) {
return new com.bsth.util.Geo.Point(
position.getCoordinate(0),
position.getCoordinate(1)
);
}
/**
* 计算点到LineString的最小距离(遍历每个线段)
* 注意:使用getPositionN获取位置,LineString无getPointN方法
*/
private double calcMinDistanceToLine(LineString lineString,
com.bsth.util.Geo.Point geoPoint) {
double minDist = Double.MAX_VALUE;
int numPoints = lineString.getNumPositions(); // 获取点数
for (int i = 0; i < numPoints - 1; i++) {
org.geolatte.geom.Position p1 = lineString.getPositionN(i);
org.geolatte.geom.Position p2 = lineString.getPositionN(i + 1);
com.bsth.util.Geo.Point geoP1 = toGeoPoint(p1);
com.bsth.util.Geo.Point geoP2 = toGeoPoint(p2);
double dist = GeoUtils.getDistanceFromLine(geoP1, geoP2, geoPoint);
minDist = Math.min(minDist, dist);
}
return minDist;
}
/**
* 构建坐标点 包含起点、中间路段中点、终点
*/
private String buildPoints(org.geolatte.geom.Point startPoint,
List<LsSectionRoute> passingSections,
org.geolatte.geom.Point endPoint) {
StringBuilder wktBuilder = new StringBuilder();
// 添加起点
wktBuilder.append(startPoint.getPosition().getCoordinate(0))
.append(" ")
.append(startPoint.getPosition().getCoordinate(1));
// 添加中间路段的中点
for (LsSectionRoute sectionRoute : passingSections) {
Section section = sectionRoute.getSection();
if (section != null && section.getGsectionVector() != null) {
LineString lineString = section.getGsectionVector();
int numPoints = lineString.getNumPositions();
int midIndex = numPoints / 2; // 取中间索引点
org.geolatte.geom.Position midPos = lineString.getPositionN(midIndex);
wktBuilder.append(",")
.append(midPos.getCoordinate(0))
.append(" ")
.append(midPos.getCoordinate(1));
}
}
// 添加终点
wktBuilder.append(",")
.append(endPoint.getPosition().getCoordinate(0))
.append(" ")
.append(endPoint.getPosition().getCoordinate(1));
return wktBuilder.toString();
}
@Transactional
@Override
public Map<String, Object> exchangeDirection(int lineId, int version) {
lsStationRouteRepository.exchangeDirection(lineId, version);
lsSectionRouteRepository.exchangeDirection(lineId, version);
return new HashMap<>();
}
@Transactional
@Override
public Map<String, Object> modifyDistance(List<Integer> ids, List<Double> distances) {
LsStationRoute stationRoute = lsStationRouteRepository.findById(ids.get(0)).get();
int currentVersion = lineVersionsRepository.findCurrentVersion(stationRoute.getLine().getId());
if (stationRoute.getVersions() < currentVersion) {
throw new IllegalArgumentException("历史版本不可变更");
}
jdbcTemplate.batchUpdate("UPDATE bsth_c_ls_stationroute SET distances = ? WHERE id = ?", new BatchPreparedStatementSetter() {
@Override
public void setValues(PreparedStatement ps, int i) throws SQLException {
ps.setDouble(1, distances.get(i));
ps.setInt(2, ids.get(i));
}
@Override
public int getBatchSize() {
return ids.size();
}
});
if (stationRoute.getVersions() == currentVersion) {
refreshCurrent(stationRoute.getLine().getId(), currentVersion);
}
return new HashMap<>();
}
@Transactional
@Override
public Map<String, Object> circularRouteHandle(Integer lineId, Integer version) {
Line line = lineRepository.findById(lineId).get();
Integer currentVersion = lineVersionsRepository.findCurrentVersion(lineId);
if (version < currentVersion) {
throw new IllegalArgumentException("历史版本不可变更");
}
Map<String, Object> params = new HashMap<>();
params.put("line.id_eq", lineId);
params.put("versions_eq", version);
params.put("destroy_eq", 0);
params.put("stationMark_in", "B,E");
Sort sort = Sort.by(Sort.Order.asc("directions"), Sort.Order.asc("stationRouteCode"));
List<LsStationRoute> routes = lsStationRouteRepository.findAll(new CustomerSpecs<>(params), sort);
LsStationRoute route = routes.get(0);
for (int i = 1;i < routes.size();i++) {
LsStationRoute route1 = routes.get(i);
if (line.getLinePlayType() == 1 && route1.getDirections() == 1) {
break;
}
route1.setStationCode(route.getStationCode());
route1.setStation(route.getStation());
}
lsStationRouteRepository.saveAll(routes);
if (version.equals(currentVersion)) {
refreshCurrent(lineId, version);
}
return new HashMap<>();
}
@Override
public List<LsStationRoute> findByLineDirectionDate(Integer lineId, Integer direction, Date begin, Date end) {
return lsStationRouteRepository.findByLineDirectionDate(lineId, direction, begin, end);
}
protected void centerPoint(Station station) {
// 中心点坐标信息
String wkt = station.getCenterPointWkt();
if (!StringUtils.isEmpty(wkt)) {
org.geolatte.geom.Point baidu = (org.geolatte.geom.Point) Wkt.fromWkt(wkt);
org.geolatte.geom.Point wgs = GeoConverter.pointBd2wgs(wkt);
station.setCenterPoint(baidu);
station.setCenterPointWgs(wgs);
}
}
protected void centerPoint(LsStationRoute route) {
// 中心点坐标信息
String wkt = route.getCenterPointWkt();
if (!StringUtils.isEmpty(wkt)) {
org.geolatte.geom.Point baidu = (org.geolatte.geom.Point) Wkt.fromWkt(wkt);
org.geolatte.geom.Point wgs = GeoConverter.pointBd2wgs(wkt);
route.setCenterPoint(baidu);
route.setCenterPointWgs(wgs);
}
}
protected void bufferPolygon(LsStationRoute stationRoute) {
String wkt = stationRoute.getBufferPolygonWkt();
if (!StringUtils.isEmpty(wkt)) {
stationRoute.setBufferPolygon((Polygon) Wkt.fromWkt(wkt));
stationRoute.setBufferPolygonWgs(GeoConverter.polygonBd2wgs(wkt));
}
}
protected void remark(LsStationRoute stationRoute) {
lsStationRouteRepository.updateStartZ(stationRoute);
lsStationRouteRepository.updateStartB(stationRoute);
lsStationRouteRepository.updateStartE(stationRoute);
}
protected void refreshCurrent(int lineId, int version) {
stationRouteRepository.deleteByLine(lineId);
stationRouteRepository.updateFromHistory(lineId, version);
}
}