Vector Map Detail adjustment via SDK

Matt_ThalesMatt_Thales Global Mapper UserPosts: 4
edited March 2012 in SDK
Hi,

The Vector Display tab of the Configuration dialog on Global Mapper application has a slider to control the vector detail shown when the map is drawn. I would like to replicate that effect through the SDK so I can reduce draw times when working with large vector maps.

Is that possible? I haven't found anything in the function reference yet.

Thanks

Comments

  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited March 2009
    While that is not exposed in the function reference, you can modify it by editing the registry. The value is stored in 'HKEY_CURRENT_USER\Software\Global Mapper\DetailOffset' (note that if you use GM_SetRegistryKey to move the settings location then 'Global Mapper' will be replaced by whatever you used in that call). The value is a DWORD, but should range from -150 (always show everything) to +150 (only show stuff when zoomed way in). The default is -150. Note it is a DWORD value, so negative values will look funny in regedit.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • Matt_ThalesMatt_Thales Global Mapper User Posts: 4
    edited March 2009
    Thanks,

    But it seems from my experiments that the registry value is only read at startup. What I really want to be able to do, is adjust the detail as the user zooms in and out. So I need to adjust the detail during runtime.
    Is it possible to do that?
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited March 2009
    Actually the detail setting is already meant to modify the level of detail displayed as you zoom in and out. Basically each feature type has a zoom level that it should be displayed at or above. The calculated view zoom level is offset by the specified detail level to make those features show up sooner or later than normal. The default value of -150 makes all features show up at all zoom levels. Anything greater than that and you'll have to zoom in further for some feature types (like residential roads) to show up.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • Matt_ThalesMatt_Thales Global Mapper User Posts: 4
    edited March 2009
    OK, now that I know what's going on, it does improve things.

    However once I've set the value to a setting where I get all the detail I need at the lower levels it does mean there's still more detail than necessary when zoomed right out.

    Thanks.
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited March 2009
    If you set the value even higher does it not give you enough at lower levels? The only way to get rid of stuff at higher zoom levels would be to set the detail level even lower. Some types are always displayed regardless of zoom level and detail setting as well.

    You could also forgo the built-in detail slider altogether and implement your own zoom-level based filtering however best fits your needs. Use the GM_SetFeatureClassEnabled function to toggle different types on and off.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • diofantisdiofantis Global Mapper User Posts: 35Trusted User
    edited March 2009
    One relative question (i believe),
    is there a way (a drawing flag for example, that i can not find) that forces one point feature not to be displayed because it is located on top of another point feature?
    A similar thing is already happening with the labels (you can not find two labels ontop of each other)

    Also, is there a way to hide a specific point/area/line and show it later?

    Thanks,
    Mike.
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited March 2009
    Mike,

    While there isn't an automatic way to hide a feature because it is under another (it will be obscured just by virtue of something being drawn on top), you can manually turn a feature off by using the GM_DeleteFeature function, then you can call that again to undelete the feature and make it display again.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • DanaBDanaB Global Mapper User Posts: 13
    edited March 2012
    Hi Mike

    Can you expand on the custom zoom-level based filtering mentioned. When using the GM_SetFeatureClassEnabled function to provide a More / Less detail view how do you configure a specific overlay (Map Catalog) for the different (x6 ?) settings. The idea is to provide the operator with a More/Less button to show/hide selected data.

    Thanks
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited March 2012
    The enabling of different feature classes based on zoom level is a global setting and not something that applies to a particular layer (like a map catalog), although I suppose if you drew each layer separately you could turn different feature types on and off around that draw to make the detail from one particular layer be higher than others.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • DanaBDanaB Global Mapper User Posts: 13
    edited March 2012
    Hi Mike

    I've tested the following code to manipulate the Vector Map Detail. The GM_GetFeatureClassInfo causes an "AccessViolationException was unhandled" error.

    Any idea what could cause this error. Without the GM_GetFeatureClassInfo I do manage to set using
    GM_SetFeatureClassEnabled ... until a gap is reached and a SDK exception is reported.

    The Test code:


    private void setFeature(byte setvalue)
    {

    GlobalMapperDLL.GM_FeatureClassInfo_t featureClassInfo = new GlobalMapperDLL.GM_FeatureClassInfo_t();

    for (GlobalMapperDLL.GM_FeatureClassType_t8 featureClassType = 0; featureClassType < GlobalMapperDLL.GM_FeatureClassType_t8.GM_FeatureClass_NumTypes; ++featureClassType)
    {
    UInt16 featureClass = 0;
    UInt16 featureClassMax = 0;
    bool currEnabled = false;

    switch (featureClassType)
    {

    case GlobalMapperDLL.GM_FeatureClassType_t8.GM_FeatureClass_Area:
    featureClass = (ushort)AreaFeatureClass_t16.AFC_MIN;
    featureClassMax = (ushort)AreaFeatureClass_t16.AFC_MAX_BUILTIN;
    break;

    case GlobalMapperDLL.GM_FeatureClassType_t8.GM_FeatureClass_Line:
    featureClass = (ushort)LineFeatureClass_t16.LFC_MIN_LINE;
    featureClassMax = (ushort)LineFeatureClass_t16.LFC_MAX_LINE;
    break;

    case GlobalMapperDLL.GM_FeatureClassType_t8.GM_FeatureClass_Point:
    featureClass = (ushort)PointFeatureClass_t16.PFC_MIN_POINT;
    featureClassMax = (ushort)PointFeatureClass_t16.PFC_MAX_POINT;
    break;
    default:
    continue;
    }

    for (; featureClass < featureClassMax; ++featureClass)
    {

    LastGMError = GlobalMapperDLL.GM_GetFeatureClassInfo(featureClass, featureClassType, ref featureClassInfo);

    if (LastGMError == GlobalMapperDLL.GM_Error_t32.GM_Error_None)
    currEnabled = GlobalMapperDLL.GM_SetFeatureClassEnabled(featureClass, featureClassType, setvalue);

    }
    }
    }
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited March 2012
    What do your declarations for the GM_GetFeatureClassInfo, GM_SetFeatureClassEnabled, and GM_FeatureClassInfo_t structures look like? In particular, make sure that you make the 'boolean' type a 'byte', and not a C# 'bool', as the C# 'bool' is a 32-bit value and not 8-bit like the 'boolean' in the C header. Here are declarations that I just added:


    // Retrieves information about a given feature class
    [DllImport(DLLFileName, EntryPoint = "GM_GetFeatureClassInfo")]
    public static extern GM_Error_t32 GM_GetFeatureClassInfo
    (
    UInt16 aFeatureClass, // IN: Feature class to get info for
    GM_FeatureClassType_t8 aFeatureClassType, // IN: Type of feature class (area, point, line)
    ref GM_FeatureClassInfo_t aFeatureClassInfo // OUT: Info about the feature class
    );

    // Enables or disables the display of the given feature class. The previous
    // enable/disable state is returned.
    [DllImport(DLLFileName, EntryPoint = "GM_SetFeatureClassEnabled")]
    public static extern byte GM_SetFeatureClassEnabled
    (
    UInt16 aFeatureClass, // IN: Feature class to get info for
    GM_FeatureClassType_t8 aFeatureClassType, // IN: Type of feature class (area, point, line)
    byte aEnable // IN: Enable or disable the feature class
    );



    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • DanaBDanaB Global Mapper User Posts: 13
    edited March 2012
    Hi Mike

    My structure declarations are OK. The only discrepancy was my GM_SetFeatureClassEnabled that returned a boolean. Even after fixing that I still get the same "AccessViolationException was unhandled" error. I am using Visual Studio 2008. I can see the return values of GM_GetFeatureClassInfo being correct in Debug mode after the error. Any ideas ?

    On a similar topic - what would be an elegant way of manipulating Vector Map Data via the SDK? Reading pre-configured filter files for different display levels that contain the feature types and feature classification status? or is there a standard Global Mapper preset table for the different more/less levels?

    Hope you can assist with these...
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited March 2012
    I'm investigating. I'm seeing the same thing as you in the sample application. However it works fine in the C++ sample application, so it is something with the call from C#, I'm just not quite sure what yet.
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited March 2012
    I found the problem, the GM_FeatureClassInfo_t structure needs to have the mDesc as an IntPtr not a String because the C# String can't hold a const char* that is returned from the SDK. It can be used to pass one in though. To get the string you would have to do some Marshal stuff to get the string from the pointer..

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
Sign In or Register to comment.