Jump to content
Sign in to follow this  
rocket

LineMapper Test Successful! Place fencelines, powerlines...

Recommended Posts

The goal:

Place all fencelines, powerlines, etc... entirely automatically from GIS data. Tool I have coded in VB called "LineMapper" takes GIS or raw visitor co-ordinate data and generates lines of objects, in batches, so that you don't need to do ANYTHING.

Creating Line List:

You can either:

- Open/Create the object lines in Globe Mapper; OR

- Record co-ordinates for each series of lines in Visitor in a text file

What i did, was load in GIS data for my real world location, in this example fencelines:

linemapper_tutorial_step1_globemapp.jpg

Generating the Object list:

Run this through LineMapper (currently VB, but I'm going to try get it written in Visitor Script - Soul_Assassin is taking a look also).

What does it do?

- works out how many objects fit along the line; and

- what angle the objects should be placed on; and

- where the objects finish

- Then it generates a list of objects for import

Import into Visitor

As per normal visitor import:

BEFORE (small section of map):

linemapper_tutorial_step2_map1_smal.jpg

AFTER (small section of map):

linemapper_tutorial_step2_map2_smal.jpg

Result:

Success! Placement is near perfect even for complex corners and gate areas. As my fencelines are made of two objects, they go up hills without issue. I just placed over 100,000 fencelines in twelve minutes! Not bad!

Can be applied to any object that goes in lines, Powerlines, fences, walls, etc...

linemapper_tutorial_buldozer3.jpg

Now if that's not the sexiest thing you've seen weeks, then I'll eat my hat :)

Share this post


Link to post
Share on other sites

We can definitely make city streets with that using only straight road pieces. Great work man, city creation just got that much easier :)

Share this post


Link to post
Share on other sites
We can definitely make city streets with that using only straight road pieces. Great work man, city creation just got that much easier :)

I hope this is true and that the AI know what to do with the roads, as the map I've been working on is being held up by roads the AI refuse to use..

Share this post


Link to post
Share on other sites

Very Interesting....the concept is that of Landbuilder....Good Work :) Please make this open source :) would love to see the code from a developers POV

Share this post


Link to post
Share on other sites
Very Interesting....the concept is that of Landbuilder....Good Work :) Please make this open source :) would love to see the code from a developers POV

Here's my current WIP code (yes, I know... its horrible VB!)

The trigonometry hurt my brain... If it wasn't for listening to Carl Sagan audiotapes as I was working it all out, I'm quite sure I would have gone insane.

Function Deg2Rad(Deg) As Double
    '
    '       Function    converts degrees to radians
    '       Passed Values:
    '           Deg [in, numeric]   value in degrees to be converted
    '
   Deg2Rad = Deg / 57.2957795130823
End Function

Function Rad2Deg(Rad) As Double
    '
    '       Function    converts radians to degrees
    '       Passed Values:
    '           Rad [in, numeric]   value in radians to be converted
    '
   Rad2Deg = 57.2957795130823 * Rad
End Function

