Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- static/swipe_map.html +78 -88
static/swipe_map.html
CHANGED
|
@@ -142,7 +142,7 @@
|
|
| 142 |
|
| 143 |
const webmap = new WebMap({
|
| 144 |
portalItem: {
|
| 145 |
-
id: "9f45f081b3e5416790b5652b5b47e90e"
|
| 146 |
},
|
| 147 |
layers: [afterBufferLayer, beforeBufferLayer, changeBufferLayer]
|
| 148 |
});
|
|
@@ -157,10 +157,10 @@
|
|
| 157 |
});
|
| 158 |
|
| 159 |
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
|
| 165 |
// 🔀 Swipe
|
| 166 |
const swipe = new Swipe({
|
|
@@ -218,7 +218,7 @@
|
|
| 218 |
if (value === undefined || colorHex === undefined) continue;
|
| 219 |
|
| 220 |
// Convierte el color HEX a [r, g, b] array
|
| 221 |
-
const colorRGB = hexToRGB(colorHex, 0.
|
| 222 |
|
| 223 |
const utm = projection.project(geom, { wkid: 32615 });
|
| 224 |
if (!utm) continue;
|
|
@@ -242,7 +242,7 @@
|
|
| 242 |
attributes: { value, color: colorHex },
|
| 243 |
symbol: {
|
| 244 |
type: "simple-fill",
|
| 245 |
-
color: colorRGB,
|
| 246 |
outline: { color: [40, 40, 40, 0], width: 0.5 }
|
| 247 |
}
|
| 248 |
}));
|
|
@@ -290,102 +290,92 @@
|
|
| 290 |
});
|
| 291 |
});
|
| 292 |
|
| 293 |
-
|
| 294 |
-
async function renderSplitGraphics(view, split_url, useBuffer = false) {
|
| 295 |
-
if (!split_url) {
|
| 296 |
-
console.warn("⚠️ split_url no especificado");
|
| 297 |
-
return;
|
| 298 |
-
}
|
| 299 |
-
|
| 300 |
-
console.log("🗂️ Cargando capa split:", split_url);
|
| 301 |
|
| 302 |
-
|
| 303 |
-
|
|
|
|
|
|
|
|
|
|
| 304 |
|
| 305 |
-
|
| 306 |
-
await geoLayer.load();
|
| 307 |
|
| 308 |
-
|
| 309 |
-
|
| 310 |
|
| 311 |
-
|
|
|
|
| 312 |
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
const c = hex.replace("#", "");
|
| 316 |
-
const bigint = parseInt(c, 16);
|
| 317 |
-
const r = (bigint >> 16) & 255;
|
| 318 |
-
const g = (bigint >> 8) & 255;
|
| 319 |
-
const b = bigint & 255;
|
| 320 |
-
return [r, g, b, alpha];
|
| 321 |
-
};
|
| 322 |
|
| 323 |
-
|
| 324 |
-
for (const f of features.features) {
|
| 325 |
-
const geom = f.geometry;
|
| 326 |
-
const attrs = f.attributes;
|
| 327 |
-
const colorHex = attrs.color ?? "#d2691e";
|
| 328 |
-
const colorRGB = hexToRGB(colorHex, 0.85);
|
| 329 |
|
| 330 |
-
|
| 331 |
-
const
|
| 332 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 333 |
|
| 334 |
-
|
| 335 |
-
|
| 336 |
|
| 337 |
-
|
| 338 |
-
spatialReference: { wkid: 32615 },
|
| 339 |
-
rings: [[
|
| 340 |
-
[x - half, y - half],
|
| 341 |
-
[x + half, y - half],
|
| 342 |
-
[x + half, y + half],
|
| 343 |
-
[x - half, y + half],
|
| 344 |
-
[x - half, y - half]
|
| 345 |
-
]]
|
| 346 |
-
});
|
| 347 |
|
| 348 |
-
const squareWGS = projection.project(squareUTM, { wkid: 4326 });
|
| 349 |
|
| 350 |
-
|
| 351 |
-
geometry: squareWGS,
|
| 352 |
-
attributes: attrs,
|
| 353 |
-
symbol: {
|
| 354 |
-
type: "simple-fill",
|
| 355 |
-
color: colorRGB,
|
| 356 |
-
outline: { color: [40, 40, 40, 0.2], width: 0.5 }
|
| 357 |
-
}
|
| 358 |
-
}));
|
| 359 |
-
} else {
|
| 360 |
-
graphics.push(new Graphic({
|
| 361 |
-
geometry: geom,
|
| 362 |
-
attributes: attrs,
|
| 363 |
-
symbol: {
|
| 364 |
-
type: "simple-marker",
|
| 365 |
-
path: "M -1 -1 L 1 1 M -1 1 L 1 -1",
|
| 366 |
-
color: colorRGB,
|
| 367 |
-
size: 9, // más grande
|
| 368 |
-
outline: {
|
| 369 |
-
color: colorRGB,
|
| 370 |
-
width: 6 // más gruesa
|
| 371 |
-
}
|
| 372 |
-
}
|
| 373 |
-
|
| 374 |
-
}));
|
| 375 |
}
|
| 376 |
-
}
|
| 377 |
-
|
| 378 |
-
splitGraphicsLayer.addMany(graphics);
|
| 379 |
-
console.log(`✅ Renderizadas ${graphics.length} features en ${useBuffer ? "modo buffer" : "modo X"}`);
|
| 380 |
-
|
| 381 |
-
// 🔹 Ajuste dinámico inverso de tamaño (zoom menor → ícono más grande)
|
| 382 |
-
|
| 383 |
|
| 384 |
-
return splitGraphicsLayer;
|
| 385 |
-
}
|
| 386 |
|
| 387 |
|
| 388 |
-
|
| 389 |
</script>
|
| 390 |
|
| 391 |
|
|
|
|
| 142 |
|
| 143 |
const webmap = new WebMap({
|
| 144 |
portalItem: {
|
| 145 |
+
id: "9f45f081b3e5416790b5652b5b47e90e"
|
| 146 |
},
|
| 147 |
layers: [afterBufferLayer, beforeBufferLayer, changeBufferLayer]
|
| 148 |
});
|
|
|
|
| 157 |
});
|
| 158 |
|
| 159 |
|
| 160 |
+
if (split_url) {
|
| 161 |
+
// Renderizar como X personalizadas
|
| 162 |
+
renderSplitGraphics(view, split_url, false);
|
| 163 |
+
}
|
| 164 |
|
| 165 |
// 🔀 Swipe
|
| 166 |
const swipe = new Swipe({
|
|
|
|
| 218 |
if (value === undefined || colorHex === undefined) continue;
|
| 219 |
|
| 220 |
// Convierte el color HEX a [r, g, b] array
|
| 221 |
+
const colorRGB = hexToRGB(colorHex, 0.9);
|
| 222 |
|
| 223 |
const utm = projection.project(geom, { wkid: 32615 });
|
| 224 |
if (!utm) continue;
|
|
|
|
| 242 |
attributes: { value, color: colorHex },
|
| 243 |
symbol: {
|
| 244 |
type: "simple-fill",
|
| 245 |
+
color: colorRGB,
|
| 246 |
outline: { color: [40, 40, 40, 0], width: 0.5 }
|
| 247 |
}
|
| 248 |
}));
|
|
|
|
| 290 |
});
|
| 291 |
});
|
| 292 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 293 |
|
| 294 |
+
async function renderSplitGraphics(view, split_url, useBuffer = false) {
|
| 295 |
+
if (!split_url) {
|
| 296 |
+
console.warn("⚠️ split_url no especificado");
|
| 297 |
+
return;
|
| 298 |
+
}
|
| 299 |
|
| 300 |
+
console.log("🗂️ Cargando capa split:", split_url);
|
|
|
|
| 301 |
|
| 302 |
+
const splitGraphicsLayer = new GraphicsLayer({ title: "Split Graphics" });
|
| 303 |
+
view.map.add(splitGraphicsLayer);
|
| 304 |
|
| 305 |
+
const geoLayer = new GeoJSONLayer({ url: split_url });
|
| 306 |
+
await geoLayer.load();
|
| 307 |
|
| 308 |
+
const features = await geoLayer.queryFeatures();
|
| 309 |
+
console.log(`📦 ${features.features.length} features cargadas desde split_url`);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 310 |
|
| 311 |
+
await projection.load();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 312 |
|
| 313 |
+
const graphics = [];
|
| 314 |
+
for (const f of features.features) {
|
| 315 |
+
const geom = f.geometry;
|
| 316 |
+
const attrs = f.attributes;
|
| 317 |
+
const colorHex = attrs.color ?? "#d2691e";
|
| 318 |
+
const colorRGB = hexToRGB(colorHex, 0.90);
|
| 319 |
+
|
| 320 |
+
if (useBuffer) {
|
| 321 |
+
const utm = projection.project(geom, { wkid: 32615 });
|
| 322 |
+
if (!utm) continue;
|
| 323 |
+
|
| 324 |
+
const { x, y } = utm;
|
| 325 |
+
const half = 50;
|
| 326 |
+
|
| 327 |
+
const squareUTM = new Polygon({
|
| 328 |
+
spatialReference: { wkid: 32615 },
|
| 329 |
+
rings: [[
|
| 330 |
+
[x - half, y - half],
|
| 331 |
+
[x + half, y - half],
|
| 332 |
+
[x + half, y + half],
|
| 333 |
+
[x - half, y + half],
|
| 334 |
+
[x - half, y - half]
|
| 335 |
+
]]
|
| 336 |
+
});
|
| 337 |
+
|
| 338 |
+
const squareWGS = projection.project(squareUTM, { wkid: 4326 });
|
| 339 |
+
|
| 340 |
+
graphics.push(new Graphic({
|
| 341 |
+
geometry: squareWGS,
|
| 342 |
+
attributes: attrs,
|
| 343 |
+
symbol: {
|
| 344 |
+
type: "simple-fill",
|
| 345 |
+
color: colorRGB,
|
| 346 |
+
outline: { color: [40, 40, 40, 0.2], width: 0.5 }
|
| 347 |
+
}
|
| 348 |
+
}));
|
| 349 |
+
} else {
|
| 350 |
+
graphics.push(new Graphic({
|
| 351 |
+
geometry: geom,
|
| 352 |
+
attributes: attrs,
|
| 353 |
+
symbol: {
|
| 354 |
+
type: "simple-marker",
|
| 355 |
+
path: "M -1 -1 L 1 1 M -1 1 L 1 -1",
|
| 356 |
+
color: colorRGB,
|
| 357 |
+
size: 9, // más grande
|
| 358 |
+
outline: {
|
| 359 |
+
color: colorRGB,
|
| 360 |
+
width: 6 // más gruesa
|
| 361 |
+
}
|
| 362 |
+
}
|
| 363 |
+
|
| 364 |
+
}));
|
| 365 |
+
}
|
| 366 |
+
}
|
| 367 |
|
| 368 |
+
splitGraphicsLayer.addMany(graphics);
|
| 369 |
+
console.log(`✅ Renderizadas ${graphics.length} features en ${useBuffer ? "modo buffer" : "modo X"}`);
|
| 370 |
|
| 371 |
+
// 🔹 Ajuste dinámico inverso de tamaño (zoom menor → ícono más grande)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 372 |
|
|
|
|
| 373 |
|
| 374 |
+
return splitGraphicsLayer;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 375 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 376 |
|
|
|
|
|
|
|
| 377 |
|
| 378 |
|
|
|
|
| 379 |
</script>
|
| 380 |
|
| 381 |
|