Problem with getting pixels for image obtained from GM_LoadOnlineLayer

BurroWranglerBurroWrangler Global Mapper UserPosts: 26Trusted User
edited November 2011 in SDK
Hi,

When I call GM_DrawLayerListToMemory after loading any online layer using GM_LoadOnlineLayer (I tried it with the "World Topo Map") and after calling the GM_RepositionLayer function to set the layer to my desired projection, the GM_DrawLayerListToMemory does not fail, but the pixels in the layer are not set correctly. Here is some example code I have been testing:


GM_LayerHandle_t32 handle = NULL;
GM_Rectangle_t rect;
rect.mMinX = -109.59032088953033;
rect.mMinY = 40.665411856272790;
rect.mMaxX = -109.35784443932485;
rect.mMaxY = 40.872789859012883;
GM_Error_t32 err = GM_LoadOnlineLayer(NULL, &rect, &handle, NULL);
// No errors returned
GM_Projection_t proj;
proj.mProjSys = 1;
proj.mDatum = 14;
proj.mUnit = 1;
proj.mNumAttrs = 1;
proj.mAttrList[0].mAttr = 31;
proj.mAttrList[0].mValue = 12.0;
// =(UTM NAD 83 Zone 12, US Survey Feet)
err = GM_RepositionLayer(handle, NULL, 0, &proj);
// No errors returned
int windowWidth = 1193, windowHeight = 887;
// opengl::Color has an array of 4 unsigned chars and is used for holding the color data
std::vector<opengl::Color> pixels(windowWidth*windowHeight);
int rowsize = windowWidth*4;
rect.mMinX = 2001083.2658190941;
rect.mMinY = 14764527.863208400;
rect.mMaxX = 2124667.1802189052;
rect.mMaxY = 14856412.969723599;
err = GM_DrawLayerListToMemory(&handle, 1, GM_DrawFlags_EraseBackground |
GM_DrawFlags_DontMaintainAspectRatio, &rect, GM_ColorFormat_32Bit_ABGR,
1193, 887, &pixels[0], rowsize);
// No errors returned
// The pixel values are not set after the above call
err = GM_DrawLayerListToMemory(&handle, 1, GM_DrawFlags_EraseBackground |
GM_DrawFlags_DontMaintainAspectRatio, NULL, GM_ColorFormat_32Bit_ABGR,
1193, 887, &pixels[0], rowsize);
// The pixel values are set if NULL is passed for the Rectangle, but I want to always set the
// rectangle for display purposes
// No errors returned

Any ideas how I can fix this problem?

Thanks,

Chris

Comments

  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited November 2011
    Chris,

    You only use the GM_RepositionLayer function to correct the native projection of a layer or rectify it using control points. If what you want to do is instead just reproject the layer you need to use the GM_SetProjection function, not GM_RepositionLayer.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • BurroWranglerBurroWrangler Global Mapper User Posts: 26Trusted User
    edited November 2011
    Ok, thanks. GM_SetProjection works! Chris
Sign In or Register to comment.