File size: 2,081 Bytes
17e77ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import requests
import urllib3
import json
from utils import geoutil
import llm_coding


def get_geojson(ent, arr, centroid):
    poly_json = {}
    poly_json['type'] = 'FeatureCollection'
    poly_json['features'] = []
    coordinates= []
    coordinates.append(arr)
    poly_json['features'].append({
    'type':'Feature',
    'id': ent,
    'properties': {
        'centroid': centroid
        },
    'geometry': {
        'type':'Polygon',
        'coordinates': coordinates
        }
    })
    return poly_json


def get_coordinates(ent):
    request_url = 'https://nominatim.openstreetmap.org/search.php?q= ' +ent +'&polygon_geojson=1&accept-language=en&format=jsonv2'
    headers = {
        "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3 Safari/605.1.15"
    }
    page = requests.get(request_url, headers=headers, verify=False)
    json_content = json.loads(page.content)
    all_coordinates = json_content[0]['geojson']['coordinates'][0]
    centroid = (float(json_content[0]['lon']), float(json_content[0]['lat']))
    for p in all_coordinates:
        p2 = (p[0], p[1])
        angle = geoutil.calculate_bearing(centroid, p2)
        p.append(angle)

    geojson = get_geojson(ent, all_coordinates, centroid)

    return geojson['features'][0]['geometry']['coordinates'][0], geojson['features'][0]['properties']['centroid']

predict_path = 'answer/GPT4o.json'
# predict_path = 'dataset/test.json'
target_path = 'dataset/dataset_20.json'
with open(predict_path, 'r') as f:
    predit = json.load(f)

with open(target_path, 'r') as f:
    target = json.load(f)


result = []
for i in range(len(predit)):
    # if llm_coding.execute_steps(i['steps']) ==
    print(predit[i])
    print(i)
    try:
        coord1 = llm_coding.execute_steps(predit[i]['steps'])
        coord2 = llm_coding.execute_steps(target[i]['steps'])

        res = coord1[(max(coord1.keys()))][0] == coord2[(max(coord2.keys()))][0]
    except:
        res = False
    result.append(res)

print(result)
print(result.count(True))