diff --git a/server/calc_model/stub/stub.json b/server/calc_model/stub/stub.json new file mode 100644 index 0000000000000000000000000000000000000000..56a1f84742d1fbc57d27ef81a7d546e390852e3a --- /dev/null +++ b/server/calc_model/stub/stub.json @@ -0,0 +1,20 @@ +[ + { + "longitude": 1.0, + "latitude": 2.0, + "precipitation": 10.5, + "thickness": 3.0, + "max_weight": 50.0, + "safety_level": 2.5, + "accuracy": 8 + }, + { + "longitude": -3.5, + "latitude": 4.5, + "precipitation": 5.0, + "thickness": 2.8, + "max_weight": 45.0, + "safety_level": 3.2, + "accuracy": 9 + } +] \ No newline at end of file diff --git a/server/calc_model/stub/stub.py b/server/calc_model/stub/stub.py new file mode 100644 index 0000000000000000000000000000000000000000..c5173747b27b5d4006674d365071cd99fda930d4 --- /dev/null +++ b/server/calc_model/stub/stub.py @@ -0,0 +1,8 @@ +import sys +sys.path.append('../..') # Add root directory to the system path +from server import DataPoint + +# Test instances +test_data1 = DataPoint(longitude=1.0, latitude=2.0, precipitation=10.5, thickness=3.0, max_weight=50.0, safety_level=2.5, accuracy=8) +test_data2 = DataPoint(longitude=-3.5, latitude=4.5, precipitation=5.0, thickness=2.8, max_weight=45.0, safety_level=3.2, accuracy=9) +test_data3 = DataPoint(longitude=0.0, latitude=0.0, precipitation=None, thickness=0.0, max_weight=0.0, safety_level=3.0, accuracy=9) diff --git a/server/calc_model/update_map.py b/server/calc_model/update_map.py new file mode 100644 index 0000000000000000000000000000000000000000..05e673232148b649386673b1e5bdae880dffd3bf --- /dev/null +++ b/server/calc_model/update_map.py @@ -0,0 +1,19 @@ +import json +from flask import Flask, jsonify +import sys +sys.path.append('..') # Add root directory to the system path +from server import DataPoint + +def process_data_point(data_point): + try: + # Convert DataPoint instance to JSON string + json_data = json.dumps(data_point.__dict__) + + # Write JSON object to response object + response = jsonify(json_data) + + return response, 200 + except Exception as e: + print(f"Error in converting point data to JSON: {e}") + + return jsonify({"error": "Internal Server Error"}), 500 \ No newline at end of file diff --git a/server/test_data.json b/server/test_data.json deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000