GM_GenerateContours for a number of elevation layers

OseiOsei Global Mapper UserPosts: 119Trusted User
edited July 2010 in SDK
I would like to generate contours for a number of elevation layers. At the moment, contours can be generated for a single elevation layer or all loaded elevation layers. I would like to generate contours for a number of elevation layers just like GenerateElevationGrid can generate grids for a number of loaded layers.

In otherwords, can GenerateContours be like

GM_Error_t32 GM_GenerateContours
(
GM_LayerHandle_t32* aLayerList, // List of layers to use or null for all
uint32 aLayerCount, // Number of layers in list (0 for all)
const GM_ContourParams_t* aContourParams, // Parameters for generating contours
GM_LayerHandle_t32* aContourLayer // OUT: Created contour layer
);

Thanks

Comments

  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited July 2010
    I have added a new GM_GenerateContoursEx function that takes a list of layers to use. I have placed a new SDK build with this functionality 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
  • OseiOsei Global Mapper User Posts: 119Trusted User
    edited July 2010
    Thanks a lot for the extra function. However, I have realised that the function does not work as expected.
    I have 3 grids and I try to generate contours for 2 of the grids (ElevationRaster-XXX).

    1. If I turn off the 3rd grid (the biggest one, Energy-XXXX) and I generate contours, I get the expected result as in expected_.gmp.
    2. If I turn on the 3rd grid and I generate contours, I get the contours generated with artefacts in the contours generated as in artefacts_.gmp.

    It seems the 3rd grid is still being used to generate the contours. How do I make it such that whether the 3rd grid is on/off does not matter?

    I have attached a zip file of the results I got.

    Thanks a lot in advance.
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited July 2010
    Can you show me how you are calling the new GM_GenerateContoursEx function to get just your two smaller layers considered? Also I notice that the bottom right smaller layer has edges where the elevation values increase steeply so you'll get contours you likely don't want, regardless of whether or not the 3rd layer is considered.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • OseiOsei Global Mapper User Posts: 119Trusted User
    edited July 2010
    After careful investigation and experimentation, I have been able to single out the causes of the strange results I get when generating contours from multiple grids.

    1. During the lifetime of the application, I set the Elevation Overrides for each grid layer. This is in order for me to set the Shader Name to something different.
    Process
    Call GetElevationOverrides
    Modify shader name
    Call SetElevationOverrides with modified ElevationOverrides

    This causes different results in that I get less contours generated. There are places where no contours are generated at all. I get 31 contours instead of the expected 61 contours. In fact, contours below 350 are not generated and apparently, 343 meters is the lowest elevation of the 3rd grid. This makes me believe that the 3rd grid still has an effect on the contours generated even though it is not used in the contour generation process.

    2. In the case of the artefacts, I have realised that if I load the grids from file directly, I don't have problem with artefacts. I however seem to have problems if I load the two grids from a Global Mapper Package file.
    To reproduce,
    1. Load file.gmp
    2. Load energy.xyz
    3. Do GenerateContoursEx with energy.xyz being visible.
    The artefacts are present.

    I have attached a modified C# sample application together with the files to help you reproduce problem 2.
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited July 2010
    Can you show me your code where you are calling and setting GM_GetElevationOverrides and GM_SetElevationOverrides along with your declarations for those functions? From your problem description I'm guessing there is an issue with the C# declaration of one of those functions or structures, resulting in the strange behavior.

    For the issue with the grid, if you don't want the .xyz file being considered when gridding shouldn't you not be passing it into the GM_GenerateContoursEx function? You should only pass in the list of layers that you want to consider to that function.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • OseiOsei Global Mapper User Posts: 119Trusted User
    edited July 2010
    I have tried to reproduce the problem in the C++ sample application. I have attached the source code. You would have to copy the GlobalMapper SDK into the Debug folder first in order to run it.

    To reproduce problem,
    1. Load file.gmp
    Loads two layers into the application.
    2. Select both layers in the ListView and click on "Generate Contours" to generate contours
    Contours get generated with message "0 areas, 65 lines, and 0 points"
    Expected contours generated...

    =============================================================
    3. Select "Generated Contours" layer and Close it.
    4. Load in energy.xyz file as Elevation Layer with UTM Zone 30 projection
    5. Select the two ElevationRaster layers as before in step 2 and click on "Generate Contours" to generate contours
    Contours get generated with message "0 areas, 136 lines, and 0 points"

    The contours generated contain the artefacts even though the energy.xyz layer was not used in the generation of the contours.

    I believe strongly that this has to do something with the fact that the 1st 2 elevation layers were loaded from a gmp file. The gmp file was created from two xyz elevation grids that I exported to a gmp file. If I therefore use the original 2 xyz grids, I get the expected results as well
    1. Load "lower right.xyz"
    2. Load "top right.xyz"
    3. Load energy.xyz with UTM Zone 30 projection (the default)
    4. Select "lower right" and "top right" layers and click on "Generate Contours" to generate contours.
    Contours generated with message "0 areas, 61 lines and 0 points" and the contours do not have any artefacts.

    =====================================================================
    Still working on porting the ElevationOverrides problem to the C++ application. Once I finish, I will post it here too.
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited July 2010
    I will take a look later today and see if I can reproduce what you are seeing and determine the cause.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited July 2010
    I was able to reproduce your issue and get it fixed. The extra layer was erroneously bleeding through at the edges even though it was on top and not involved in the contour operation. I have placed a new SDK build with this fixed 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
  • OseiOsei Global Mapper User Posts: 119Trusted User
    edited July 2010
    So far I have been able to fix one of the problems I outlined earlier. I am still left with fixing the second problem which involved problems after calling SetElevationOverrides.

    I have further modified the C++ sample application to further demonstrate this problem and the source code has been attached. Once again, you would have to copy the Global Mapper SDK into the Debug folder first in order to run it.

    1. Load file.gmp
    Loads two layers into the application.
    2. Load energy.xyz into application as Elevation Layer with UTM Zone 30 projection.
    3. Select first 2 layers in the ListView and click on "Generate Contours" to generate contours
    Contours get generated with message "0 areas, 65 lines, and 0 points"
    Expected contours generated...
    ===============================================================

    4. Select "Generated Contours" layer and close it.
    5. Click on "Add Custom Shaders" and "Set Elev Overrides" buttons
    6. Select the two ElevationRaster layers as before in step 3 and click on "Generate Contours" to generate contours
    Contours get generated with message "0 areas, 34 lines, and 0 points"

    The contours generated do not go below 343.39 meters which happens to be the lowest elevation of the energy.xyz grid. This means contours 340 and below do not get generated even though the energy.xyz layer was not used in the generation of the contours.

    This happens even if I use "top right.xyz" and "lower right.xyz" instead of file.gmp.
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited July 2010
    I took a look and found the issue was related to using layer-specific shaders rather than sharing a shader. I have fixed it and now the correct elevation range is used. I have placed a new SDK build with the fix 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
Sign In or Register to comment.