MapInfo Pro Developers User Group

Welcome to the MapInfo Pro Developers community!  We are a group dedicated to the discussion and understanding of MapBasic and .Net MapInfoPro AddIn development. Bring your questions and ideas here. This group includes several members of the Pro development team from around the world.

Please feel free to start a discussion in the discussion tab or join in a conversation.

Product Information  Ideas Portal  MapInfo Community Downloads

Discussions

Members

Resources

Events

 View Only
  • 1.  How do I find the mid point of a line along the line

    Posted 11-02-2018 01:02

    I need to find the midpoint (not centroid) of a line on the line and get the x and y coordinates.

     

    In SQL (Server) I see there are some options - https://ask.sqlservercentral.com/questions/87890/how-do-i-find-a-point-half-way-between-2-points.html

     

    Also in QGIS -https://gis.stackexchange.com/questions/258308/create-mid-point-from-line-layer/258317

     

    Is there a tool in Mapinfo (ideally Mapbasic) for this?



  • 2.  RE: How do I find the mid point of a line along the line

    Employee
    Posted 11-07-2018 04:07

    Have a look at this function in the OBJLib that can be found on Github:

    Function OBJCartesianCreatePointAlong

    ( ByVal oPolyline As Object 'The polyline to create the point along

    , ByVal fDistance As Float 'Distance along polyline, can also be negative

    , ByVal fOffset As Float 'Offset from polyline, negative is left, positive is right

    ) As Object

    It doesn't give you the mid point directly but can be used to do it if you pass in the value of the distance parameter as half the object length:

    oMidPoint = OBJCartesianCreatePointAlong(oSel, CartesianObjectLen(oSel) / 2, 0)

    You can find it here on Github: https://github.com/PeterHorsbollMoller/mbLibrary.

    Look for the OBJLib.def and OBJLib.mb files.

    Note that it only supports lines and single segment polylines.