MapInfo Pro Developers User Group

 View Only
Expand all | Collapse all

There seems to be a distance limit to the CartesianOffsetXY function

  • 1.  There seems to be a distance limit to the CartesianOffsetXY function

    Posted 04-07-2020 09:28
    Hi, We have a MapInfo table of region objects representing specific symbology (letters and arrows).
    Previously in a MapX application we transformed the location of these objects using the basic transformation of coordinate formula for each node.
    But in MapInfo 64bit (MBv17) I was trying to make use of the CartesianOffsetXY function. This works fine but seems to be limited to an offset of100000m. Is there any particular reason for this? I want to be able to relocate these objects anywhere within the UK.
    If there is a limit as it looks then I'll have to revert to altering each node mathematically.
    Thanks
    David

    ------------------------------
    David Wilson
    Buchanan Computing
    London, UK
    ------------------------------


  • 2.  RE: There seems to be a distance limit to the CartesianOffsetXY function

    Employee
    Posted 04-08-2020 08:37
    Edited by William Wemple 04-08-2020 08:38
    I am not aware of a limit although there could be one . 
    If you export this table to the MIF format, you can edit the MIF file  in a text editor and use a TRANSFORM clause in the header to shift objects however far you want in X or Y units, or move them into a different quadrant  of the Earth for that matter.  Re-import the MIF and  check your results.
    There is a tool provided with MIPro called Register Vector that does this via a UI to move objects in a map, but it's just as easy to do this in a MIF file.
    See the documentation in MapInfo Pro User Guide for MapInfo Interchange Format (last section under Useful Tables and Information)
    The transform clause has the following syntax:
    TRANSFORM Xmultiplier, Ymultiplier, Xdisplacement, Ydisplacement
    A zero used instructs MapInfo Pro to ignore that parameter.
    Insert this TRANSFORM clause right after the CoordSys clause in the MIF file header.

    So if you just wanted to move all objects in the table  500000 meters East  (east of PM in the UK) you would add a transform clause like this:
    TRANSFORM 0, 0, 500000, 0

    Hope this helps.
    -Bill

    ------------------------------
    Bill Wemple
    Principal QA Engineer
    Pitney Bowes
    Troy, NY
    ------------------------------



  • 3.  RE: There seems to be a distance limit to the CartesianOffsetXY function

    Posted 04-08-2020 08:50
    Hi Bill,
    Thanks for the reply. Unfortunately we want to repeatedly copy/move objects differing amounts as required by the user.
    So I've just modified the procedure to update every node in the required object as we did in the old MapX code.
    It's not that slow but I expect the main MB function would have been quicker.

     for i = 1 to ObjectInfo(oObject,OBJ_INFO_NPOLYGONS)
      for j = 1 to ObjectInfo(oObject,OBJ_INFO_NPOLYGONS +i) -1
       X = ObjectNodeX(oObject,i,j) + iOffX
       Y = ObjectNodeY(oObject,i,j) + iOffY
       Alter object oObject  node set position i, j (X,Y)
      Next
     next

    Cheers
    David


    ------------------------------
    David Wilson
    Buchanan Computing
    London, UK
    ------------------------------



  • 4.  RE: There seems to be a distance limit to the CartesianOffsetXY function

    Posted 04-09-2020 09:05
    Hi David
    100000m or 1000000m?
    Could this be a Bounding Co-ordinates issue?​

    ------------------------------
    John Ievers
    CDR Group
    Hope Valley, United Kingdom
    ------------------------------



  • 5.  RE: There seems to be a distance limit to the CartesianOffsetXY function

    Posted 04-09-2020 09:48
    Hi John
    I do not think so. I've tried doing it manually in the MapInfo MapBasic window as below and the points do not appear at the correct location.
    But my previous post altering the nodes works ok.

    set coordsys Earth Projection 8, 79, "m", -2, 49, 0.9996012717, 400000, -100000 Bounds (1, 1) (680000, 1250000)
    set distance units "m"
    dim o as object
    dim cosmo as string
    cosmo = windowinfo(frontwindow(),10)
    o = createpoint(100000,100000)
    o = cartesianoffsetXY(o,0,300000,"m")
    insert into cosmo (obj) values (o)
    Set Map  Center (100000, 200000)

    Cheers
    David

    ------------------------------
    David Wilson
    Buchanan Computing
    London, UK
    ------------------------------



  • 6.  RE: There seems to be a distance limit to the CartesianOffsetXY function

    Posted 04-09-2020 13:42

    Hello David,

     

    Perhaps check the coordsys in the TAB file that you have open in the frontwindow() mapper. You can at the TAB in notepad or any other text editor.

     

    Failing that, try your MapBasic code against a brand new table in British National Grid. If it works, you'll know it's something related to your table.

     

    Regards,

    Warren Vick

     

     






  • 7.  RE: There seems to be a distance limit to the CartesianOffsetXY function

    Employee
    Posted 04-14-2020 08:40
    Hi David

    This does indeed look a bit weird.
    I tried with a more simple version of your code and just printed the coordinates of the moved point:
    set coordsys Earth Projection 8, 79, "m", -2, 49, 0.9996012717, 400000, -100000 Bounds (1, 1) (680000, 1250000)
    dim o1 as object
    dim o2 as object
    o1 = createpoint(100000,100000)
    o2 = o1
    Print "1. " + FormatNumber$(Round(CentroidX(o2), 1)) + " | " + FormatNumber$(Round(CentroidY(o2), 1))
    o2 = cartesianoffsetXY(o2,0,300000,"m")
    Print "2. " + FormatNumber$(Round(CentroidX(o2), 1)) + " | " + FormatNumber$(Round(CentroidY(o2), 1))
    o2 = cartesianoffsetXY(o2,0,300000,"m")
    Print "3. " + FormatNumber$(Round(CentroidX(o2), 1)) + " | " + FormatNumber$(Round(CentroidY(o2), 1))
    o2 = cartesianoffsetXY(o2,0,300000,"m")
    Print "4. " + FormatNumber$(Round(CentroidX(o2), 1)) + " | " + FormatNumber$(Round(CentroidY(o2), 1))
    o2 = cartesianoffsetXY(o2,0,300000,"m")
    Print "5. " + FormatNumber$(Round(CentroidX(o2), 1)) + " | " + FormatNumber$(Round(CentroidY(o2), 1))

    This is the result from the Message window:
    1. 100,000 | 100,000
    2. 100,000 | 199,999
    3. 100,000 | 399,997
    4. 100,000 | 699,997
    5. 100,000 | 999,997

    Notice that I tried moving the point 4 times and that it actually seems to "pick up speed".
    For the first Offset, it's only moved 99,999 meters. Next time it's moved 199,998 meters, and the last two times it's moved the specified 300,000 meters

    I also tried using the cartesianOffset function where you specify a direction and a distance. 
    set coordsys Earth Projection 8, 79, "m", -2, 49, 0.9996012717, 400000, -100000 Bounds (1, 1) (680000, 1250000)
    dim o1 as object
    dim o2 as object
    o1 = createpoint(100000,100000)
    o2 = o1
    Print "1. " + FormatNumber$(Round(CentroidX(o2), 1)) + " | " + FormatNumber$(Round(CentroidY(o2), 1))
    o2 = Cartesianoffset(o2,90,300000,"m")
    Print "2. " + FormatNumber$(Round(CentroidX(o2), 1)) + " | " + FormatNumber$(Round(CentroidY(o2), 1))
    o2 = Cartesianoffset(o2,90,300000,"m")
    Print "3. " + FormatNumber$(Round(CentroidX(o2), 1)) + " | " + FormatNumber$(Round(CentroidY(o2), 1))
    o2 = Cartesianoffset(o2,90,300000,"m")
    Print "4. " + FormatNumber$(Round(CentroidX(o2), 1)) + " | " + FormatNumber$(Round(CentroidY(o2), 1))
    o2 = Cartesianoffset(o2,90,300000,"m")
    Print "5. " + FormatNumber$(Round(CentroidX(o2), 1)) + " | " + FormatNumber$(Round(CentroidY(o2), 1))

    This works more stable until the point reaches the boundary at 1,250,000:
    1. 100,000 | 100,000
    2. 100,000 | 400,000
    3. 100,000 | 700,000
    4. 100,000 | 1,000,000
    5. 100,000 | 1,250,000

    I'll pass this onto our support so that we can get engineering looking at this.

    ------------------------------
    Peter Horsbøll Møller
    Distinguished Engineer
    Pitney Bowes Software & Data
    ------------------------------



  • 8.  RE: There seems to be a distance limit to the CartesianOffsetXY function

    Posted 04-14-2020 09:22

    Hi Peter,

    Thanks for looking at this, I was beginning to doubt myself. It's strange that it's not consistent, hopefully it's something fairly straight forward to fix.

    I had wondered if it had anything to do with MapInfo preferences default map projection settings, mine are set to Brit Nat Grid and changing to Lat/Long didn't have any effect.

    Cheers

    David



    ------------------------------
    David Wilson
    Buchanan Computing
    London, UK
    ------------------------------



  • 9.  RE: There seems to be a distance limit to the CartesianOffsetXY function

    Employee
    Posted 04-14-2020 09:27
    PS:

    I just tried changing the initial point to this:
    o1 = createpoint(300000,400000)

    And now it seems that the function works properly all the time.
    Let's see what support/engineering comes back with

    ------------------------------
    Peter Horsbøll Møller
    Distinguished Engineer
    Pitney Bowes Software & Data
    ------------------------------



  • 10.  RE: There seems to be a distance limit to the CartesianOffsetXY function

    Posted 04-23-2020 14:45
    Confirmed it as a bug and it will be addressed in 2019.2 release this summer. Interestingly enough, it is indeed related to the fact that table is bounded and point that you are trying to move 300,000 meters north is only 100,000 meters away from the table bounds.

    We are using a generic algorithm to do offset calculations and in this particular case we are not selecting best starting conditions for the algorithm. Temporary solution until we release the fix could be to extend coordinate system bounds.

    Andrei

    ------------------------------
    Andrei Veselov
    Pitney Bowes Software Inc.
    Troy NY
    ------------------------------



  • 11.  RE: There seems to be a distance limit to the CartesianOffsetXY function

    Posted 04-24-2020 03:31
    Hi Andrei,
    Thanks for letting me know. I've already altered the code to move each node, so will leave it like that rather than altering the bounds. Hopefully there are no other functions affected by the use of table bounds.

    David

    ------------------------------
    David Wilson
    Buchanan Computing
    London, UK
    ------------------------------



  • 12.  RE: There seems to be a distance limit to the CartesianOffsetXY function

    Employee
    Posted 12-02-2020 05:04
    Hi David

    Just wanted to let you know that this has been fixed in MapInfo Pro v2019.3

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



  • 13.  RE: There seems to be a distance limit to the CartesianOffsetXY function

    Posted 12-02-2020 12:13
    Hi Peter,
    Thanks for letting me know. I'll look to change our code once we move across to v2019, I'm sure that will be quicker than the way I'm currently doing it.

    Cheers
    David

    ------------------------------
    David Wilson
    Buchanan Computing
    London, UK
    ------------------------------