PageSourceSearch

https://proparcel.com/static/js/initialization/bina_ciz_toolbar.js?v=20260819-lonlat

js proparcel.com collected 2026-09-24 14:51:18 UTC 10,311 bytes, 545 lines download raw bytes

1/**
2
3 * /harita/ action bar — "Proje Oluştur" → /bina-ciz/ (seçili parsel query ile).
4
5 *
6
7 * Tam sayfa geçişinde lastParcelResponse kaybolur; TKGM yeniden çağrısı
8
9 * günlük limitte 403 verir. Bu yüzden geometriyi sessionStorage'a yazarız.
10
11 *
12
13 * Girişli tüm kullanıcılar açabilir (misafir kilidi: toolbar_extras_auth_gate).
14
15 */
16
17(function () {
18
19  "use strict";
20
21
22
23  var STASH_KEY = "pp_bina_ciz_parcel_v1";
24
25
26
27  function appendLocationNames(url) {
28
29    try {
30
31      var u = new URL(url, window.location.origin);
32
33      function pickText(id) {
34
35        var el = document.getElementById(id);
36
37        if (!el || !el.selectedOptions || !el.selectedOptions[0]) return "";
38
39        return String(el.selectedOptions[0].textContent || "").trim();
40
41      }
42
43      var ilName = pickText("il-select");
44
45      var ilceName = pickText("ilce-select");
46
47      var mhName = pickText("mahalle-select");
48
49      if (ilName) {
50
51        u.searchParams.set("il", ilName);
52
53        u.searchParams.set("il_name", ilName);
54
55      }
56
57      if (ilceName) {
58
59        u.searchParams.set("ilce", ilceName);
60
61        u.searchParams.set("ilce_name", ilceName);
62
63      }
64
65      if (mhName) u.searchParams.set("mahalle_name", mhName);
66
67      return u.pathname + u.search;
68
69    } catch (_) {
70
71      return url;
72
73    }
74
75  }
76
77
78
79  function buildBinaCizUrlFromParcel() {
80
81    var base = "/bina-ciz/";
82
83    try {
84
85      if (typeof window.build3dEditorUrlFromParcel === "function") {
86
87        var editorUrl = String(window.build3dEditorUrlFromParcel() || "");
88
89        if (editorUrl.indexOf("/3d-editor/") === 0) {
90
91          return appendLocationNames(editorUrl.replace("/3d-editor/", "/bina-ciz/"));
92
93        }
94
95        if (editorUrl.indexOf("/3d-editor") === 0) {
96
97          return appendLocationNames(editorUrl.replace("/3d-editor", "/bina-ciz"));
98
99        }
100
101      }
102
103    } catch (_) {}
104
105    return base;
106
107  }
108
109
110
111  window.buildBinaCizUrlFromParcel = buildBinaCizUrlFromParcel;
112
113
114
115  function pickStr(o, keys) {
116
117    if (!o || typeof o !== "object") return "";
118
119    for (var i = 0; i < keys.length; i++) {
120
121      var v = o[keys[i]];
122
123      if (v != null && String(v).trim() !== "" && String(v).trim() !== "null") {
124
125        return String(v).trim();
126
127      }
128
129    }
130
131    return "";
132
133  }
134
135
136
137  /** Basit sorgu / harita kaynaklarından GeoJSON geometry çıkar. */
138
139  function resolveParcelGeometry(data) {
140
141    var geometry = null;
142
143    try {
144
145      if (window.lastTkgmData && window.lastTkgmData.geometry && window.lastTkgmData.geometry.coordinates) {
146        return window.lastTkgmData.geometry;
147      }
148
149      if (data && data.geometry && data.geometry.coordinates) {
150        return data.geometry;
151      }
152
153      var pp = data && data.parameters_polygons && data.parameters_polygons.parcel_polygon;
154
155      if (pp && typeof pp === "object") {
156
157        if (pp.type === "FeatureCollection" && pp.features && pp.features[0]) {
158
159          geometry = pp.features[0].geometry || null;
160
161        } else if (pp.type === "Feature" && pp.geometry) {
162
163          geometry = pp.geometry;
164
165        } else if ((pp.type === "Polygon" || pp.type === "MultiPolygon") && pp.coordinates) {
166
167          geometry = pp;
168
169        }
170
171      }
172
173      if (!geometry && data && data.geometry) geometry = data.geometry;
174
175      if (!geometry && data && data.parameters_data && data.parameters_data.parcel_geometry) {
176
177        geometry = data.parameters_data.parcel_geometry;
178
179      }
180
181      if (!geometry && window.lastTkgmData && window.lastTkgmData.geometry) {
182
183        geometry = window.lastTkgmData.geometry;
184
185      }
186
187      if (!geometry && window.globalLayers && window.globalLayers.parcel_polygon) {
188
189        var gl = window.globalLayers.parcel_polygon;
190
191        if (gl.type === "FeatureCollection" && gl.features && gl.features[0]) {
192
193          geometry = gl.features[0].geometry || null;
194
195        } else if (gl.geometry) {
196
197          geometry = gl.geometry;
198
199        } else if (gl.coordinates) {
200
201          geometry = gl;
202
203        }
204
205      }
206
207      if (!geometry && window.multipleParcels && window.multipleParcels.length) {
208
209        var last = window.multipleParcels[window.multipleParcels.length - 1];
210
211        if (last && last.geometry) geometry = last.geometry;
212
213      }
214
215    } catch (_) {}
216
217    return geometry;
218
219  }
220
221
222
223  function stashParcelForBinaCiz() {
224
225    var sources = [
226
227      window.lastParcelResponse,
228
229      window.data_general,
230
231      window.lastTkgmData,
232
233      window.lastResponseData,
234
235    ];
236
237    var geometry = null;
238
239    var data = null;
240
241    for (var i = 0; i < sources.length; i++) {
242
243      if (!sources[i]) continue;
244
245      geometry = resolveParcelGeometry(sources[i]);
246
247      if (geometry && geometry.coordinates) {
248
249        data = sources[i];
250
251        break;
252
253      }
254
255    }
256
257    if (!geometry || !geometry.coordinates) {
258
259      try {
260
261        if (window.globalLayers && window.globalLayers.parcel_polygon) {
262
263          geometry = resolveParcelGeometry(window.globalLayers.parcel_polygon);
264
265          data = window.globalLayers.parcel_polygon;
266
267        }
268
269      } catch (_) {}
270
271    }
272
273    if (!geometry || !geometry.coordinates) {
274
275      try {
276
277        console.warn("[bina-ciz] stash: geometri yok");
278
279      } catch (_) {}
280
281      return false;
282
283    }
284
285    if (!data) data = window.lastTkgmData || window.lastParcelResponse || {};
286
287
288
289    var props =
290
291      (data && data.properties) ||
292
293      (data && data.parameters_data && data.parameters_data.parcel_values) ||
294
295      (window.lastTkgmData && window.lastTkgmData.properties) ||
296
297      {};
298
299    var pv = (data && data.parameters_data && data.parameters_data.parcel_values) || {};
300
301    try {
302
303      var mergeMeta = window.__ppKentselMergeMeta;
304
305      if (mergeMeta && mergeMeta.area_m2 != null && Number(mergeMeta.area_m2) > 0) {
306
307        var areaVal = Number(mergeMeta.area_m2);
308
309        props = Object.assign({}, props, {
310
311          alan: areaVal,
312
313          area: areaVal,
314
315          area_m2: areaVal,
316
317          yuzolcum: areaVal,
318
319          Yuzolcum: areaVal,
320
321        });
322
323        pv = Object.assign({}, pv, { alan: areaVal, area_m2: areaVal, yuzolcum: areaVal });
324
325      }
326
327    } catch (_) {}
328
329
330
331    var payload = {
332
333      v: 1,
334
335      saved_at: Date.now(),
336
337      geometry: geometry,
338
339      properties: props,
340
341      parameters_data: Object.assign({}, data && data.parameters_data ? data.parameters_data : {}, { parcel_values: pv }),
342
343      mahalle: pickStr(props, ["mahalleId", "mahalle_id", "mahalleTkgmValue"]) ||
344
345        pickStr(pv, ["mahalleId", "mahalle_id"]) ||
346
347        "",
348
349      ada: pickStr(props, ["adaNo", "ada", "Ada"]) || pickStr(pv, ["adaNo", "ada"]) || "",
350
351      parsel: pickStr(props, ["parselNo", "parsel", "Parsel"]) || pickStr(pv, ["parselNo", "parsel"]) || "",
352
353      reset_buildings: !!(window.__ppKentselMergeMeta && window.__ppKentselMergeMeta.reset_buildings),
354
355      kentsel_donusum: !!(window.__ppKentselMergeMeta && window.__ppKentselMergeMeta.kentsel_donusum),
356
357      area_m2: (window.__ppKentselMergeMeta && window.__ppKentselMergeMeta.area_m2) || null,
358
359    };
360
361
362
363    try {
364
365      sessionStorage.setItem(STASH_KEY, JSON.stringify(payload));
366
367      // Eski rapor köprüsü — editör yedek kaynak olarak okuyabilir
368
369      try {
370
371        sessionStorage.setItem(
372
373          "pp_report_data",
374
375          JSON.stringify({
376
377            geometry: geometry,
378
379            properties: props,
380
381            parameters_data: payload.parameters_data,
382
383            parameters_polygons: {
384
385              parcel_polygon: {
386
387                type: "FeatureCollection",
388
389                features: [{ type: "Feature", geometry: geometry, properties: props }],
390
391              },
392
393            },
394
395          })
396
397        );
398
399      } catch (_) {}
400
401      return true;
402
403    } catch (e) {
404
405      try {
406
407        console.warn("[bina-ciz] stash yazılamadı:", e);
408
409      } catch (_) {}
410
411      return false;
412
413    }
414
415  }
416
417
418
419  window.ppStashParcelForBinaCiz = stashParcelForBinaCiz;
420
421  window.PP_BINA_CIZ_STASH_KEY = STASH_KEY;
422
423
424
425  function hasParcel() {
426
427    try {
428
429      if (typeof window.ppHasParcelDrawableOnMap === "function") {
430
431        return !!window.ppHasParcelDrawableOnMap();
432
433      }
434
435    } catch (_) {}
436
437    try {
438
439      if (window.multipleParcels && window.multipleParcels.length > 0) return true;
440
441    } catch (_) {}
442
443    try {
444
445      var d = window.lastParcelResponse || window.data_general;
446
447      var fc = d && d.parameters_polygons && d.parameters_polygons.parcel_polygon;
448
449      if (fc && fc.features && fc.features.length > 0) return true;
450
451    } catch (_) {}
452
453    return false;
454
455  }
456
457
458
459  async function openBinaCizFromToolbar(e) {
460
461    if (e) {
462
463      e.preventDefault();
464
465      e.stopPropagation();
466
467    }
468
469    var link = document.getElementById("pp-ne-yapilir-btn");
470
471    if (link && link.getAttribute("aria-disabled") === "true") return;
472
473
474
475    if (!hasParcel()) {
476
477      window.alert("Önce haritada bir parsel seçin veya sorgulayın.");
478
479      return;
480
481    }
482
483
484
485    // Geometriyi taşı — TKGM günlük limitinde editör boş kalmasın
486
487    stashParcelForBinaCiz();
488
489
490
491    var url = buildBinaCizUrlFromParcel();
492
493    if (link) {
494
495      link.setAttribute("href", url);
496
497      link.setAttribute("data-pp-original-href", url);
498
499    }
500
501    window.location.href = url;
502
503  }
504
505
506
507  window.openBinaCizFromToolbar = openBinaCizFromToolbar;
508
509
510
511  function bind() {
512
513    var a = document.getElementById("pp-ne-yapilir-btn");
514
515    if (!a || a.getAttribute("data-pp-bina-ciz-bound") === "1") return;
516
517    a.setAttribute("data-pp-bina-ciz-bound", "1");
518
519    a.addEventListener("click", openBinaCizFromToolbar);
520
521  }
522
523
524
525  function boot() {
526
527    bind();
528
529  }
530
531
532
533  if (document.readyState === "loading") {
534
535    document.addEventListener("DOMContentLoaded", boot);
536
537  } else {
538
539    boot();
540
541  }
542
543})();
544
545

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.