Exemple #1
0
/* the contents of the map tab have been changed */
static void map_update(area_context_t *context, bool forced) {

  /* map is first tab (page 0) */
  if(!forced && !current_tab_is(context, TAB_LABEL_MAP)) {
    g_debug("schedule map redraw");
    context->map.needs_redraw = true;
    return;
  }

  g_debug("do map redraw");

  /* check if the position is invalid */
  if(!context->bounds.valid()) {
    /* no coordinates given: display around the current GPS position if available */
    pos_t pos = context->area.gps_state->get_pos();
    int zoom = 12;
    if(!pos.valid()) {
      /* no GPS position available: display the entire world */
      pos.lat = 0.0;
      pos.lon = 0.0;
      zoom = 1;
    }

    osm_gps_map_set_center_and_zoom(context->map.widget, pos.lat, pos.lon, zoom);
    osm_gps_map_track_remove_all(context->map.widget);
  } else {

    osm_gps_map_set_center(context->map.widget, context->bounds.centerLat(),
                           context->bounds.centerLon());

    /* we know the widgets pixel size, we know the required real size, */
    /* we want the zoom! */
    GtkWidget *wd = GTK_WIDGET(context->map.widget);
    double vzoom = wd->allocation.height / context->bounds.latDist();
    double hzoom = wd->allocation.width  / context->bounds.lonDist();

    /* use smallest zoom, so everything fits on screen */
    osm_gps_map_set_zoom(context->map.widget,
                         log2((45.0 / 32.0) * std::min(vzoom, hzoom)) - 1);

    /* ---------- draw border (as a gps track) -------------- */
    osm_gps_map_track_remove_all(context->map.widget);

    if(context->bounds.normalized()) {
      GSList *box = pos_append(nullptr, context->bounds.min.lat, context->bounds.min.lon);
      box = pos_append(box, context->bounds.max.lat, context->bounds.min.lon);
      box = pos_append(box, context->bounds.max.lat, context->bounds.max.lon);
      box = pos_append(box, context->bounds.min.lat, context->bounds.max.lon);
      box = pos_append(box, context->bounds.min.lat, context->bounds.min.lon);

      osm_gps_map_add_track(context->map.widget, box);
    }
  }

  // show all other bounds
  std::for_each(context->area.other_bounds.begin(), context->area.other_bounds.end(),
                add_bounds(context->map.widget));

  context->map.needs_redraw = false;
}
Exemple #2
0
void invariant_sett::add_type_bounds(const exprt &expr, const typet &type)
{
  if(expr.type()==type)
    return;

  if(type.id()==ID_unsignedbv)
  {
    unsigned op_width=to_unsignedbv_type(type).get_width();

    if(op_width<=8)
    {
      unsigned a;
      if(get_object(expr, a))
        return;

      add_bounds(a, boundst(0, power(2, op_width)-1));
    }
  }
}