Bora9 commited on
Commit
6de23d6
·
verified ·
1 Parent(s): a1ff651

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +164 -114
app.py CHANGED
@@ -5,8 +5,11 @@ import plotly.graph_objects as go
5
  import plotly.express as px
6
  import folium
7
  from folium.plugins import MarkerCluster
 
 
 
8
 
9
- # Streamlit-Folium kütüphanesini güvenli içe aktarma
10
  try:
11
  from streamlit_folium import st_folium
12
  HAS_FOLIUM_EXT = True
@@ -15,25 +18,23 @@ except ImportError:
15
  HAS_FOLIUM_EXT = False
16
 
17
  # -----------------------------------------------------------------------------
18
- # 1. SAYFA YAPILANDIRMASI & TEMA
19
  # -----------------------------------------------------------------------------
20
  st.set_page_config(
21
- page_title="BoraPalyAI | GeoTech & TIJBA Platformu",
22
  page_icon="🌍",
23
  layout="wide",
24
  initial_sidebar_state="expanded"
25
  )
26
 
27
- # CSS Stil Tanımlamaları (unsafe_allow_html=True ile)
 
 
 
 
 
28
  st.markdown("""
29
  <style>
30
- .metric-card {
31
- background-color: #1E222D;
32
- border-radius: 10px;
33
- padding: 15px;
34
- border-left: 5px solid #00D1B2;
35
- margin-bottom: 10px;
36
- }
37
  .tijba-card {
38
  background-color: #181B22;
39
  border: 1px solid #2D313E;
@@ -52,63 +53,102 @@ st.markdown("""
52
  """, unsafe_allow_html=True)
53
 
54
  # -----------------------------------------------------------------------------
55
- # 2. SİDEBAR & PARSEL SORGULAMA PANELİ
56
  # -----------------------------------------------------------------------------
57
  st.sidebar.title("🌍 BoraPalyAI Geo-Portal")
58
- st.sidebar.markdown("**Mekânsal & Geoteknik Parsel Analizi**")
59
 
60
- st.sidebar.subheader("📍 Parsel Seçimi")
61
- il = st.sidebar.selectbox("İl", ["İzmir", "İstanbul", "Ankara", "Antalya", "Muğla"])
62
- ilce = st.sidebar.text_input("İlçe", "Urla")
63
- ada = st.sidebar.number_input("Ada", value=102, step=1)
64
- parsel = st.sidebar.number_input("Parsel", value=14, step=1)
65
 
66
- # Varsayılan Merkez Koordinatı (Örnek: İzmir Urla)
67
- lat, lon = 38.3225, 26.7682
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
 
69
  st.sidebar.divider()
70
- st.sidebar.subheader("🎛️ Katman & 3D Kontrolleri")
71
- show_wells = st.sidebar.checkbox("Yeraltı Su Kuyuları (DSİ)", value=True)
72
- show_geology = st.sidebar.checkbox("MTA Formasyon / Jeoloji Katmanı", value=True)
73
  z_exaggeration = st.sidebar.slider("3D Yükseklik Abartısı (Z-Factor)", 1.0, 5.0, 2.5, 0.5)
74
 
 
 
 
 
 
 
 
75
  # -----------------------------------------------------------------------------
76
- # 3. ANA BAŞLIK VE ÖZET METRİKLER (KPIs)
77
  # -----------------------------------------------------------------------------
78
- st.title(f"📍 Parsel Analiz Raporu: {il} / {ilce} - Ada {ada} / Parsel {parsel}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
 
80
  col1, col2, col3, col4, col5 = st.columns(5)
81
- col1.metric("📐 Parsel Alanı", "4,850 m²", "+12 m² (Hassas)")
82
- col2.metric("⛰️ Ortalama Rakım", "142 m", "Kot Farkı: 8.4m")
83
- col3.metric("📐 Ort. Eğim", "% 11.2", "Orta Eğimli")
84
- col4.metric("💧 Tahmini Su Kotu", "18 - 24 m", "Statik Seviye")
85
- col5.metric("🧱 Ana Kaya Yapısı", "Kireçtaşı", "MTA: Alüvyon/Kalker")
86
 
87
  st.divider()
88
 
89
  # -----------------------------------------------------------------------------
90
- # 4. TAB YAPISI (2D Harita, 3D DEM, Jeoloji Kesiti, TIJBA Sosyal Ağ)
91
  # -----------------------------------------------------------------------------
92
  tab1, tab2, tab3, tab4 = st.tabs([
93
- "🗺️ 2D Harita & Katmanlar",
94
- "🏔️ 3D Arazi (DEM) & Topoğrafya",
95
  "🧱 Jeolojik Kolon Kesiti",
96
  "🌐 TIJBA Jeoloji Sosyal Ağı"
97
  ])
98
 
99
- # --- TAB 1: 2D FOLIUM HARİTASI ---
100
  with tab1:
101
- st.subheader("Interactive CBS Katmanları & Parsel Sınırları")
102
-
 
103
  m = folium.Map(location=[lat, lon], zoom_start=16, tiles="OpenStreetMap")
104
 
105
- # Parsel Poligonu (Simülasyon)
 
106
  parsel_coords = [
107
- [lat + 0.0010, lon - 0.0010],
108
- [lat + 0.0012, lon + 0.0008],
109
- [lat - 0.0008, lon + 0.0011],
110
- [lat - 0.0011, lon - 0.0007]
111
  ]
 
112
  folium.Polygon(
113
  locations=parsel_coords,
114
  color="red",
@@ -116,63 +156,76 @@ with tab1:
116
  fill=True,
117
  fill_color="crimson",
118
  fill_opacity=0.35,
119
- tooltip="Parsel Sınırı (4,850 m²)"
120
  ).add_to(m)
121
 
122
- # Su Kuyuları Katmanı
 
 
 
 
 
 
 
123
  if show_wells:
124
  well_cluster = MarkerCluster(name="Su Kuyuları").add_to(m)
125
- wells = [
126
- [lat + 0.0015, lon - 0.0005, "Kuyu #1 (Derinlik: 45m, Debi: 2.5 L/s)"],
127
- [lat - 0.0012, lon + 0.0015, "Kuyu #2 (Derinlik: 60m, Debi: 4.0 L/s)"],
128
- [lat + 0.0005, lon + 0.0020, "Kuyu #3 (Ruhsatlı DSİ Kuyusu)"]
129
- ]
130
- for w_lat, w_lon, info in wells:
131
  folium.Marker(
132
  location=[w_lat, w_lon],
133
- popup=info,
134
  icon=folium.Icon(color="blue", icon="tint", prefix="fa")
135
  ).add_to(well_cluster)
136
 
137
- # MTA Jeoloji Katmanı (Simülasyon Alanı)
138
  if show_geology:
139
  folium.Rectangle(
140
  bounds=[[lat - 0.003, lon - 0.003], [lat + 0.003, lon + 0.003]],
141
- color="orange",
142
- weight=1,
143
- fill=True,
144
- fill_color="khaki",
145
- fill_opacity=0.2,
146
- tooltip="MTA Formasyon: Neojen Kireçtaşı - Alüvyon Geçişi"
147
  ).add_to(m)
148
 
149
- # Harita Gösterimi
150
  if HAS_FOLIUM_EXT:
151
- st_folium(m, width="100%", height=550)
 
 
 
 
 
 
 
 
 
 
 
 
152
  else:
153
  components.html(m._repr_html_(), height=550)
154
 
155
  # --- TAB 2: 3D ARAZİ MODELİ (DEM EXAGGERATED) ---
156
  with tab2:
157
- st.subheader("3D Abartılı Arazi Yüzeyi & Yükseklik Profili")
158
 
159
  col_dem1, col_dem2 = st.columns([3, 1])
160
 
161
  with col_dem1:
162
- # Sentetik DEM Verisi Üretimi
163
- grid_size = 30
164
  x = np.linspace(-2, 2, grid_size)
165
  y = np.linspace(-2, 2, grid_size)
166
  X, Y = np.meshgrid(x, y)
167
- Z = (100 + 15 * np.sin(X) + 20 * np.cos(Y) + (X**2 + Y**2) * 2) * z_exaggeration
 
 
168
 
169
  fig_3d = go.Figure(data=[go.Surface(z=Z, colorscale='Earth', showscale=True)])
170
  fig_3d.update_layout(
171
- title=f"3D Yükseklik Modeli (Z-Abartı Faktörü: {z_exaggeration}x)",
172
  autosize=True,
173
  scene=dict(
174
- xaxis_title='Doğu-Batı (m)',
175
- yaxis_title='Kuzey-Güney (m)',
176
  zaxis_title='Rakım (m)',
177
  aspectratio=dict(x=1, y=1, z=0.5)
178
  ),
@@ -182,25 +235,26 @@ with tab2:
182
  st.plotly_chart(fig_3d, use_container_width=True)
183
 
184
  with col_dem2:
185
- st.markdown("### 🏔️ Topoğrafik Analiz")
186
- st.info("**En Yüksek Kot:** 150.4 m\n\n**En Düşük Kot:** 142.0 m\n\n**Maksimum Eğim:** %18.4 (Güney-Doğu Yönü)")
187
- st.warning("⚠️ **Hafriyat Uyarısı:** Parsel güney cephesinde >%15 eğim bulunmaktadır. İstinat duvarı gerekebilir.")
 
 
188
 
189
- # --- TAB 3: JEOLOJİK KOLON KESİTİ TAHMİNİ ---
 
 
190
  with tab3:
191
- st.subheader("Tahmini Stratigrafik Kolon Kesiti & Litoloji")
192
- st.caption("Çevre sondaj verileri ve MTA jeoloji haritalarından uzamsal interpolasyon (Kriging) ile üretilmiştir.")
193
 
194
  col_geo1, col_geo2 = st.columns([2, 1])
195
 
196
  with col_geo1:
197
- # Stratigrafik Katman Tablosu Görselleştirme
198
  layers_df = pd.DataFrame({
199
- "Katman": ["Bitkisel Toprak (B.T.)", "Killi-Tınlı Alüvyon", "Ayrışmış Kireçtaşı (Marn)", "Masif Kireçtaşı (Ana Kaya)"],
200
- "Kalıntı Derinlik (m)": [1.5, 6.5, 12.0, 30.0],
201
- "Kalınlık (m)": [1.5, 5.0, 5.5, 18.0],
202
- "SPT (N60)": ["5 - 8", "12 - 20", "30 - 50", ">50 (Refü)"],
203
- "Renk": ["#8B5A2B", "#CD853F", "#D2B48C", "#808080"]
204
  })
205
 
206
  fig_strat = px.bar(
@@ -211,55 +265,52 @@ with tab3:
211
  color="Katman",
212
  text="SPT (N60)",
213
  color_discrete_sequence=layers_df["Renk"].tolist(),
214
- title="Derinliğe Göre Tabaka Dağılımı ve Zemin Direnci (SPT)"
215
  )
216
  fig_strat.update_layout(height=400, showlegend=False)
217
  st.plotly_chart(fig_strat, use_container_width=True)
218
 
219
  with col_geo2:
220
- st.markdown("### 💧 Yeraltı Suyu Özeti")
221
- st.markdown("""
222
- * **Statik Su Seviyesi:** 19.5 metre
223
- * **Dinamik Su Seviyesi:** 24.0 metre
224
- * **Beklenen Akifer Tipi:** Karstik Kireçtaşı Çatlak Suyu
225
- * **Tavsiye Edilen Sondaj Derinliği:** 60 - 70 metre
226
  """)
227
 
228
- # --- TAB 4: TIJBA JEOLOJİ SOSYAL AĞI INTEGRASYONU ---
229
  with tab4:
230
- st.subheader("🌐 TIJBA - Jeoloji Sosyal Medyası & Saha Akışı")
231
- st.caption("Bu parsel ve çevresi hakkında jeoloji mühendislerinin ve arsa sahiplerinin paylaşımları.")
232
 
233
  col_tij1, col_tij2 = st.columns([2, 1])
234
 
235
  with col_tij1:
236
- # Sosyal Gönderi Oluşturma Formu
237
- with st.expander("➕ TIJBA'ya Saha Raporu veya Görsel Ekle"):
238
- post_text = st.text_area("Saha gözleminiz veya sondaj notunuz:", placeholder="Örn: 15. metrede yeraltı suyuna rastlandı...")
239
- uploaded_file = st.file_uploader("Sondaj Logu / PDF / Fotoğraf Yükle", type=["png", "jpg", "pdf"])
240
- if st.button("TIJBA Ağında Paylaş"):
241
- st.success("✅ Gözleminiz coğrafi etiketle (Geo-Tag) veritabanına işlendi ve akışa eklendi!")
242
 
243
  st.divider()
244
- st.markdown("### 📰 Bölgesel Saha Akışı")
245
 
246
- # Simüle Gönderiler
247
  posts = [
248
  {
249
- "user": "Jeo. Müh. Ahmet Yılmaz",
250
  "role": "Saha Mühendisi",
251
- "time": "2 saat önce",
252
- "dist": "120m mesafede",
253
- "content": "Parselin 100m batısındaki şantiyemizde yapılan 25m'lik sondajda 14. metrede karstik boşluğa rastlandı. Temel tasarımında radye önerilir.",
254
- "likes": 14
255
  },
256
  {
257
- "user": "Dr. Canan Kaya",
258
- "role": "Hidrojeolog",
259
  "time": "1 gün önce",
260
- "dist": "450m mesafede",
261
- "content": "Urla bölgesindeki Neojen kireçtaşlarında yeraltı su seviyesi mevsimsel olarak 3-4 metre dalgalanma gösteriyor. Kuyu açacakların bilgisine.",
262
- "likes": 29
263
  }
264
  ]
265
 
@@ -269,21 +320,20 @@ with tab4:
269
  <span class="badge-geo">{p['role']}</span> <b>{p['user']}</b>
270
  <span style="color:gray; font-size:0.8em;">• {p['time']} ({p['dist']})</span>
271
  <p style="margin-top:8px;">{p['content']}</p>
272
- <small>❤️ {p['likes']} Mühendis Katıldı</small>
273
  </div>
274
  """, unsafe_allow_html=True)
