libmap.dll and mapObj->extent

Ian Erickson ierickson at ANALYGIS.COM
Sun Jun 17 22:03:23 EDT 2007


Perhaps I'm missing something here....

I've got a C++ project that (in keeping with the shp2img.c source), 
loads a map, and creates an image, saves the image, and then closes 
frees the stuff up.

I'm trying to return the extents of the map as loaded but no matter what 
I do, I'm only getting 0's for maxx, maxy, minx, and miny.  The 
application does indees return the desired map, and it does function 
correctly but all I want is access to the extent properties once set in 
the mapObj.

Perhaps someone can tell me what I'm doing wrong:

//----------------------------------------------------------------------------------

void makeMap( string mapfile = "", double xmax = 180.0, double ymax = 
90.0, double xmin = -180.0, double ymin = -90.0, int width = 400, int 
height = 400  )
{
    mapObj *map = NULL;
    imageObj *image = NULL;

    if (mapfile.empty()) {
        cout << "The mapfile parameter is empty." << endl;
        return;
    }
    if (!fileExists( mapfile )) {
        cout << "The specifed file does not exist." << endl;
        return;
    }

    cout << "Loading the map file (" << mapfile.c_str() << ")..." <<endl;
    map = msLoadMap( _strdup( mapfile.c_str() ), NULL );
    cout << "Name: " << map->name << endl;
    msMapSetSize( map, width, height );
    cout << "Width, Height: " << map->width << ", " << map->height << endl;

    msMapSetExtent( map, xmin, ymin, xmax, ymax );
    cout << "Extents: (" << map->extent.minx << ", " << map->extent.miny 
<< ") (" << map->extent.maxx << ", " << map->extent.maxy << ")" << endl;

    cout << "Writing the map image..." << endl;
    image = msDrawMap( map );
    msSaveImage( map, image, 
"C:\\Projects\\Company\\Apogee_Mapping\\PDFMaps\\test.png" );

    cout << "Cleaning up..." << endl;
    msFreeImage( image );
    msFreeMap( map );
    msCleanup();

    cout << "Done." << endl;
}

-- 
Ian 



More information about the mapserver-users mailing list