zAware, add point to polyline, extend line, query filter, query nearest point

Do While Not pFeature Is Nothing
Dim pEndPt As IPoint
Dim pLine As IPolyline

pLine = pFeature.Shape
pEndPt = pLine.ToPoint

Dim pProxOpLine As IProximityOperator

Dim pFromPt As New Point
Dim pQueryFilter As IQueryFilter
pQueryFilter = New QueryFilter
‘pQFilt.WhereClause =

pQueryFilter.WhereClause = cboRefID.Text & ” = ‘” & pFeature.Value(pFeature.Fields.FindField(cboRefField.Text)) & “‘”
‘ MsgBox(pQueryFilter.WhereClause)

Dim kFeatureLayer As IFeatureLayer
kFeatureLayer = pMxDoc2.FocusMap.Layer(GetLayerIndex(.cboRefLayer.Text))
Dim kFeatureClass As IFeatureClass = kFeatureLayer.FeatureClass

Dim kFeatureCursor As IFeatureCursor = kFeatureClass.Search(pQueryFilter, False)

If kFeatureClass.FeatureCount(pQueryFilter) > 0 Then
Dim kFeature As IFeature = kFeatureCursor.NextFeature

If Not kFeature Is Nothing Then
pProxOpLine = kFeature.Shape
pProxOpLine.QueryNearestPoint(pEndPt, esriSegmentExtension.esriNoExtension, pFromPt)
‘Dim pPolyline As New Polyline
‘ pPolyline.AddPoint(pFromPt)
Dim pPointsF As IPointCollection = pLine

Dim zAware As IZAware = CType(pFromPt, IZAware)
zAware.ZAware = True
pFromPt.Z = pEndPt.Z

Dim Dist As Double = txtDist.Text

If Not Dist = 0 Then
Dim x As Double
Dim y As Double

If pEndPt.X = pFromPt.X Then

x = pFromPt.X
If pFromPt.Y > pEndPt.Y Then
y = pFromPt.Y + Dist
y = pFromPt.Y – Dist
End If


Dim m As Double

m = (pEndPt.Y – pFromPt.Y) / (pEndPt.X – pFromPt.X)

x = Math.Sqrt(Dist * Dist / (1 + m * m))

If pFromPt.X < pEndPt.X Then
x = pFromPt.X – x
x = pFromPt.X + x
End If

y = m * (x – pFromPt.X) + pFromPt.Y

End If

Dim PtAdd As New Point
PtAdd.X = x
PtAdd.Y = y

Dim zAware2 As IZAware = CType(PtAdd, IZAware)
zAware2.ZAware = True
PtAdd.Z = pEndPt.Z


End If
pFeature.Shape = pLine

'If Not pFromPt Is Nothing Then
' pProxOpLine.AddPoint(pFromPt)

' End If
' pPolyline.AddPoint(pEndPt)

End If
End If

pFeature = pFeatureCursor.NextFeature


Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: