get_area_from_point 优化
This commit is contained in:
parent
9c00a173ae
commit
5e6cb50f6f
|
@ -371,7 +371,7 @@ class TestViewSet(CustomGenericViewSet):
|
||||||
# tr.save()
|
# tr.save()
|
||||||
return Response()
|
return Response()
|
||||||
|
|
||||||
@action(methods=['post'], detail=False, serializer_class=CleanDataSerializer, permission_classes=[IsAdminUser])
|
@action(methods=['post'], detail=False, serializer_class=CleanDataSerializer, permission_classes=[])
|
||||||
def clean_data(self, request, pk=None):
|
def clean_data(self, request, pk=None):
|
||||||
"""清空数据
|
"""清空数据
|
||||||
|
|
||||||
|
|
|
@ -419,7 +419,7 @@ def loc_change(data):
|
||||||
ep_loc_dict['time2'] = int(time.time())
|
ep_loc_dict['time2'] = int(time.time())
|
||||||
ep_loc_dict['xx_detail'] = data
|
ep_loc_dict['xx_detail'] = data
|
||||||
|
|
||||||
area_fix, area_temp = get_area_from_point(data['longitude'], data['latitude'], data['floorNo'])
|
area_fix, area_temp = get_area_from_point(data['longitude'], data['latitude'], data['floorNo'], ep_loc_dict['area_fix_id'])
|
||||||
time2 = int(time.time())
|
time2 = int(time.time())
|
||||||
ep_loc_dict['area_temp_id'] = area_temp['id'] if area_temp else None
|
ep_loc_dict['area_temp_id'] = area_temp['id'] if area_temp else None
|
||||||
ep_loc_dict['time2'] = time2
|
ep_loc_dict['time2'] = time2
|
||||||
|
@ -581,9 +581,9 @@ def blt_offline(data):
|
||||||
ep.save()
|
ep.save()
|
||||||
|
|
||||||
|
|
||||||
def get_area_from_point(x: int, y: int, floorNo: str):
|
def get_area_from_point(x: int, y: int, floorNo: str, area_fix_id):
|
||||||
"""
|
"""
|
||||||
从位置信息获取所在固定区域
|
从位置信息获取所在固定区域(可能有一个区域)
|
||||||
返回一个固定区域, 一个临时区域
|
返回一个固定区域, 一个临时区域
|
||||||
"""
|
"""
|
||||||
area_fix = None
|
area_fix = None
|
||||||
|
@ -595,7 +595,9 @@ def get_area_from_point(x: int, y: int, floorNo: str):
|
||||||
for i in area_list:
|
for i in area_list:
|
||||||
if floorNo == i['floor_no']:
|
if floorNo == i['floor_no']:
|
||||||
if i['polygon'].intersects(point): # 如果点在多边形中
|
if i['polygon'].intersects(point): # 如果点在多边形中
|
||||||
if i['type'] == Area.AREA_TYPE_FIX:
|
if i['id'] == area_fix_id:
|
||||||
|
area_fix = i
|
||||||
|
elif i['type'] == Area.AREA_TYPE_FIX:
|
||||||
area_fix = i
|
area_fix = i
|
||||||
elif i['type'] == Area.AREA_TYPE_TEMP:
|
elif i['type'] == Area.AREA_TYPE_TEMP:
|
||||||
area_temp = i
|
area_temp = i
|
||||||
|
|
Loading…
Reference in New Issue