all groups > dotnet academic > march 2004 >
You're in the

dotnet academic

group:

Shape Files


Shape Files Vishruth
3/28/2004 9:36:12 PM
dotnet academic: In my coding of ESRI Shape files I read the pdf document available and i tried the coding of my own but I was unable to get even any one of the shape file while i'm checking the output.I tried my level best but really unable to get the output.So readers I'll be very thankfull if u could correct my error and provide me the correct source code please.Thanks in advance

Form Module:

Dim cn As New ADODB.Connectio
Dim rs As New ADODB.Recordse
Dim i As Intege

Private Sub Command2_Click(
Dim SHPFile As New ESRIShapeV2.ShapeFile ' ESRIShapeV2.Shap
Dim shpPOLYGON As CPolygo
Dim shpPOLYLINE As CPolyLin
Dim shpPOINT As CPoin
Dim shpPART As CPar
Dim sfilepath As Strin
Dim pt As CPoint, pt1 As CPoin

sfilepath = App.pat
If Right(sfilepath, 1) = "\" The
sfilepath = Mid(sfilepath, 1, Len(sfilepath) - 1
End I

On Error Resume Nex
For Each Var In Array("dbf", "shp", "shx"
If Len(Dir(sfilepath & "\Polygon." & Var, vbNormal)) <> 0 The
Kill sfilepath & "\Polygon." & Va
Kill sfilepath & "\Polyline." & Va
Kill sfilepath & "\MultiPoint." & Va
End I
Next Va

Set SHPFile = New ESRIShapeV2.ShapeFil
SHPFile.FileName sfilepath & "\Polygon.SHP", CREATEIT, SHAPEFILETYPE.typePolygo

If SHPFile.FileType = Polygon The

Set shpPOLYGON = New CPolygo
Set shpPART = New CPar
Set shpPOINT = New CPoin
Set pt = New CPoin
Set pt1 = New CPoin
i =
rs.MoveFirs

For i = 0 To rs.RecordCoun
pt.X = rs.Fields("easting").Value 'x
pt.Y = rs.Fields("northing").Value 'y

rs.MoveNex
pt1.X = rs.Fields("easting").Value 'x
pt1.Y = rs.Fields("northing").Value 'y
shpPART.Add shpPOIN
shpPOLYGON.Add shpPAR
SHPFile.Add shpPOLYGO
Nex

If SHPFile.Count > 0 The
SHPFile.Sav
End I
Set SHPFile = Nothin
End I
Set SHPFile = New ESRIShapeV2.ShapeFil
SHPFile.FileName sfilepath & "\Polyline.SHP", CREATEIT, SHAPEFILETYPE.typePolyLin

If SHPFile.FileType = PolyLine The
Set shpPOLYLINE = New CPolyLin
Set shpPART = New CPar
Set shpPOINT = New CPoin
Set pt = New CPoin
Set pt1 = New CPoin
For i = 0 To rs.RecordCoun
pt.X = rs.Fields("easting").Value 'x
pt.Y = rs.Fields("northing").Value 'y
rs.MoveNex
pt1.X = rs.Fields("easting").Value 'x
pt1.Y = rs.Fields("northing").Value 'y
shpPART.Add shpPOIN
shpPOLYLINE.Add shpPAR
SHPFile.Add shpPOLYLIN

Nex

If SHPFile.Count > 0 The
SHPFile.Sav
End I
Set SHPFile = Nothin
End I
Set SHPFile = New ESRIShapeV2.ShapeFil
SHPFile.FileName sfilepath & "\point.SHP", CREATEIT, SHAPEFILETYPE.typeMultiPoin

'If SHPFile.FileType = Point The
Set shpPOINT = New CPoin
Set pt = New CPoin
Set pt1 = New CPoin
For i = 0 To rs.RecordCoun
pt.X = rs.Fields("easting").Value 'x
pt.Y = rs.Fields("northing").Value 'y
rs.MoveNex
pt1.X = rs.Fields("easting").Value 'x
pt1.Y = rs.Fields("northing").Value 'y

Nex
shpPART.Add shpPOIN
SHPFile.Add shpPOIN

If SHPFile.Count > 0 The
SHPFile.Sav
End I
Set SHPFile = Nothin
'End I


'End Selec

End Su

Private Sub Form_Load(
Set cn = New ADODB.Connectio
strSQL = "select Node_1.Easting,Node_1.Northing,Node_1.SurveyID,BDY.Order from (Node_1 inner join BDY on Node_1.NodeID=BDY.NodeID)inner join Survey_1 on BDY.ID=Survey_1.ID where node_1.Surveyid = 5 or node_1.Surveyid = 14 order by Node_1.SurveyID,BDY.Order
cn.ConnectionString = " Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.path & "\" & "sample2.mdb;Persist Security Info=False"
cn.Open
Set rs = New ADODB.Recordset
rs.Open strSQL, cn, adOpenKeyset, adLockPessimistic
End Sub


Module:-
Dim rs As New ADODB.Recordset
Dim cn As New ADODB.Connection
Public Sub Make(ByVal originpoint As CPoint, ByVal sizePoint As CPoint)
Dim pt As CPoint, pt1 As CPoint
Set originpoint = New CPoint
Set pt = New CPoint
Set pt1 = New CPoint

Call main


originpoint.X = rs.Fields("easting").Value
originpoint.Y = rs.Fields("northing").Value
rs.MoveNext
sizePoint.X = rs.Fields("easting").Value 'x2
sizePoint.Y = rs.Fields("northing").Value '500 y2
pt.X = originpoint.X
pt.X = originpoint.X
pt.Y = originpoint.Y
pt1.X = sizePoint.X
pt1.Y = sizePoint.Y


End Sub
Public Sub MakeEmpty()
strSQL = "select Node_1.Easting,Node_1.Northing,Node_1.SurveyID,BDY.Order from (Node_1 inner join BDY on Node_1.NodeID=BDY.NodeID)inner join Survey_1 on BDY.ID=Survey_1.ID where node_1.Surveyid = 5 or node_1.Surveyid = 14 order by Node_1.SurveyID,BDY.Order"
'cn.ConnectionString = " Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.path & "\" & "sample2.mdb;Persist Security Info=False"
'cn.Open
Set rs = New ADODB.Recordset
rs.Open strSQL, cn, adOpenKeyset, adLockPessimistic
Dim pt As CPoint, pt1 As CPoint
Set pt = New CPoint
pt.X = rs.Fields("easting").Value
pt.Y = rs.Fields("northing").Value
rs.MoveNext
pt1.X = rs.Fields("easting").Value
pt1.Y = rs.Fields("northing").Value
End Sub

Public Sub main()
cn.ConnectionString = " Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.path & "\" & "sample2.mdb;Persist Security Info=False"
cn.Open
strSQL = "select Node_1.Easting,Node_1.Northing,Node_1.SurveyID,BDY.Order from (Node_1 inner join BDY on Node_1.NodeID=BDY.NodeID)inner join Survey_1 on BDY.ID=Survey_1.ID where node_1.Surveyid = 5 or node_1.Surveyid = 14 order by Node_1.SurveyID,BDY.Order"
Set rs = New ADODB.Recordset
rs.Open strSQL, cn, adOpenKeyset, adLockPessimistic

End Sub

Class Module:-
CPart:-

'Class CPart
'Implements shape parts for polygons and polylines

Option Explicit

Private part As Collection
Private Extent As CRect
Public Property Get Left() As Double
Left = Extent.Left
End Property

Public Property Let Left(aValue As Double)
Extent.Left = aValue
End Property

Public Property Get Right() As Double
Right = Extent.Right
End Property

Public Property Let Right(aValue As Double)
Extent.Right = aValue
End Property

Public Property Get Top() As Double
Top = Extent.Top
End Property

Re: Shape Files DotNetJunkies User
8/31/2004 5:08:22 AM
Hi there,

I would like to help you. Although I'm using a different version of shapefile class, I was able to create the three shp files with some minor changes to your code (and using a different database). One problem I found was when I tried to open the shp files in ArcMap it gave an error saying is couldn't find the table...

Is it possible for you to send me your vb project containing all classfiles. Please also include your database.

Kind regards,
Raymond

r.vanderwel@students.uu.nl

---
Posted using Wimdows.net NntpNews Component -

AddThis Social Bookmark Button