275
 
276
  with col_tij2:
277
- st.markdown("### 🏆 Katkıda Bulunanlar")
278
  st.markdown("""
279
- 1. 🥇 **Jeo. Müh. Ahmet Y.** (42 Rapor)
280
- 2. 🥈 **Dr. Canan K.** (28 Rapor)
281
- 3. 🥉 **Sondaj A.Ş.** (19 Log)
282
  """)
283
- st.info("💡 TIJBA sosyal ağında paylaşılan her doğruluk onaylı zemin etüdü, yapay zeka modelimizin 3D kesit tahmin başarısını artırır.")
284
 
285
  # -----------------------------------------------------------------------------
286
- # ALT BİLGİ (FOOTER)
287
  # -----------------------------------------------------------------------------
288
  st.divider()
289
- st.caption("© 2026 BoraPalyAI & TIJBA GeoTech Platformu | CBS Veri Standartları ile Uyumludur.")
 
5
  import plotly.express as px
6
  import folium
7
  from folium.plugins import MarkerCluster
8
+ import json
9
+ import urllib.request
10
+ import urllib.parse
11
 
12
+ # Streamlit-Folium kütüphanesini kontrol etme
13
  try:
14
  from streamlit_folium import st_folium
15
  HAS_FOLIUM_EXT = True
 
