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.  Can we create a point in a separate tab file by considering the certain distance from a line layer?

    Posted 04-12-2018 09:44

    I have a polyline (PL) TAB file and i have distances in distanceTable (DT). Now i want to create a TAB file(PT) with points based on the locations of the polyline layer and the distance from the distance Table.

    Lets get into details..

    1. In the PL TAB i have road network with road names
    2. in the DT TAB i have road name and distance ( 5km, 10km,3 km)

     

    Now i want to create a tab file with points.. Point locations should come from PL TAB file. And the location will be 5KM distance from the starting point of the road network.. consider that as point A

    Then i want to create another point with 10 KM distance from Point A on the road. Lets call it as POINT B

    Then i want to create another point with 3KM distance from Point B on the road

    So the point creation should be like a batch process.. And the distances will be dynamic coming from another table..

    Can we do something like this from Mapinfo? is there any other process we could use SQL/ PostgreSQL GIS functions to make this work?

    Looking forward to the suggestions.

    -Krishna.



  • 2.  RE: Can we create a point in a separate tab file by considering the certain distance from a line layer?

    Posted 04-12-2018 22:52

    Hi Krishna,

    There are probably tools around already that can help with this. I found the following site on Stack Overflow that might help with the logic: https://stackoverflow.com/questions/2094268/moving-a-point-along-a-path-in-sql-server-2008. The logic would be similar if programming in MapBasic. MapBasic functions to use would perhaps include ObjectInfo (to extract the number of nodes in a polyline), ObjectNodeX and ObjectNodeY, and Distance.

    I hope this helps.



  • 3.  RE: Can we create a point in a separate tab file by considering the certain distance from a line layer?

    Employee
    Posted 04-13-2018 05:12

    Is the point moved along a single polyline feature or can it be multiple lines it needs to be moved along?



  • 4.  RE: Can we create a point in a separate tab file by considering the certain distance from a line layer?

    Posted 04-13-2018 07:10

    Hi @Peter Horsbøll Møller? There are multiple lines but the locations that we need to capture should be restricted to a single polyline.. For other lines there are other distances to capture the locations.



  • 5.  RE: Can we create a point in a separate tab file by considering the certain distance from a line layer?

    Posted 04-13-2018 08:35

    Hi @James Nolet? , thanks for the reference . iI have created those functions. But when i check witht my sample data it is throwing this error..

    Msg 6522, Level 16, State 1, Line 2

    A .NET Framework error occurred during execution of user-defined routine or aggregate "geography": 

    System.FormatException: 24201: Latitude values must be between -90 and 90 degrees.

    System.FormatException: 

      at Microsoft.SqlServer.Types.GeographyValidator.ValidatePoint(Double x, Double y, Nullable`1 z, Nullable`1 m)

      at Microsoft.SqlServer.Types.Validator.AddLine(Double x, Double y, Nullable`1 z, Nullable`1 m)

      at Microsoft.SqlServer.Types.ForwardingGeoDataSink.AddLine(Double x, Double y, Nullable`1 z, Nullable`1 m)

      at Microsoft.SqlServer.Types.CoordinateReversingGeoDataSink.AddLine(Double x, Double y, Nullable`1 z, Nullable`1 m)

      at Microsoft.SqlServer.Types.WellKnownTextReader.ParseLineStringText()

      at Microsoft.SqlServer.Types.WellKnownTextReader.ParseTaggedText(OpenGisType type)

      at Microsoft.SqlServer.Types.WellKnownTextReader.Read(OpenGisType type, Int32 srid)

      at Microsoft.SqlServer.Types.SqlGeography.ParseText(OpenGisType type, SqlChars taggedText, Int32 srid)

      at Microsoft.SqlServer.Types.SqlGeography.GeographyFromText(OpenGisType type, SqlChars taggedText, Int32 srid).

    Guess What? It is working fine with the data that the commented person has kept in the test example. And also it is the process where you are calculating the distance from start point of Polyline for all the distances.

    But i want to calculate the distance from Start point for the first distance. For the second distance for the same polyline, i want to find the location from Point A(Recently caulated point) and distance of X then i should get the location with the distance of first distance+X from start point of polyline.

    Hope i am making sense.



  • 6.  RE: Can we create a point in a separate tab file by considering the certain distance from a line layer?

    Posted 04-13-2018 09:06

    Hi @James Nolet? I am able to run it properly now. But the distance seems to be not accurate as i can check in the google maps. But the location capturing should be dynamic. How do i run it? It has to take the line string from one table and distances for that line string from other table.

     

    Lets say Table 1 has line strings with ID's and Table 2 has distances and then line string ID.. So it means Line strings and point has Line ID in common.

    Now i want to create points Table 3 with the lat longs and the Line string ID.

    Is this this the correct way of approaching ? Pls suggest :)

     



  • 7.  RE: Can we create a point in a separate tab file by considering the certain distance from a line layer?

    Posted 04-13-2018 20:12

    In the link I provided, someone has provided an amended function that provides more accurate results. Did you see that? Also, to iterate through your line objects, you will need to create a stored procedure if using SQL Server. Check out SQL Server cursors for retrieving one record at a time from a table.

    If you're unfamiliar with how to do this, replication of the logic in MapBasic may be a better way to go.



  • 8.  RE: Can we create a point in a separate tab file by considering the certain distance from a line layer?

    Posted 04-14-2018 02:44

    I have tried the other function but it wasn't working. first response was fine but all the 3 distances are calculated from the start point of the line string. I want to find location fro the second distance from the output of the first distance. Unfortunately i am not good at coding and MapBasic :|

    Looking forward to the experts support towards this :D