@pretto/places 0.22.0 → 0.23.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.js +16 -3
- package/dist/module.js +16 -3
- package/dist/municipalitySearch.d.ts +7 -0
- package/dist/municipalitySearch.d.ts.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -48,7 +48,7 @@ const convertFirstLetterToUpperCase = (str) => {
|
|
48
48
|
};
|
49
49
|
const getUri = (search, departmentOnly) => {
|
50
50
|
const PLACES_API = 'https://geo.api.gouv.fr';
|
51
|
-
const QUERY_FIELDS = `boost=population&fields=departement${departmentOnly ? ',centre' : ',codesPostaux,centre'}`;
|
51
|
+
const QUERY_FIELDS = `boost=population&fields=departement${departmentOnly ? ',centre,contour' : ',codesPostaux,centre,contour'}`;
|
52
52
|
const formatedSearch = encodeURIComponent(search);
|
53
53
|
const uri = {
|
54
54
|
departments: `${PLACES_API}/departements/${formatedSearch}/communes?${QUERY_FIELDS}`,
|
@@ -79,6 +79,7 @@ const responseFormat = (places, country, search, departmentOnly) => {
|
|
79
79
|
center,
|
80
80
|
city: place.nom,
|
81
81
|
country,
|
82
|
+
outline: place.contour.coordinates[0].map(([longitude, latitude]) => ({ longitude, latitude })),
|
82
83
|
zipcode: ((_b = place.departement) === null || _b === void 0 ? void 0 : _b.code) || '',
|
83
84
|
},
|
84
85
|
};
|
@@ -91,7 +92,13 @@ const responseFormat = (places, country, search, departmentOnly) => {
|
|
91
92
|
return [
|
92
93
|
{
|
93
94
|
label: `${places[0].nom} (${search})`,
|
94
|
-
value: {
|
95
|
+
value: {
|
96
|
+
center,
|
97
|
+
city: places[0].nom,
|
98
|
+
country,
|
99
|
+
outline: places[0].contour.coordinates[0].map(([longitude, latitude]) => ({ longitude, latitude })),
|
100
|
+
zipcode: search,
|
101
|
+
},
|
95
102
|
},
|
96
103
|
];
|
97
104
|
}
|
@@ -104,7 +111,13 @@ const responseFormat = (places, country, search, departmentOnly) => {
|
|
104
111
|
...acc,
|
105
112
|
{
|
106
113
|
label: `${place.nom} (${curr})`,
|
107
|
-
value: {
|
114
|
+
value: {
|
115
|
+
center,
|
116
|
+
city: place.nom,
|
117
|
+
country,
|
118
|
+
outline: place.contour.coordinates[0].map(([longitude, latitude]) => ({ longitude, latitude })),
|
119
|
+
zipcode: curr,
|
120
|
+
},
|
108
121
|
},
|
109
122
|
];
|
110
123
|
}, []);
|
package/dist/module.js
CHANGED
@@ -38,7 +38,7 @@ const convertFirstLetterToUpperCase = (str) => {
|
|
38
38
|
};
|
39
39
|
const getUri = (search, departmentOnly) => {
|
40
40
|
const PLACES_API = 'https://geo.api.gouv.fr';
|
41
|
-
const QUERY_FIELDS = `boost=population&fields=departement${departmentOnly ? ',centre' : ',codesPostaux,centre'}`;
|
41
|
+
const QUERY_FIELDS = `boost=population&fields=departement${departmentOnly ? ',centre,contour' : ',codesPostaux,centre,contour'}`;
|
42
42
|
const formatedSearch = encodeURIComponent(search);
|
43
43
|
const uri = {
|
44
44
|
departments: `${PLACES_API}/departements/${formatedSearch}/communes?${QUERY_FIELDS}`,
|
@@ -69,6 +69,7 @@ const responseFormat = (places, country, search, departmentOnly) => {
|
|
69
69
|
center,
|
70
70
|
city: place.nom,
|
71
71
|
country,
|
72
|
+
outline: place.contour.coordinates[0].map(([longitude, latitude]) => ({ longitude, latitude })),
|
72
73
|
zipcode: ((_b = place.departement) === null || _b === void 0 ? void 0 : _b.code) || '',
|
73
74
|
},
|
74
75
|
};
|
@@ -81,7 +82,13 @@ const responseFormat = (places, country, search, departmentOnly) => {
|
|
81
82
|
return [
|
82
83
|
{
|
83
84
|
label: `${places[0].nom} (${search})`,
|
84
|
-
value: {
|
85
|
+
value: {
|
86
|
+
center,
|
87
|
+
city: places[0].nom,
|
88
|
+
country,
|
89
|
+
outline: places[0].contour.coordinates[0].map(([longitude, latitude]) => ({ longitude, latitude })),
|
90
|
+
zipcode: search,
|
91
|
+
},
|
85
92
|
},
|
86
93
|
];
|
87
94
|
}
|
@@ -94,7 +101,13 @@ const responseFormat = (places, country, search, departmentOnly) => {
|
|
94
101
|
...acc,
|
95
102
|
{
|
96
103
|
label: `${place.nom} (${curr})`,
|
97
|
-
value: {
|
104
|
+
value: {
|
105
|
+
center,
|
106
|
+
city: place.nom,
|
107
|
+
country,
|
108
|
+
outline: place.contour.coordinates[0].map(([longitude, latitude]) => ({ longitude, latitude })),
|
109
|
+
zipcode: curr,
|
110
|
+
},
|
98
111
|
},
|
99
112
|
];
|
100
113
|
}, []);
|
@@ -7,6 +7,10 @@ export interface MunicipalitySearchResult {
|
|
7
7
|
} | null;
|
8
8
|
city: string;
|
9
9
|
country: string;
|
10
|
+
outline: Array<{
|
11
|
+
latitude: number;
|
12
|
+
longitude: number;
|
13
|
+
}>;
|
10
14
|
zipcode: string;
|
11
15
|
};
|
12
16
|
}
|
@@ -21,6 +25,9 @@ export interface MunicipalityApiResult {
|
|
21
25
|
nom: string;
|
22
26
|
};
|
23
27
|
codesPostaux: string[];
|
28
|
+
contour: {
|
29
|
+
coordinates: Array<Array<Array<number>>>;
|
30
|
+
};
|
24
31
|
}
|
25
32
|
interface Options {
|
26
33
|
country?: string;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"municipalitySearch.d.ts","sourceRoot":"","sources":["../src/municipalitySearch.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE;QACL,MAAM,EAAE;YAAE,QAAQ,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAE,GAAG,IAAI,CAAA;QACtD,IAAI,EAAE,MAAM,CAAA;QACZ,OAAO,EAAE,MAAM,CAAA;QACf,OAAO,EAAE,MAAM,CAAA;KAChB,CAAA;CACF;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE;QAAE,WAAW,EAAE,MAAM,EAAE,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CA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MAAM,EACd,OAAO,CAAC,EAAE,OAAO,EACjB,aAAa,CAAC,EAAE,MAAM,KACnB,OAAO,CAAC,wBAAwB,EAAE,GAAG,MAAM,CAAC,CAAA;AAEjD,aAAK,kBAAkB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,wBAAwB,EAAE,GAAG,MAAM,CAAC,CAAA;AA6E7G,eAAO,MAAM,OAAO,EAAE,kBAoCrB,CAAA;AAID,eAAO,MAAM,GAAG,EAAE,2BAQjB,CAAA"}
|
package/dist/utils.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,6BAA6B,QAAS,MAAM,WAMxD,CAAA;AAED,eAAO,MAAM,MAAM,WAAY,MAAM,kBAAkB,OAAO,
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,6BAA6B,QAAS,MAAM,WAMxD,CAAA;AAED,eAAO,MAAM,MAAM,WAAY,MAAM,kBAAkB,OAAO,WAe7D,CAAA"}
|