Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
@opencollabnexus/geolocation
Advanced tools
geocoding and reverse geocoding without using google maps api based on a custom data dump
A TypeScript package for geocoding and reverse geocoding functionalities, allowing you to retrieve location details based on addresses or coordinates. This package works completely offline and doesn't make calls to any third-party services.
To install the GeoLocation package, use npm:
npm install @opencollabnexus/geolocation
Import the package and create an instance of the GeoLocationDump class, passing the pincode dump as a parameter. If no parameter is provided, the package will use a default pincode dump containing all Indian pincodes.
import { GeoLocationFactory } from 'geolocation-package';
// Create an instance of the GeoLocationDump class
const geoLocation = GeoLocationFactory(pincodeDump);
To geocode an incomplete address, use the geocode method. It takes an address parameter and returns a list of possible matches containing location details.
const searchParam = 'Your incomplete address';
const searchResults = geoLocation.geocode(searchParam);
console.log(searchResults);
To perform reverse geocoding, use the reverseGeocode method. Pass the latitude and longitude of a location as parameters, and it will return an object containing detailed information about the closest match, including the distance between the found result and the provided coordinates.
const latitude = 9.123456;
const longitude = 92.654321;
const reverseGeocodedResult = geoLocation.reverseGeocode(latitude, longitude);
console.log(reverseGeocodedResult);
The GeoLocation package requires a pincode dump to function correctly. The pincode dump is an array of objects containing location details, in the following format:
[
{
"state_name": "Andaman and Nicobar Islands",
"district_name": "Nicobar",
"taluk": "Carnicobar",
"pincode": 744301,
"country": "India",
"pincode_lat": 9.1573175,
"pincode_lon": 92.7580701
},
...
]
If you have a large pincode dump, it is recommended to divide the dump based on criteria such as country or state. By segmenting the pincode dump, you can initialize multiple instances of the GeoLocationDump class and refer to the appropriate instance for finding pincode details of a specific country or state.
import { GeoLocationFactory } from 'geolocation-package';
// Initialize multiple instances with segmented pincode dumps
const geoLocationIndia = GeoLocationFactory(pincodeDumpIndia);
const geoLocationUSA = GeoLocationFactory(pincodeDumpUSA);
// Initialize more instances for other countries or states if needed
// Use the appropriate instance for geocoding or reverse geocoding
const searchResultsIndia = geoLocationIndia.geocode('Address in India');
const searchResultsUSA = geoLocationUSA.geocode('Address in USA');
// Perform reverse geocoding using the appropriate instance
const reverseGeocodedResultIndia = geoLocationIndia.reverseGeocode(latitude, longitude);
const reverseGeocodedResultUSA = geoLocationUSA.reverseGeocode(latitude, longitude);
In the future, the package aims to include built-in segmentation functionality to handle large pincode dumps more efficiently.
This project is licensed under the MIT License.
FAQs
geocoding and reverse geocoding without using google maps api based on a custom data dump
The npm package @opencollabnexus/geolocation receives a total of 20 weekly downloads. As such, @opencollabnexus/geolocation popularity was classified as not popular.
We found that @opencollabnexus/geolocation demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.