May thanks to all who helped.  Below is the original question and the responses from 5 
very nice folks.

Original Message:

> Is there a way to extract to Lat/Long's of the starting and ending points 
> of a line object?  Does anyone know where I can get that mapbasic code, 
> as I don't think that can be done in MI alone.  Thanks ... Mike

Responses:

(1)

Here is some sample Mapbasic code.  You can open a Mapbasic window in Mapinfo and 
enter this (obviously change your layer names to match).

Open Table ".\WI\WIAdam\WIAdams1.tab" Interactive
        Alter Table "WIAdams1" ( add FROM_LAT Decimal(9,6),FROM_LONG 
Decimal(11,6),TO_LAT Decimal(9,6),TO_LONG Decimal(11,6)) Interactive
        update WIAdams1 set FROM_LONG = objectgeography(WIAdams1.obj ,1)
        update WIAdams1 set FROM_LAT = objectgeography(WIAdams1.obj ,2)
        update WIAdams1 set TO_LONG = objectgeography(WIAdams1.obj ,3)
        update WIAdams1 set TO_LAT = objectgeography(WIAdams1.obj ,4)
Commit Table WIAdams1
Close Table WIAdams1

Hope this helps.

Michael Davern
Customer Support Representative
Geographic Data Technology
11 Lafayette Street
Lebanon, NH 03766
(800) 331-7881
[EMAIL PROTECTED]
http://www.geographic.com
43.6° N 72.1° W

(2)

If you export to a mid\mif you will see all of the starting and ending
points of all the line objects.  If you are to see this data displayed in a
different way, you could write some code to identify the records you want
and then use some code like:

Include "mapbasic.def"
Dim a as integer
Dim oLine as object
Dim fXbeg,fXend,fYbeg,fYend as float

'query something into MySelection

for a = 1 to tableinfo(MySelection,tab_info_nrows)
        fetch rec a from MySelection
        oLine = MySelection.obj
fXBeg = ObjectGeography(oLine, OBJ_GEO_LINEBEGX)  
fXend = ObjectGeography(oLine, OBJ_GEO_LINEENDX) 
fYbeg = ObjectGeography(oLine, OBJ_GEO_LINEBEGY)
fYend = ObjectGeography(oLine, OBJ_GEO_LINEENDY)
'Now you can do what you wish with these values.  Print them, insert them
into a table etc.
next

close table MySelection
-----------------------------------

If you need more help, let me know or the list know and we will try to help
you.

Good luck,

Carol Sheehan

(3)

Sub CalcLonLat( fltFrom_Lat As Float, fltTo_Lat As Float, fltFrom_Lon As
Float,
                    fltTo_Lon As Float, ByVal objData As Object )

Dim lngPointCount As Integer
Dim intSectionCount As SmallInt
Dim intObjectType As SmallInt

intObjectType = ObjectInfo(objData, OBJ_INFO_TYPE)
If (intObjectType = OBJ_TYPE_LINE Or intObjectType = OBJ_TYPE_PLINE) Then
        ' Calc values using Node test
        intSectionCount = ObjectInfo(objData, OBJ_INFO_NPOLYGONS)
        lngPointCount = ObjectInfo(objData, OBJ_INFO_NPNTS)
        If (intSectionCount >= 1 And lngPointCount > 0) Then
                fltFrom_Lat = ObjectNodeY(objData, 1, 1)
                fltFrom_Lon = ObjectNodeX(objData, 1, 1)
                lngPointCount = ObjectInfo(objData, OBJ_INFO_NPOLYGONS+intSectionCount)
                fltTo_Lat = ObjectNodeY(objData, intSectionCount, lngPointCount)
                fltTo_Lon = ObjectNodeX(objData, intSectionCount, lngPointCount)
                If (fltFrom_Lat <> 0 And fltTo_Lat <> 0 And fltFrom_Lon <> 0 And 
fltTo_Lon
<> 0) Then
                        Goto CalcLonLat_Exit
                End If
        End If
End If

End Sub

Pass in each object that you want the start and end lon/lat for. Put this in
a MapBasic script and it will work.
        - Sesheeka

(4)

You can update four columns with the coordinates of the end points of a
line with these 4 values;

objectinfo(obj,1)
objectinfo(obj,2)
objectinfo(obj,3)
objectinfo(obj,4)

