@@ -37,159 +37,6 @@ def generate_topographic_plan():
3737 url = plan .save ()
3838 return jsonify ({"message" : "Topographic plan generated" , "filename" : plan .name , "url" : url }), 200
3939
40- # @app.route("/route/plan", methods=["POST"])
41- # def generate_route_plan():
42- # data = request.get_json()
43- # plan = PlanProps(**data)
44- # return jsonify({"message": "Cadastral plan generated", "filename": plan.name, "url": "url"}), 200
45-
46- # def read_json_file(file_path: str):
47- # """
48- # Reads data from a JSON file.
49- #
50- # Args:
51- # file_path (str): Path to the JSON file.
52- #
53- # Returns:
54- # dict | list: Parsed JSON data.
55- # """
56- # try:
57- # with open(file_path, "r", encoding="utf-8") as f:
58- # data = json.load(f)
59- # return data
60- # except FileNotFoundError:
61- # print(f"Error: File '{file_path}' not found.")
62- # return None
63- # except json.JSONDecodeError as e:
64- # print(f"Error: Failed to decode JSON - {e}")
65- # return None
66-
67- # @app.route("/topographic/plan", methods=["POST"])
68- # def generate_topographic_plan():
69- # data = request.get_json()
70- #
71- # plan = PlanProps(**data)
72- #
73- # drawer = SurveyDXFManager(plan_name=plan.name, scale=plan.get_drawing_scale())
74- # drawer.setup_font(plan.font)
75- # drawer.setup_topo_point_style()
76- #
77- # data = read_json_file("point2.json")
78- # plan.coordinates = [CoordinateProps(**c) for c in data]
79- #
80- # # draw spot heights
81- # # for coord in plan.coordinates:
82- # # drawer.add_topo_point(coord.easting, coord.northing, coord.elevation, f"{coord.elevation:.3f}", plan.top_setting.point_label_scale)
83- #
84- # # Generate a surface (TIN interpolation).
85- # x = np.array([coord.easting for coord in plan.coordinates])
86- # y = np.array([coord.northing for coord in plan.coordinates])
87- # z = np.array([coord.elevation for coord in plan.coordinates])
88- #
89- # # Create triangulation
90- # triangulation = Triangulation(x, y)
91- #
92- # # Generate contour levels
93- # z_min, z_max = z.min(), z.max()
94- # levels = np.linspace(z_min, z_max, 100)
95- #
96- # # Create matplotlib contours (using memory buffer to avoid display)
97- # contours = plt.tricontour(triangulation, z, levels=levels)
98-
99- # # Define major contour interval (every 5th contour)
100- # major_interval = max(1, len(levels) // 5)
101- #
102- # # Extract and draw contour lines
103- # contour_data = []
104- #
105- # # Access contour segments using allsegs attribute (more reliable)
106- # if hasattr(contours, 'allsegs') and len(contours.allsegs) > 0:
107- # for level_idx, level_segments in enumerate(contours.allsegs):
108- # elevation = levels[level_idx]
109- # is_major = (level_idx % major_interval == 0)
110- # layer_name = 'CONTOURS_MAJOR' if is_major else 'CONTOURS_MINOR'
111- #
112- # # Process each contour segment at this elevation
113- # for segment in level_segments:
114- # if len(segment) < 2:
115- # continue
116- #
117- # # Convert to list of tuples for ezdxf
118- # points = [(float(x), float(y), float(elevation)) for x, y in segment]
119- #
120- # # Add polyline to DXF
121- # polyline = drawer.msp.add_polyline3d(
122- # points,
123- # dxfattribs={'layer': layer_name}
124- # )
125- #
126- # # Store contour data
127- # contour_data.append({
128- # 'elevation': elevation,
129- # 'coordinates': segment,
130- # 'is_major': is_major,
131- # 'polyline': polyline
132- # })
133- #
134- # # Add elevation labels for major contours
135- # if is_major and len(points) > 0:
136- # # Place label at midpoint of contour
137- # mid_idx = len(points) // 2
138- # label_x, label_y, _ = points[mid_idx]
139- #
140- # drawer.msp.add_text(
141- # f"{elevation:.1f}",
142- # dxfattribs={
143- # 'layer': 'CONTOUR_LABELS',
144- # 'height': 2.5,
145- # 'style': 'Standard'
146- # }
147- # ).set_placement((label_x, label_y), align=TextEntityAlignment.MIDDLE_CENTER)
148- # else:
149- # print("Warning: No contour segments found. Check your input data.")
150- #
151- # # # Create triangulation
152- # # triangulation = Triangulation(x, y)
153- # #
154- # # # Draw triangle edges
155- # # for triangle in triangulation.triangles:
156- # # # Get the three vertices of each triangle
157- # # p1 = (x[triangle[0]], y[triangle[0]])
158- # # p2 = (x[triangle[1]], y[triangle[1]])
159- # # p3 = (x[triangle[2]], y[triangle[2]])
160- # #
161- # # # Create closed polyline for triangle
162- # # triangle_points = [p1, p2, p3, p1] # Close the triangle
163- # #
164- # # drawer.msp.add_lwpolyline(
165- # # triangle_points,
166- # # dxfattribs={'layer': "TIN_TRIANGLES"}
167- # # )
168- #
169- # # # Find range
170- # # z_min, z_max = z.min(), z.max()
171- # #
172- # # # Choose interval (e.g., 1 meter)
173- # # interval = 0.1
174- # #
175- # # # Define levels
176- # # levels = np.arange(np.floor(z_min), np.ceil(z_max) + interval, interval)
177- # #
178- # # contours = plt.tricontour(triang, z, levels=levels)
179- # #
180- # # # ✅ Each contour level has multiple paths
181- # # for level, path_collection in zip(contours.levels, contours.get_paths()):
182- # # for polygon in path_collection.to_polygons():
183- # # points = [(pt[0], pt[1], float(level)) for pt in polygon]
184- # # if len(points) > 1:
185- # # # Create 3D polyline
186- # # drawer.msp.add_polyline3d(points, dxfattribs={"layer": "CONTOURS"})
187- #
188- # drawer.save_dxf()
189- # # url = drawer.save()
190- # return jsonify({"message": "Topographic plan generated", "filename": plan.name, "url": "url"}), 200
191-
192-
19340
19441@app .errorhandler (404 )
19542def not_found (e ):
0 commit comments