18
  HAS_FOLIUM_EXT = False
19
 
20
  # -----------------------------------------------------------------------------
21
+ # 1. SAYFA YAPILANDIRMASI & SESSION STATE (KONUM HAFIZASI)
22
  # -----------------------------------------------------------------------------
23
  st.set_page_config(
24
+ page_title="BoraPalyAI | Tüm Türkiye Geo-Portal",
25
  page_icon="🌍",
26
  layout="wide",
27
  initial_sidebar_state="expanded"
28
  )
29
 
30
+ # Varsayılan Konum (Session State)
31
+ if "lat" not in st.session_state:
32
+ st.session_state["lat"] = 38.3225
33
+ st.session_state["lon"] = 26.7682
34
+ st.session_state["location_name"] = "İzmir, Urla"
35
+
36
  st.markdown("""
37
  <style>
 
 
 
 
 
 
 
38
  .tijba-card {
39
  background-color: #181B22;
40
  border: 1px solid #2D313E;
 
53
  """, unsafe_allow_html=True)
54
 
55
  # -----------------------------------------------------------------------------
56
+ # 2. SİDEBAR & TÜRKİYE GENELİ LOKASYON ARAMA
57
  # -----------------------------------------------------------------------------
58
  st.sidebar.title("🌍 BoraPalyAI Geo-Portal")
