@tpzdsp/next-toolkit 1.2.5 → 1.2.6
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/package.json +1 -1
- package/src/map/osOpenNamesSearch.ts +29 -12
package/package.json
CHANGED
|
@@ -4,6 +4,13 @@ export type SearchOption = {
|
|
|
4
4
|
url?: string;
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
+
export type SearchResult = {
|
|
8
|
+
lon: number;
|
|
9
|
+
lat: number;
|
|
10
|
+
address?: string;
|
|
11
|
+
bbox?: number[];
|
|
12
|
+
};
|
|
13
|
+
|
|
7
14
|
/**
|
|
8
15
|
* Custom provider for OS OpenNames search.
|
|
9
16
|
*/
|
|
@@ -37,18 +44,28 @@ export const osOpenNamesSearch = (options?: SearchOption) => {
|
|
|
37
44
|
return [];
|
|
38
45
|
}
|
|
39
46
|
|
|
40
|
-
return features
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
return features
|
|
48
|
+
.map((feature) => {
|
|
49
|
+
if (feature.geometry.type === 'Point') {
|
|
50
|
+
const result: SearchResult = {
|
|
51
|
+
lon: feature.geometry.coordinates[0],
|
|
52
|
+
lat: feature.geometry.coordinates[1],
|
|
53
|
+
address: feature?.properties?.address,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// Only include bbox if it's not empty
|
|
57
|
+
if (feature.bbox && Array.isArray(feature.bbox) && feature.bbox.length > 0) {
|
|
58
|
+
result.bbox = feature.bbox;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
console.error('Geometry type is not Point');
|
|
65
|
+
|
|
66
|
+
return null;
|
|
67
|
+
})
|
|
68
|
+
.filter(Boolean);
|
|
52
69
|
},
|
|
53
70
|
};
|
|
54
71
|
};
|