ConvertCoordinates failing to convert from Irish Grid To ETRS89

Issue #3 resolved
Urvan created an issue

Im calling the function

ConvertCoordinates(sourceSRID, targetSRID, 0, 0,ref input, ref output, ref datum))

where sourceSRID = 29903 targetSRID = 4937

The input coordinates are : input.X = 197633.13413602728 input..Y = 42463.572674536168 input.Z =0

I tried all the datums, but no results..

The function returns TRUE, but the output =0 for each element.

See the screenshot for the DLL and DAT files I'm using

It wotks well for the UK grid

gr

Urvan

Comments (17)

  1. Paul Michell repo owner

    Urvan,

    It sound to me like you either do not have Malin Head selected as input datum, or if you are using an early version of the DLL where you have to explicitly select the revision year i.e.:

    ConvertCoordinates(29903, 4937, 2015, 0, input, output, 13)

    Please check that you are using the latest build of the DLL (available from the downloads section here dated 2016-09-11) it is more robust in its handling of revision years and will default to 2015 if not specified. By the way, are you aware that the example you give is an offshore location?

  2. Urvan reporter

    Hi Paul,

    The DLL is dated 16/08/2016 and is the latest I can find.

    But I found out that if you call the api the first time with datum =0, it will fail the rest of the times you call the API

    At this moment I’m calling the function with a non zero value and it’s returning values..

    Gr

    Urvan

    With kind regards / met vriendelijke groet, Urvan Pourier Senior Software Engineer [Description: Description: Description: Description: Description: Description: logo-van-oord-mi] Van Oord Dredging and Marine Contractors Visiting address: Schaardijk 211 3063 NH Rotterdam

    T +31 (0)88 826 8497 F +31 (0)88 826 8100 M +31 (0)629 546 311 I www.vanoord.comhttp://www.vanoord.com/ Disclaimer: This mail transmission and any attached files are confidential and are intended for the addressee only. If you are not the person or organization to whom it is addressed, you must not copy, disclose, distribute or take any action in reliance upon it. If you have received this message in error, please contact the sender by email and delete all copies of this message and all copies of any attached files.

  3. Paul Michell repo owner

    Yes that is the latest DLL. It is the zip file that is dated 2016-09-11. Do I take it you have it working now?

  4. Urvan reporter

    Hi Paul

    I have it working, but don’t know why it’s working..

    When it didn’t work, I was passing datum =0 to the API.

    After I changed that to datum =1 , I was getting results. Even when the datum =1 (Newlyn) is the wrong one..(I was passing 200000, 250000 as coordinates in IG)

    What I noticed is that if you enter the API with the datum not equal to 0, the output is always 0..Is this correct?

    Gr

    Urvan

  5. Urvan reporter

    Hi Paul

    Another question:

    Is the DLL thread safe??

    What we are trying to do is using the Irish grid, automaticly figure out which datum we are using:

    This is a part of the code: foreach (var oSGMDatum in Enum.GetValues(typeof(OSGMDatums))) { datum = (int)oSGMDatum; if (ConvertCoordinates(sourceSRID, targetSRID, 0, 0,ref input, ref output, ref datum)) { //do something }

    }

    Where the Source SRID = 29903 and the targetSRID = 4937

    public enum OSGMDatums
    {
      // NoneOrOutOfArea = 0,
      OrdnanceDatumNewlyn = 1,
      StMarys = 2,
      Douglas02 = 3,
      Stornoway15 = 4,
      //      StKilda = 5,
      Lerwick = 6,
      OrkneyNewlyn = 7,
      //FairIsle = 8,
      //FlannanIsles = 9,
      //NorthRona = 10,
      //SuleSkerry = 11,
      //Foula = 12,
      MalinHead = 13,
      Belfast = 14,
      Offshore = 15,
      OutSideOfficialExtent = 16
    }
    

    So basically if we can’t get a valid output we switch to another datum and try to get a coordinate..

    What I’m noticing is that at a certain moment every things fails and no valid coordinates are calculated..

    How are the data files loaded? Are they all loaded at once or just when you need them?

    Gr

    Urvan

  6. Paul Michell repo owner

    Urvan,

    What I noticed is that if you enter the API with the datum not equal to 0, the output is always 0..Is this correct?

    The input datum value is ignored for all transformations except those involving source coordinates in ITM or IG. In these cases it must be 13 or 14 for Malin Head or Belfast respectively. The output value only has a meaning for transformations where the target system is IG, ITM, or BNG in which case it is the datum used for the z coordinate. In these cases a return value of 0 means 'Out of Area'.

    Is the DLL thread safe??

    The honest answer is that it is untested in a multi-threaded environment. Off hand, I can't think of anything that would prevent multi-threaded use. However, you could always wrap the call in a critical section to isolate the library execution from the rest of your system.

    What we are trying to do is using the Irish grid, automaticly figure out which datum we are using

    There is no need to do this, IG never uses any datum other than 13 or 14 and this can only have two values along the border strip between NI and the Republic. All the other Data are only used with BNG non-mainland zones. Unlike IG and ITM they never overlap so there can only be one valid BNG datum for any given point.

    How are the data files loaded? Are they all loaded at once or just when you need them?

    The data files are all loaded when the DLL is first initialised. Once loaded the transformation function reads the static memory tables and makes no further use of the files. It will load all of the data files it finds, tables may be deleted if they are not going to be used. For example if you do not need BNG you can safely delete GM02GB.dat, GM15GB.dat, TN02GB.dat and TN15GB.dat. If you do not want to do GM02/TN02 transformations, you could delete all files with '02' in the name.

    Am I right in assuming your program is written in C#? Would you be prepared to submit an example of a minimal library call in C# that I can include in the examples section of the repository?

    Kind regards,

    Paul

  7. David Grover

    Hi Paul, I'm trying to get a minimal example together using C# but the return is always zero. Did you have a minimal library call in C# submitted?

  8. Paul Michell repo owner

    David,

    I'm afraid I don't have a C# example and it is a language I am not familiar with. Off the top of my head, check that the appropriate parameters are being passed by reference (however you do that in C#?). If you do get it working, I would love to add it as an additional example.

    Kind regards,

    Paul

  9. Craig Mellon

    Would be great to see an example of using this with c#, is it possible for you to post an example or instructions on how to use this library in c# please

  10. Paul Michell repo owner

    Vincent,

    I've replied to your email, but for the benefit of others reading this thread: I think your problem is you are working in degrees when GIQ.dll uses radians for angular measure! GridInquestII.exe has extra software layers that convert the angles to user specifiable formats in degrees, whereas GIQ.dll is a much lower level interface that works entirely in radians for angles and metres for scalars. You have to perform any desired unit conversions yourself.

    Kind regards,

    Paul

  11. Paul Michell repo owner

    If there is anyone who has a working sample in C# that they would be willing to share, I would gladly add it to the repository for the benefit of other C# programmers out there.

    Thanks,

    Paul

  12. Mrinal Das

    Hi Paul,

    I have been looking at using your GridInQuestII library from C# code. I was a stuck initially, but after going through your comments above I have now got working copy of C# wrapper code. I am trying to find out best way to share the code for adding to your examples list, if there is an easy way through bitbucket.

    Thanks.

    Kind regards,

    Mrinal

  13. Paul Michell repo owner

    Mrinal,

    Thank you. If it is in your own repository, I could copy it from there and upload it as part of the examples here. Alternatively, if you would like to email me a zipped copy of the files I could work from that. A contact email is available on my website here: http://michellcomputing.co.uk/contact.html.

    Kind regards,

    Paul

  14. Mrinal Das

    Hi Paul,

    Thank you for your quick response and thank you for your excellent effort with coordinate transformations and most importantly making the library available publicly. 

    I have emailed you the source files of C# wrapper with examples. Please add to your examples list as it will be easier for others to find those in single place.

    Thank you again for your excellent effort.

    Kind regards,

    Mrinal

  15. Log in to comment