59
+ st.sidebar.markdown("**Tüm Türkiye İnteraktif Parsel & Jeoloji Analizi**")
60
 
61
+ st.sidebar.divider()
62
+ st.sidebar.subheader("🔍 Türkiye Geneli Konum Ara")
63
+ search_query = st.sidebar.text_input("İl, İlçe, Mahalle veya Adres:", placeholder="Örn: Bodrum, Çankaya Ankara, Kadıköy")
 
 
64
 
65
+ if st.sidebar.button("🔎 Haritada Bul"):
66
+ if search_query:
67
+ try:
68
+ # OpenStreetMap Nominatim Servisi ile Ücretsiz Geocoding
69
+ encoded_query = urllib.parse.quote(f"{search_query}, Turkey")
70
+ url = f"https://nominatim.openstreetmap.org/search?format=json&q={encoded_query}"
71
+ req = urllib.request.Request(url, headers={'User-Agent': 'BoraPalyAI-App'})
72
+
73
+ with urllib.request.urlopen(req) as response:
74
+ data = json.loads(response.read().decode())
75
+ if data:
76
+ st.session_state["lat"] = float(data[0]["lat"])
77
+ st.session_state["lon"] = float(data[0]["lon"])
78
+ st.session_state["location_name"] = data[0]["display_name"].split(',')[0]
79
+ st.rerun()
80
+ else:
81
+ st.sidebar.error("Lokasyon bulunamadı! Lütfen arama metnini kontrol edin.")
82
+ except Exception as e:
83
+ st.sidebar.error(f"Arama gerçekleştirilemedi: {e}")
84
 