Sub ProcessLineMapperShapefileExport()
   Dim pi As Double
   pi = Atn(1) * 4

   Dim iRow      As Long
   Dim Fname     As Variant
   Dim Record    As String
   Dim LineP     As Variant
   Dim iCol      As Integer
   Dim WS As Worksheet

   userD_objectType1 = "fence_post_usec"
   userD_objectType2 = "fence_line_usec"
   userD_Offset = True
   userD_objectSize = 4
   userD_objectAngle = 90
   userD_MaxXY = 30720
   SkipLastObj = False

   Fname = Application.GetOpenFilename("Text Files (*.txt),*.txt", , _
            "Select Text Data File")
   If Fname = False Then Exit Sub

   Open Fname For Input As #1
   iRow = 1
   iGroup = 2
   Do Until EOF(1)

       'Get First Line, Group ID
       Line Input #1, Record
       iGroup = Val(Record)
       If Not EOF(1) Then
           Line Input #1, Record
           LineP = Split(Record, ";")
           xStart = Val(LineP(0))
           yStart = Val(LineP(1))

           'Start Collection
           Do Until Record = "END"
               Line Input #1, Record
               If Not Record = "END" Then

   ' ****
               'Get Next End
               LineP = Split(Record, ";")
               xEnd = Val(LineP(0))
               yEnd = Val(LineP(1))

               'get starting positions
               xLength = xEnd - xStart
               yLength = yEnd - yStart

               'Workout length angle and length
               legLength = Sqr((xLength ^ 2) + (yLength ^ 2))
               legAngle = Atn(yLength / xLength)
               If xLength < 0 Then legAngle = legAngle + 3.14159265

               'workout length for each step in leg
               legStepX = Cos(legAngle) * userD_objectSize
               legStepY = Sin(legAngle) * userD_objectSize

               'Set initial leg positions
               xPosObj = xStart
               yPosObj = yStart

               'loop through object placement till end
               While legLength > 0
                   'Place next object
                   If yPosObj > 0 Then
                       'If yPosObj > 0 Then
                           '###
                           'Only Place object if within map
                           Cells(iRow, 1) = """" & userD_objectType1 & """;" & xPosObj & ";" & yPosObj & ";0;" & (userD_objectAngle - Rad2Deg(legAngle) + userD_objectAngle) & ";"

                           'Change to next row
                           iRow = iRow + 1
                           If iRow > 1048576 Then
                               Set WS = Sheets.Add
                               iRow = 1
                           End If

                           'Place second object if required (used for Pylons)
                           If userD_Offset Then
                               Cells(iRow, 1) = """" & userD_objectType2 & """;" & (xPosObj + (legStepX)) & ";" & (yPosObj + (legStepY)) & ";0;" & (userD_objectAngle - Rad2Deg(legAngle) + userD_objectAngle) & ";"
                               'Change to next row
                               iRow = iRow + 1
                               If iRow > 1048576 Then
                                   Set WS = Sheets.Add
                                   iRow = 1
                               End If
                           End If
                           '###
                       'End If
                       SkipLastObj = False
                       Else
                       SkipLastObj = True
                   End If
                   'Adjust Length Travelled
                   legLength = legLength - userD_objectSize

                   'Set new object position
                   xPosObj = xPosObj + legStepX
                   yPosObj = yPosObj + legStepY
               Wend

               'set new start location
               xStart = xPosObj
               yStart = yPosObj
   ' ****
               End If
           Loop
           'Delete last object if double object
           If Not SkipLastObj Then
               iRow = iRow - 1
               Cells(iRow, 1) = ""
           End If
       End If
   Loop
   Close 1
End Sub

Share this post


Link to post
Share on other sites

Thanks for posting the code, I program in C# and am now proficient in it. So if you would like any assistance at all, I would be more than happy to have a go with anything :)

Share this post


Link to post
Share on other sites

Is it possible as well for linemapper to do walled compounds:rolleyes::pray: since they may be placed the same as fences..?

Share this post


Link to post
Share on other sites
Is it possible as well for linemapper to do walled compounds:rolleyes::pray: since they may be placed the same as fences..?

Yes, it does anything that is placed in a line, it can handle up to two objects making the line (for example, power_line and power_pole) or single objects (wall)

Share this post


Link to post
Share on other sites
Yes, it does anything that is placed in a line, it can handle up to two objects making the line (for example, power_line and power_pole) or single objects (wall)

Very interesting work indeed Rocket! Exactly how would one go in and create the line data from global mapper or visitor?

Would there be a way to create lines from something like a satellite image? By outlining the lines on walled compounds and areas as well? I would love to try this but I have no clue to how to exactly start the process:confused:

Any extra tips?

Share this post


Link to post
Share on other sites

Hi Rocket!

Just wondering if you've developed this idea further?

Did you ever manage to get this LineMapper script working as a visitor script?

B

Share this post


Link to post
Share on other sites

Great work!

Please accept all the "street cred" I have to offer.

Share this post


Link to post
Share on other sites

Looks terrific! Step by step, Visitor gets easier for us :)

Share this post


Link to post
Share on other sites

Hmmm...

My interest in this has just shifted gear recently from a largely theoretical "wow thats amazingly clever!" to "hold on, I have 30,000 wall segments to place! how do you USE this???" heheh

However, I notice that Rocket seems to be AWOL @ the moment, and hasn't posted at all this year so far! Hopefully everythings OK with him!... I guess we just sit tight and wait for him to return.....

B

Share this post


Link to post
Share on other sites

Well it's all good,but where is it available for download ? :)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×