Problem with getting pixels for image obtained from GM_LoadOnlineLayer
BurroWrangler
Global Mapper UserTrusted User
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
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
-
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 -
Ok, thanks. GM_SetProjection works! Chris
Categories
- 12.7K All Categories
- 5.6K Features Discussion
- 342 Downloading Imagery
- 1.3K Elevation Data
- 380 Georeferencing Imagery Discussion
- 628 GM Script Language
- 53 User Scripts
- 113 GPS Features
- 414 Projection Questions
- 819 Raster Data
- 1.3K Vector Data
- 6.6K Support
- 177 Announcement and News
- 908 Bug Report
- 558 SDK
- 1.2K Suggestion Box
- 3.7K Technical Support
- 562 Other Discussion
- 129 GIS Data Sources
- 27 Global Mapper Showcase
- 233 How I use Global Mapper
- 107 Global Mapper Forum Website