85
  st.sidebar.divider()
86
+ st.sidebar.subheader("📍 Manuel Koordinat / Parsel Bilgisi")
87
+ ada = st.sidebar.number_input("Ada No", value=102, step=1)
88
+ parsel = st.sidebar.number_input("Parsel No", value=14, step=1)
89
  z_exaggeration = st.sidebar.slider("3D Yükseklik Abartısı (Z-Factor)", 1.0, 5.0, 2.5, 0.5)
90
 
91
+ show_wells = st.sidebar.checkbox("Yeraltı Su Kuyuları Katmanı", value=True)
92
+ show_geology = st.sidebar.checkbox("MTA Jeoloji Katmanı", value=True)
93
+
94
+ # Aktif Koordinatlar
95
+ lat = st.session_state["lat"]
96
+ lon = st.session_state["lon"]
97
+
98
  # -----------------------------------------------------------------------------
99
+ # 3. DİNAMİK METRİKLER (KOORDİNATA GÖRE RASTGELE/DİNAMİK HESAPLAMA)
100
  # -----------------------------------------------------------------------------
101
+ # Seçilen koordinata özel deterministik rastgele sayı tohumu (seed)
102
+ seed = int((abs(lat) + abs(lon)) * 1000) % 100000
103
+ np.random.seed(seed)
104
+
105
+ area_m2 = int(np.random.uniform(1500, 12000))
106
+ avg_elevation = int(np.random.uniform(10, 850))
107
+ slope_pct = round(np.random.uniform(2.0, 22.0), 1)
108
+ water_table_min = int(np.random.uniform(8, 35))
109
+ water_table_max = water_table_min + int(np.random.uniform(5, 15))
110
+
111
+ rock_types = ["Kireçtaşı (Kalker)", "Alüvyon / Kil", "Andezit / Bazalt", "Marn / Kumtaşı", "Şist / Metamorfik"]
112
+ selected_rock = rock_types[seed % len(rock_types)]
113
+
114
+ st.title(f"📍 Parsel Analiz Raporu: {st.session_state['location_name']}")
115
+ st.caption(f"Seçili Konum Koordinatları: **Enlem:** {lat:.5f} | **Boylam:** {lon:.5f} | **Ada:** {ada} / **Parsel:** {parsel}")
116
 
