Global Mapper v25.0

Load images in custom defined area

mrkrishnan
mrkrishnan Global Mapper User
edited June 2010 in SDK
hai
i have created my own vector layer like building.
In that area i want load some images in that area.
Is there any API to load images in custom defined area?


Regards
Radhakrishnan

Comments

  • global_mapper
    global_mapper Administrator
    edited May 2010
    There's not an API to load images in just an area, you would need to know what actual image files that you want to load, or you could use the GM_LoadOnlineLayer function to load data from an online source for that particular area.

    One option if you have a large collection of imagery is to create a map catalog from the images, then just load the map catalog file. It will automatically load the images needed for display of a particular area, then unload them when not needed anymore.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • mrkrishnan
    mrkrishnan Global Mapper User
    edited May 2010
    hai
    Actually my requirement is to create one custom layer with some mountain, buildings, hills etc.
    Is GM_CreateCustomRasterLayer API is suitable for that?
    If yes then can you give and example for how to use it?

    Regards
    Radhakrishnan
  • global_mapper
    global_mapper Administrator
    edited May 2010
    The GM_CreateCustomRasterLayer function is for creating a custom layer from an in-memory bitmap. It sounds to me more like you have separate vector features that you want to create a layer from, in which case you would use the GM_CreateCustomVectorLayer function, then use the GM_AddAreaToVectorLayer, GM_AddLineToVectorLayer, and GM_AddPointToVectorLayer functions to add individual vector features to that layer for rendering.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • mrkrishnan
    mrkrishnan Global Mapper User
    edited June 2010
    hai
    i have created a custom vector layer and in that i have added one area. For this area creation i just converted the mouse position in lat and long coordinate and made a list of points. Finally i added that into layer list, but in the output the area is not in the position which i was defined. It is displayed in some other place. i don't know the reason. Please guide me to resolve this issue.


    Regards
    Radhakrishnan
  • mrkrishnan
    mrkrishnan Global Mapper User
    edited June 2010
    Hai

    Please read the last reply also.
    Just now i found that is because of GM_DrawFlags_DontMaintainAspectRatio. If i set GM_DrawFlags_IncrementalRender it is coming properly.But i want GM_DrawFlags_DontMaintainAspectRatio mode becouse i need the data should be loaded in full window size. How can resolve this issue?

    Regards
    Radhakrishnan
  • global_mapper
    global_mapper Administrator
    edited June 2010
    What projection are you using when you create your custom vector layer? Where are your features showing up? Make sure that you aren't swapping the X (longitude) and Y (latitude) values when creating your point list.

    To combine draw flags, just add or OR them together when passing them to the draw function.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • mrkrishnan
    mrkrishnan Global Mapper User
    edited June 2010
    i tried that also, but still it is not coming properly. if i could change latitude and longitude coordinate then it should reflect in vertical direction also (but in vertical the map is always matching with window size with/without GM_DrawFlags_DontMaintainAspectRatio flag, so it is not affected).
    But i my case because of the aspect radio the misplacement is happening in horizontal direction. have set GM_DrawFlags_IncrementalRender|GM_DrawFlags_DontMaintainAspectRatio as drawing flag parameter.
  • global_mapper
    global_mapper Administrator
    edited June 2010
    Can you provide some screenshots and maybe some example code/coordinates? I'm not really sure what you are trying to say. Is this perhaps caused by the projection used to view the data? Note that if you have your projection set to Geographic, you will see significant distortion in the X direction if you are not near the equator. Other projections may be more appropriate for viewing the data without distortion.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • mrkrishnan
    mrkrishnan Global Mapper User
    edited June 2010
    hi
    i have attached the output snapshot. In that the yellow line(draw using paint for your reference) indicates the area which i am trying to define, but i got the result in gray color area.

    These are the lines used to convert from pixel coordinate to lat long value.
    {
    // Get the current view projection
    GM_Projection_t theCurProj;
    GM_Error_t32 theErr = GM_GetProjection( &theCurProj );
    if ( GM_Error_None != theErr )
    {
    return ( theErr );
    }

    // Setup a lat/lon projection with the current datum
    GM_Projection_t theGeoProj;
    memset( &theGeoProj, 0, sizeof theGeoProj );
    theGeoProj.mProjSys = GM_PRJ_GEO;
    theGeoProj.mDatum = theCurProj.mDatum;
    theGeoProj.mUnit = GM_PRJ_UNIT_ARC_DEGREES;

    // Get the ground coordinates associated with the pixel
    double theGroundX, theGroundY;
    theErr = ConvertCoordPixelToGround( aPixelX, aPixelY, theGroundX, theGroundY );
    if ( GM_Error_None != theErr )
    {
    return ( theErr );
    }

    // Project the ground coordinates to lat/lon
    theErr = GM_ProjectPoint
    (
    theGroundX, theGroundY, &aLon, &aLat, NULL, &theGeoProj
    );
    return ( theErr );
    }

    GM_Error_t32
    GM_MapWindow::ConvertCoordPixelToGround
    (
    sint32 aPixelX, // in: x pixel coordinate in draw window
    sint32 aPixelY, // in: y pixel coordiante in draw window
    double& aGroundX, // out: ground X coordinate
    double& aGroundY // out: ground Y coordinate
    ) const
    {
    // Convert the draw rectangle into a GM_PixelRect_t
    GM_PixelRect_t theDrawRect;
    theDrawRect.mLeft = mDrawWndRect.left;
    theDrawRect.mRight = mDrawWndRect.right;
    theDrawRect.mTop = mDrawWndRect.top;
    theDrawRect.mBottom = mDrawWndRect.bottom;

    // Set the orientation
    GM_SetOrientation( mOrientation );

    // Convert the coordinate to pixel coordinates
    GM_Error_t32 theErr = GM_ConvertCoordPixelToGround
    (
    aPixelX,
    aPixelY,
    &aGroundX,
    &aGroundY,
    &mCurViewRect,
    &theDrawRect
    );

    return ( theErr );
    } // end of function GM_MapWindow::ConvertCoordPixelToGround



    Regards
    Radhakrishnan
  • global_mapper
    global_mapper Administrator
    edited June 2010
    I think the issue is that the GM_ConvertCoordPixelToGround function always assumes that the aspect ratio is being maintained, while in your case it is not. I have updated that function to use the last "maintain aspect ratio" setting from a draw, which I think will fix your issue. I have placed a new SDK build with this change at http://www.globalmapper.com/GlobalMapperSDK_v134_beta.zip for you to try.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • mrkrishnan
    mrkrishnan Global Mapper User
    edited June 2010
    Thanks mike, but i couldn't download that file. It is downloaded as 0 byte size.
    Can you check the link and let me know.
    Thanks in advance.


    Regards
    Radhakrishnan
  • global_mapper
    global_mapper Administrator
    edited June 2010
    The file downloads fine for me as a 52.2 MB file. Please try your download again as the link is correct.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • mrkrishnan
    mrkrishnan Global Mapper User
    edited June 2010
    thank you mike. i have downloaded that one and now it is working fine.


    Regards
    Radhakrishnan