1 represents the beginning X coordinate of the line.
2 represents the beginning Y coordinate of the line.
3 represents the ending X coordinate of the line.
4 represents the ending Y coordinate of the line.

Hope that works for you.
Richard Duncan

(5)

You'll probably get a bunch of replies to this, but here goes.
Make four new columns in your line table for StartX,StartY and EndX, EndY.
Then Update Column StartX in yourlinetable with Value:
ObjectGeography(obj,1)
That updates the startX column with the first  X node of the line.
Continue on using (obj,2) for StartY, 
3 = EndX
4 = EndY

The MapBasic term for code 1 is OBJ_GEO_LINEBEGX, (and similarly 2 =
..._LINEBEGY) but you have to use the numeric equivalent from inside MI.

If you open the MapBasic window in Mapnfo when you do this, you could
copy/paste the line and change column and ObjectGeography code in each line.
I'm attaching a post explaining all the codes you can use with
ObjectGeography like getting the radius or text angle.
Drop me a line if you need any other help or clarification
Regards,
Jason
 <<ObjGeo.txt>> 
¤»¥«¤»§«¤»¥«¤»§«¤»¥«¤»
Jason Adam
Computer Draftsperson
Monopros Limited
Toronto, ON

Attchement to (5)

The possible second parameters for the ObjectGeography() function are:


OBJ_GEO_MINX        minimum x coordinate of an object's minimum
                    bounding bounding rectangle (MBR), unless object
                    is a line; if object is a line, returns same
                    value as OBJ_GEO_LINEBEGX.
OBJ_GEO_MINY     minimum y coordinate of object's MBR. For lines,
                    returns OBJ_GEO_LINEBEGY value.
OBJ_GEO_MAXX     maximum x coordinate of object's MBR. Does not
                    apply to Point objects. For lines, returns
                    OBJ_GEO_LINEENDX value.
OBJ_GEO_MAXY     maximum y coordinate of the object's MBR. Does not
                    apply to Point objects. For lines, returns
                    OBJ_GEO_LINEENDY value.
OBJ_GEO_ARCBEGANGLE beginning angle of an Arc object.
OBJ_GEO_ARCENDANGLE ending angle of an Arc object.
OBJ_GEO_LINEBEGX      x coordinate of the starting node of a Line object.
OBJ_GEO_LINEBEGY      y coordinate of the starting node of a Line object.
OBJ_GEO_LINEENDX      x coordinate of the ending node of a Line object.
OBJ_GEO_LINEENDY      y coordinate of the ending node of a Line object.
OBJ_GEO_POINTX   x coordinate of a Point object.
OBJ_GEO_POINTY   y coordinate of a Point object.
OBJ_GEO_ROUNDRADIUS diameter of the circle that defines the rounded
                    corner of a Rounded Rectangle object, expressed in
                    terms of coordinate units (e.g. degrees).
OBJ_GEO_TEXTLINEX     x coordinate of end of a Text object's label line.
OBJ_GEO_TEXTLINEY     y coordinate of end of a Text object's label line.
OBJ_GEO_TEXTANGLE     rotation angle of a Text object.

Where

OBJ_GEO_MINX        = 1
OBJ_GEO_LINEBEGX    = 1
OBJ_GEO_POINTX      = 1
OBJ_GEO_MINY        = 2
OBJ_GEO_LINEBEGY    = 2
OBJ_GEO_POINTY      = 2
OBJ_GEO_MAXX        = 3
OBJ_GEO_LINEENDX    = 3
OBJ_GEO_MAXY        = 4
OBJ_GEO_LINEENDY    = 4
OBJ_GEO_ARCBEGANGLE = 5
OBJ_GEO_TEXTLINEX   = 5
OBJ_GEO_ROUNDRADIUS = 5
OBJ_GEO_ARCENDANGLE = 6
OBJ_GEO_TEXTLINEY   = 6
OBJ_GEO_TEXTANGLE   = 7

Michael F. Branagan

Home/Casa:
10207 Green Holly Terrace
Silver Spring, MD 20902-5812
Voice: (301)-754-0160
Fax: (301)-754-0160
Email: [EMAIL PROTECTED]
Web: none

Office/Officina:
USEPA, Office of Policy
401 M Street, SW (Room 3208)
Washington, DC 20460
Voice: (202)-260-7569
Fax: (202)-260-6732
Email: [EMAIL PROTECTED]
Web: www.epa.gov

----------------------------------------------------------------------
To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and put
"unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]

Reply via email to