-
Notifications
You must be signed in to change notification settings - Fork 0
/
EmineSAHIN.mb
345 lines (223 loc) · 7.39 KB
/
EmineSAHIN.mb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
Include "MapBasic.def"
Declare Sub Main
Declare Sub cokgen_parametre
Declare Sub cokgen_ucgenle
Declare Sub harita_penceresini_aktiflestir
Declare Function tablo_acik_mi(ByVal tabloAdi as String) as Logical
Declare Function ucgen_olustur_dogrula(ckgn_id as Smallint, noktano2 as Smallint, noktano3 as Smallint, ByVal KNoktaTablo as String) as Logical
Declare Sub cikis
Sub Main
' Koordinat sistemi ayarlamasi yapilir.
Set Map Area Units "sq m" Distance units "m"
Set coordsys window frontwindow()
' Menü olusturulur.
Create Menu "COKGEN CEPHE" as
"&Cokgen Parametreleri" calling cokgen_parametre,
"(-",
"Cikis" calling cikis
Alter Menu Bar Add "COKGEN CEPHE"
Create Menu "UCGENLEME" as
"&Cokgen Ucgenle" calling cokgen_ucgenle,
"(-",
"Cikis" calling cikis
Alter Menu Bar Add "UCGENLEME"
Create Menu "KESÝSÝM BULMA"
"&Kesisim Bulma" calling kesisim_bulma
"(-",
"Cikis" calling cikis
End Sub
Sub cokgen_parametre
Dim n_tablo,j,c_id,n_cokgen,i As Smallint
Dim c_obj As Object
Dim c_perim,c_area,x(1),y(1),s,min_s,max_s,toplam_s,ort_s As Float
'Tabloyu silmek icin prosedür.
Delete from NOKTA_KOOR
Commit Table NOKTA_KOOR
Pack Table NOKTA_KOOR Graphic Data
'Tablo olusturulur.
Select * from COKGEN into cokgen_temp
Fetch first from cokgen_temp
n_tablo = TableInfo(cokgen_temp,TAB_INFO_NROWS)
'Mesaj penceresi silinir.
Print Chr$(12)
Print "Cokgen Cephe"
Print ".........................."
j=1
Do While not eot(cokgen_temp)
'Cokgenin ID si ve geometrisi alinir.
c_id = cokgen_temp.CokgenID
c_obj = cokgen_temp-obj
'n point seklinde nokta sayisi tanimlanir ve ObjectInfo nokta sayisini 1 fazla döndürdüðü için 1 çikarlir.
n_cokgen = ObjectInfo(c_obj,OBJ_INFO_NPNTS)-1
'kenar hesabinda ilk noktanin tekrar kullanilmasi gerektiði için 1 eklenir.
Redim x(n_cokgen+1)
Redim y(n_cokgen+1)
'Cokgenin cevresini bulmak icin fonksiyon.
c_perim = CartesianPerimeter (c_obj, "m")
For i = 1 to n_cokgen
'Cokgenin köse noktalarinin koordinatlari elde edilir.
x(i) = ObjectNodeX(c_obj,1,i)
y(i) = ObjectNodeY(c_obj,1,i)
'Köse noktalarinin koordinatlari tabloya yazdirilir, ilaveten köþe noktalarinda noktalar olusturulur.
Insert into NOKTA_KOOR(CokgenID,NoktaNo,Saga_X,Yukari_Y,obj)Values(c_id,i,x(i),y(i),CreatePoint(x(i),y(i)))
Next
toplam_s = 0
For i = 1 to n_cokgen
if i = n_cokgen then
'Kenar bulmada ilk kenar tekrar kullanýlacaðý icin 1 eklenir.
x(i+1) - x(1)
y(i+1) - y(1)
End if
s = CartesianDistance(x(i),y(i),x(i+1),y(i+1),"m")
'min max kenar degerleri sürekli güncellenir.
If i = 1 then
min_s = s
max_s = s
Else
If (s < min_s) then min_s = s
ElseIf (s > max_s) then max_s = s
End If
End If
toplam_s = toplam_s + s
Next
'ortalama kenar hesaplanir.
ort_s = Round(toplam_s / n_cokgen,0.01)
Update COKGEN
Set
'Cokgenle ilgili bilgiler elde edilir. RowID deki satir numarasine göre yazilir, j sayaci ile degistirilir.
CokgenID = j,
NoktaSayisi = n_cokgen,
Cevre = c_perim,
MinKenarUz = min_s,
MaxKenarUz = max_s,
OrtKenarUz = ort_s,
Where RowID = j
'j sayac görevi görür cokgen ID ye bu deger atanýr.
j = j + 1
'sonraki satira gecilir.
Fetch Next From cokgen_temp
Loop
'Tablolar acilir.
Browse * From COKGEN
Browse * From NOKTA_KOOR
Print "ÝSLEM TAMAMLANDI!"
End Sub
Sub kesisim_bulma
Dim n_tablo,j,c_id,n_cokgen,i As Smallint
Dim c_obj As Object
Dim c_perim,c_area,x(1),y(1),s,min_s,max_s,toplam_s,ort_s As Float
L1 = Line joining points A(x1,y1) and B(x2,y2) L2 = Line joining points c(x3,y3) and D(x4,y4)
For Line L1
Line Equation : y = m1*x + c1
slope m1 : (y2-y1)/(x2-x1)
Y intercept : c1 = (y1 - m1*x1)
For Line L2
Line Equation : y = m2*x + c2
slope m2 : (y4-y3)/(x4-x3)
Y intercept : c2 = (y3 - m2*x3)
For Point of Intersection
Solving the above equations we get
x = (c2 -c1)/(m1-m2)
y = (c1*m2 - c2*m1)/(m2-m1)
End sub
Sub cokgen_ucgenle
Dim n_tablo,j,c_id,n_cokgen, i As Smallint
Dim c_obj As Object
Dim c_perim,c_area,x(1),y(1),s,min_s,max_s,toplam_s,ort_s As Float
Dim CokgenTablo,KNTablo,nno1,nno2,nno3 as String
'Bu varyans degiskeni ile tablodaki isimler yerine böyle takma isimler kullanilabilir.
Dim KNStn11, KNStn12, KN1_RowOrder, KN1ID, KN2ID, KN1KoorX, KN1Obj, KN2Obj, CKGNID, CKGNObj, KNStnX, KNStnY as Alias
Dim ucgen_kontrol as Logical
'Alt prosedür cagirilir.
Call harita_penceresini_aktiflestir
KNTablo = "KOSENOKTA"
Delete from KNTablo
Commit Table KNTablo
Pack Table KNTablo Graphic Data
'Tablonun acik mi kapali mi oldugu kontrol edilir.
If tablo_acik_mi("KN1Tablo")then
Close table "KN1Tablo"
End if
If tablo_acik_mi("KN2Tablo")then
Close table "KN2Tablo"
End if
CokgenTablo = "COKGENTABLO"
'Gecici bir tabloya deger atamasi yapilir.
Select * from CokgenTablo into cokgen_temp
Fetch first from cokgen_temp
n_tablo = TableInfo(cokgen_temp,TAB_INFO_NROWS)
Print Chr$(12)
Do While not eot(cokgen_temp)
c_id = cokgen_temp.COKGENID
c_obj = cokgen_temp.obj
n_cokgen = ObjectInfo(c_obj, OBJ_INFO_NPNTS)-1
Redim x(n_cokgen+1)
Redim y(n_cokgen+1)
c_perim = CartesianPerimeter(c_obj,"m")
c_area = CartesianArea(c_obj,"sq m")
For i = 1 to n_cokgen
x(i) = ObjectNodeX(c_obj,1,i)
y(i) = ObjectNodeY(c_obj,1,i)
'Köse koordinatlari yazdirilir.
Insert into KNTablo(CpkgenID,NoktaNo,Saga_X,Yukari_Y,obj)Values(c_id,i,x(i),y(i),CreatePoint(x(i),y(i)))
Next
If tablo_acik_mi("KN1Tablo")then
Close table "KNTablo"
End if
If tablo_acik_mi("KN2Tablo")then
Close table "K2Tablo"
End if
'2 ayri tablo olusturulur.
Select NoktaNo "ID1",Saga_X,Yukari_Y From KNTablo Order By Saga_X Into KN2TabloX
Commit table KN1TabloX as "KN1Tablo.tab"
Open table "KN1Tablo"
Select NoktaNo "ID2",Saga_X,yukari_Y from KNTablo Order By Saga_X Into KN2TabloX
Commit table KN2TabloX as "KN2Tablo.tab"
Open table "KN2Tablo"
'Varyans degiskenleri
KN1ID = KN1Tablo & ".ID1"
KN2ID = KN2Tablo & ".ID2"
KN1KoorX = KN1Tablo & ".Saga_X" 'X'e göre sirralama icin
KN1obj = KN1Tablo & ".obj"
KN2obj = KN2Tablo & ".obj"
CKGNID = CokgenTablo & ".CokgenID"
CKGNObj = CokgenTablo & ".Obj"
Select CKGNID,KN1ID,KN2ID, CartesianObjectDistance(KN1obj,KN2obj,"m")"Uz_m",KN1KoorX
From KN1Tablo,CokgenTablo,KN2Tablo
Where KN1obj Within CKGNObj And KN2obj Within CKGNObj and KN1ID <> KN2ID
Order by Col5, Col4
Into UZUNLUK
Browse * From UZUNLUK
Map from UZUNLUK, CokgenTablo
Fetch first from UZUNLUK
Do While Not EOT(UZUNLUK)
nno1 = UZUNLUK.ID1
nno2 = UZUNLUK.ID2
Fetch Next From UZUNLUK
nno3 = UZUNLUK.ID2
ucgen_kontrol = ucgen_olustur_dogrula (c_id as Smallint, nno2 as Smallint, nno3 as Smallint, ByVal "KNTablo" as String) as Logical
Loop
Fetch next from cookgen_temp
Loop
End Sub
Function Ucgen_olustur_dogrula (ckgn_id as Smallint, noktano1 as Smallint, noktano2 as Smallint, nooktano3 as Smallint, ByVal KNoktaTablo as String) as Logical
Dim ucgen_nesne as Object
Dim x_u, y_u as Float
Create Region Into Variable ucgen_nesne 0
Select * From KNoktaTablo Where NoktaNo = Any (noktano1, noktano2, nooktano3) Into ucgen_nokta
Fetch First From ucgen_nokta
For j = 1 to 3
x_u = ucgen_nokta.SagaX
y_u = ucgen_nokta.SagaY
Alter object ucgen_nokta
Next
Insert Into UCGEN (Object) Values (ucgen_nesne)
End function
Sub cikis
'Cikis yaparken olusan tablolar sildirilir.
Print Chr$(12)
Delete from NOKTA_KOOR
Commit Table NOKTA_KOOR
Pack Table NOKTA_KOOR Graphic Data
End Program
End Sub