aboutsummaryrefslogtreecommitdiffstats
path: root/src/scripts/functionality/sheet-map/index.ts
diff options
context:
space:
mode:
authorArpit Chakladar <arpitchakladar+git@gmail.com>2026-07-13 23:32:26 +0530
committerGitHub <noreply@github.com>2026-07-13 23:32:26 +0530
commitce401d03e75bcbfd1cdfa963954e0807219fb80d (patch)
tree52a813c1705a952312c20c328b00fa845a3453f9 /src/scripts/functionality/sheet-map/index.ts
parent98e7019c61ea0ffe344ef7ce809d38d62254a9fc (diff)
parentdfba7ff6fff7bde33b40a343a2318b35c429b40f (diff)
downloadbanglar-bhumi-utils-ce401d03e75bcbfd1cdfa963954e0807219fb80d.tar.gz
banglar-bhumi-utils-ce401d03e75bcbfd1cdfa963954e0807219fb80d.zip
Merge pull request #6 from arpitchakladar/adding-documentation-comments
Adding documentation comments
Diffstat (limited to 'src/scripts/functionality/sheet-map/index.ts')
-rw-r--r--src/scripts/functionality/sheet-map/index.ts160
1 files changed, 0 insertions, 160 deletions
diff --git a/src/scripts/functionality/sheet-map/index.ts b/src/scripts/functionality/sheet-map/index.ts
deleted file mode 100644
index 71228fe..0000000
--- a/src/scripts/functionality/sheet-map/index.ts
+++ /dev/null
@@ -1,160 +0,0 @@
-import { generateWebPage } from "@/shared/generate-web-page";
-import getDownloadMapPDFPageContent from "@/scripts/functionality/sheet-map/download-map-pdf-page-content.html";
-import getMapPlotPolygonPathElement from "@/scripts/functionality/sheet-map/map-plot-polygon-path-element.html";
-import getMapPlotNumberLabelTextElement from "@/scripts/functionality/sheet-map/map-plot-number-label-text-element.html";
-import getPlotInformationElement from "@/scripts/functionality/sheet-map/plot-information-element.html";
-
-interface PlotPolygon {
- plotArea: number;
- plotno: string;
- polygon: string;
-};
-
-interface PlotNumberLabel {
- plotno: string;
- point: string;
-}
-
-const headerElement = document.querySelector("#headerTable > tbody > tr")!;
-const plotNumberInput = document.querySelector<HTMLInputElement>("#txtPlotNo")!;
-const plotInformation = document.createElement("div") as HTMLDivElement;
-let plotPolygonPathElements = "";
-let plotNumberLabelTextElements = "";
-
-document.body.appendChild(plotInformation);
-
-const createHeaderButton = (text: string) => {
- const buttonContainer = document.createElement("td");
- const button = document.createElement("button");
- button.innerHTML = text;
- button.style.display = "none";
- buttonContainer.appendChild(button);
- headerElement.appendChild(buttonContainer);
- return button;
-};
-
-const setPlotInformation = (plotPolygon: PlotPolygon | null | undefined = null) => {
- plotInformation.innerHTML = plotPolygon ? getPlotInformationElement({
- area: (plotPolygon.plotArea/1000).toFixed(3),
- plotNumber: plotPolygon.plotno
- }) : getPlotInformationElement({
- area: "0.000",
- plotNumber: ""
- });
-};
-
-const downloadPDF = (labelPoints: boolean = true) => {
- const _getMapDetail = (i: number) => {
- const detail = document.querySelector(`#headerTable > tbody > tr > td:nth-child(${i})`)!
- .innerHTML
- .split("[")[1]
- .trim();
- return detail.substr(0, detail.length - 1);
- };
- generateWebPage(
- getDownloadMapPDFPageContent({
- district: _getMapDetail(1),
- block: _getMapDetail(2),
- mouza: _getMapDetail(3),
- mapContent: plotPolygonPathElements + (labelPoints ? plotNumberLabelTextElements : "")
- }),
- "map"
- );
-};
-
-const downloadPDFButton = createHeaderButton("SAVE PDF");
-const downloadPDFNoLabelButton = createHeaderButton("SAVE PDF (NO LABEL)");
-
-downloadPDFButton.addEventListener("click", e => {
- e.preventDefault();
- downloadPDF();
-});
-
-downloadPDFNoLabelButton.addEventListener("click", e => {
- e.preventDefault();
- downloadPDF(false);
-});
-
-setPlotInformation();
-
-(async () => {
- const searchParams = new URLSearchParams(window.location.search);
- const response1 = await fetch(
- "/BanglarBhumi/sheetMap_populateLayerData?lstSheetNo=" + searchParams.get("lstSheetNo"),
- {
- method: "POST"
- });
- const plotPolygonList: PlotPolygon[] = (await response1.json()).features;
- const response2 = await fetch(
- "/BanglarBhumi/sheetMap_populateCentroidData?lstSheetNo=" + searchParams.get("lstSheetNo"),
- {
- method: "POST"
- });
- const plotNumberLabelList: PlotNumberLabel[] = (await response2.json()).features;
- let plotPolygons: { [key: string]: PlotPolygon } = {};
-
- for (const plotPolygon of plotPolygonList) {
- const plotPolygonPoints = plotPolygon.polygon.split("(((")[1].split(")))")[0];
- plotPolygonPathElements += getMapPlotPolygonPathElement({
- polygonVertices: plotPolygonPoints
- });
- }
-
- for (const plotNumberLabel of plotNumberLabelList) {
- const plotNumberLabelPoint = plotNumberLabel.point.split("(")[1].split(")")[0].split(" ");
- plotNumberLabelTextElements += getMapPlotNumberLabelTextElement({
- x: plotNumberLabelPoint[0],
- y: plotNumberLabelPoint[1],
- plotNumber: plotNumberLabel.plotno
- });
- }
-
- downloadPDFButton.style.display = "inherit";
- downloadPDFNoLabelButton.style.display = "inherit";
-
- document.querySelector("#btnSearch")!.addEventListener("click", () => {
- let plotPolygon;
- for (const p of plotPolygonList) {
- if (p.plotno === plotNumberInput.value) {
- plotPolygon = p;
- break;
- }
- }
- setPlotInformation(plotPolygon);
- });
-
- await new Promise<void>((resolve, reject) => {
- const plotElementIdsControl = setInterval(() => {
- let i = 0;
- let plotElements = document.querySelector("#OpenLayers_Layer_Vector_25_vroot")?.children || [];
- if (plotElements.length) {
- clearInterval(plotElementIdsControl);
- for (let i = 0; i < plotElements.length; i++) {
- plotPolygons[plotElements[i].id] = plotPolygonList[i];
- }
- resolve();
- }
- }, 50);
- });
-
- setInterval(() => {
- for (const plotElementId in plotPolygons) {
- const e = document.getElementById(plotElementId);
- if (e) {
- e.removeEventListener("click", handlePlotClick);
- e.addEventListener("click", handlePlotClick);
- }
- }
- }, 300);
-
- const handlePlotClick = (e: MouseEvent) => {
- document.querySelectorAll("path").forEach(e => {
- e.setAttribute("fill", "#ffcc66");
- });
-
- const target = e.target as SVGPathElement;
-
- target.setAttribute("fill", "#8aeeef");
- setPlotInformation(plotPolygons[target.id]);
- };
-})();