Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kfw_tools
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bo
kfw_tools
Commits
f1edc0ff
Commit
f1edc0ff
authored
Jul 02, 2025
by
bo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化订单导航
parent
50a3f7f9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
3 deletions
+30
-3
recm_path.py
src/lib/recm_path.py
+30
-3
No files found.
src/lib/recm_path.py
View file @
f1edc0ff
# coding: utf-8
# coding: utf-8
import
math
import
math
import
time
def
generate_possible_path
(
arrays
):
def
generate_possible_path
(
arrays
):
...
@@ -121,6 +122,29 @@ def match_order(orders, path):
...
@@ -121,6 +122,29 @@ def match_order(orders, path):
def
get_order_path
(
order_strs
,
start_poi_str
=
''
):
def
get_order_path
(
order_strs
,
start_poi_str
=
''
):
orders
=
str2orders
(
order_strs
)
orders
=
str2orders
(
order_strs
)
last_poi
=
start_poi_str
closest_dis
=
0
fn_path
=
[]
while
orders
:
min_dis
=
9999999999
tmp_order
=
None
for
order
in
orders
:
tmp_dis
=
get_dis
(
last_poi
,
orders
[
order
][
0
])
if
tmp_dis
<
min_dis
:
min_dis
=
tmp_dis
tmp_order
=
order
closest_dis
+=
min_dis
order
=
orders
.
pop
(
tmp_order
)
idx
=
1
if
len
(
order
)
==
2
else
2
if
idx
==
1
:
orders
[
tmp_order
]
=
[
order
[
1
]]
fn_path
.
append
([
tmp_order
,
order
[
0
],
str
(
idx
)])
last_poi
=
order
[
0
]
return
";"
.
join
([
','
.
join
(
path
)
for
path
in
fn_path
]),
closest_dis
def
get_order_path_all
(
order_strs
,
start_poi_str
=
''
):
orders
=
str2orders
(
order_strs
)
locs
=
orders
.
values
()[:
5
]
locs
=
orders
.
values
()[:
5
]
all_path
=
generate_possible_path
(
locs
)
all_path
=
generate_possible_path
(
locs
)
best_path
,
closest_dis
=
(
get_best_path
(
all_path
,
start_poi_str
))
best_path
,
closest_dis
=
(
get_best_path
(
all_path
,
start_poi_str
))
...
@@ -134,12 +158,15 @@ if __name__ == '__main__':
...
@@ -134,12 +158,15 @@ if __name__ == '__main__':
tmpcd
=
0
tmpcd
=
0
strs
=
'id1,116,39,116.4,39.9;id2,116.3,39.97;id3,116.60,39.67'
strs
=
'id1,116,39,116.4,39.9;id2,116.3,39.97;id3,116.60,39.67'
# strs = '1551101515,110.47847748,29.12586975,110.47585113,29.13276902;1551101443,110.49884945,29.13684405,110.49618740,29.13216188;1551100204,110.46364600,29.13979500,110.43194723,29.13712246;1551100127,110.49648300,29.11439100,110.49784583,29.11305473;1551099953,110.49297600,29.13722200,110.47381488,29.13417613;1551099949,110.49889237,29.13005353,110.48189045,29.13802390;1551099684,110.48303223,29.13754845,110.48199650,29.14022133;1551099589,110.49887627,29.13003832,110.48528137,29.13825283;1551098955,110.49852200,29.13588100,110.49852926,29.13586055;1551098182,110.48904419,29.13865852,110.49150540,29.11542065'
# strs = '1551101515,110.47847748,29.12586975,110.47585113,29.13276902;1551101443,110.49884945,29.13684405,110.49618740,29.13216188;1551100204,110.46364600,29.13979500,110.43194723,29.13712246;1551100127,110.49648300,29.11439100,110.49784583,29.11305473;1551099953,110.49297600,29.13722200,110.47381488,29.13417613;1551099949,110.49889237,29.13005353,110.48189045,29.13802390;1551099684,110.48303223,29.13754845,110.48199650,29.14022133;1551099589,110.49887627,29.13003832,110.48528137,29.13825283;1551098955,110.49852200,29.13588100,110.49852926,29.13586055;1551098182,110.48904419,29.13865852,110.49150540,29.11542065'
strs
=
'1551103134,110.47121600,29.13402500,110.48718800,29.13851600;1551102629,110.46813279,29.13366297,110.45269720,29.13795196;1551102202,110.49289800,29.13730100,110.49726539,29.12888991;1551102191,110.47121600,29.13402500,110.48213100,29.13675800;1551101768,110.50223541,29.13923073,110.49040770,29.11378568;1551101515,110.47136000,29.13393000,110.47585113,29.13276902;1551101443,110.49672300,29.13168700,110.49618740,29.13216188'
#
strs = '1551103134,110.47121600,29.13402500,110.48718800,29.13851600;1551102629,110.46813279,29.13366297,110.45269720,29.13795196;1551102202,110.49289800,29.13730100,110.49726539,29.12888991;1551102191,110.47121600,29.13402500,110.48213100,29.13675800;1551101768,110.50223541,29.13923073,110.49040770,29.11378568;1551101515,110.47136000,29.13393000,110.47585113,29.13276902;1551101443,110.49672300,29.13168700,110.49618740,29.13216188'
# strs = '1551101768,110.50223541,29.13923073,110.49040770,29.11378568;1551101515,110.47136000,29.13393000,110.47585113,29.13276902;1551101443,110.49291300,29.13725500,110.49618740,29.13216188'
# strs = '1551101768,110.50223541,29.13923073,110.49040770,29.11378568;1551101515,110.47136000,29.13393000,110.47585113,29.13276902;1551101443,110.49291300,29.13725500,110.49618740,29.13216188'
#`strs = ''
#`strs = ''
# strs = '1551101768,110.50223541,29.13923073,110.49040770,29.11378568;1551101515,110.47136000,29.13393000,110.47585113,29.13276902;1551101443,110.49291300,29.13725500,110.49618740,29.13216188;1551102191,110.47121600,29.13402500,110.48213100,29.13675800;1551101768,110.50223541,29.13923073,110.49040770,29.11378568'
# strs = '1551101768,110.50223541,29.13923073,110.49040770,29.11378568;1551101515,110.47136000,29.13393000,110.47585113,29.13276902;1551101443,110.49291300,29.13725500,110.49618740,29.13216188;1551102191,110.47121600,29.13402500,110.48213100,29.13675800;1551101768,110.50223541,29.13923073,110.49040770,29.11378568'
cur_poi
=
'116,39'
print
(
get_order_path
(
strs
,
'116,39'
))
strs
=
'10565418649787965,123.78060865,41.31343931,123.76915906,41.29009318;220174975,123.78365709,41.31230343,123.77642755,41.2865735;1939674437406842907,123.790948,41.317638,123.77728118,41.28852207;10565547841512824,123.77720084,41.31253626,123.77776732,41.29130467;10565562546479057,123.78235573,41.31413129,123.7705417,41.2952553;2361438908924901441,123.78760647,41.30865004,123.78258269,41.29694752'
cur_poi
=
'123.79319763183594,41.296627044677734'
print
(
get_order_path_all
(
strs
,
cur_poi
))
print
(
get_order_path
(
strs
,
cur_poi
))
# print(tmpc)
# print(tmpc)
exit
(
0
)
exit
(
0
)
orders
=
str2orders
(
strs
)
orders
=
str2orders
(
strs
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment