Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
search_tips
Project
Project
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
rank
search_tips
Commits
e74cccde
Commit
e74cccde
authored
Apr 21, 2020
by
李小芳
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'hisp' into 'master'
add See merge request
!78
parents
537d95fd
622a216a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
7 deletions
+6
-7
tools.py
libs/tools.py
+6
-7
No files found.
libs/tools.py
View file @
e74cccde
...
...
@@ -58,26 +58,26 @@ def point_distance(lon1, lat1, lon2, lat2):
# haversine公式
dlon
=
lon2
-
lon1
dlat
=
lat2
-
lat1
a
=
sin
(
dlat
/
2
)
**
2
+
cos
(
lat1
)
*
cos
(
lat2
)
*
sin
(
dlon
/
2
)
**
2
a
=
sin
(
dlat
/
2
)
**
2
+
cos
(
lat1
)
*
cos
(
lat2
)
*
sin
(
dlon
/
2
)
**
2
c
=
2
*
asin
(
sqrt
(
a
))
r
=
6371
# 地球平均半径,单位为km
return
c
*
r
*
1000
class
HostpitalPosInfo
(
object
):
hospital_pos_dict
=
dict
()
@classmethod
def
get_hostpital_info
(
cls
):
try
:
if
len
(
cls
.
hospital_pos_dict
)
==
0
:
query_results
=
doctor
.
Hospital
.
objects
.
filter
(
is_online
=
True
)
#query_results = django.db.models.QuerySet(model=doctor.Hospital, query=query)
query_results
=
doctor
.
Hospital
.
objects
.
filter
()
#
query_results = django.db.models.QuerySet(model=doctor.Hospital, query=query)
for
item
in
query_results
:
name
=
item
.
name
lng
=
float
(
item
.
baidu_loc_lng
)
lat
=
float
(
item
.
baidu_loc_lat
)
cls
.
hospital_pos_dict
[
name
]
=
[
lng
,
lat
]
cls
.
hospital_pos_dict
[
name
]
=
[
lng
,
lat
]
return
cls
.
hospital_pos_dict
except
:
...
...
@@ -85,4 +85,4 @@ class HostpitalPosInfo(object):
return
cls
.
hospital_pos_dict
g_hospital_pos_dict
=
HostpitalPosInfo
.
get_hostpital_info
()
\ No newline at end of file
g_hospital_pos_dict
=
HostpitalPosInfo
.
get_hostpital_info
()
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