MapInfo Wishlist Response #1

By Andrew Dressel

I hadn't been keeping up with my reading at Directions Mag when one of our favorite customers, Steve Wallace at the Florida Farm Bureau, sent me a message that mentioned the wish list.When I checked it out, you might imagine my surprise to see 145 wishes for MapInfo Professional. (It turns out that most come directly from the popular MapInfo-L wish list.)

I started wading through them and saw right away that some could be addressed immediately.In fact, I had already been working on one due to a question raised in a user group meeting I attended recently: rotating symbols.

So, here is a tool, written in MapBasic, that MapInfo Professional users can install to handle items #1 and #5 based on popularity as of July 26, 1999.

Item # 1 (12 votes)
Product: MapInfo Professional
Category: General
Date: 7/12/99
String Substitution.
Replace string "A" with string "B" when found in column "ColX" of a table or selection.
Author: MapInfo-L

This is really pretty easy and straight forward in MapBasic, and most of the code I wrote deals with the user interface.Once I have the name of the table, the name of the column, the 'replace' string, and the 'with' string in string variables, this is all I have to do:

  Fetch First From sTable
  Do While Not EOT(sTable)
    sText = aColumn
    i = InStr(1, sText, sReplace)
    If i > 0 Then
      iRowID = aRowID
      sText = Left$(sText, i-1) + sWith +
              Right$(sText, Len(sText)-Len(sReplace)-i+1)
      Update sTable Set sColumn = sText Where RowID = iRowID
    End If
    Fetch Next From sTable

Item # 5 (7 votes)
Product: MapInfo Professional
Category: General
Date: 7/12/99
Symbol Rotation.
Symbols should be able to be rotated, and the rotation controlled by a pointer to some database column containing the rotation values.
Author: MapInfo-L

It is possible to rotate symbols individually through the user interface, and it is also quite easy to rotate a bunch of symbols based on a value in a database column with MapBasic, but it involves a few more variables: (in order of appearance)

sTable: string that contains the table name
oOld: object that contains the current geographic object
aObj: alias that refers to the geographic object column
iRowID: integer that contains the current row number
aRowID: alias that refers to the current row number
sOldSymbol: symbol that contains the existing symbol
iSymobl: integer that contains the number of the existing symbol
iColor: integer that contains the color of the existing symbol
iSize: integer that contains the size of the existing symbol
sFont: string that contains the font name of the existing symbol
iStyle: integer that contains the style of the existing symbol
aColumn: alias that refers to the column that contains the angle
oNew: object that contains the new, rotated symbol

  Fetch First From sTable
  Do While Not EOT(sTable)
    oOld = aObj
    iRowID = aRowID
    sOldSymbol = ObjectInfo(oOld , OBJ_INFO_SYMBOL)
    iSymbol = StyleAttr(sOldSymbol, SYMBOL_CODE)
    iColor = StyleAttr(sOldSymbol, SYMBOL_COLOR)
    iSize = StyleAttr(sOldSymbol, SYMBOL_POINTSIZE)
    sFont = StyleAttr(sOldSymbol, SYMBOL_FONT_NAME)
    iStyle = StyleAttr(sOldSymbol, SYMBOL_FONT_STYLE)
    Create Point Into Variable oNew (CentroidX(oOld ),
                                     CentroidY(oOld ))
      Symbol MakeFontSymbol(iSymbol, iColor, iSize, sFont,
                            iStyle, aColumn)
    Update sTable Set obj = oNew Where RowID = iRowID
    Fetch Next From sTable

Three other capabilities I had already built into the tool to address user group feed back are:

3.Automatically pick the column that contains 'lat' or 'y' for the latitude column and pick the column that contains 'lon' or 'x' for the longitude column when creating point based on coordinates stored in columns.

4.Automatically populate two columns (create them if necessary) with coordinate values of object centroid.

5.Automatically convert a column to character and pad the values it contains with the correct number of leading zeros so that ZIPCodes look correct and match properly.

Here is the complete tool.I've compiled it with MapBasic version 4.1.2 so that anyone with MapInfo Professional 4.1.2 or greater can use it.


  • Published Tuesday, July 27th, 1999

    Written by Andrew Dressel

    If you liked this article subscribe to our bimonthly newsletter...stay informed on the latest geospatial technology

    Sign up

    © 2017 Directions Media. All Rights Reserved.