UNPKG

digipinjs

Version:

A comprehensive TypeScript library for encoding and decoding Indian geographic coordinates into DIGIPIN format (Indian Postal Digital PIN system). Features CLI tools, caching, batch processing, and Express middleware for seamless integration.

27 lines (26 loc) 828 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.toGeoJson = toGeoJson; const core_1 = require("./core"); const util_1 = require("./util"); /** * Convert a DIGIPIN to a GeoJSON Point Feature. * @param pin The DIGIPIN string. * @param properties Optional additional properties for the feature. * @param options Decode options (caching). */ function toGeoJson(pin, properties = {}, options = {}) { const normalized = (0, util_1.normalizeDigiPin)(pin); const { latitude, longitude } = (0, core_1.getLatLngFromDigiPin)(normalized, options); return { type: 'Feature', geometry: { type: 'Point', coordinates: [longitude, latitude], }, properties: { ...properties, pin: normalized, }, }; }