Skip to main content

libshumate/auto/
raster_renderer.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files)
4// DO NOT EDIT
5
6use crate::{DataSource, MapProjection, MapSource, ffi};
7use glib::{prelude::*, translate::*};
8
9glib::wrapper! {
10    ///
11    ///
12    /// ## Properties
13    ///
14    ///
15    /// #### `data-source`
16    ///  The data source that provides image tiles to display. In most cases,
17    /// a [`TileDownloader`][crate::TileDownloader] is sufficient.
18    ///
19    /// Readable | Writable | Construct Only
20    /// <details><summary><h4>MapSource</h4></summary>
21    ///
22    ///
23    /// #### `id`
24    ///  The id of the map source
25    ///
26    /// Readable | Writable | Construct
27    ///
28    ///
29    /// #### `license`
30    ///  The usage license of the map source
31    ///
32    /// Readable | Writable | Construct
33    ///
34    ///
35    /// #### `license-uri`
36    ///  The usage license's uri for more information
37    ///
38    /// Readable | Writable | Construct
39    ///
40    ///
41    /// #### `max-zoom-level`
42    ///  The maximum zoom level
43    ///
44    /// Readable | Writable | Construct
45    ///
46    ///
47    /// #### `min-zoom-level`
48    ///  The minimum zoom level
49    ///
50    /// Readable | Writable | Construct
51    ///
52    ///
53    /// #### `name`
54    ///  The name of the map source
55    ///
56    /// Readable | Writable | Construct
57    ///
58    ///
59    /// #### `projection`
60    ///  The map projection of the map source
61    ///
62    /// Readable | Writable | Construct
63    ///
64    ///
65    /// #### `tile-size`
66    ///  The tile size of the map source
67    ///
68    /// Readable | Writable | Construct
69    /// </details>
70    ///
71    /// # Implements
72    ///
73    /// [`MapSourceExt`][trait@crate::prelude::MapSourceExt], [`trait@glib::ObjectExt`]
74    #[doc(alias = "ShumateRasterRenderer")]
75    pub struct RasterRenderer(Object<ffi::ShumateRasterRenderer, ffi::ShumateRasterRendererClass>) @extends MapSource;
76
77    match fn {
78        type_ => || ffi::shumate_raster_renderer_get_type(),
79    }
80}
81
82impl RasterRenderer {
83    /// Creates a new [`RasterRenderer`][crate::RasterRenderer] that uses the given data source.
84    /// ## `data_source`
85    /// a [`DataSource`][crate::DataSource] to provide tile image data
86    ///
87    /// # Returns
88    ///
89    /// a newly constructed [`RasterRenderer`][crate::RasterRenderer]
90    #[doc(alias = "shumate_raster_renderer_new")]
91    pub fn new(data_source: &impl IsA<DataSource>) -> RasterRenderer {
92        skip_assert_initialized!();
93        unsafe {
94            from_glib_full(ffi::shumate_raster_renderer_new(
95                data_source.as_ref().to_glib_none().0,
96            ))
97        }
98    }
99
100    /// Creates a new [`RasterRenderer`][crate::RasterRenderer] that fetches tiles from the given URL
101    /// using a [`TileDownloader`][crate::TileDownloader] data source.
102    ///
103    /// Equivalent to:
104    ///
105    /// **⚠️ The following code is in c ⚠️**
106    ///
107    /// ```c
108    /// g_autoptr(ShumateTileDownloader) source = shumate_tile_downloader_new (url_template);
109    /// ShumateRasterRenderer *renderer = shumate_raster_renderer_new (source);
110    /// ```
111    /// ## `url_template`
112    /// a URL template to fetch tiles from
113    ///
114    /// # Returns
115    ///
116    /// a newly constructed [`RasterRenderer`][crate::RasterRenderer]
117    #[doc(alias = "shumate_raster_renderer_new_from_url")]
118    #[doc(alias = "new_from_url")]
119    pub fn from_url(url_template: &str) -> RasterRenderer {
120        assert_initialized_main_thread!();
121        unsafe {
122            from_glib_full(ffi::shumate_raster_renderer_new_from_url(
123                url_template.to_glib_none().0,
124            ))
125        }
126    }
127
128    /// Creates a new [`RasterRenderer`][crate::RasterRenderer] with the given details and a data
129    /// source.
130    /// ## `id`
131    /// the map source's id
132    /// ## `name`
133    /// the map source's name
134    /// ## `license`
135    /// the map source's license
136    /// ## `license_uri`
137    /// the map source's license URI
138    /// ## `min_zoom`
139    /// the map source's minimum zoom level
140    /// ## `max_zoom`
141    /// the map source's maximum zoom level
142    /// ## `tile_size`
143    /// the map source's tile size (in pixels)
144    /// ## `projection`
145    /// the map source's projection
146    /// ## `data_source`
147    /// a [`DataSource`][crate::DataSource] to provide tile image data
148    ///
149    /// # Returns
150    ///
151    /// a newly constructed [`RasterRenderer`][crate::RasterRenderer]
152    #[doc(alias = "shumate_raster_renderer_new_full")]
153    pub fn new_full(
154        id: &str,
155        name: &str,
156        license: &str,
157        license_uri: &str,
158        min_zoom: u32,
159        max_zoom: u32,
160        tile_size: u32,
161        projection: MapProjection,
162        data_source: &impl IsA<DataSource>,
163    ) -> RasterRenderer {
164        skip_assert_initialized!();
165        unsafe {
166            from_glib_full(ffi::shumate_raster_renderer_new_full(
167                id.to_glib_none().0,
168                name.to_glib_none().0,
169                license.to_glib_none().0,
170                license_uri.to_glib_none().0,
171                min_zoom,
172                max_zoom,
173                tile_size,
174                projection.into_glib(),
175                data_source.as_ref().to_glib_none().0,
176            ))
177        }
178    }
179
180    /// Creates a new [`RasterRenderer`][crate::RasterRenderer] with the given details and a data
181    /// source.
182    /// ## `id`
183    /// the map source's id
184    /// ## `name`
185    /// the map source's name
186    /// ## `license`
187    /// the map source's license
188    /// ## `license_uri`
189    /// the map source's license URI
190    /// ## `min_zoom`
191    /// the map source's minimum zoom level
192    /// ## `max_zoom`
193    /// the map source's maximum zoom level
194    /// ## `tile_size`
195    /// the map source's tile size (in pixels)
196    /// ## `projection`
197    /// the map source's projection
198    /// ## `url_template`
199    /// a URL template to fetch tiles from
200    ///
201    /// # Returns
202    ///
203    /// a newly constructed [`RasterRenderer`][crate::RasterRenderer]
204    #[doc(alias = "shumate_raster_renderer_new_full_from_url")]
205    pub fn new_full_from_url(
206        id: &str,
207        name: &str,
208        license: &str,
209        license_uri: &str,
210        min_zoom: u32,
211        max_zoom: u32,
212        tile_size: u32,
213        projection: MapProjection,
214        url_template: &str,
215    ) -> RasterRenderer {
216        assert_initialized_main_thread!();
217        unsafe {
218            from_glib_full(ffi::shumate_raster_renderer_new_full_from_url(
219                id.to_glib_none().0,
220                name.to_glib_none().0,
221                license.to_glib_none().0,
222                license_uri.to_glib_none().0,
223                min_zoom,
224                max_zoom,
225                tile_size,
226                projection.into_glib(),
227                url_template.to_glib_none().0,
228            ))
229        }
230    }
231
232    // rustdoc-stripper-ignore-next
233    /// Creates a new builder-pattern struct instance to construct [`RasterRenderer`] objects.
234    ///
235    /// This method returns an instance of [`RasterRendererBuilder`](crate::builders::RasterRendererBuilder) which can be used to create [`RasterRenderer`] objects.
236    pub fn builder() -> RasterRendererBuilder {
237        RasterRendererBuilder::new()
238    }
239
240    /// The data source that provides image tiles to display. In most cases,
241    /// a [`TileDownloader`][crate::TileDownloader] is sufficient.
242    #[doc(alias = "data-source")]
243    pub fn data_source(&self) -> Option<DataSource> {
244        ObjectExt::property(self, "data-source")
245    }
246}
247
248impl Default for RasterRenderer {
249    fn default() -> Self {
250        glib::object::Object::new::<Self>()
251    }
252}
253
254// rustdoc-stripper-ignore-next
255/// A [builder-pattern] type to construct [`RasterRenderer`] objects.
256///
257/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
258#[must_use = "The builder must be built to be used"]
259pub struct RasterRendererBuilder {
260    builder: glib::object::ObjectBuilder<'static, RasterRenderer>,
261}
262
263impl RasterRendererBuilder {
264    fn new() -> Self {
265        Self {
266            builder: glib::object::Object::builder(),
267        }
268    }
269
270    /// The data source that provides image tiles to display. In most cases,
271    /// a [`TileDownloader`][crate::TileDownloader] is sufficient.
272    pub fn data_source(self, data_source: &impl IsA<DataSource>) -> Self {
273        Self {
274            builder: self
275                .builder
276                .property("data-source", data_source.clone().upcast()),
277        }
278    }
279
280    /// The id of the map source
281    pub fn id(self, id: impl Into<glib::GString>) -> Self {
282        Self {
283            builder: self.builder.property("id", id.into()),
284        }
285    }
286
287    /// The usage license of the map source
288    pub fn license(self, license: impl Into<glib::GString>) -> Self {
289        Self {
290            builder: self.builder.property("license", license.into()),
291        }
292    }
293
294    /// The usage license's uri for more information
295    pub fn license_uri(self, license_uri: impl Into<glib::GString>) -> Self {
296        Self {
297            builder: self.builder.property("license-uri", license_uri.into()),
298        }
299    }
300
301    /// The maximum zoom level
302    pub fn max_zoom_level(self, max_zoom_level: u32) -> Self {
303        Self {
304            builder: self.builder.property("max-zoom-level", max_zoom_level),
305        }
306    }
307
308    /// The minimum zoom level
309    pub fn min_zoom_level(self, min_zoom_level: u32) -> Self {
310        Self {
311            builder: self.builder.property("min-zoom-level", min_zoom_level),
312        }
313    }
314
315    /// The name of the map source
316    pub fn name(self, name: impl Into<glib::GString>) -> Self {
317        Self {
318            builder: self.builder.property("name", name.into()),
319        }
320    }
321
322    /// The map projection of the map source
323    pub fn projection(self, projection: MapProjection) -> Self {
324        Self {
325            builder: self.builder.property("projection", projection),
326        }
327    }
328
329    /// The tile size of the map source
330    pub fn tile_size(self, tile_size: u32) -> Self {
331        Self {
332            builder: self.builder.property("tile-size", tile_size),
333        }
334    }
335
336    // rustdoc-stripper-ignore-next
337    /// Build the [`RasterRenderer`].
338    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
339    pub fn build(self) -> RasterRenderer {
340        assert_initialized_main_thread!();
341        self.builder.build()
342    }
343}