Spaces:
Runtime error
Runtime error
Suchinthana commited on
Commit Β·
85bb77d
1
Parent(s): 6aa54a4
apply only in polygon
Browse files179 unmodified lines18018118218318418518618718812 unmodified lines20120220320420520620720820921021121221321436 unmodified lines251252253254255256257179 unmodified lines# Update the GeoJSON with sorted coordinatesgeojson['features'][0]['geometry']['coordinates'][0] = sorted_coordinates#log geojsonlogger.info(f"Sorted GeoJSON: {geojson}")return geojson# Generate static map image12 unmodified linesfor coord in coords:m.add_marker(CircleMarker((coord[0], coord[1]), '#1C00ff00' if invisible else '#42445A85', 100))elif geom_type in ["Polygon", "MultiPolygon"]:# Sort coordinates for simple polygonsif geom_type == "Polygon":oredered_geojson = sort_coordinates_for_simple_polygon(geojson_data)feature["geometry"]["coordinates"] = oredered_geojson["features"][0]["geometry"]["coordinates"]coords = feature["geometry"]["coordinates"]logger.info(f"coords: {coords}")for polygon in coords:logger.info(f"polygon: {polygon}")m.add_polygon(Polygon([(c[0], c[1]) for c in polygon], '#1C00ff00' if invisible else '#42445A85', 3))return m.render()36 unmodified linesresponse = process_openai_response(query)geojson_data = generate_geojson(response)map_image = generate_static_map(geojson_data)empty_map_image = generate_static_map(geojson_data, invisible=True)difference = np.abs(np.array(map_image.convert("RGB")) - np.array(empty_map_image.convert("RGB")))179 unmodified lines18018118218318418512 unmodified lines19819920020120220320436 unmodified lines241242243244245246247248249250251179 unmodified lines# Update the GeoJSON with sorted coordinatesgeojson['features'][0]['geometry']['coordinates'][0] = sorted_coordinatesreturn geojson# Generate static map image12 unmodified linesfor coord in coords:m.add_marker(CircleMarker((coord[0], coord[1]), '#1C00ff00' if invisible else '#42445A85', 100))elif geom_type in ["Polygon", "MultiPolygon"]:for polygon in coords:m.add_polygon(Polygon([(c[0], c[1]) for c in polygon], '#1C00ff00' if invisible else '#42445A85', 3))return m.render()36 unmodified linesresponse = process_openai_response(query)geojson_data = generate_geojson(response)if geojson_data["features"][0]["geometry"]["type"] == 'Polygon':geojson_data_coords = sort_coordinates_for_simple_polygon(geojson_data)map_image = generate_static_map(geojson_data_coords)else:map_image = generate_static_map(geojson_data)empty_map_image = generate_static_map(geojson_data, invisible=True)difference = np.abs(np.array(map_image.convert("RGB")) - np.array(empty_map_image.convert("RGB")))
app.py+5-11