Dear All,

Thank you very much to all who replied, trying to help:  Trey Pattillo, =
Tim Nuteson and Derek Snyder

Briefly the subject was:
Working with a street layer I would like to create objects for each =3D
street intersection point



The best solution came from Trey Pattillo:

The method I have used is slow, as it iterates thru the street list and =
uses
the FIND command to look for the intersections, just like in the Ctrl+F.

1) Create the table to hold your "finds" and make it editable
    This can be done in code

2) build a list of unique street names into 2 variables
    Select * from StreetTable Group By Street Order By Street Into =
Street1
    Select * from Street1 Into Street2

3) set up FIND USING
    Find Using StreetTable(Street)

4) loop thru Street1 and see if Street2 intersects it [cmd_info_x,
cmd_info_y] when Cmd_Info_Find_RC > 0
    get the x and y and put in map

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D   CODE SAMPLE =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Dim aObj as Object
Dim LookFor As String
Create Table "Intersect" (Street1 Char(30), Street2 Char(30)) File
"C:\MapInfo\Data\Intersect.tab" TYPE DBF
Create Map For Intersect
Select * from StreetTable Group By Street Order By Street Into Street1
Select * from Street1 Into Street2
Find Using StreetTable(Street)
Fetch First From Street1
while not eot(Street1)
    Fetch First From Street2
    While not eot(Street2)
        LookFor=3DStreet1.Street+" && "+Street2.Street
        Find LookFor
        If CommandInfo(CMD_INFO_FIND_RC)>0 then
            aObj=3DCreatePoint Into Variable aObj (CMD_INFO_X, =
CMD_INFO_Y)
MakeSymbol(33,12,0)
            Insert Into IntersectionTable (Street1,Street2,obj) Values
(Street1.Street,Street2.Street,aObj)
        End If
        Fetch Next From Street2
    Wend '' street2
    Fetch Next From Stree1
Wend '' street1
undim aObj
undim LookFor



The following was suggested by Derek Snyder

Create Objects As Intersect produces a result of that space that is the
intersection of ALL of the objects, not any 2 objects.

What you probably want to use is Objects Intersect.  Use the input table =
as
both the selection.  This should give you what you want.

Another alternative is to use the IntersectNodes() MapBasic function.  =
This
only takes 2 objects at a time, so it is a bit more cumbersome.  But, it
will work with Line and Polyline objects as input, so you won't need to =
do
the buffer step.





Finally I add my code (inspired from Trey Pattillo's code), adjusted to =
suit my needs:

Sub GenerateIntersections

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D   CODE SAMPLE =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Dim aObj as Object
Dim szLookFor as String
Dim szStr1, szStr2 as String
Dim fLon, fLat as Float
Dim snNumStr1, snI, snJ as Smallint

Select * from SourceTab Group By StreetName Order By StreetName Into =
Street1
snNumStr1=3DTableInfo(Street1, TAB_INFO_NROWS)

Select * from Street1 Into Street2

Find Using SourceTab(StreetName)
For snI=3D1 to snNumStr1
        fetch rec snI from Street1
        szStr1=3DStreet1.StreetName
        For snJ=3D1 to snNumStr1                '* Table Street1 and Street2 have the 
same =
number of records
                Fetch rec snJ From Street2
                szStr2=3DStreet2.StreetName
                If szStr1<>szStr2 Then  '* Remove self-intersection cases
                        szLookFor=3DszStr1+" && "+szStr2
                        Find szLookFor

                        If CommandInfo(CMD_INFO_FIND_RC)=3D1 then       '* consider 
only "exacy =
match" cases
                                fLon=3DCommandInfo(CMD_INFO_X)
                                fLat=3DCommandInfo(CMD_INFO_Y)
                        aObj=3DCreatePoint(fLon, fLat)
                            Insert Into DestTab (Street1,Street2,obj)
                                        Values(szStr1,szStr2,aObj)
                        End If
                End If
        Next
        Print ">>>Lap "+snI+"<<<"       '* Just to see the progress
Next
End Sub
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D   END CODE SAMPLE =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

NOTE:
The resulting table (DestTab) will contain duplicated points for each =
intersection.
This can be removed by running two queries:
Select Street1, Street2, CentroidX(obj), CentroidY(obj) from DestTab =
into IntersCoord
Select * from IntersCoord Group by COL3, COL4 into IntersGRP

Save the table IntersGRP and then create points using COL3, COL4.



Mircea Baila
MobiFon, Romania
E-mail:  [EMAIL PROTECTED]
Web: www.connex.ro



_______________________________________________________________________
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, send e-mail to [EMAIL PROTECTED] and
put "unsubscribe MapInfo-L" in the message body.

Reply via email to