MapBasic people, beware. I sent this in to the MI tech team as a
bug to be fixed, but until this gets corrected, you might want to
be aware of it. It's a sneaky one.

The following scrapplication opens the states table into a pair
of windows, and then sets the coordsys of the last to state plane
for Colorado (the first is lat/lon). Then it creates a little
table to hold points, adds this to both maps, and creates a point
near Boulder, Colorado... which --hahaha-- actually appears in
southern California! This exhibits itself in both MI/MB versions
4.5 and 5.5.

If you open the maps in the other order (i.e. with the lat/lon
window opened last) everthing is fine. So, the workaround is to
EXPLICITLY set the coordsys after all maps are opened or make
sure the last window opened uses the coordsys with which you will
be building map objects.

Here's the little bugger that demos this:
'--- start of code ---
'Coordsys_Bug.mb
'Demonstrates a subtle bug or WAD in MB. When you open windows 
'the default coordsys used by MB is set to the coordsys of the 
'map opened LAST. 
'I thought the default coordsys was "earth projection 1, 0"?
'-----

include "mapbasic.def"

declare sub main

sub main
dim objPoint as object
dim sFile as string
dim nMap1, nMap2 as integer

'Clear the crash zone
        close all interactive

'Open the states table
        sFile = FileOpenDlg ("", "States.tab", "TAB", 
                        "Open the Standard MI states map")
        if sFile = "" then 
                exit sub
        end if
        Open Table sFile As States Interactive

'Open the lat/lon window
        Map From States 
                Position (3.6,0) Units "in"
                Width 3.5 Units "in" Height 4.0 Units "in" 
        nMap1 = FrontWindow()
        Set Map CoordSys Earth Projection 1, 0
                Center (-105,40)
                Zoom 1200 Units "mi"

'Open the State Plane window
        Map From States 
                Position (0,0) Units "in"
                Width 3.5 Units "in" Height 4.0 Units "in" 
        nMap2 = FrontWindow()
        Set Map CoordSys Earth Projection 3, 33, "survey ft", 
                -105.5, 37.8333333333, 38.45, 39.75, 3000000, 1000000
                Center (3140089.07,1789525.078)
                Zoom 1200 Units "mi"

'Create a table to hold points
        create table LOST (
                Id integer)
        file ApplicationDirectory$() + "Lost.tab"
        create map for LOST

'Add table to maps
        add map window nMap1 layer LOST 
        add map window nMap2 layer LOST 

'Create a point near Boulder, Colorado
        create point into variable objPoint 
                (-105, 40)
        symbol MakeSymbol (34, YELLOW, 12)

'Whoops! It ends up lost in the Californian desert!
        insert into LOST (obj) values (objPoint)
end sub
'--- end of code ---

- Bill Thoen
----------------------------------------------------------------------
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