]> git.street.me.uk Git - andy/viking.git/blobdiff - src/file.c
Fix intermittent problem of map redraw.
[andy/viking.git] / src / file.c
index a5f01427f21b1387335647ef994289cab05720f7..2e8542d00db23fbf642e5afdf4502feff52d01ad 100644 (file)
@@ -172,6 +172,11 @@ static void file_write ( VikAggregateLayer *top, FILE *f, gpointer vp )
       push(&stack);
       stack->data = (gpointer) vik_aggregate_layer_get_children(VIK_AGGREGATE_LAYER(current_layer));
     }
       push(&stack);
       stack->data = (gpointer) vik_aggregate_layer_get_children(VIK_AGGREGATE_LAYER(current_layer));
     }
+    else if ( current_layer->type == VIK_LAYER_GPS && !vik_gps_layer_is_empty(VIK_GPS_LAYER(current_layer)) )
+    {
+      push(&stack);
+      stack->data = (gpointer) vik_gps_layer_get_children(VIK_GPS_LAYER(current_layer));
+    }
     else
     {
       stack->data = (gpointer) ((GList *)stack->data)->next;
     else
     {
       stack->data = (gpointer) ((GList *)stack->data)->next;
@@ -245,9 +250,10 @@ static void file_read ( VikAggregateLayer *top, FILE *f, gpointer vp )
         continue;
       else if ( str_starts_with ( line, "Layer ", 6, TRUE ) )
       {
         continue;
       else if ( str_starts_with ( line, "Layer ", 6, TRUE ) )
       {
-        if ( ( ! stack->data ) || VIK_LAYER(stack->data)->type != VIK_LAYER_AGGREGATE )
+        int parent_type = VIK_LAYER(stack->data)->type;
+        if ( ( ! stack->data ) || ((parent_type != VIK_LAYER_AGGREGATE) && (parent_type != VIK_LAYER_GPS)) )
         {
         {
-          g_warning ( "Line %ld: Layer command inside non-Aggregate Layer", line_num );
+          g_warning ( "Line %ld: Layer command inside non-Aggregate Layer (type %d)", line_num, parent_type );
           push(&stack); /* inside INVALID layer */
           stack->data = NULL;
           continue;
           push(&stack); /* inside INVALID layer */
           stack->data = NULL;
           continue;
@@ -261,6 +267,12 @@ static void file_read ( VikAggregateLayer *top, FILE *f, gpointer vp )
             g_warning ( "Line %ld: Unknown type %s\n", line_num, line+6 );
             stack->data = NULL;
           }
             g_warning ( "Line %ld: Unknown type %s\n", line_num, line+6 );
             stack->data = NULL;
           }
+          else if (parent_type == VIK_LAYER_GPS)
+          {
+            stack->data = (gpointer) vik_gps_layer_get_a_child(VIK_GPS_LAYER(stack->under->data));
+            params = vik_layer_get_interface(type)->params;
+            params_count = vik_layer_get_interface(type)->params_count;
+          }
           else
           {
             stack->data = (gpointer) vik_layer_create ( type, vp, NULL, FALSE );
           else
           {
             stack->data = (gpointer) vik_layer_create ( type, vp, NULL, FALSE );
@@ -277,8 +289,15 @@ static void file_read ( VikAggregateLayer *top, FILE *f, gpointer vp )
         {
           if ( stack->data && stack->under->data )
           {
         {
           if ( stack->data && stack->under->data )
           {
-            vik_aggregate_layer_add_layer ( VIK_AGGREGATE_LAYER(stack->under->data), VIK_LAYER(stack->data) );
-            vik_layer_post_read ( VIK_LAYER(stack->data), vp );
+            if (VIK_LAYER(stack->under->data)->type == VIK_LAYER_AGGREGATE) {
+              vik_aggregate_layer_add_layer ( VIK_AGGREGATE_LAYER(stack->under->data), VIK_LAYER(stack->data) );
+              vik_layer_post_read ( VIK_LAYER(stack->data), vp );
+            }
+            else if (VIK_LAYER(stack->under->data)->type == VIK_LAYER_GPS) {
+              /* TODO: anything else needs to be done here ? */
+            }
+            else
+              g_warning ( "Line %ld: EndLayer command inside non-Aggregate Layer (type %d)", line_num, VIK_LAYER(stack->data)->type );
           }
           pop(&stack);
         }
           }
           pop(&stack);
         }