## [Fmaps-devel] Map Projection Question

 [Fmaps-devel] Map Projection Question From: James Caple - 2000-11-04 06:15:26 Attachments: text/plain israel2pts.txt ```/* * Map Testing * Copyright (C) 2000, James Caple, All Rights Reserved. * * The purpose of this project is to be able to display the outline * of the continents of the world by taking lat/lon coordinates from a * file and displaying them on a Gtk Canvas; to better understand map * projections; to improve my shoddy C skills; to free the world of tyrrany. * * Status: * * 11/3/2000 - So far, I am parsing the lat/lon coordinates from a data file, and trying * to derive an EllipsoidalMercator projection for each individual point. * I am not yet able to convert the 'projected' point to a useable x,y * coordinate for cartesian plotting. What's up with that? */ #include #include #include #include #include #include #include /* * Function Protottypes */ static void CreateMainWindow(); void CreateToolBar (GtkWidget *vbox); void getProjectionPoints( double *x, double *y, float lat, float lon ); /* * Global Variables */ GtkWidget *window; GtkWidget *drawing_area; GtkWidget *menu; GtkWidget *menu_bar; GtkWidget *file_item; GtkWidget *view_item; GtkWidget *tools_item; GtkWidget *window_item; GtkWidget *help_item; GtkWidget *open_item; GtkWidget *save_item; GtkWidget *quit_item; GtkWidget *vbox; GtkWidget *toolbar; GtkWidget *status_bar; gint context_id; #define width_buffer 195 #define height_buffer 150 #define BUFFER_SIZE (16 * 1024) #define MAX_LINES 200 #define PI 3.14159265359 /* Structures */ typedef struct { char country[100]; int longitude; int latitude; int x; int y; } GeoPoint; /*Gtkwidget Button */ /* Backing pixmap for drawing area */ static GdkPixmap *pixmap = NULL; /********************* Event Functions *******************************/ /* * Callback to print out menu click events */ void PrintFunc (GtkWidget *widget, gpointer data) { g_print ("Menu Item Clicked. Do something quick!\n"); } /* Create a new backing pixmap of the appropriate size */ static gint configure_event (GtkWidget *widget, GdkEventConfigure *event) { if (pixmap) gdk_pixmap_unref(pixmap); pixmap = gdk_pixmap_new(widget->window, widget->allocation.width, widget->allocation.height, -1); gdk_draw_rectangle (pixmap, widget->style->white_gc, TRUE, 0, 0, widget->allocation.width, widget->allocation.height); return TRUE; } /* Draw a rectangle on the screen, size depending on pressure, and color on the type of device */ static void draw_brush (GtkWidget *widget, float lat, float lon) { GdkGC *gc; GdkRectangle update_rect; double x, y; /* switch (source) { case GDK_SOURCE_MOUSE: gc = widget->style->dark_gc[GTK_WIDGET_STATE (widget)]; break; case GDK_SOURCE_PEN: gc = widget->style->black_gc; break; case GDK_SOURCE_ERASER: gc = widget->style->white_gc; break; default: gc = widget->style->light_gc[GTK_WIDGET_STATE (widget)]; } */ gc = widget->style->black_gc; getProjectionPoints( &x, &y, lat, lon ); //DEBUG printf("Graphing x,y, %d, %d\n", x, y); update_rect.x = x; update_rect.y = y; /** printf("Lat: %f, Lon: %f\n", lat, lon); update_rect.x = lat; update_rect.y = lon; **/ update_rect.width = 3; update_rect.height = 3; gdk_draw_rectangle (pixmap, gc, TRUE, update_rect.x, update_rect.y, update_rect.width, update_rect.height); gtk_widget_draw (widget, &update_rect); } /** Test Projections **/ void getProjectionPoints( double *x, double *y, float lat, float lon ) { /** Yes, I'm flailing here! **/ /** int R = 6378137; *x = abs( ( R * lon * cos( lat ) ) / 100000 ); *y = abs( ( R * (1 + cos( lat ) ) * tan ( lat/2 ) ) / 100000 ); printf("Projected lat: %d lon: %d\n", *x, *y); **/ /** Projection algorithm derived from GeoTools' ElipsoidalMercator.java class **/ double rx = (PI/(double)180)*lon; double ry = (PI/(double)180)*lat; double t = (0.081819221)*sin(ry); *x = 6378.137*rx; *y = 6378.137*log(tan(PI/4.0 + ry/2.0) * pow(((1.0-t)/(1.0+t)), 0.081819221/2.0)); printf("Projection coordinates: %d, %d\n", *x, *y); } /* Redraw the screen from the backing pixmap */ static gint expose_event (GtkWidget *widget, GdkEventExpose *event) { gdk_draw_pixmap(widget->window, widget->style->fg_gc[GTK_WIDGET_STATE (widget)], pixmap, event->area.x, event->area.y, event->area.x, event->area.y, event->area.width, event->area.height); return FALSE; } static void print_button_press (guint32 deviceid) { GList *tmp_list; /* gdk_input_list_devices returns an internal list, so we shouldn't free it afterwards */ tmp_list = gdk_input_list_devices(); while (tmp_list) { GdkDeviceInfo *info = (GdkDeviceInfo *)tmp_list->data; if (info->deviceid == deviceid) { //g_print("Button press on device '%s'\n", info->name); char data[30]; strcpy( data, info->name); gtk_statusbar_push( GTK_STATUSBAR(status_bar), GPOINTER_TO_INT(context_id), data); return; } tmp_list = tmp_list->next; } } static gint button_press_event (GtkWidget *widget, GdkEventButton *event) { /* print_button_press (event->deviceid); if (event->button == 1 && pixmap != NULL) draw_brush (widget, event->source, event->x, event->y, event->pressure); */ return TRUE; } static gint motion_notify_event (GtkWidget *widget, GdkEventMotion *event) { gdouble x, y; gdouble pressure; GdkModifierType state; if (event->is_hint) gdk_input_window_get_pointer (event->window, event->deviceid, &x, &y, &pressure, NULL, NULL, &state); else { x = event->x; y = event->y; pressure = event->pressure; state = event->state; } /* if (state & GDK_BUTTON1_MASK && pixmap != NULL) draw_brush (widget, event->source, x, y, pressure); */ return TRUE; } void input_dialog_destroy (GtkWidget *w, gpointer data) { *((GtkWidget **)data) = NULL; } /************************************************************* * Close App ************************************************************/ gint EndProgram() { /* -- End GTK event loop processing -- */ gtk_main_quit(); return (FALSE); } void push_item( GtkWidget *widget, gpointer data ) { static int count = 1; char buff[20]; g_snprintf(buff, 20, "Item %d", count++); gtk_statusbar_push( GTK_STATUSBAR(status_bar), GPOINTER_TO_INT(data), buff); return; } void pop_item( GtkWidget *widget, gpointer data ) { gtk_statusbar_pop( GTK_STATUSBAR(status_bar), GPOINTER_TO_INT(data) ); return; } /************************************************************** * Main Function **************************************************************/ int main( int argc, char *argv[] ) { gtk_init (&argc, &argv); /* -- Create Main Window -- */ CreateMainWindow(); /* -- Await user input events -- */ gtk_main(); return(0); } /*************************************************************** * Read in map coordinates and plot ***************************************************************/ void PlotWorldMapPoints( GtkWidget *widget ) { /* Read data files(s) */ FILE *in_file; char fline[MAX_LINES]; float data[2000][2]; int i; /*GeoPoint *israel[500];*/ int counter = -1; int arr_cnt = -1; if ( (in_file = fopen("israel2pts.txt", "r")) == NULL ) { fprintf(stderr, "Error: Unable to open file\n"); } while ( fgets(fline, MAX_LINES, in_file) != NULL ) { counter++; if ( strncmp(fline, "END", 3) == 0 ) break; if ( counter > 1 ) { arr_cnt++; /*printf("Line: %s", fline);*/ sscanf( fline, "%f %f", &data[arr_cnt][0], &data[arr_cnt][1] ); } } /*printf("Element 200,0 %f\n", data[200][0]);*/ fclose(in_file); for (i=0; i < 490; i++) { if (pixmap != NULL) { printf("Plotting X %f, Y %f\n", data[i][0], data[i][1]); draw_brush( widget, data[i][0], data[i][1] ); } } } /**************************************************************** * Create the main GUI window ****************************************************************/ static void CreateMainWindow() { window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), "Map, Copyright (C) 2000, James Caple, All Rights Reserved"); gtk_window_set_default_size (GTK_WINDOW (window), 800, 540); gtk_signal_connect (GTK_OBJECT (window), "delete_event", (GtkSignalFunc) gtk_main_quit, NULL); vbox = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (window), vbox); gtk_widget_show (vbox); /* * Create File Menus */ menu = gtk_menu_new(); open_item = gtk_menu_item_new_with_label ("Open"); save_item = gtk_menu_item_new_with_label ("Save"); quit_item = gtk_menu_item_new_with_label ("Quit"); gtk_menu_append (GTK_MENU (menu), open_item); gtk_menu_append (GTK_MENU (menu), save_item); gtk_menu_append (GTK_MENU (menu), quit_item); gtk_signal_connect_object (GTK_OBJECT (open_item), "activate", GTK_SIGNAL_FUNC (PrintFunc), (gpointer) "Open File Requested"); gtk_signal_connect_object (GTK_OBJECT (save_item), "activate", GTK_SIGNAL_FUNC (PrintFunc), (gpointer) "Save File Requested"); gtk_signal_connect_object (GTK_OBJECT (quit_item), "activate", GTK_SIGNAL_FUNC (EndProgram), (gpointer) "Quit App Requested"); gtk_widget_show (open_item); gtk_widget_show (save_item); gtk_widget_show (quit_item); /* -- File -- */ file_item = gtk_menu_item_new_with_label ("File"); gtk_widget_show (file_item); gtk_menu_item_set_submenu (GTK_MENU_ITEM (file_item), menu); /* -- View -- */ view_item = gtk_menu_item_new_with_label ("View"); gtk_widget_show (view_item); /* -- Tools --*/ tools_item = gtk_menu_item_new_with_label ("Tools"); gtk_widget_show (tools_item); /* -- Window -- */ window_item = gtk_menu_item_new_with_label ("Window"); gtk_widget_show (window_item); /* -- Help -- */ help_item = gtk_menu_item_new_with_label ("Help"); gtk_widget_show (help_item); menu_bar = gtk_menu_bar_new (); gtk_box_pack_start (GTK_BOX (vbox), menu_bar, FALSE, TRUE, 2); gtk_widget_show (menu_bar); gtk_menu_bar_append (GTK_MENU_BAR (menu_bar), file_item); gtk_menu_bar_append (GTK_MENU_BAR (menu_bar), view_item); gtk_menu_bar_append (GTK_MENU_BAR (menu_bar), tools_item); gtk_menu_bar_append (GTK_MENU_BAR (menu_bar), window_item); gtk_menu_bar_append (GTK_MENU_BAR (menu_bar), help_item); /* Create the drawing area */ drawing_area = gtk_drawing_area_new (); gtk_drawing_area_size (GTK_DRAWING_AREA (drawing_area), 750, 480); gtk_box_pack_start (GTK_BOX (vbox), drawing_area, TRUE, TRUE, 0); gtk_widget_show (drawing_area); /* Signals used to handle backing pixmap */ gtk_signal_connect (GTK_OBJECT (drawing_area), "expose_event", (GtkSignalFunc) expose_event, NULL); gtk_signal_connect (GTK_OBJECT(drawing_area),"configure_event", (GtkSignalFunc) configure_event, NULL); /* Event signals */ gtk_signal_connect (GTK_OBJECT (drawing_area), "motion_notify_event", (GtkSignalFunc) motion_notify_event, NULL); gtk_signal_connect (GTK_OBJECT (drawing_area), "button_press_event", (GtkSignalFunc) button_press_event, NULL); gtk_widget_set_events (drawing_area, GDK_EXPOSURE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK); /* The following call enables tracking and processing of extension events for the drawing area */ gtk_widget_set_extension_events (drawing_area, GDK_EXTENSION_EVENTS_CURSOR); /* -- Create the toolbar -- */ //CreateToolBar (vbox); status_bar = gtk_statusbar_new(); gtk_box_pack_start (GTK_BOX (vbox), status_bar, TRUE, TRUE, 0); gtk_widget_show (status_bar); context_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(status_bar), "Statusbar example"); /* Write something to status bar */ gtk_statusbar_push( GTK_STATUSBAR(status_bar), GPOINTER_TO_INT(context_id), "This is a test status..."); gtk_widget_show (window); PlotWorldMapPoints( drawing_area ); } ```

 [Fmaps-devel] Map Projection Question From: James Caple - 2000-11-04 06:15:26 Attachments: text/plain israel2pts.txt ```/* * Map Testing * Copyright (C) 2000, James Caple, All Rights Reserved. * * The purpose of this project is to be able to display the outline * of the continents of the world by taking lat/lon coordinates from a * file and displaying them on a Gtk Canvas; to better understand map * projections; to improve my shoddy C skills; to free the world of tyrrany. * * Status: * * 11/3/2000 - So far, I am parsing the lat/lon coordinates from a data file, and trying * to derive an EllipsoidalMercator projection for each individual point. * I am not yet able to convert the 'projected' point to a useable x,y * coordinate for cartesian plotting. What's up with that? */ #include #include #include #include #include #include #include /* * Function Protottypes */ static void CreateMainWindow(); void CreateToolBar (GtkWidget *vbox); void getProjectionPoints( double *x, double *y, float lat, float lon ); /* * Global Variables */ GtkWidget *window; GtkWidget *drawing_area; GtkWidget *menu; GtkWidget *menu_bar; GtkWidget *file_item; GtkWidget *view_item; GtkWidget *tools_item; GtkWidget *window_item; GtkWidget *help_item; GtkWidget *open_item; GtkWidget *save_item; GtkWidget *quit_item; GtkWidget *vbox; GtkWidget *toolbar; GtkWidget *status_bar; gint context_id; #define width_buffer 195 #define height_buffer 150 #define BUFFER_SIZE (16 * 1024) #define MAX_LINES 200 #define PI 3.14159265359 /* Structures */ typedef struct { char country[100]; int longitude; int latitude; int x; int y; } GeoPoint; /*Gtkwidget Button */ /* Backing pixmap for drawing area */ static GdkPixmap *pixmap = NULL; /********************* Event Functions *******************************/ /* * Callback to print out menu click events */ void PrintFunc (GtkWidget *widget, gpointer data) { g_print ("Menu Item Clicked. Do something quick!\n"); } /* Create a new backing pixmap of the appropriate size */ static gint configure_event (GtkWidget *widget, GdkEventConfigure *event) { if (pixmap) gdk_pixmap_unref(pixmap); pixmap = gdk_pixmap_new(widget->window, widget->allocation.width, widget->allocation.height, -1); gdk_draw_rectangle (pixmap, widget->style->white_gc, TRUE, 0, 0, widget->allocation.width, widget->allocation.height); return TRUE; } /* Draw a rectangle on the screen, size depending on pressure, and color on the type of device */ static void draw_brush (GtkWidget *widget, float lat, float lon) { GdkGC *gc; GdkRectangle update_rect; double x, y; /* switch (source) { case GDK_SOURCE_MOUSE: gc = widget->style->dark_gc[GTK_WIDGET_STATE (widget)]; break; case GDK_SOURCE_PEN: gc = widget->style->black_gc; break; case GDK_SOURCE_ERASER: gc = widget->style->white_gc; break; default: gc = widget->style->light_gc[GTK_WIDGET_STATE (widget)]; } */ gc = widget->style->black_gc; getProjectionPoints( &x, &y, lat, lon ); //DEBUG printf("Graphing x,y, %d, %d\n", x, y); update_rect.x = x; update_rect.y = y; /** printf("Lat: %f, Lon: %f\n", lat, lon); update_rect.x = lat; update_rect.y = lon; **/ update_rect.width = 3; update_rect.height = 3; gdk_draw_rectangle (pixmap, gc, TRUE, update_rect.x, update_rect.y, update_rect.width, update_rect.height); gtk_widget_draw (widget, &update_rect); } /** Test Projections **/ void getProjectionPoints( double *x, double *y, float lat, float lon ) { /** Yes, I'm flailing here! **/ /** int R = 6378137; *x = abs( ( R * lon * cos( lat ) ) / 100000 ); *y = abs( ( R * (1 + cos( lat ) ) * tan ( lat/2 ) ) / 100000 ); printf("Projected lat: %d lon: %d\n", *x, *y); **/ /** Projection algorithm derived from GeoTools' ElipsoidalMercator.java class **/ double rx = (PI/(double)180)*lon; double ry = (PI/(double)180)*lat; double t = (0.081819221)*sin(ry); *x = 6378.137*rx; *y = 6378.137*log(tan(PI/4.0 + ry/2.0) * pow(((1.0-t)/(1.0+t)), 0.081819221/2.0)); printf("Projection coordinates: %d, %d\n", *x, *y); } /* Redraw the screen from the backing pixmap */ static gint expose_event (GtkWidget *widget, GdkEventExpose *event) { gdk_draw_pixmap(widget->window, widget->style->fg_gc[GTK_WIDGET_STATE (widget)], pixmap, event->area.x, event->area.y, event->area.x, event->area.y, event->area.width, event->area.height); return FALSE; } static void print_button_press (guint32 deviceid) { GList *tmp_list; /* gdk_input_list_devices returns an internal list, so we shouldn't free it afterwards */ tmp_list = gdk_input_list_devices(); while (tmp_list) { GdkDeviceInfo *info = (GdkDeviceInfo *)tmp_list->data; if (info->deviceid == deviceid) { //g_print("Button press on device '%s'\n", info->name); char data[30]; strcpy( data, info->name); gtk_statusbar_push( GTK_STATUSBAR(status_bar), GPOINTER_TO_INT(context_id), data); return; } tmp_list = tmp_list->next; } } static gint button_press_event (GtkWidget *widget, GdkEventButton *event) { /* print_button_press (event->deviceid); if (event->button == 1 && pixmap != NULL) draw_brush (widget, event->source, event->x, event->y, event->pressure); */ return TRUE; } static gint motion_notify_event (GtkWidget *widget, GdkEventMotion *event) { gdouble x, y; gdouble pressure; GdkModifierType state; if (event->is_hint) gdk_input_window_get_pointer (event->window, event->deviceid, &x, &y, &pressure, NULL, NULL, &state); else { x = event->x; y = event->y; pressure = event->pressure; state = event->state; } /* if (state & GDK_BUTTON1_MASK && pixmap != NULL) draw_brush (widget, event->source, x, y, pressure); */ return TRUE; } void input_dialog_destroy (GtkWidget *w, gpointer data) { *((GtkWidget **)data) = NULL; } /************************************************************* * Close App ************************************************************/ gint EndProgram() { /* -- End GTK event loop processing -- */ gtk_main_quit(); return (FALSE); } void push_item( GtkWidget *widget, gpointer data ) { static int count = 1; char buff[20]; g_snprintf(buff, 20, "Item %d", count++); gtk_statusbar_push( GTK_STATUSBAR(status_bar), GPOINTER_TO_INT(data), buff); return; } void pop_item( GtkWidget *widget, gpointer data ) { gtk_statusbar_pop( GTK_STATUSBAR(status_bar), GPOINTER_TO_INT(data) ); return; } /************************************************************** * Main Function **************************************************************/ int main( int argc, char *argv[] ) { gtk_init (&argc, &argv); /* -- Create Main Window -- */ CreateMainWindow(); /* -- Await user input events -- */ gtk_main(); return(0); } /*************************************************************** * Read in map coordinates and plot ***************************************************************/ void PlotWorldMapPoints( GtkWidget *widget ) { /* Read data files(s) */ FILE *in_file; char fline[MAX_LINES]; float data[2000][2]; int i; /*GeoPoint *israel[500];*/ int counter = -1; int arr_cnt = -1; if ( (in_file = fopen("israel2pts.txt", "r")) == NULL ) { fprintf(stderr, "Error: Unable to open file\n"); } while ( fgets(fline, MAX_LINES, in_file) != NULL ) { counter++; if ( strncmp(fline, "END", 3) == 0 ) break; if ( counter > 1 ) { arr_cnt++; /*printf("Line: %s", fline);*/ sscanf( fline, "%f %f", &data[arr_cnt][0], &data[arr_cnt][1] ); } } /*printf("Element 200,0 %f\n", data[200][0]);*/ fclose(in_file); for (i=0; i < 490; i++) { if (pixmap != NULL) { printf("Plotting X %f, Y %f\n", data[i][0], data[i][1]); draw_brush( widget, data[i][0], data[i][1] ); } } } /**************************************************************** * Create the main GUI window ****************************************************************/ static void CreateMainWindow() { window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), "Map, Copyright (C) 2000, James Caple, All Rights Reserved"); gtk_window_set_default_size (GTK_WINDOW (window), 800, 540); gtk_signal_connect (GTK_OBJECT (window), "delete_event", (GtkSignalFunc) gtk_main_quit, NULL); vbox = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (window), vbox); gtk_widget_show (vbox); /* * Create File Menus */ menu = gtk_menu_new(); open_item = gtk_menu_item_new_with_label ("Open"); save_item = gtk_menu_item_new_with_label ("Save"); quit_item = gtk_menu_item_new_with_label ("Quit"); gtk_menu_append (GTK_MENU (menu), open_item); gtk_menu_append (GTK_MENU (menu), save_item); gtk_menu_append (GTK_MENU (menu), quit_item); gtk_signal_connect_object (GTK_OBJECT (open_item), "activate", GTK_SIGNAL_FUNC (PrintFunc), (gpointer) "Open File Requested"); gtk_signal_connect_object (GTK_OBJECT (save_item), "activate", GTK_SIGNAL_FUNC (PrintFunc), (gpointer) "Save File Requested"); gtk_signal_connect_object (GTK_OBJECT (quit_item), "activate", GTK_SIGNAL_FUNC (EndProgram), (gpointer) "Quit App Requested"); gtk_widget_show (open_item); gtk_widget_show (save_item); gtk_widget_show (quit_item); /* -- File -- */ file_item = gtk_menu_item_new_with_label ("File"); gtk_widget_show (file_item); gtk_menu_item_set_submenu (GTK_MENU_ITEM (file_item), menu); /* -- View -- */ view_item = gtk_menu_item_new_with_label ("View"); gtk_widget_show (view_item); /* -- Tools --*/ tools_item = gtk_menu_item_new_with_label ("Tools"); gtk_widget_show (tools_item); /* -- Window -- */ window_item = gtk_menu_item_new_with_label ("Window"); gtk_widget_show (window_item); /* -- Help -- */ help_item = gtk_menu_item_new_with_label ("Help"); gtk_widget_show (help_item); menu_bar = gtk_menu_bar_new (); gtk_box_pack_start (GTK_BOX (vbox), menu_bar, FALSE, TRUE, 2); gtk_widget_show (menu_bar); gtk_menu_bar_append (GTK_MENU_BAR (menu_bar), file_item); gtk_menu_bar_append (GTK_MENU_BAR (menu_bar), view_item); gtk_menu_bar_append (GTK_MENU_BAR (menu_bar), tools_item); gtk_menu_bar_append (GTK_MENU_BAR (menu_bar), window_item); gtk_menu_bar_append (GTK_MENU_BAR (menu_bar), help_item); /* Create the drawing area */ drawing_area = gtk_drawing_area_new (); gtk_drawing_area_size (GTK_DRAWING_AREA (drawing_area), 750, 480); gtk_box_pack_start (GTK_BOX (vbox), drawing_area, TRUE, TRUE, 0); gtk_widget_show (drawing_area); /* Signals used to handle backing pixmap */ gtk_signal_connect (GTK_OBJECT (drawing_area), "expose_event", (GtkSignalFunc) expose_event, NULL); gtk_signal_connect (GTK_OBJECT(drawing_area),"configure_event", (GtkSignalFunc) configure_event, NULL); /* Event signals */ gtk_signal_connect (GTK_OBJECT (drawing_area), "motion_notify_event", (GtkSignalFunc) motion_notify_event, NULL); gtk_signal_connect (GTK_OBJECT (drawing_area), "button_press_event", (GtkSignalFunc) button_press_event, NULL); gtk_widget_set_events (drawing_area, GDK_EXPOSURE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK); /* The following call enables tracking and processing of extension events for the drawing area */ gtk_widget_set_extension_events (drawing_area, GDK_EXTENSION_EVENTS_CURSOR); /* -- Create the toolbar -- */ //CreateToolBar (vbox); status_bar = gtk_statusbar_new(); gtk_box_pack_start (GTK_BOX (vbox), status_bar, TRUE, TRUE, 0); gtk_widget_show (status_bar); context_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(status_bar), "Statusbar example"); /* Write something to status bar */ gtk_statusbar_push( GTK_STATUSBAR(status_bar), GPOINTER_TO_INT(context_id), "This is a test status..."); gtk_widget_show (window); PlotWorldMapPoints( drawing_area ); } ```
 Re: [Fmaps-devel] Map Projection Question From: Franck Martin - 2000-11-04 06:40:56 ```To answer quickly to your first question, you need gtkglarea widget which also requires either Mesa or OpenGL Look in the INSTALL file for some info... The gtkglaera widget is on the CVS tree of Gnome, but also available as a rpm for Mandrake/Redhat. Look for it on http://www.rpmfind.net Now I will have a look at your code... more later... There is a great tool called geotrans which does what you want, but needs to be converted... Proj.4 latest has some datum shift transformation but it is more a basic projection library. You may see that in FMaps there is a gtkwidget called gtkfmaps. For the moment the widget is not an individual library, but it is created to be one... I becoming more confident with gnome work, so I may split the application from the widget in the future... Cheers... James Caple wrote: > FMaps/GeoTools Dudes, > > I'm trying to develop a 'simple' Gtk app. with a similar functionality > as FMaps and GeoTools in that I want to display a simple map of the > world. > I've looked at GeoTools, and got some tips there... Was wondering if > I might solicit some feedback on how to display > a map in some Gtk widget. I'm having a tough time with the whole map > projection idear. > > I'm enclosing source code and a data file of a project I'm trying to > get working. The goal of which is to display a map (ANY MAP!) > by transposing lat/long files from a data file to cartesian x,y > coordinates readable in a Gtk Map Display tool. I'm seeking help, > tips, etc. > on the projection part. > > I tried to build FMaps but got the following error on my RedHat Linux > box running kernel 2.2.5-15 and gtk 1.2.1-10.... > > gtkfmaps.c: In function `gtk_fmaps_get_type': > gtkfmaps.c:61: `GTK_TYPE_GL_AREA' undeclared (first use in this > function) > gtkfmaps.c:61: (Each undeclared identifier is reported only once > gtkfmaps.c:61: for each function it appears in.) > gtkfmaps.c: In function `gtk_fmaps_class_init': > gtkfmaps.c:80: `GTK_TYPE_GL_AREA' undeclared (first use in this > function) > gtkfmaps.c: In function `gtk_fmaps_realize': > gtkfmaps.c:274: warning: implicit declaration of function > `gtk_gl_area_make_current' > make[2]: *** [gtkfmaps.o] Error 1 > make[2]: Leaving directory `/home/accounts/jcaple/GNFS/FMaps/src' > make[1]: *** [all-recursive] Error 1 > make[1]: Leaving directory `/home/accounts/jcaple/GNFS/FMaps' > make: *** [all-recursive-am] Error 2 > --------------- > [jcaple@... FMaps]\$ uname -a > Linux sitting-bull 2.2.5-15 #1 Mon Apr 19 23:00:46 EDT 1999 i686 > unknown > [jcaple@... FMaps]\$ rpm -qa | grep gtk > gtk+-1.2.1-10 > gtk+-devel-1.2.1-10 > gtk+10-1.0.6-5 > gtk-engines-0.5-16 > pygtk-0.5.12-2 > > Thanks for your time! > > James ```