Dev.to WebDev 🛠 Dev 👁 2 📖 1 min read

Convert Indian Land Units (Sq Ft, Cents, Guntas, Acres) in a Few Lines of JS

`If you build anything for Indian real estate, you'll run into land units fast. Sellers in Tamil Nadu often quote cents. Buyers in Karnataka think in guntas. Brochures use sq ft. Here's a tiny converter that keeps them a

`If you build anything for Indian real estate, you'll run into land units fast. Sellers in Tamil Nadu often quote cents. Buyers in Karnataka think in guntas. Brochures use sq ft. Here's a tiny converter that keeps them all in sync.

The conversion table

`js
const SQFT_PER = {
sqft: 1,
sqm: 10.7639,
sqyd: 9,
cent: 435.6,
gunta: 1089,
acre: 43560,
};

function convertLand(value, from, to) {
if (!(from in SQFT_PER) || !(to in SQFT_PER)) throw new Error("Unknown unit");
return (value * SQFT_PER[from]) / SQFT_PER[to];
}

console.log(convertLand(10000, "sqft", "cent").toFixed(1)); // 23.0
console.log(convertLand(10000, "sqft", "gunta").toFixed(2)); // 9.18
console.log(convertLand(10, "gunta", "sqft")); // 10890
console.log(convertLand(25, "cent", "sqft")); // 10890
`

A useful surprise

10 guntas and 25 cents are both 10,890 sq ft. The units sound completely different, but the land is the same size. A converter like this saves buyers from comparing plots that only look different on paper.

Show everything at once

js
function allUnits(sqft) {
return Object.fromEntries(
Object.keys(SQFT_PER).map((u) => [u, +convertLand(sqft, "sqft", u).toFixed(2)])
);
}
console.log(allUnits(10000));

Where it helps

  • Listing pages that show every unit side by side
  • Comparison tools across projects
  • Calculators for price per unit

Why a quarter acre (about 23 cents) is such a popular size: answered here. For one example of a small layout in this size range, see why one project chose only 33 plots in Phase 1.

If you work with plot layouts, you might also like this tiny edge plot finder in JS and GeoJSON.`


``

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.