@bd-geo-data/bd-location-data 1.0.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 +156 -0
- package/data.json +3217 -0
- package/index.js +133 -0
- package/package.json +21 -0
package/index.js
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
const data = require('./data.json');
|
|
2
|
+
|
|
3
|
+
// সব বিভাগ পান
|
|
4
|
+
function allDivisions(lang = 'en') {
|
|
5
|
+
return data.divisions.map(d => lang === 'bn' ? d.bn : d.name);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// বিভাগের সব জেলা পান
|
|
9
|
+
function districtsOf(divisionName, lang = 'en') {
|
|
10
|
+
const division = data.divisions.find(
|
|
11
|
+
d => d.name.toLowerCase() === divisionName.toLowerCase() || d.bn === divisionName
|
|
12
|
+
);
|
|
13
|
+
if (!division) return [];
|
|
14
|
+
return division.districts.map(d => lang === 'bn' ? d.bn : d.name);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// জেলার সব থানা পান
|
|
18
|
+
function thanasOf(districtName, lang = 'en') {
|
|
19
|
+
for (const division of data.divisions) {
|
|
20
|
+
const district = division.districts.find(
|
|
21
|
+
d => d.name.toLowerCase() === districtName.toLowerCase() || d.bn === districtName
|
|
22
|
+
);
|
|
23
|
+
if (district) return district.thana.map(t => lang === 'bn' ? t.bn : t.name);
|
|
24
|
+
}
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// জেলার থানা + পোস্টকোড সহ পান
|
|
29
|
+
function thanasWithPostcodeOf(districtName, lang = 'en') {
|
|
30
|
+
for (const division of data.divisions) {
|
|
31
|
+
const district = division.districts.find(
|
|
32
|
+
d => d.name.toLowerCase() === districtName.toLowerCase() || d.bn === districtName
|
|
33
|
+
);
|
|
34
|
+
if (district) {
|
|
35
|
+
return district.thana.map(t => ({
|
|
36
|
+
name: lang === 'bn' ? t.bn : t.name,
|
|
37
|
+
postcode: t.postcode
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// পোস্টকোড দিয়ে থানা খোঁজা
|
|
45
|
+
function findByPostcode(postcode) {
|
|
46
|
+
const results = [];
|
|
47
|
+
for (const division of data.divisions) {
|
|
48
|
+
for (const district of division.districts) {
|
|
49
|
+
for (const thana of district.thana) {
|
|
50
|
+
if (thana.postcode === postcode) {
|
|
51
|
+
results.push({
|
|
52
|
+
division: division.name, divisionBn: division.bn,
|
|
53
|
+
district: district.name, districtBn: district.bn,
|
|
54
|
+
thana: thana.name, thanaBn: thana.bn,
|
|
55
|
+
postcode: thana.postcode
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return results;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// সব জেলা পান
|
|
65
|
+
function allDistricts(lang = 'en') {
|
|
66
|
+
return data.divisions.flatMap(d => d.districts.map(dist => lang === 'bn' ? dist.bn : dist.name));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// সব থানা পান
|
|
70
|
+
function allThanas(lang = 'en') {
|
|
71
|
+
return data.divisions.flatMap(d =>
|
|
72
|
+
d.districts.flatMap(dist => dist.thana.map(t => lang === 'bn' ? t.bn : t.name))
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// সব থানা পোস্টকোড সহ
|
|
77
|
+
function allThanasWithPostcode() {
|
|
78
|
+
return data.divisions.flatMap(d =>
|
|
79
|
+
d.districts.flatMap(dist =>
|
|
80
|
+
dist.thana.map(t => ({
|
|
81
|
+
division: d.name, divisionBn: d.bn,
|
|
82
|
+
district: dist.name, districtBn: dist.bn,
|
|
83
|
+
thana: t.name, thanaBn: t.bn,
|
|
84
|
+
postcode: t.postcode
|
|
85
|
+
}))
|
|
86
|
+
)
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// সম্পূর্ণ ডেটা পান
|
|
91
|
+
function getAllData() {
|
|
92
|
+
return data;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// নাম দিয়ে খোঁজা
|
|
96
|
+
function search(query) {
|
|
97
|
+
const results = [];
|
|
98
|
+
const q = query.toLowerCase();
|
|
99
|
+
for (const division of data.divisions) {
|
|
100
|
+
if (division.name.toLowerCase().includes(q) || division.bn.includes(query)) {
|
|
101
|
+
results.push({ name: division.name, bn: division.bn, type: 'division' });
|
|
102
|
+
}
|
|
103
|
+
for (const district of division.districts) {
|
|
104
|
+
if (district.name.toLowerCase().includes(q) || district.bn.includes(query)) {
|
|
105
|
+
results.push({ name: district.name, bn: district.bn, type: 'district', division: division.name, divisionBn: division.bn });
|
|
106
|
+
}
|
|
107
|
+
for (const thana of district.thana) {
|
|
108
|
+
if (thana.name.toLowerCase().includes(q) || thana.bn.includes(query)) {
|
|
109
|
+
results.push({
|
|
110
|
+
name: thana.name, bn: thana.bn, type: 'thana',
|
|
111
|
+
postcode: thana.postcode,
|
|
112
|
+
district: district.name, districtBn: district.bn,
|
|
113
|
+
division: division.name, divisionBn: division.bn
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return results;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
module.exports = {
|
|
123
|
+
allDivisions,
|
|
124
|
+
allDistricts,
|
|
125
|
+
allThanas,
|
|
126
|
+
allThanasWithPostcode,
|
|
127
|
+
districtsOf,
|
|
128
|
+
thanasOf,
|
|
129
|
+
thanasWithPostcodeOf,
|
|
130
|
+
findByPostcode,
|
|
131
|
+
getAllData,
|
|
132
|
+
search
|
|
133
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bd-geo-data/bd-location-data",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "বাংলাদেশের সকল বিভাগ, জেলা ও থানার তথ্য (ইংরেজি ও বাংলায়) | Bangladesh divisions, districts, and thanas in English and Bangla",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"bangladesh",
|
|
11
|
+
"division",
|
|
12
|
+
"district",
|
|
13
|
+
"thana",
|
|
14
|
+
"upazila",
|
|
15
|
+
"bangla",
|
|
16
|
+
"location",
|
|
17
|
+
"bd"
|
|
18
|
+
],
|
|
19
|
+
"author": "Creative-Md-Arif",
|
|
20
|
+
"license": "MIT"
|
|
21
|
+
}
|