|
@@ -23,11 +23,12 @@ def convert_to_polygon(points):
|
|
|
|
|
|
def get_town_list2(location_list:list,db):
|
|
|
# resutl = []
|
|
|
+ # print(len(location_list))
|
|
|
if len(location_list) ==0:
|
|
|
return []
|
|
|
query = []
|
|
|
for location in location_list:
|
|
|
- if isinstance(location,dict):
|
|
|
+ if isinstance(location,list):
|
|
|
pass
|
|
|
else:
|
|
|
return []
|
|
@@ -35,7 +36,7 @@ def get_town_list2(location_list:list,db):
|
|
|
query.append(f"ST_Intersects(geometry,ST_PolygonFromText( '{location}', 4326 ))")
|
|
|
query=' or '.join(query)
|
|
|
sql = text(f"""SELECT DISTINCT `name`,properties,pac FROM tp_geojson_data_zj WHERE {query}""")
|
|
|
- # print(sql)
|
|
|
+ # print(sql.text)
|
|
|
resutl=db.execute(sql).all()
|
|
|
return resutl
|
|
|
|
|
@@ -45,7 +46,7 @@ def get_village_list(location_list:list,db,pac=''):
|
|
|
resutl = []
|
|
|
query = []
|
|
|
for location in location_list:
|
|
|
- if isinstance(location,dict):
|
|
|
+ if isinstance(location,list):
|
|
|
pass
|
|
|
else:
|
|
|
return []
|
|
@@ -122,7 +123,7 @@ def get_town_village_list(locations,db):
|
|
|
# 初始化一个空的MultiPolygon来容纳所有多边形
|
|
|
|
|
|
intersected_towns = get_town_list2(locations,db)
|
|
|
-
|
|
|
+ print(intersected_towns)
|
|
|
# 初始化一个空列表来存储结果
|
|
|
intersected_names_and_pacs = []
|
|
|
town_count = len(intersected_towns)
|
|
@@ -272,7 +273,7 @@ def count_emergency_management(location_list: list, db):
|
|
|
def get_hospital_list(location_list:list,db):
|
|
|
resutl = []
|
|
|
for location in location_list:
|
|
|
- if isinstance(location,dict):
|
|
|
+ if isinstance(location,list):
|
|
|
pass
|
|
|
else:
|
|
|
return []
|
|
@@ -286,7 +287,7 @@ def get_emergency_shelter_list(location_list:list,db):
|
|
|
|
|
|
resutl = []
|
|
|
for location in location_list:
|
|
|
- if isinstance(location,dict):
|
|
|
+ if isinstance(location,list):
|
|
|
pass
|
|
|
else:
|
|
|
return []
|
|
@@ -302,7 +303,7 @@ def get_waterlogged_roads_list(location_list:list,db):
|
|
|
|
|
|
resutl = []
|
|
|
for location in location_list:
|
|
|
- if isinstance(location,dict):
|
|
|
+ if isinstance(location,list):
|
|
|
pass
|
|
|
else:
|
|
|
return []
|
|
@@ -314,16 +315,30 @@ def get_waterlogged_roads_list(location_list:list,db):
|
|
|
return resutl
|
|
|
|
|
|
def get_point_list(location_list:list,db):
|
|
|
-
|
|
|
- resutl = []
|
|
|
+ if len(location_list) == 0:
|
|
|
+ return []
|
|
|
+ query = []
|
|
|
for location in location_list:
|
|
|
- if isinstance(location,dict):
|
|
|
+ if isinstance(location, list):
|
|
|
pass
|
|
|
else:
|
|
|
return []
|
|
|
- location = convert_to_polygon(location)
|
|
|
-
|
|
|
- sql = text(f"""SELECT `id` ,`name`, longitude, latitude, `dataType` FROM point_data WHERE ST_Contains(ST_PolygonFromText( '{location}', 4326 ),ST_PointFromText(CONCAT('POINT(', latitude, ' ', longitude, ')'), 4326))""")
|
|
|
-
|
|
|
- resutl+=db.execute(sql).all()
|
|
|
- return resutl
|
|
|
+ location = convert_to_polygon(location) # ,geometry
|
|
|
+ query.append(f"ST_Contains(ST_PolygonFromText( '{location}', 4326 ),ST_PointFromText(CONCAT('POINT(', latitude, ' ', longitude, ')'), 4326))")
|
|
|
+ query = ' or '.join(query)
|
|
|
+ sql = text(f"""SELECT `id` ,`name`, longitude, latitude, `dataType` FROM point_data WHERE {query}""")
|
|
|
+ # print(sql.text)
|
|
|
+ resutl = db.execute(sql).all()
|
|
|
+ return resutl
|
|
|
+ # resutl = []
|
|
|
+ # for location in location_list:
|
|
|
+ # if isinstance(location,list):
|
|
|
+ # pass
|
|
|
+ # else:
|
|
|
+ # return []
|
|
|
+ # location = convert_to_polygon(location)
|
|
|
+ #
|
|
|
+ # sql = text(f"""SELECT `id` ,`name`, longitude, latitude, `dataType` FROM point_data WHERE ST_Contains(ST_PolygonFromText( '{location}', 4326 ),ST_PointFromText(CONCAT('POINT(', latitude, ' ', longitude, ')'), 4326))""")
|
|
|
+ #
|
|
|
+ # resutl+=db.execute(sql).all()
|
|
|
+ # return resutl
|