feat: Add Leaflet map integration and project coordinates handling

- Updated package.json to include dependencies for Leaflet and Playwright testing.
- Added new images for Leaflet markers and layers.
- Created scripts for generating test data with project coordinates.
- Enhanced ProjectViewPage to display project coordinates and integrated ProjectMap component.
- Modified ProjectForm to include coordinates input field.
- Implemented CustomWMTSMap and EnhancedLeafletMap components for improved map functionality.
- Created ProjectMap component to dynamically render project location on the map.
- Added mapLayers configuration for various base layers including Polish Geoportal.
- Implemented WMTS capabilities handling for dynamic layer loading.
- Updated database initialization to include coordinates column in projects table.
- Modified project creation and update functions to handle coordinates.
- Added utility functions for formatting project status and deadlines.
This commit is contained in:
2025-06-18 12:47:04 +02:00
parent c983ba9882
commit 603634e8a4
21 changed files with 8022 additions and 36 deletions

View File

@@ -0,0 +1,65 @@
// Map layer configurations
import { generateLayerConfig } from './wmtsCapabilities';
// Generate layer configurations from WMTS capabilities
const polishOrthophoto = generateLayerConfig('orthophoto');
export const mapLayers = {
base: [
{
name: "OpenStreetMap",
checked: true,
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
url: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
maxZoom: 19
},
polishOrthophoto,
{
name: "Polish Land Records (WMS)",
attribution: '&copy; <a href="https://www.gugik.gov.pl/">GUGiK</a>',
// This is actually a WMS service, not WMTS as discovered from GetCapabilities
url: "https://integracja.gugik.gov.pl/cgi-bin/KrajowaIntegracjaEwidencjiGruntow?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&BBOX={bbox-epsg-3857}&CRS=EPSG:3857&WIDTH=256&HEIGHT=256&LAYERS=EGiB&STYLES=&FORMAT=image/png",
maxZoom: 19,
tileSize: 256
},
{
name: "Satellite (Esri)",
attribution: '&copy; <a href="https://www.esri.com/">Esri</a> &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community',
url: "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",
maxZoom: 19
},
{
name: "Topographic",
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, &copy; <a href="https://carto.com/attributions">CARTO</a>',
url: "https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png",
maxZoom: 19
}
].filter(Boolean) // Remove any null entries
};
// WMTS services configuration with GetCapabilities URLs
export const wmtsServices = {
polishOrthophoto: {
capabilitiesUrl: "https://mapy.geoportal.gov.pl/wss/service/PZGIK/ORTO/WMTS/StandardResolution?Service=WMTS&Request=GetCapabilities",
layer: "ORTO",
style: "default",
tilematrixSet: "EPSG:2180",
format: "image/jpeg"
}
};
// Helper function to check WMTS capabilities
export async function checkWMTSCapabilities(serviceKey) {
const service = wmtsServices[serviceKey];
if (!service) return null;
try {
const response = await fetch(service.capabilitiesUrl);
const xml = await response.text();
console.log(`WMTS Capabilities for ${serviceKey}:`, xml);
return xml;
} catch (error) {
console.error(`Failed to fetch WMTS capabilities for ${serviceKey}:`, error);
return null;
}
}