Re: Handling long SVG strings in Path



I went with the fopen to open a file containing the SVG data. The problem that I'm encountering is that nothing is being drawn on the canvas. I thought that maybe it was because the string was to long. So I made it very small, something like "M 20 20 L 4000 4000", which should draw a simple line. But, alas this produced no line. Not sure what the problem is but here is the code, any help would be appreciated.

#define MAX_LEN 5000

void read_gis(char *gis)
{   
    FILE * gis_file;
    gchar *path_data;
   
    gis_file = fopen(gis,"r");
    if (gis_file != NULL)
    {
        char path[MAX_LEN + 1];
        fgets(path, MAX_LEN + 1, gis_file);
        printf("%s\n",path);
        fclose (gis_file);
       
        path_data = path;
        goo_canvas_path_new(root,path_data,"stroke-color","white","line-width",5.0,NULL);
    }
}


On Mon, May 4, 2009 at 4:01 PM, Damon Chaplin <damon karuna eclipse co uk> wrote:

On Mon, 2009-05-04 at 11:36 -0500, Jamie Lahowetz wrote:
> I am new to C and am trying to translate a Perl program I wrote over
> to C. The program displays shapefiles using the path call in goocanvas
> and utilizes svg to make them look right. The strings that the
> shapefiles generate can be 1million+ characters in size so they are
> very large. My question is, what is the best way to handle such a
> large string in C and insert it into path? Thanks.

You could just use g_file_get_contents() and read it all in in one go,
then free it when you've parsed it. Though it may be safer to use
fopen() and fread() to parse a bit at a time. (Or the new g_file_read()
and GInputStream functions in GIO.)

Note that GooCanvasPath is only intended to be used for reasonably small
paths. So break your shapefiles into pieces if you can.

Damon





--
Jamie Ryan Lahowetz
University of Nebraska - Lincoln
Graduate Student - Geosciences
402.304.0766
jlahowetz gmail com


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