addstationstemplate.html
8 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
<!-- 手动添加站点 -->
<div class="modal fade" id="add_station_template_modal" tabindex="-1" role="basic" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
<h4 class="modal-title">手动添加站点</h4>
</div>
<div class="modal-body">
<form class="form-horizontal" role="form" id="save_station_template_form" action="/module" method="post">
<div class="alert alert-danger display-hide"> <button class="close" data-close="alert"></button>
您的输入有误,请检查下面的输入项
</div>
<!-- 站点名称 -->
<div class="form-body">
<div class="form-group">
<label class="control-label col-md-3">
<span class="required"> * </span> 站点信息:
</label>
<div class="col-md-9">
<textarea class="form-control" rows="12" name="stations" id="stationsInput" placeholder="站点信息"></textarea>
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">坐标系类型:</label>
<div class="col-md-9">
<div class="icheck-list">
<!--<label>
<input type="radio" class="icheck" name="baseRes" value='No'> 暂无坐标系
</label>
<label>
<input type="radio" class="icheck" name="baseRes" value='GCJ02' > 火星坐标系
</label>
<label>
<input type="radio" class="icheck" name="baseRes" value='BD09'> 百度坐标系
</label>-->
<label>
<input type="radio" class="icheck" name="baseRes" value='WGS84' checked> WGS84坐标系
</label>
</div>
</div>
</div>
<!-- 版本号 -->
<div class="form-body">
<div class="form-group">
<label class="col-md-3 control-label">版本号 :</label>
<div class="col-md-6">
<input type="text" class="form-control" name="versions" id='versionsInput' Readonly>
</div>
</div>
</div>
<div class="form-group">
<div class="alert alert-info font-blue-chambray" style="background-color: #2C3E50">
<h5 class="block"><span class="help-block" style="color:#1bbc9b;"> * 手动添加站点规划说明: </span></h5>
<p>
<span class="help-block" style="color:#1bbc9b;">
请在文本域中按站点顺序依次输入站点名称(如果已有站点GPS坐标(坐标点也用【Tab】键隔开),请将坐标跟在站点名称后面用【Tab】键隔开),每输入完一个站名时请按回车键【Enter】换行.
例如:<br><br>
浦东大道金桥路 121.496612 31.238960<br>
浦东大道居家桥路 121.496618 31.238957<br>
浦东大道德平路 121.496622 31.238948<br>
</span>
</p>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn default" data-dismiss="modal" id="addMobalHiden">取消</button>
<button type="button" class="btn btn-primary" id="templateSaveData">提交数据</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$('#add_station_template_modal').on('modal.show', function(event) {
var properties = RoutesOperation.getProperties();
setTimeout(function(){$('#add_station_template_modal').modal({show : true,backdrop: 'static', keyboard: false});},200);
var form = $('#save_station_template_form');
var error = $('.alert-danger', form);
$('#versionsInput').val(properties.versions);
$('.modal-footer #templateSaveData').on('click',function() {
form.submit();
});
form.validate({
errorElement: 'span',
errorClass: 'help-block help-block-error',
focusInvalid: false,
rules: {
'stations': {required: true}
},
invalidHandler: function(event, validator) {
error.show();
App.scrollTo(error, -200);
},
highlight: function(element) {
$(element).closest('.form-group').addClass('has-error');
},
unhighlight: function(element) {
$(element).closest('.form-group').removeClass('has-error');
},
success: function(label) {
label.closest('.form-group').removeClass('has-error');
},
submitHandler: function(f) {
$('#add_station_template_modal').modal('hide');
var directionData = properties.directions;
var lineNameV = $('.portlet-title .caption').text();
var dirStr = '';
if (directionData == 0) {
dirStr = '上行路段';
$('#upToolsMobal').hide();
} else if (directionData == 1) {
dirStr = '下行路段';
$('#downToolsMobal').hide();
}
var i = layer.load(0,{offset:['200px', '280px']});
var paramsForm = form.serializeJSON();
var baseResValue = paramsForm.baseRes;
var array = paramsForm.stations.split('\r\n');
var arrayFormat = inputStationValueFormat(array);
// 根据站点名称获取百度坐标
RoutesOperation.stationsNameToPoints(arrayFormat, function(resultJson) {
// 根据坐标点获取两点之间的时间与距离
RoutesOperation.getDistanceAndTotime(resultJson, function(stationdataList) {
var params = {};
params.lineId = properties.lineId;
params.versions = properties.versions;
params.directions = properties.directions;
params.stationJSON = resultJson;
RoutesOperation.lineInfoPanl(lineNameV, directionData, function(BusLine) {
if (BusLine && Polygon){
var Polygon = BusLine.getPolyline();
var polyGonArray = Polygon.getPath();
var jsonArray = [{sectionName: lineNameV+dirStr, points: polyGonArray}];
params.sectionJSON = jsonArray;
addSave(params, properties.lineId, directionData);
} else {
RoutesOperation.getSectionListPlonly(stationdataList,function(sectiondata) {
params.sectionJSON = sectiondata;
addSave(params, properties.lineId, directionData);
});
}
});
});
});
}
});
function inputStationValueFormat(paramsStationsArray) {
var stationList = [];
var len = paramsStationsArray.length;
for (var k = 0;k < len;k++) {
if (paramsStationsArray[k] == "") {
continue;
}
var tempStr = paramsStationsArray[k].split('\t');
if (tempStr.length < 2) {
stationList.push({name: paramsStationsArray[k]+"公交车站", wgs: {x: '',y: ''}});
} else {
stationList.push({name: tempStr[0]+"公交车站", wgs: {x: tempStr[1], y: tempStr[2]}});
}
}
return stationList;
}
function addSave(params, lineId, directionData) {
debugger;
// 参数集合
if (!params.versions) {
params.versions = '1';
}
formatRoutes(params);
//return;
RoutesService.manualSave(params, function(res) {
layer.closeAll();
if (res.status == 'SUCCESS') {
layer.msg('保存成功!');
} else {
layer.msg('保存失败!');
}
RoutesOperation.clearMarkAndOverlays();
RoutesOperation.resjtreeDate(lineId, directionData, params.versions);
});
}
function formatRoutes(params) {
var stationRoutes = [], sectionRoutes = [], sectionRouteCode = 1;
params.stationJSON.forEach(function(item) {
stationRoutes.push({stationName: item.name, shapedType: 'r', radius: 80, destroy: 0, distances: 0, toTime: 0, station: {stationName: item.name, centerPointWkt: 'POINT(' + item.potion.lng + ' ' + item.potion.lat + ')'}});
})
params.sectionJSON.forEach(function(item) {
var centerPointWkt = [];
item.points.forEach(function(item1) {
centerPointWkt.push(item1.lng + ' ' + item1.lat);
})
sectionRoutes.push({sectionrouteCode: sectionRouteCode, destroy: 0, section: {sectionName: item.sectionName, bsectionVectorWkt: 'LINESTRING(' + centerPointWkt.join(',') + ')'}});
sectionRouteCode++;
})
params.stationRoutes = stationRoutes;
params.sectionRoutes = sectionRoutes;
}
});
</script>