GM_LoadTerraServerLayer problem

golfmonkegolfmonke Global Mapper UserPosts: 13
edited October 2008 in SDK
Hello,

I'm attempting to call GM_LoadTerraServerLayer and am getting the following exception:

AccessViolationException was unhandled

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Has anybody seen this exception and know what the problem is?

I've been searching on google for answers for a while now, and have only been using C# for a week now, so i've really got no clue what's going on here :(

Btw, I am using the C# Example application, and I am calling GM_LoadTerraServerLayer at the end of the
frmMain() method in frmMain.cs


Mike

Comments

  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited October 2008
    Can you provide your declaration of the GM_LoadTerraServerLayer function and how you are calling it?

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • golfmonkegolfmonke Global Mapper User Posts: 13
    edited October 2008
    Hi Mike,

    Here is the declaration in GlobalMapperDLLWrapper.cs
    [DllImport(DLLFileName, EntryPoint = "GM_LoadTerraServerLayer")]
            public static extern GM_Error_t32 GM_LoadTerraServerLayer(String aFilename, 
                GM_Rectangle_t rectangle, out IntPtr aLayer);
    

    In words this is what i'm doing.....

    1 - Calling GM_LoadRectifiedLayer with the world file projection
    2 - Drawing the Image
    3 - setting a GPS lat/long projection
    4 - calling draw image
    5 - getting the Info.GM_Rectangle_t and passing it into GM_LoadTerraServerLayer, calling with ("UrbanArea") theme

    I'm in the process of trying it without doing the first 5 steps, will see if it makes a difference.

    Mike
  • golfmonkegolfmonke Global Mapper User Posts: 13
    edited October 2008
    Just tried it without all the steps, just creating a rectangle and making the call, same result. I took the values for the rectangle from the rectangle gathered in step 5 above, and they look correct to me.
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited October 2008
    I think it is the rectangle parameter that is the problem. It needs to be declared as 'ByRef' or perhaps 'out' (I'm not a C# programmer) as the SDK expects a pointer to a GM_Rectangle_t structure and not a copy of the structure.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • golfmonkegolfmonke Global Mapper User Posts: 13
    edited October 2008
    OK, I have tried it with both the ref and out keywords and the exception has gone away, but it doesn't draw the image to the viewer..... (all i've done is change the GM_LoadLayer to GM_LoadTerraServerLayer in the LoadLayer(string file) method of frmMain.cs. Using load layer the viewer displays the image fine, are there different steps to follow to be able to draw a layer that is loaded with GM_LoadTerraServerLayer?

    BTW, how can I tell which parameters expect a reference and which ones expect a copy?

    by looking at the sdk function reference...

    M_DLL_EXPORTED GM_Error_t32 GM_LoadTerraServerLayer
    (
    const char* aThemeName, // in: name of the theme to load ("drg", "doq", etc.) or NULL to ask user
    const GM_Rectangle_t* aLatLonRect,// in: lat/lon rect to import (NULL to ask user)
    GM_LayerHandle_t32* aLayer // out: handle to loaded TerraServer layer
    );

    from what I remember from C++, the * indicates a reference right?

    But the definition doesn't require the ref or out keyword for aThemeName, is there a way for me to distinguish?

    Thanks a lot!
    Mike
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited October 2008
    Mike,

    The '*' means the address of a variable, which will pretty much always be a reference. The String class is special in that it implicity supplies a pointer to the character buffer, so a String by value is a char*.

    What are you passing in for the rectangle to draw? You might define the rectangle parameter as an IntPtr and pass 0 for NULL so that you get a dialog prompting the user. Also, what are you passing for the theme name? Is the function returning an error?

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • golfmonkegolfmonke Global Mapper User Posts: 13
    edited October 2008
    Ah, ok, good to know.

    I'm passing in the following rectangle (which I obtained after loading another terra server jpg file w world file and projection, that one displayed properly btw..)


    GM_Rectangle_t rectangle = new GM_Rectangle_t();

    rectangle.MaxX = -73.529649993015354;
    rectangle.MaxY = 41.359154296624325;
    rectangle.MinX = -73.533636419060571;
    rectangle.MinY = 41.356150725150535;

    I tried passing in these values after passing in a null IntPtr and getting the popup.

    No errors (GM_Error_None) and the image still doesn't get drawn. I am passing in "UrbanArea" for the theme btw.

    I'm going to try saving the layer to an image file, see if anything is there.

    Also gonna try some other themes to see if I get anything.

    BTW, this is the rectangle for the TerraServer image which I purchased, so they must have this area in some theme.
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited October 2008
    You say that you purchased a block of data. Are you perhaps talking about terraserver.com data, which is completely different from the TerraServer-USA data served up in Global Mapper? The TerraServer-USA data is free USGS DRG, DOQ, and urban area imagery, whereas terraserver.com is a commercial imagery vendor that sells data.

    You might try the DRG or DOQ layer as they should cover that area, whereas the UrbanArea layer only has very limited coverage and will be blank in most cases (it is good where it exists though).

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • golfmonkegolfmonke Global Mapper User Posts: 13
    edited October 2008
    Jeeez, I knew it was too good to be true :P

    Yes, it is an image file from TerraServer.com, I figured it was the same thing. :(

    Let me try another theme and see what kind of crap I get :P
  • golfmonkegolfmonke Global Mapper User Posts: 13
    edited October 2008
    Yep, that works perfectly, it isn't what I need, but it works fine.

    BTW, do you know of any other color satelite image provider besides TerraServer.com that I could check out as a source of images?

    They are kind of expensive, I plan on trying to negotiate a bulk deal, but would be nice to know if there are other possible sources.
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited October 2008
    DigitalGlobe is generally considered the #1 provider of high-res imagery worldwide. In the Global Mapper application you can use the File->Download Online Imagery menu command to pull that data down, both free watermarked data and premium unwatermarked imagery that you can export. You can purchase premium access from Global Mapper - Purchase DigitalGlobe Imagery Access or even purchase imagery directly from them at DigitalGlobe | An Imagery and Information Company.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • golfmonkegolfmonke Global Mapper User Posts: 13
    edited October 2008
    I see , ya I have been to their site before.....

    I need to use these images for commercial use and be able to distribute them on handhelds purchased by customers so I don't think that qualifies with the Terms of service document listed on your purchase page.
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited October 2008
    They are pretty restrictive with what you can do with their data, so you might have to go with someone else.
Sign In or Register to comment.