[libshumate] map-layer: Rename some variables



commit 240815cb3347bd6a4ba93497334f6d6f33afff98
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Sun Mar 7 19:44:15 2021 -0300

    map-layer: Rename some variables
    
    While technically the latitude and longitude that ShumateViewport reports
    is indeed relative to its center, this is an implementation detail. It gets
    confusing when we mix map coordinates with geographic coordinates and actor
    coordinates.
    
    Rename 'center_' to 'latitude_' in the allocation function.

 shumate/shumate-map-layer.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
---
diff --git a/shumate/shumate-map-layer.c b/shumate/shumate-map-layer.c
index 3bb2d40..45165c7 100644
--- a/shumate/shumate-map-layer.c
+++ b/shumate/shumate-map-layer.c
@@ -367,8 +367,8 @@ shumate_map_layer_size_allocate (GtkWidget *widget,
   GtkAllocation child_allocation;
   guint tile_size;
   guint zoom_level;
-  double center_latitude, center_longitude;
-  guint center_x, center_y;
+  double latitude, longitude;
+  guint longitude_x, latitude_y;
   int x_offset, y_offset;
   guint tile_column, tile_row;
   guint tile_initial_column, tile_initial_row;
@@ -377,19 +377,19 @@ shumate_map_layer_size_allocate (GtkWidget *widget,
   viewport = shumate_layer_get_viewport (SHUMATE_LAYER (self));
   tile_size = shumate_map_source_get_tile_size (self->map_source);
   zoom_level = shumate_viewport_get_zoom_level (viewport);
-  center_latitude = shumate_location_get_latitude (SHUMATE_LOCATION (viewport));
-  center_longitude = shumate_location_get_longitude (SHUMATE_LOCATION (viewport));
-  center_x = (guint) shumate_map_source_get_x (self->map_source, zoom_level, center_longitude);
-  center_y = (guint) shumate_map_source_get_y (self->map_source, zoom_level, center_latitude);
+  latitude = shumate_location_get_latitude (SHUMATE_LOCATION (viewport));
+  longitude = shumate_location_get_longitude (SHUMATE_LOCATION (viewport));
+  latitude_y = (guint) shumate_map_source_get_y (self->map_source, zoom_level, latitude);
+  longitude_x = (guint) shumate_map_source_get_x (self->map_source, zoom_level, longitude);
   source_rows = shumate_map_source_get_row_count (self->map_source, zoom_level);
   source_columns = shumate_map_source_get_column_count (self->map_source, zoom_level);
 
   // This is the (column,row) of the top left ShumateTile
-  tile_initial_row = (center_y - height/2)/tile_size;
-  tile_initial_column = (center_x - width/2)/tile_size;
+  tile_initial_row = (latitude_y - height/2)/tile_size;
+  tile_initial_column = (longitude_x - width/2)/tile_size;
 
-  x_offset = (center_x - tile_initial_column * tile_size) - width/2;
-  y_offset = (center_y - tile_initial_row * tile_size) - height/2;
+  x_offset = (longitude_x - tile_initial_column * tile_size) - width/2;
+  y_offset = (latitude_y - tile_initial_row * tile_size) - height/2;
   child_allocation.y = -y_offset;
   child_allocation.width = tile_size;
   child_allocation.height = tile_size;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]