117
  col1, col2, col3, col4, col5 = st.columns(5)
118
+ col1.metric("📐 Parsel Alanı", f"{area_m2:,} m²")
119
+ col2.metric("⛰️ Ort. Rakım", f"{avg_elevation} m")
120
+ col3.metric("📐 Ort. Eğim", f"% {slope_pct}")
121
+ col4.metric("💧 Su Kotu", f"{water_table_min} - {water_table_max} m")
122
+ col5.metric("🧱 Ana Kaya", selected_rock)
123
 
124
  st.divider()
125
 
126
  # -----------------------------------------------------------------------------
127
+ # 4. TAB YAPISI
128
  # -----------------------------------------------------------------------------
129
  tab1, tab2, tab3, tab4 = st.tabs([
130
+ "🗺️ Interactive Harita (Tıkla & Seç)",
131
+ "🏔️ 3D Arazi (DEM) Modeli",
132
  "🧱 Jeolojik Kolon Kesiti",
133
  "🌐 TIJBA Jeoloji Sosyal Ağı"
134
  ])
135
 
136
+ # --- TAB 1: INTERAKTİF HARİTA (HARİTADAN TIKLAYIP PARSEL SEÇME) ---
137
  with tab1:
138
+ st.subheader("💡 Haritaya Tıklayarak Türkiye'nin İstediğiniz Yerinden Parsel Seçebilirsiniz!")
139
+ st.info("👇 Haritada istediğiniz bir noktaya tıkladığınızda sistem o konumun 3D arazisini ve jeolojik verilerini anında günceller.")
140
+
141
  m = folium.Map(location=[lat, lon], zoom_start=16, tiles="OpenStreetMap")
142
 
143
+ # Seçilen Noktaya Dinamik Parsel Poligonu Oluşturma
144
+ offset = 0.0008
145
  parsel_coords = [
146
+ [lat + offset, lon - offset],
147
+ [lat + offset * 1.2, lon + offset * 0.9],
148
+ [lat - offset * 0.8, lon + offset * 1.1],
149
+ [lat - offset, lon - offset * 0.7]
150
  ]
151
+
152
  folium.Polygon(
153
  locations=parsel_coords,
154
  color="red",
 
156
  fill=True,
157
  fill_color="crimson",
158
  fill_opacity=0.35,
159
+ tooltip=f"Seçili Parsel Sınırı ({area_m2:,} m²)"
160
  ).add_to(m)
161
 
162
+ # Seçili Nokta İbreleri
163
+ folium.Marker(
164
+ location=[lat, lon],
165
+ popup=f"Seçilen Konum: {lat:.4f}, {lon:.4f}",
166
+ icon=folium.Icon(color="red", icon="info-sign")
167
+ ).add_to(m)
168
+
169
+ # Su Kuyuları Katmanı (Dinamik Etrafa Serpiştirilmiş)
170
  if show_wells:
171
  well_cluster = MarkerCluster(name="Su Kuyuları").add_to(m)
172
+ for i in range(3):
173
+ w_lat = lat + np.random.uniform(-0.002, 0.002)
174
+ w_lon = lon + np.random.uniform(-0.002, 0.002)
 
 
 
175
  folium.Marker(
176
  location=[w_lat, w_lon],
177
+ popup=f"Kuyu #{i+1} (Derinlik: {np.random.randint(30,90)}m)",
178
  icon=folium.Icon(color="blue", icon="tint", prefix="fa")
179
  ).add_to(well_cluster)
180
 
181
+ # MTA Formasyon Katmanı
182
  if show_geology:
183
  folium.Rectangle(
184
  bounds=[[lat - 0.003, lon - 0.003], [lat + 0.003, lon + 0.003]],
185
+ color="orange", weight=1, fill=True, fill_color="khaki", fill_opacity=0.2,
186
+ tooltip=f"MTA Saha Formasyonu: {selected_rock}"
 
 
 
 
187
  ).add_to(m)
188
 
