Skip to content

Commit 3955061

Browse files
Update README.md (#104)
1 parent 6e2269a commit 3955061

File tree

1 file changed

+30
-19
lines changed

1 file changed

+30
-19
lines changed

README.md

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![PlatformIO](https://img.shields.io/badge/PlatformIO-Compatible-green?logo=platformio)](https://registry.platformio.org/libraries/celliesprojects/openstreetmap-esp32)
77
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/0961fc2320cd495a9411eb391d5791ca)](https://app.codacy.com/gh/CelliesProjects/OpenStreetMap-esp32/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
88

9-
This library provides a [OpenStreetMap](https://www.openstreetmap.org/) (OSM) map fetching and tile caching system for ESP32-based devices.
9+
This PlatformIO library provides a [OpenStreetMap](https://www.openstreetmap.org/) (OSM) map fetching and tile caching system for ESP32-based devices.
1010
Under the hood it uses [LovyanGFX](https://github.com/lovyan03/LovyanGFX) and [PNGdec](https://github.com/bitbank2/PNGdec) to do the heavy lifting.
1111

1212
[![map](https://github.com/user-attachments/assets/39a7f287-c59d-4365-888a-d4c3f77a1dd1 "Click to visit OpenStreetMap.org")](https://www.openstreetmap.org/)
@@ -21,9 +21,8 @@ OSM tiles are quite large at 128kB or insane large at 512kB per tile, so psram i
2121

2222
### Multiple tile formats and providers are supported
2323

24-
Different tile formats and multiple tile providers?
25-
Swap tile provider and tile format at runtime?
26-
This library can do that and is very easy to configure and use.
24+
You can switch provider and tile format at runtime, or set up a different default tile provider if you want.
25+
This library can do it all and is very easy to configure and use.
2726

2827
## How to use
2928

@@ -47,7 +46,19 @@ lib_deps =
4746
bitbank2/PNGdec@^1.1.3
4847
```
4948

50-
## Functions
49+
## Functions
50+
51+
### Get the minimum zoom level
52+
53+
```c++
54+
int getMinZoom()
55+
```
56+
57+
### Get the maximum zoom level
58+
59+
```c++
60+
int getMaxZoom()
61+
```
5162

5263
### Set map size
5364

@@ -56,6 +67,7 @@ void setSize(uint16_t w, uint16_t h)
5667
```
5768
5869
- If no size is set a 320px by 240px map will be returned.
70+
- The tile cache might need resizing if the size is increased.
5971
6072
### Get the number of tiles needed to cache a map
6173
@@ -71,15 +83,15 @@ This returns the number of tiles required to cache the given map size.
7183
bool resizeTilesCache(uint16_t numberOfTiles)
7284
```
7385
74-
- If the cache is not resized before the first call to `fetchMap`, the cache will be auto initialized.
86+
- If the cache is not resized before the first call to `fetchMap`, the cache will be auto initialized with the amount of tiles returned by `tilesNeeded(w, h)` where `w` and `h` are the current map width and height.
7587
- The cache content is cleared before resizing.
7688
- Each 256px tile allocates **128kB** psram.
7789
- Each 512px tile allocates **512kB** psram.
7890
7991
**Don't over-allocate**
8092
When resizing the cache, keep in mind that the map sprite also uses psram.
8193
The PNG decoders -~50kB for each core- also live in psram.
82-
Use the above `tilesNeeded` function to calculate a safe and sane cache size.
94+
Use the above `tilesNeeded` function to calculate a safe and sane cache size if you change the map size.
8395
8496
### Fetch a map
8597
@@ -91,12 +103,14 @@ bool fetchMap(LGFX_Sprite &map, double longitude, double latitude, uint8_t zoom)
91103
- Overflowing `latitude` are clamped to +-90°.
92104
- Valid range for the `zoom` level is from `getMinZoom()` to `getMaxZoom()`.
93105

94-
### Free the memory used by the tile cache
106+
### Free the psram memory used by the tile cache
95107

96108
```c++
97109
void freeTilesCache()
98110
```
99111

112+
- Does **not** free the PNG decoder(s).
113+
100114
### Switch to a different tile provider
101115

102116
```c++
@@ -118,27 +132,24 @@ Example use:
118132
const int numberOfProviders = OSM_TILEPROVIDERS;
119133
```
120134

121-
In the default setup there is only one provider defined.
135+
**Note:** In the default setup there is only one provider defined.
136+
122137
See `src/TileProvider.hpp` for example setups for [https://www.thunderforest.com/](https://www.thunderforest.com/) that only require an API key and commenting/uncommenting 2 lines.
123138

124139
Registration and a hobby tier are available for free.
125140

126-
### Get the provider name
141+
### Adding tile providers
127142

128-
```c++
129-
char *getProviderName()
130-
```
143+
Other providers should work if a new definition is created in `src/TileProvider.hpp`.
144+
Check out the existing templates to see how this works.
131145

132-
### Get the minimum zoom level
146+
If you encounter a problem or want to request support for a new provider, please check the [issue tracker](../../issues) for existing reports or [open an issue](../../issues/new).
133147

134-
```c++
135-
int getMinZoom()
136-
```
137148

138-
### Get the maximum zoom level
149+
### Get the provider name
139150

140151
```c++
141-
int getMaxZoom()
152+
char *getProviderName()
142153
```
143154

144155
## Example code

0 commit comments

Comments
 (0)