[libshumate] Use doubles for zoom level
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libshumate] Use doubles for zoom level
- Date: Thu, 6 May 2021 17:48:57 +0000 (UTC)
commit 8908d636ab97d44cf5cefb70713a7eb6e5bb3327
Author: James Westman <james jwestman net>
Date: Mon Apr 12 18:21:46 2021 -0500
Use doubles for zoom level
shumate/shumate-map-source.c | 10 +++++-----
shumate/shumate-map-source.h | 10 +++++-----
shumate/shumate-viewport.c | 20 ++++++++++----------
shumate/shumate-viewport.h | 4 ++--
tests/coordinate.c | 4 ++--
5 files changed, 24 insertions(+), 24 deletions(-)
---
diff --git a/shumate/shumate-map-source.c b/shumate/shumate-map-source.c
index 907a59a..66571b1 100644
--- a/shumate/shumate-map-source.c
+++ b/shumate/shumate-map-source.c
@@ -207,7 +207,7 @@ shumate_map_source_get_projection (ShumateMapSource *map_source)
*/
double
shumate_map_source_get_x (ShumateMapSource *map_source,
- guint zoom_level,
+ double zoom_level,
double longitude)
{
g_return_val_if_fail (SHUMATE_IS_MAP_SOURCE (map_source), 0.0);
@@ -232,7 +232,7 @@ shumate_map_source_get_x (ShumateMapSource *map_source,
*/
double
shumate_map_source_get_y (ShumateMapSource *map_source,
- guint zoom_level,
+ double zoom_level,
double latitude)
{
double sin_latitude;
@@ -259,7 +259,7 @@ shumate_map_source_get_y (ShumateMapSource *map_source,
*/
double
shumate_map_source_get_longitude (ShumateMapSource *map_source,
- guint zoom_level,
+ double zoom_level,
double x)
{
double longitude;
@@ -286,7 +286,7 @@ shumate_map_source_get_longitude (ShumateMapSource *map_source,
*/
double
shumate_map_source_get_latitude (ShumateMapSource *map_source,
- guint zoom_level,
+ double zoom_level,
double y)
{
double latitude, map_size, dy;
@@ -355,7 +355,7 @@ shumate_map_source_get_column_count (ShumateMapSource *map_source,
*/
double
shumate_map_source_get_meters_per_pixel (ShumateMapSource *map_source,
- guint zoom_level,
+ double zoom_level,
double latitude,
G_GNUC_UNUSED double longitude)
{
diff --git a/shumate/shumate-map-source.h b/shumate/shumate-map-source.h
index 83389f3..59e27ca 100644
--- a/shumate/shumate-map-source.h
+++ b/shumate/shumate-map-source.h
@@ -79,23 +79,23 @@ guint shumate_map_source_get_tile_size (ShumateMapSource *map_source);
ShumateMapProjection shumate_map_source_get_projection (ShumateMapSource *map_source);
double shumate_map_source_get_x (ShumateMapSource *map_source,
- guint zoom_level,
+ double zoom_level,
double longitude);
double shumate_map_source_get_y (ShumateMapSource *map_source,
- guint zoom_level,
+ double zoom_level,
double latitude);
double shumate_map_source_get_longitude (ShumateMapSource *map_source,
- guint zoom_level,
+ double zoom_level,
double x);
double shumate_map_source_get_latitude (ShumateMapSource *map_source,
- guint zoom_level,
+ double zoom_level,
double y);
guint shumate_map_source_get_row_count (ShumateMapSource *map_source,
guint zoom_level);
guint shumate_map_source_get_column_count (ShumateMapSource *map_source,
guint zoom_level);
double shumate_map_source_get_meters_per_pixel (ShumateMapSource *map_source,
- guint zoom_level,
+ double zoom_level,
double latitude,
double longitude);
diff --git a/shumate/shumate-viewport.c b/shumate/shumate-viewport.c
index d23957c..8b18004 100644
--- a/shumate/shumate-viewport.c
+++ b/shumate/shumate-viewport.c
@@ -40,7 +40,7 @@ struct _ShumateViewport
double lon;
double lat;
- guint zoom_level;
+ double zoom_level;
guint min_zoom_level;
guint max_zoom_level;
@@ -112,7 +112,7 @@ shumate_viewport_get_property (GObject *object,
switch (prop_id)
{
case PROP_ZOOM_LEVEL:
- g_value_set_uint (value, self->zoom_level);
+ g_value_set_double (value, self->zoom_level);
break;
case PROP_MIN_ZOOM_LEVEL:
@@ -152,7 +152,7 @@ shumate_viewport_set_property (GObject *object,
switch (prop_id)
{
case PROP_ZOOM_LEVEL:
- shumate_viewport_set_zoom_level (self, g_value_get_uint (value));
+ shumate_viewport_set_zoom_level (self, g_value_get_double (value));
break;
case PROP_MIN_ZOOM_LEVEL:
@@ -208,11 +208,11 @@ shumate_viewport_class_init (ShumateViewportClass *klass)
* The level of zoom of the content.
*/
obj_properties[PROP_ZOOM_LEVEL] =
- g_param_spec_uint ("zoom-level",
- "Zoom level",
- "The level of zoom of the map",
- 0, 20, 3,
- G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
+ g_param_spec_double ("zoom-level",
+ "Zoom level",
+ "The level of zoom of the map",
+ 0, 20, 3,
+ G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* ShumateViewport:min-zoom-level:
@@ -298,7 +298,7 @@ shumate_viewport_new (void)
*/
void
shumate_viewport_set_zoom_level (ShumateViewport *self,
- guint zoom_level)
+ double zoom_level)
{
g_return_if_fail (SHUMATE_IS_VIEWPORT (self));
@@ -319,7 +319,7 @@ shumate_viewport_set_zoom_level (ShumateViewport *self,
*
* Returns: the current zoom level
*/
-guint
+double
shumate_viewport_get_zoom_level (ShumateViewport *self)
{
g_return_val_if_fail (SHUMATE_IS_VIEWPORT (self), 0U);
diff --git a/shumate/shumate-viewport.h b/shumate/shumate-viewport.h
index 1c1509e..dcb96a5 100644
--- a/shumate/shumate-viewport.h
+++ b/shumate/shumate-viewport.h
@@ -38,8 +38,8 @@ G_DECLARE_FINAL_TYPE (ShumateViewport, shumate_viewport, SHUMATE, VIEWPORT, GObj
ShumateViewport *shumate_viewport_new (void);
void shumate_viewport_set_zoom_level (ShumateViewport *self,
- guint zoom_level);
-guint shumate_viewport_get_zoom_level (ShumateViewport *self);
+ double zoom_level);
+double shumate_viewport_get_zoom_level (ShumateViewport *self);
void shumate_viewport_set_max_zoom_level (ShumateViewport *self,
guint max_zoom_level);
diff --git a/tests/coordinate.c b/tests/coordinate.c
index 004b1c1..9fa1960 100644
--- a/tests/coordinate.c
+++ b/tests/coordinate.c
@@ -10,7 +10,7 @@ test_coordinate_convert (void)
ShumateMapSource *source;
double latitude = -73.75f;
double longitude = 45.466f;
- guint zoom_level;
+ double zoom_level;
factory = shumate_map_source_factory_dup_default ();
@@ -22,7 +22,7 @@ test_coordinate_convert (void)
for (zoom_level = shumate_map_source_get_min_zoom_level (source);
zoom_level <= shumate_map_source_get_max_zoom_level (source);
- zoom_level++)
+ zoom_level += 0.5)
{
double x;
double y;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]