189
+ # Harita Etkileşimi ve Tıklama Yakalama
190
  if HAS_FOLIUM_EXT:
191
+ map_data = st_folium(m, width="100%", height=550, key="main_map")
192
+
193
+ # Kullanıcı haritada yeni bir yere tıkladıysa
194
+ if map_data and map_data.get("last_clicked"):
195
+ clicked_lat = map_data["last_clicked"]["lat"]
196
+ clicked_lon = map_data["last_clicked"]["lng"]
197
+
198
+ # Eğer tıklanan koordinat mevcut koordinattan farklıysa güncelle
199
+ if abs(clicked_lat - lat) > 0.0001 or abs(clicked_lon - lon) > 0.0001:
200
+ st.session_state["lat"] = clicked_lat
201
+ st.session_state["lon"] = clicked_lon
202
+ st.session_state["location_name"] = f"Seçilen Nokta ({clicked_lat:.4f}, {clicked_lon:.4f})"
203
+ st.rerun()
204
  else:
205
  components.html(m._repr_html_(), height=550)
206
 
207
  # --- TAB 2: 3D ARAZİ MODELİ (DEM EXAGGERATED) ---
208
  with tab2:
209
+ st.subheader(f"3D Topoğrafya & Yüzey Modeli ({st.session_state['location_name']})")
210
 
211
  col_dem1, col_dem2 = st.columns([3, 1])
212
 
213
  with col_dem1:
214
+ grid_size = 35
 
215
  x = np.linspace(-2, 2, grid_size)
216
  y = np.linspace(-2, 2, grid_size)
217
  X, Y = np.meshgrid(x, y)
218
+
219
+ # Koordinata özel 3D topoğrafik dalgalanma üretimi
220
+ Z = (avg_elevation + (slope_pct * 2) * np.sin(X + seed) + 15 * np.cos(Y * 1.5) + (X**2 + Y**2) * 3) * z_exaggeration
221
 
222
  fig_3d = go.Figure(data=[go.Surface(z=Z, colorscale='Earth', showscale=True)])
