浏览代码

[bug]: 修复更换模型接口后出现的bug

liutao 1 月之前
父节点
当前提交
ff358ddec4
共有 1 个文件被更改,包括 14 次插入39 次删除
  1. 14 39
      aiAgent_gd/qwen_agent/tools/gis/spatial_analysis/geo_analysis.py

+ 14 - 39
aiAgent_gd/qwen_agent/tools/gis/spatial_analysis/geo_analysis.py

@@ -91,35 +91,23 @@ def ghfx(wkt_str: str):
 
 def post_analysis(url: str, wkt_str: str):
     esrijson = pygeoconv.wkt_to_esri_json(wkt_str, 4490)
+    del esrijson['spatialReference']
     esrijson_str = json.dumps(esrijson)
     print(esrijson_str)
-    params = {
+    data = {
         "where": "1=1",
-        "text": "",
-        "objectIds": "",
-        "time": "",
         "geometry": esrijson_str,
         "geometryType": "esriGeometryPolygon",
         "inSR": "4490",
         "spatialRel": "esriSpatialRelIntersects",
-        "relationParam": "",
         "outFields": "*",
         "returnGeometry": "true",
-        "maxAllowableOffset": "",
-        "geometryPrecision": "",
         "outSR": "4490",
-        "returnIdsOnly": "false",
-        "returnCountOnly": "false",
-        "orderByFields": "",
-        "groupByFieldsForStatistics": "",
-        "outStatistics": "",
-        "returnZ": "false",
-        "returnM": "false",
-        "gdbVersion": "",
-        "returnDistinctValues": "false",
         "f": "pjson"
     }
-    response = requests.get(url, params=params)
+    headers = {'Content-Type': 'application/x-www-form-urlencoded'}
+    response = requests.post(url, data=data, headers=headers)
+    print(response.status_code)
     if response.status_code != 200:
         return
     data = json.loads(response.text)
@@ -151,35 +139,23 @@ def intersects_analysis(features, wkt_geometry=None):
 
 def post_analysis_ghfx(url: str, wkt_str: str):
     esrijson = pygeoconv.wkt_to_esri_json(wkt_str, 4490)
+    del esrijson['spatialReference']
     esrijson_str = json.dumps(esrijson)
     print(esrijson_str)
-    params = {
+    data = {
         "where": "1=1",
-        "text": "",
-        "objectIds": "",
-        "time": "",
         "geometry": esrijson_str,
         "geometryType": "esriGeometryPolygon",
         "inSR": "4490",
         "spatialRel": "esriSpatialRelIntersects",
-        "relationParam": "",
         "outFields": "*",
         "returnGeometry": "true",
-        "maxAllowableOffset": "",
-        "geometryPrecision": "",
         "outSR": "4490",
-        "returnIdsOnly": "false",
-        "returnCountOnly": "false",
-        "orderByFields": "",
-        "groupByFieldsForStatistics": "",
-        "outStatistics": "",
-        "returnZ": "false",
-        "returnM": "false",
-        "gdbVersion": "",
-        "returnDistinctValues": "false",
         "f": "pjson"
     }
-    response = requests.get(url, params=params)
+    headers = {'Content-Type': 'application/x-www-form-urlencoded'}
+    response = requests.post(url, data=data, headers=headers)
+    print(response.status_code)
     if response.status_code != 200:
         return
     data = json.loads(response.text)
@@ -217,15 +193,14 @@ def intersects_analysis_ghfx(features, wkt_geometry=None):
 
 
 if __name__ == '__main__':
-    aa = 'POLYGON ((119.75040489300011 29.99197722300005, 119.75034240600007 29.99201998600006, 119.75032272600004 29.991977963000068, 119.7503085620001 29.991947718000063, 119.75028765700006 29.991903077000075, 119.75028764400008 29.991903025000056, 119.75028763600005 29.99190298900004, 119.750344917 29.991891876000068, 119.75034496700005 29.991891965000036, 119.75038859900008 29.991968378000024, 119.75038862600002 29.991968359000055, 119.75051228200005 29.99188183800004, 119.75054646900003 29.991857916000072, 119.75062249100006 29.991804724000076, 119.75062257800005 29.991804805000072, 119.75064561500005 29.991826483000068, 119.75058765900008 29.99186079800006, 119.75047659300003 29.99193154900007, 119.7504209010001 29.991967026000054, 119.75040489300011 29.99197722300005))'
+    # aa = 'POLYGON ((119.75040489300011 29.99197722300005, 119.75034240600007 29.99201998600006, 119.75032272600004 29.991977963000068, 119.7503085620001 29.991947718000063, 119.75028765700006 29.991903077000075, 119.75028764400008 29.991903025000056, 119.75028763600005 29.99190298900004, 119.750344917 29.991891876000068, 119.75034496700005 29.991891965000036, 119.75038859900008 29.991968378000024, 119.75038862600002 29.991968359000055, 119.75051228200005 29.99188183800004, 119.75054646900003 29.991857916000072, 119.75062249100006 29.991804724000076, 119.75062257800005 29.991804805000072, 119.75064561500005 29.991826483000068, 119.75058765900008 29.99186079800006, 119.75047659300003 29.99193154900007, 119.7504209010001 29.991967026000054, 119.75040489300011 29.99197722300005))'
     # # asyncio.run(intersect_kfq(aa))
-    # wkt_str = 'POLYGON ((117.11419709081183 36.182983468640515, 117.11420047198547 36.18294635016128, 117.11421755948791 36.182947168376224, 117.11429144933 36.182950712593104, 117.11428765128782 36.18298780623907, 117.11421406714791 36.182984281554766, 117.11419709081183 36.182983468640515))'
+    wkt_str = 'POLYGON ((117.11419709081183 36.182983468640515, 117.11420047198547 36.18294635016128, 117.11421755948791 36.182947168376224, 117.11429144933 36.182950712593104, 117.11428765128782 36.18298780623907, 117.11421406714791 36.182984281554766, 117.11419709081183 36.182983468640515))'
     # # url = 'http://60.191.110.204:6080/arcgis/rest/services/sd_dxyd/dxyd_xz/MapServer/0/query'
     # # post_analysis(url, wkt_str)
-    # r = sqsx(wkt_str)
+    r = sqsx(wkt_str)
     # print(r)
     # with open(r'D:\Users\Desktop\新建文本文档.txt', 'r', encoding='utf-8') as file:
     #     data = json.load(file)
-    c = ghfx(aa)
     # 打印加载后的数据
-    print(c)
+    print(r)