MapInfo Pro Developers User Group

Expand all | Collapse all

What is the best way to extract geography objects as WKT?

  • 1.  What is the best way to extract geography objects as WKT?

    Posted 10-11-2018 06:30

    We have an .NET extension that need to extract geography objects as WKT. Today we are using a combination of ObjectInfo/ObjectGeography/ObjectNodeX/ObjectNodeY to extract the information needed and build the WKT. However this has very bad performance and becomes useless with large objects.

    We have looked at the new MDAL API and it looks promising but how can we use that to access tables that are open in MI Pro?

    The documentation stated "Pro style transactions on MapInfo and MapInfo Extended tables - This allows for background threads to edit tables open in Pro and let the end user decide to commit or revert the changes." but I can't find any more information about this.

    Thanks!

    /Krister

     



  • 2.  RE: What is the best way to extract geography objects as WKT?

    Posted 10-11-2018 03:28
      |   view attached

    Hi Krister,

    You are on the right path. MDAL, MapInfo Data Access Library, is what you are looking for. It's basic a subset of MapXtreme .NET so if you have any experience using this, it will be easy for you to use.

    Did you have a look at the Extensibility Reference Help that can be found in the MapBasic v17.0 installation folder?

    MDAL Help

    Look for this method in the Help file: FeatureGeometryFactory.FeatureGeometryToWKT.

    Also we have included a sample application that gives you some basic samples to get started using the MDAL. Have a look at the MapInfoDataAccessLibraryExample in this folder: Samples\RIBBONINTERFACE\DotNet\MapInfoDataAccessLibraryExamples.

    PS: Congratulations on your award for Most Innovative Design at the Pitney Bowes EMEA Partner Conference!



  • 3.  RE: What is the best way to extract geography objects as WKT?

    Posted 10-11-2018 03:43

    Hi Peter,

    Thanks for your reply and congratulations!

    Yes, I have been looking at the documentation and have a good knowledge of MapXtreme but my problem is how to access tables that are open in MI Pro. When I first heard of MDAL I thought that the Catalog would automatically contain all tables that are open in MI Pro but as I understand it now I need to call OpenTable as in MapXtreme.

    So if the user has uncommited changes in TAB-files that are open in MI Pro I can't access that data using MDAL.

    What I do now is that i execute a query in MapBasic and save that to a temporary table. I then commit that table to a file that I open in MDAL. This works but I do not like having to write a file each time I execute a query.

    Something like this:

    MIDo("Select * From Test Where {CONDITIONS} Into \"TempTable\" Noselect");

    MIDo("Commit Table TempTable As \"C:\\temp\\TempTable.tab\"");

    MapInfo.Engine.Session.Current.Catalog.OpenTable("C:\\temp\\TempTable.tab");

     

     



  • 4.  RE: What is the best way to extract geography objects as WKT?

    Posted 10-11-2018 05:13

    If you are building the query yourself, you could do something along these lines:

    MICommand command = connection.CreateCommand();

    IResultSetFeatureCollection resultset = null;

    command.CommandText = "Select * From Test Where {CONDITIONS}";

    command.ExecuteFeatureCollection(resultset,ResultSetCombineMode.Replace);

    which would result in a set of features in the FeatureCollection resultset.



  • 5.  RE: What is the best way to extract geography objects as WKT?

    Posted 10-12-2018 02:02

    Yes, but my problem is accessing table Test in MDAL. To use your code above I first need to load the table with MapInfo.Engine.Session.Current.Catalog.OpenTable("{PATH_TO_TABLE}\\Test.tab"); and if Test has uncomitted changes in MI Pro I will not have access to that data.



  • 6.  RE: What is the best way to extract geography objects as WKT?

    Pitney Bowes
    Posted 10-21-2018 18:28

    ?You are correct that MDAL cannot currently access uncommitted transactions to a Mapinfo table. On the Pro team we require that any transactions be committed or reverted before attempting to modify the table using MDAL. Read access to the base table should be ok.

     

    You workaround makes sense if you can identify which records are in the transaction file.