Subscribe to this thread
Home - General / All posts - create lines from a point drawing
Bernd Raab68 post(s)
#17-Jun-24 13:58

i have a point drawing A and in the attribute table are two fields L for length and W for the bearing. I want to create a line drawing based on L and W with the starting point in the table row.

My sql skills are not very good. Can anybody help me out?

volker

1,088 post(s)
#17-Jun-24 14:10

That`s a MFD8 Script:

Sub Main

Set windows = Application.WindowSet

Set window = windows.ActiveWindow

Set component = window.Component

' -- fail if there is no opened windows

If windows.Count = 0 Then

MsgBox "No active window"

Exit Sub

End If

' -- fail if active component is not a drawing

If component.Type <> ComponentDrawing Then

MsgBox "Active component is not a drawing"

Exit Sub

End If

Set sourcedrawing = window.ActiveComponent

Set sourceTable = sourceDrawing.OwnedTable

Set dataRecords = sourceTable.RecordSet

pi = 3.141592653589793

For recordIndex = 0 To dataRecords.Count-1

Set record = dataRecords(recordIndex)

'- log starting location

x = record.Data("X (I)")

y = record.Data("Y (I)")

' -- create point

azimuth = CDbl((record.Data("G1P1_Azimut")) * pi / 180)

distance = CDbl(record.Data("G1P1_Entfernung"))

dx = Sin(azimuth)*distance

dy = Cos(azimuth)*distance

x1 = x + dx

y1 = y + dy

Set pointSet = Application.NewPointSet

Set point = Application.NewPoint

point.x = x1

point.y = y1

pointSet.Add(point)

Set geom = Application.NewGeom(GeomPoint, pointSet)

' -- append point

sourcedrawing.ObjectSet.Add(geom)

' -- transfer Name field

sourceTable.RecordSet(sourceTable.RecordSet.Count - 1).Data("Name") = record.Data("Name")

Next

End Sub


http://www.thegisservicesector.de

volker

1,088 post(s)
#17-Jun-24 14:34

in Sql (here in GON):

SELECT --[BAUMART] AS [BA], [BHD] AS [Durchm], [HOEHE] AS [H],-- ANY, ATTRIBUTE, YOU, LIKE,

--AND

-- calculate the position of the recorded trees

AssignCoordSys(

NewPoint(

-- new X Coord

Sin([AZIMUT]*360/400 * 3.141592653589793/180) * [ENTFERNUNG] + [GemessenX],

-- new Y Coord

Cos([AZIMUT]*360/400 * 3.141592653589793/180) * [ENTFERNUNG] + GemessenY]

),

-- Coord Ref Sys

CoordSys("TEST_DRAWING" AS COMPONENT)

) AS [Geom]

From [TEST_DRAWING]

-- GROUP BY [BAUMART], [BHD], [HOEHE]

;


http://www.thegisservicesector.de

Sloots

690 post(s)
online
#18-Jun-24 11:21

My SQL Solution using SQL and SQL Functions.

Attachments:
Lines From Point Bearing and Length.map


http://www.mppng.nl/manifold/pointlabeler

ych618 post(s)
#18-Jun-24 11:55

Hi Sloots,

I may be mistaken, but generally speaking, bearings of 0 and 360 correspond to the North ?

I see that your bearing 90 is pointing North.

Does your function need any adjustment ?

ych618 post(s)
#18-Jun-24 12:56

Hi again Sloots,

I see now your original function is using "math bearing" with 0 degrees pointing East and 90 degrees pointing North , so counter-clockwise)

Showing compass bearing 0/360 degrees to North would need the following adjustment in your function.

FUNCTION DegToRad(@degrees FLOAT64) FLOAT64 AS (

( - @degrees + 90 ) / 180 * PI

) END;

-- mind the minus sign (-) before @degrees, then adding +90

Thanks for sharing your SQL solution !

Sloots

690 post(s)
online
#18-Jun-24 13:14

Thanks for the update!


http://www.mppng.nl/manifold/pointlabeler

Bernd Raab68 post(s)
#18-Jun-24 18:06

thank you very much Sloots and ych61. It does what i need

Manifold User Community Use Agreement Copyright (C) 2007-2021 Manifold Software Limited. All rights reserved.