MapInfo Pro

Expand all | Collapse all

Adding in a WFS Server programatically

  • 1.  Adding in a WFS Server programatically

    Posted 05-07-2021 02:41
    G'day All,

    I am in the process of integrating our DBYD Ticket WFS feed in a workspace using allowing the user to enable and disable the layer
    via a custom dialog. This works well on the PC I am testing on as I have manually added the server into the server list.

    However when I try it on a machine that it has not been manually entered, I get the username and password screen to access the WFS feed but even after entering the correct credentials nothing happens and I presume it is because the server has not been manually added into the server list on those PC's.

    Rather than actually adding the server to every pc manually, Is there a way to add in a WFS server programatically? I am coding in Mapbasic.




    Thanks in advance,
    Murray

    ------------------------------
    Murray Jamieson
    Waratah-Wynyard Council
    Wynyard TAS
    ------------------------------


  • 2.  RE: Adding in a WFS Server programatically

    Posted 05-10-2021 04:00
    Hi Murray

    There is no specific MapBasic statement for doing this.
    However, the server list is stored in an XML file: %appdata%\MapInfo\MapInfo\Professional\1900\MIWFSServers.xml.

    <?xml version="1.0" encoding="UTF-8"?>
    <MI_WFS_ServerList version="1.0">
      <Server>
        <HTTP>http://www.mapinfo.com/miwfs</HTTP>
        <Description>MapInfo Web Feature Service Demo</Description>
        <Default/>
      </Server>
      ...
      <Server>
        <HTTP>http://kort.aws.dk/geoserver/aws4/wfs?</HTTP>
        <Description>Danmarks Autoritative Adresser</Description>
        <WFSVersion>1</WFSVersion>
      </Server>
    </MI_WFS_ServerList>

    Each server starts with the <Server> tag and ends with the similar end tag </Server>.
    This means you can add a new server by writing the necessary elements to the file.

    Be aware that the file does look nicely formatted with each element on a new individual line. But you can't be sure of that.

    You can edit the file using the Open File and write the lines to a copy as you read them in a temporary folder.
    Add the new server at the of the file end or the beginning of the file.
    Once done, close the two files and rename the temporary file to replace the existing file.

    ------------------------------
    Peter Horsbøll Møller
    Principal Presales Consultant | Distinguished Engineer
    Precisely | Trust in Data
    ------------------------------