PageSourceSearch

https://proparcel.com/static/js/graphics/elevation/elevation_view.js

js proparcel.com collected 2026-09-24 14:51:39 UTC 7,125 bytes, 188 lines download raw bytes

1/**
2 * Yükselti Görünümü (50m² Grid Analizi) Çizim Modülü
3 * 
4 * Bu modül arazi poligonunu 50m²'lik gridlerle yapılan yükseklik analizinin
5 * harita üzerinde görselleştirilmesini sağlar.
6 * 
7 * Mevcut render sistemini kullanır (window.globalLayers + window.renderLayer)
8 */
9
10/**
11 * Yükselti görünümünü çiz (ana fonksiyon)
12 * Backend'den gelen gradient_polygon formatını kullanır.
13 * Her kategori için birleştirilmiş (union) tek poligon + gradient yeşil renk.
14 * @param {Object} elevationViewData - Backend'den gelen yükselti görünümü verileri
15 */
16function drawElevationView(elevationViewData) {
17    if (!elevationViewData) return;
18
19    const gradientData = elevationViewData.gradient_polygon;
20    if (!gradientData || !Array.isArray(gradientData.gradient_features) || gradientData.gradient_features.length === 0) return;
21
22    const features = [];
23
24    gradientData.gradient_features.forEach(item => {
25        if (!item.geometry || !item.geometry.coordinates) return;
26        features.push({
27            type: 'Feature',
28            geometry: item.geometry,
29            properties: {
30                category_index: item.category_index,
31                elevation_min: item.elevation_range ? item.elevation_range[0] : null,
32                elevation_max: item.elevation_range ? item.elevation_range[1] : null,
33                color: item.color,
34                color_intensity: item.color_intensity || 0,
35                cell_count: item.cell_count || 0
36            }
37        });
38    });
39
40    if (features.length === 0) return;
41
42    if (!window.globalLayers) window.globalLayers = {};
43    window.globalLayers['parcel_elevation_view_all'] = features;
44
45    if (typeof window.renderLayer === 'function') {
46        window.renderLayer('parcel_elevation_view_all', { visible: true });
47
48        const map = window.mapManager?.getCurrentMap();
49        if (map) {
50            if (map.getLayer('parcel_polygon-fill')) map.moveLayer('parcel_polygon-fill');
51            if (map.getLayer('parcel_polygon')) map.moveLayer('parcel_polygon');
52            if (map.getLayer('parcel_polygon_label')) map.moveLayer('parcel_polygon_label');
53        }
54    }
55
56    window.currentElevationViewData = elevationViewData;
57}
58
59/**
60 * Mahalle yükselti görünümünü çiz
61 * @param {Object} elevationViewData - Backend'den gelen mahalle yükselti görünümü verileri
62 */
63function drawQuarterElevationView(elevationViewData) {
64
65    if (!elevationViewData) {
66        return;
67    }
68
69        // Kategorilere göre features oluştur
70        const categories = elevationViewData.elevation_categories || [];
71        
72        
73        if (!categories || categories.length === 0) {
74            return;
75        }
76
77        // Her kategori için ayrı features oluştur
78        const features = [];
79        
80        categories.forEach((category, idx) => {
81            const polygons = category.polygons || [];
82            const colorIntensity = category.color_intensity || 0;
83            
84            // Renk yoğunluğuna göre mavi tonları (açık maviden koyu maviye)
85            // Açık: #ADD8E6 (Light Blue), Koyu: #00008B (Dark Blue)
86            const lightBlue = { r: 173, g: 216, b: 230 };
87            const darkBlue = { r: 0, g: 0, b: 139 };
88            
89            const r = Math.round(lightBlue.r + (darkBlue.r - lightBlue.r) * colorIntensity);
90            const g = Math.round(lightBlue.g + (darkBlue.g - lightBlue.g) * colorIntensity);
91            const b = Math.round(lightBlue.b + (darkBlue.b - lightBlue.b) * colorIntensity);
92            
93            const color = `rgb(${r}, ${g}, ${b})`;
94            
95            // Her poligonu feature olarak ekle
96            polygons.forEach(polygon => {
97                if (polygon && polygon.coordinates) {
98                    features.push({
99                        type: 'Feature',
100                        geometry: polygon,
101                        properties: {
102                            category_index: category.category_index,
103                            elevation_min: category.elevation_range[0],
104                            elevation_max: category.elevation_range[1],
105                            color: color,
106                            color_intensity: colorIntensity,
107                            cell_count: category.cell_count || 0
108                        }
109                    });
110                }
111            });
112        });
113
114        if (features.length === 0) {
115            return;
116        }
117
118
119        // Veriyi global layers'a kaydet
120        if (!window.globalLayers) {
121            window.globalLayers = {};
122        }
123        window.globalLayers['quarter_elevation_view_all'] = features;
124
125
126        // Render fonksiyonunu çağır (görünür olarak)
127        if (typeof window.renderLayer === 'function') {
128            window.renderLayer('quarter_elevation_view_all', { visible: true });
129        } else {
130        }
131
132        // Global değişkene kaydet
133        window.currentQuarterElevationViewData = elevationViewData;
134
135
136}
137
138/**
139 * Yükselti görünümünü temizle
140 */
141function clearElevationView() {
142
143        const map = window.mapManager?.getCurrentMap?.();
144        const emptyFC = { type:'FeatureCollection', features: [] };
145        
146        // Parsel yükseklik katmanlarını temizle
147        const parcelElevationLayers = ['parcel_elevation_view_all', 'parcel_elevation_view_all-fill'];
148        parcelElevationLayers.forEach(layerId => {
149            // Katmanı gizle
150            if (typeof window.setLayerVisibility === 'function') {
151                window.setLayerVisibility(layerId, false);
152            }
153            
154            // Source verisini temizle
155            if (map && map.getSource(layerId) && map.getSource(layerId).setData) {
156                    map.getSource(layerId).setData(emptyFC);
157            }
158        });
159        
160        // Mahalle yükseklik katmanlarını temizle
161        const quarterElevationLayers = ['quarter_elevation_view_all', 'quarter_elevation_view_all-fill'];
162        quarterElevationLayers.forEach(layerId => {
163            // Katmanı gizle
164            if (typeof window.setLayerVisibility === 'function') {
165                window.setLayerVisibility(layerId, false);
166            }
167            
168            // Source verisini temizle
169            if (map && map.getSource(layerId) && map.getSource(layerId).setData) {
170                    map.getSource(layerId).setData(emptyFC);
171            }
172        });
173
174        // Global veriyi temizle
175        if (window.globalLayers) {
176            delete window.globalLayers['parcel_elevation_view_all'];
177            delete window.globalLayers['quarter_elevation_view_all'];
178        }
179        window.currentElevationViewData = null;
180        window.currentQuarterElevationViewData = null;
181
182}
183
184// Global fonksiyonları tanımla
185window.drawElevationView = drawElevationView;
186window.drawQuarterElevationView = drawQuarterElevationView;
187window.clearElevationView = clearElevationView;
188

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.