Avoid Projection Dialog
Hi,
(1) I would like to set the default projection so the projection dialog does not show when I load a layer.
(2) I will almost always work with the RD (Dutch Grid) Proj. To create a GM_Projection_t, do I have to set the Proj, Datum, Unit, and all the attributes or is there any way to let the SDK fill those parametes (as the Projection dialog must do internally)?
Thanks a lot
Oscar
(1) I would like to set the default projection so the projection dialog does not show when I load a layer.
(2) I will almost always work with the RD (Dutch Grid) Proj. To create a GM_Projection_t, do I have to set the Proj, Datum, Unit, and all the attributes or is there any way to let the SDK fill those parametes (as the Projection dialog must do internally)?
Thanks a lot
Oscar
Comments
-
Oscar,
What you can do is use the GM_SetQueryProjectionCallback function to provide your own function to call when the projection for a layer cannot automatically be determined. Then you just fill in the provided GM_Projection_t structure as below:
aProj.mProjSys = GM_PRJ_DUTCH_GRID;
aProj.mDatum = GM_DATUM_DUTCH;
aProj.mUnits = GM_PRJ_UNITS_METERS;
aProj.mNumAttrs = 0;
When you use the GM_PRJ_DUTCH_GRID projection the parameters are implied.
Let me know if I can be of further assistance.
Thanks,
Mike
Global Mapper Support
support@globalmapper.com -
I am working in c#, I extended the wrapper in with the following function:
[DllImport(DLLFileName, EntryPoint = "GM_SetQueryProjectionCallback")]
public static extern void GM_SetQueryProjectionCallback(GM_QueryProjectionCallbackFunc aCallbackFunc);
As expected, the GM_QueryProjectionCallbackFunc is unknown. The only reference I found in GlobalMapperInterface.h is:
typedef boolean (__stdcall *GM_QueryProjectionCallbackFunc)
(
GM_Projection_t* aProj, // OUT: projection structure to fill in
const GM_Point_t* aInitialPos, // IN: optional coordinate in projection
GM_ElevUnits_t8* aElevUnits // OUT: optional, set to elevation
);
I don't know what to do with this, to tell you the truth.
What kind of function must the callback be? Void? returning a projection?
Thanks
Oscar -
Further information,
I have created the type
public delegate bool GM_QueryProjectionCallbackFunc(out GM_Projection_t aProj, GM_Point_t aInitialPos, out GM_ElevUnits_t8 aElevUnits) in the wrapper.
In my application I set the callback as:
GlobalMapperDLL.GM_QueryProjectionCallbackFunc myCallbackDelegate = new GlobalMapperDLL.GM_QueryProjectionCallbackFunc(setDutchProjection);
GlobalMapperDLL.GM_SetQueryProjectionCallback(myCallbackDelegate);
And the function itself is:
private static bool setDutchProjection(out GM_Projection_t aProj, GM_Point_t aInitialPos, out GlobalMapperDLL.GM_ElevUnits_t8 aElevUnits)
{
aProj = new GM_Projection_t();
aProj.mProjSys = PROJSYS.GM_PRJ_DUTCH_GRID;
aProj.mDatum = DATUM.GM_DATUM_DUTCH;
aProj.mUnit = UNIT.GM_PRJ_UNIT_METERS;
aProj.mNumAttrs = 0;
aElevUnits = GlobalMapperDLL.GM_ElevUnits_t8.GM_ElevUnit_Meters;
return true;
}
All trying to imitate the GlobalMapperInterfac.h definition mentioned in the previous message.
It launches a GM_LoadError when calling GM_LoadLayer
Any idea?
Thanks
Oscar -
Oscar,
I think you are close, you just need to correct your callback function declaration. Try the following (note the pointer parameters should be 'ref' so that pointers are passed and the 'boolean' type in the SDK maps to 'Byte' in C#, not the C# 'bool' which is 4 bytes):
// Message callback function declaration
public delegate Byte GM_QueryProjectionCallbackDef
(
ref GM_Projection_t aProj, // OUT: projection structure to fill in
ref GM_Point_t aInitialPos, // IN: optional coordinate in projection
ref GM_ElevUnits_t8 aElevUnits // OUT: optional, set to elevation
);
[DllImport(DLLFileName, EntryPoint = "GM_SetQueryProjectionCallback")]
public static extern void GM_SetQueryProjectionCallback
(
GM_QueryProjectionCallbackDef aCallBackFunc
);
Let me know if I can be of further assistance.
Thanks,
Mike
Global Mapper Support
support@globalmapper.com
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