Skip to content

Commit 1816612

Browse files
committed
main
1 parent fb9468b commit 1816612

17 files changed

Lines changed: 217 additions & 27 deletions

app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def generate_topographic_plan():
9595
#
9696
# # Create matplotlib contours (using memory buffer to avoid display)
9797
# contours = plt.tricontour(triangulation, z, levels=levels)
98-
#
98+
9999
# # Define major contour interval (every 5th contour)
100100
# major_interval = max(1, len(levels) // 5)
101101
#
-243 KB
Binary file not shown.

dxf.py

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
import uuid
1111
import zipfile
1212
from upload import upload_file
13-
from ezdxf import bbox
13+
from ezdxf import bbox, colors
14+
1415

1516

1617
class SurveyDXFManager:
@@ -49,9 +50,9 @@ def _setup_layers(self):
4950
for name, color in layers:
5051
self.doc.layers.add(name=name, color=color)
5152

52-
# self.doc.layers.new('CONTOURS_MAJOR', dxfattribs={'color': colors.RED, 'lineweight': 50})
53-
# self.doc.layers.new('CONTOURS_MINOR', dxfattribs={'color': colors.BLUE, 'lineweight': 25})
54-
# self.doc.layers.new('CONTOUR_LABELS', dxfattribs={'color': colors.BLACK})
53+
self.doc.layers.new('CONTOURS_MAJOR', dxfattribs={'color': colors.RED})
54+
self.doc.layers.new('CONTOURS_MINOR', dxfattribs={'true_color': ezdxf.colors.rgb2int((127, 31, 0))})
55+
self.doc.layers.new('CONTOUR_LABELS', dxfattribs={'color': colors.BLACK})
5556
# self.doc.layers.new("TIN_TRIANGLES", dxfattribs={'color': colors.CYAN, 'lineweight': 10})
5657

5758
def setup_beacon_style(self, type_: str = "box", size: float = 1.0):
@@ -394,7 +395,7 @@ def draw_topo_point(self, x: float, y: float, z: float = 0, label: str = None, t
394395
dxfattribs={
395396
'layer': 'SPOT_HEIGHTS',
396397
'height': text_height,
397-
'style': 'SURVEY_TEXT',
398+
'style': 'Standard',
398399
'color': 7 # Black/White
399400
}
400401
).set_placement(
@@ -458,27 +459,27 @@ def save_dwg(self, dxf_filepath: str, filepath: str = None):
458459
odafc.convert(dxf_filepath, filepath)
459460

460461
def save(self, paper_size: str = "A4", orientation: str = "portrait"):
461-
# with tempfile.TemporaryDirectory() as tmpdir:
462-
filename = self.get_filename()
463-
dxf_path = os.path.join("", f"{filename}.dxf")
464-
# dwg_path = os.path.join(tmpdir, f"{filename}.dwg")
465-
pdf_path = os.path.join("", f"{filename}.pdf")
466-
zip_path = os.path.join("", f"{filename}.zip")
467-
468-
self.save_dxf(dxf_path)
469-
# self.save_dwg(dxf_path, dwg_path)
470-
self.save_pdf(pdf_path, paper_size=paper_size, orientation=orientation)
471-
472-
# Create a ZIP file containing all three formats
473-
with zipfile.ZipFile(zip_path, "w") as zipf:
474-
zipf.write(dxf_path, os.path.basename(dxf_path))
475-
# zipf.write(dwg_path, os.path.basename(dwg_path))
476-
zipf.write(pdf_path, os.path.basename(pdf_path))
477-
478-
url = upload_file(zip_path, folder="survey_plans", file_name=filename)
479-
if url is None:
480-
raise Exception("Upload failed")
481-
return url
462+
with tempfile.TemporaryDirectory() as tmpdir:
463+
filename = self.get_filename()
464+
dxf_path = os.path.join("", f"{filename}.dxf")
465+
dwg_path = os.path.join(tmpdir, f"{filename}.dwg")
466+
pdf_path = os.path.join("", f"{filename}.pdf")
467+
zip_path = os.path.join("", f"{filename}.zip")
468+
469+
self.save_dxf(dxf_path)
470+
self.save_dwg(dxf_path, dwg_path)
471+
self.save_pdf(pdf_path, paper_size=paper_size, orientation=orientation)
472+
473+
# Create a ZIP file containing all three formats
474+
with zipfile.ZipFile(zip_path, "w") as zipf:
475+
zipf.write(dxf_path, os.path.basename(dxf_path))
476+
zipf.write(dwg_path, os.path.basename(dwg_path))
477+
zipf.write(pdf_path, os.path.basename(pdf_path))
478+
479+
url = upload_file(zip_path, folder="survey_plans", file_name=filename)
480+
if url is None:
481+
raise Exception("Upload failed")
482+
return url
482483

483484
# def add_topo_point(self, x: float, y: float, z: float, label: str = None, text_height: float = 1.0):
484485
# self.msp.add_blockref(

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ PyMuPDF==1.26.4
2626
pyparsing==3.2.4
2727
python-dateutil==2.9.0.post0
2828
python-dotenv==1.1.1
29+
scipy==1.16.2
2930
six==1.17.0
3031
soupsieve==2.8
3132
typing-inspection==0.4.1
-752 KB
Binary file not shown.
-752 KB
Binary file not shown.
-528 KB
Binary file not shown.
-552 KB
Binary file not shown.
-773 KB
Binary file not shown.
-770 KB
Binary file not shown.

0 commit comments

Comments
 (0)