feat: add Geoportal link for project coordinates with EPSG:2180 projection

This commit is contained in:
2025-11-05 11:21:00 +01:00
parent cc242d4e10
commit eec0c0a281

View File

@@ -19,6 +19,7 @@ import ProjectAssigneeDropdown from "@/components/ProjectAssigneeDropdown";
import ClientProjectMap from "@/components/ui/ClientProjectMap"; import ClientProjectMap from "@/components/ui/ClientProjectMap";
import FileUploadBox from "@/components/FileUploadBox"; import FileUploadBox from "@/components/FileUploadBox";
import FileItem from "@/components/FileItem"; import FileItem from "@/components/FileItem";
import proj4 from "proj4";
export default function ProjectViewPage() { export default function ProjectViewPage() {
const params = useParams(); const params = useParams();
@@ -467,6 +468,41 @@ export default function ProjectViewPage() {
/> />
</svg> </svg>
</a> </a>
<a
href={(() => {
// Define EPSG:2180 projection (Poland CS92)
proj4.defs("EPSG:2180", "+proj=tmerc +lat_0=0 +lon_0=19 +k=0.9993 +x_0=500000 +y_0=-5300000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs");
const [lat, lng] = project.coordinates.split(',').map(c => parseFloat(c.trim()));
// Convert WGS84 to EPSG:2180
const [x, y] = proj4('EPSG:4326', 'EPSG:2180', [lng, lat]);
// Create bbox with ~100m offset in each direction
const offset = 100;
const bbox = `${x - offset},${y - offset},${x + offset},${y + offset}`;
return `https://mapy.geoportal.gov.pl/imap/Imgp_2.html?gpmap=gp0&bbox=${bbox}&variant=KATASTER`;
})()}
target="_blank"
rel="noopener noreferrer"
className="text-green-600 hover:text-green-800 transition-colors"
title="Otwórz w Geoportal"
>
<svg
className="w-5 h-5"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M9 20l-5.447-2.724A1 1 0 013 16.382V5.618a1 1 0 011.447-.894L9 7m0 13l6-3m-6 3V7m6 10l4.553 2.276A1 1 0 0021 18.382V7.618a1 1 0 00-1.447-.894L15 4m0 13V4m0 0L9 7"
/>
</svg>
</a>
</div> </div>
</div> </div>
)} {project.notes && ( )} {project.notes && (