223
  fig_3d.update_layout(
224
+ title=f"3D Yükseklik Yüzeyi (Z-Abartı Faktörü: {z_exaggeration}x)",
225
  autosize=True,
226
  scene=dict(
227
+ xaxis_title='X (Metre)',
228
+ yaxis_title='Y (Metre)',
229
  zaxis_title='Rakım (m)',
230
  aspectratio=dict(x=1, y=1, z=0.5)
231
  ),
 
235
  st.plotly_chart(fig_3d, use_container_width=True)
236
 
237
  with col_dem2:
238
+ st.markdown("### 🏔️ Topoğrafik Özet")
239
+ st.info(f"**Ortalama Rakım:** {avg_elevation} m\n\n**Maksimum Eğim:** %{slope_pct}\n\n**Zemin Yapısı:** {selected_rock}")
240
+ if slope_pct > 12.0:
241
+ st.warning("⚠️ **Eğim Uyarısı:** Parselde yüksek kot farkı ve eğim bulunmaktadır. Hafriyat ve istinat projeksiyonu önerilir.")
242
+ else:
243
 
244
+ st.success("✅ **Düşük Eğim:** Arazi düz/az eğimli yapılaşmaya uygundur.")
245
+
246
+ # --- TAB 3: JEOLOJİK KOLON KESİTİ ---
247
  with tab3:
248
+ st.subheader("Tahmini Stratigrafik Kolon Kesiti")
 
249
 
250
  col_geo1, col_geo2 = st.columns([2, 1])
251
 
252
  with col_geo1:
 
253
  layers_df = pd.DataFrame({
254
+ "Katman": ["Bitkisel Toprak", "Üst Sert Kil / Alüvyon", f"Ayrışmış {selected_rock}", f"Masif {selected_rock} (Ana Kaya)"],
255
+ "Kalınlık (m)": [1.2, round(water_table_min * 0.3, 1), round(water_table_min * 0.6, 1), 25.0],
256
+ "SPT (N60)": ["4 - 8", "12 - 18", "25 - 45", ">50 (Refü)"],
257
+ "Renk": ["#8B5A2B", "#CD853F", "#D2B48C", "#708090"]
 
258
  })
259
 
260
  fig_strat = px.bar(
 
265
  color="Katman",
266
  text="SPT (N60)",
267
  color_discrete_sequence=layers_df["Renk"].tolist(),
268
+ title="Derinlik Katmanları ve SPT Direnç Değerleri"
269
  )
270
  fig_strat.update_layout(height=400, showlegend=False)
271
  st.plotly_chart(fig_strat, use_container_width=True)
272
 
273
  with col_geo2:
274
+ st.markdown("### 💧 Yeraltı Suyu Bilgisi")
275
+ st.markdown(f"""
276
+ * **Tahmini Statik Su Kotu:** {water_table_min} metre
277
+ * **Dinamik Su Seviyesi:** {water_table_max} metre
278
+ * **Önerilen Sondaj Derinliği:** {water_table_max + 25} metre
279
+ * **Formasyon:** {selected_rock} Akifer Yapısı
280
  """)
281
 
282
+ # --- TAB 4: TIJBA JEOLOJİ SOSYAL AĞI ---
283
  with tab4:
284
+ st.subheader("🌐 TIJBA - Bölgesel Saha Akışı & Geoteknik Sosyal Ağ")
 
285
 
286
  col_tij1, col_tij2 = st.columns([2, 1])
287
 
288
  with col_tij1:
289
+ with st.expander(f"➕ {st.session_state['location_name']} İçi Konum Etiketli Paylaşım Yap"):
290
+ post_text = st.text_area("Saha gözlemi veya zemin etüt notunuz:", placeholder="Örn: Sondajda 12. metrede su çıktı...")
291
+ uploaded_file = st.file_uploader("Sondaj Logu / PDF Yükle", type=["png", "jpg", "pdf"])
292
+ if st.button("TIJBA Ağında Yayınla"):
293
+ st.success("✅ Gözleminiz seçili koordinat etiketli olarak TIJBA veritabanına eklendi!")
 
294
 
295
  st.divider()
296
+ st.markdown(f"### 📰 {st.session_state['location_name']} Çevresindeki Paylaşımlar")
297
 
 
298
  posts = [
299
  {
300
+ "user": "Jeo. Müh. Mehmet Can",
301
  "role": "Saha Mühendisi",
302
+ "time": "3 saat önce",
303
+ "dist": "250m yakınında",
304
+ "content": f"Seçilen parsele yakın bölgede yapılan sondajda {selected_rock} tabakası tespit edilmiştir.",
305
+ "likes": 18
306
  },
307
  {
308
+ "user": "Dr. Selin Aksoy",
309
+ "role": "Geoteknik Uzmanı",
310
  "time": "1 gün önce",
311
+ "dist": "500m yakınında",
312
+ "content": f"Bölgede su seviyesi ortalama {water_table_min}m civarındadır. Temel kazısında yeraltı suyuna dikkat edilmeli.",
313
+ "likes": 32
314
  }
315
  ]
316
 
 
320
  <span class="badge-geo">{p['role']}</span> <b>{p['user']}</b>
321
  <span style="color:gray; font-size:0.8em;">• {p['time']} ({p['dist']})</span>
322
  <p style="margin-top:8px;">{p['content']}</p>
323
+ <small>❤️ {p['likes']} Mühendis Onayladı</small>
324
  </div>
325
  """, unsafe_allow_html=True)
326
 
327
  with col_tij2:
328
+ st.markdown("### 🏆 Bölgesel Katkıda Bulunanlar")
329
  st.markdown("""
330
+ 1. 🥇 **Jeo. Müh. Mehmet C.** (34 Katkı)
331
+ 2. 🥈 **Dr. Selin A.** (21 Katkı)
332
+ 3. 🥉 **GeoTek Laboratuvarı** (15 Log)
333
  """)
 
334
 
335
  # -----------------------------------------------------------------------------
336
+ # FOOTER
337
  # -----------------------------------------------------------------------------
338
  st.divider()
339
+ st.caption("© 2026 BoraPalyAI & TIJBA GeoTech Platformu | Tüm Türkiye İçin Açık Harita Servisleri Entegre Edilmiştir.")