quantaroute-geocoding 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -9
- package/dist/client.js +1 -1
- package/dist/digipin-core.d.ts +16 -0
- package/dist/digipin-core.js +124 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +7 -1
- package/dist/location-lookup.js +1 -1
- package/dist/offline.d.ts +0 -2
- package/dist/offline.js +13 -27
- package/dist/security.js +1 -1
- package/package.json +4 -11
package/README.md
CHANGED
|
@@ -33,11 +33,13 @@ A **unique** Node.js/TypeScript library for geocoding addresses to DigiPin codes
|
|
|
33
33
|
npm install quantaroute-geocoding
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
**What's included:**
|
|
37
|
+
- ✅ Official India Post DigiPin algorithm (vendored, no external dependencies)
|
|
38
|
+
- ✅ Complete offline DigiPin processing
|
|
39
|
+
- ✅ Location Lookup API client
|
|
40
|
+
- ✅ Geocoding & Reverse Geocoding
|
|
41
|
+
- ✅ Enterprise-grade security (RASP, code obfuscation)
|
|
42
|
+
- ✅ Full TypeScript support
|
|
41
43
|
|
|
42
44
|
## Quick Start
|
|
43
45
|
|
|
@@ -100,29 +102,78 @@ console.log(`House Name: ${reverseResult.addressComponents.amenity || reverseRes
|
|
|
100
102
|
|
|
101
103
|
### Offline Processing
|
|
102
104
|
|
|
105
|
+
**NEW: Official India Post DigiPin Algorithm Vendored!** 🎉
|
|
106
|
+
|
|
107
|
+
`quantaroute-geocoding` now includes the **official DigiPin algorithm** directly - no external dependencies needed!
|
|
108
|
+
|
|
109
|
+
#### Using OfflineProcessor Class
|
|
110
|
+
|
|
103
111
|
```typescript
|
|
104
112
|
import { OfflineProcessor } from 'quantaroute-geocoding';
|
|
105
113
|
|
|
106
|
-
// Initialize offline processor
|
|
114
|
+
// Initialize offline processor (no dependencies needed!)
|
|
107
115
|
const processor = new OfflineProcessor();
|
|
108
116
|
|
|
109
|
-
// Convert coordinates to DigiPin (offline)
|
|
117
|
+
// Convert coordinates to DigiPin (offline, 100% accurate)
|
|
110
118
|
const offlineResult = processor.coordinatesToDigiPin(28.6139, 77.2090);
|
|
111
|
-
console.log(`DigiPin: ${offlineResult.digipin}`);
|
|
119
|
+
console.log(`DigiPin: ${offlineResult.digipin}`); // "39J-438-TJC7"
|
|
120
|
+
console.log(`Source: ${offlineResult.source}`); // "offline"
|
|
112
121
|
|
|
113
122
|
// Convert DigiPin to coordinates (offline)
|
|
114
123
|
const coordsResult = processor.digiPinToCoordinates("39J-438-TJC7");
|
|
115
|
-
console.log(`
|
|
124
|
+
console.log(`Latitude: ${coordsResult.coordinates.latitude}`);
|
|
125
|
+
console.log(`Longitude: ${coordsResult.coordinates.longitude}`);
|
|
116
126
|
|
|
117
127
|
// Validate DigiPin format
|
|
118
128
|
const validation = processor.validateDigiPin("39J-438-TJC7");
|
|
119
129
|
console.log(`Valid: ${validation.isValid}`);
|
|
130
|
+
if (!validation.isValid) {
|
|
131
|
+
console.log(`Errors: ${validation.errors.join(', ')}`);
|
|
132
|
+
}
|
|
120
133
|
|
|
121
134
|
// Calculate distance between coordinates
|
|
122
135
|
const distance = processor.calculateDistance(28.6139, 77.2090, 28.6150, 77.2100);
|
|
123
136
|
console.log(`Distance: ${distance.toFixed(2)} km`);
|
|
124
137
|
```
|
|
125
138
|
|
|
139
|
+
#### Using Core DigiPin Functions Directly
|
|
140
|
+
|
|
141
|
+
For simple use cases, you can use the core functions directly:
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
import {
|
|
145
|
+
getDigiPin,
|
|
146
|
+
getLatLngFromDigiPin,
|
|
147
|
+
isValidDigiPinFormat,
|
|
148
|
+
getBounds
|
|
149
|
+
} from 'quantaroute-geocoding';
|
|
150
|
+
|
|
151
|
+
// Convert coordinates to DigiPin
|
|
152
|
+
const digipin = getDigiPin(28.6139, 77.2090);
|
|
153
|
+
console.log('DigiPin:', digipin); // "39J-438-TJC7"
|
|
154
|
+
|
|
155
|
+
// Convert DigiPin to coordinates
|
|
156
|
+
const coords = getLatLngFromDigiPin("39J-438-TJC7");
|
|
157
|
+
console.log('Latitude:', coords.latitude); // "28.613900"
|
|
158
|
+
console.log('Longitude:', coords.longitude); // "77.209000"
|
|
159
|
+
|
|
160
|
+
// Validate DigiPin
|
|
161
|
+
const isValid = isValidDigiPinFormat("39J-438-TJC7");
|
|
162
|
+
console.log('Valid:', isValid); // true
|
|
163
|
+
|
|
164
|
+
// Get India bounds covered by DigiPin
|
|
165
|
+
const bounds = getBounds();
|
|
166
|
+
console.log('Bounds:', bounds);
|
|
167
|
+
// { minLat: 2.5, maxLat: 38.5, minLon: 63.5, maxLon: 99.5 }
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
**Why This Matters:**
|
|
171
|
+
- ✅ **Zero Dependencies**: No need to install separate `digipin` packages
|
|
172
|
+
- ✅ **100% Offline**: Works without internet or API calls
|
|
173
|
+
- ✅ **Official Algorithm**: Same code as India Post's official implementation
|
|
174
|
+
- ✅ **Apache 2.0 License**: Open source from Government of India
|
|
175
|
+
- ✅ **Type-Safe**: Full TypeScript definitions included
|
|
176
|
+
|
|
126
177
|
### 🔔 Webhook Management
|
|
127
178
|
|
|
128
179
|
```typescript
|