Keep in mind that an interactive user is working in a different
memory space than a MapBasic app, but apparently even opening a
workspace with a map in it that contains a "set map coordsys..."
command affects both environments the same way. I don't believe
that it should. Under mapbasic, the default coordsys should only
change when the programmer says so. 

And while I'm on the soapbox here, I'd like to see a real
CoordsysInfo() function to make it easier to keep track of this
environment variable. I had thought that I could create such a
function for myself by simply keeping track of a global variable
(which would assume that the initial default is "earth projection
1, 0") and making calls to another custom function,
SetCoordsys(), when I want to set it differently, but no, that
won't work reliably. Any time a map window is opened and the set
map coordsys... clause is used, you lose control of the current
coordsys and there is no way to discover what it is!

I will post any news I get from MI tech support, but I thought
developers ought to be on gaurd about this one, because in
certain situation it could cause you to go mad trying to track
down such a bug. I think the temporary cure is to set the
coordsys explicitly any time you are about to issue a command
that is affected by the current coordsys. Restoring the coordsys
to its previous state is impossible to garauntee, however.
Although perhaps if you closely monitor all window open activity,
you might be able to infer the default coordsys with calls to
MapperInfo(), and take advantage of this bug.

- Bill Thoen

[EMAIL PROTECTED] wrote:
> 
> Bill,
> 
> You're right. Your app doesn't work, and the default ought to be "Earth
> Projection 1,0".
> 
> It might be a side-effect from a "fix" MapInfo introduced at some point.
> One that I found to my surprise during a MapBasic course I was giving !
> 
> The interactive user normally equals a MapBasic program wrt. scope etc.
> Again normally, to enable usage of non-default coordinates the user should:
> 1. Open the MapBasic window
> 2. Enter "Set Coordsys something..." and hit Enter
> 
> What I found was, that setting the projection for a mapper, i.e.
> Map/Options.../Projection...,
> had the unexpected side-effect of setting the user's coordinate system to
> the
> same projection. Your MB-bug seems to generate a similar side-effect.
> 
> I can see why it was introduced for the interactive user - even though a
> specific
> menu item would be much better (e.g. Options/Interactive Preferences) - but
> in the
> MB programming environment itself this is simply not Ok.
> 
> I hope you'll post any responses from MapInfo TS on this bug on the list.
> 
> Regards
> Lars Nielsen
> 
> **********************************************************
> Lars Nielsen                            [EMAIL PROTECTED]
> Development Manager, Special Products Contact
> Kampsax GIS, Odense              http://www.kampsax-gis.dk
> Authorized MapInfo Distributor in Denmark & Norway
> Address: Rugaardsvej 55, DK-5000 Odense C
> Telephone: +45 6313-5000           Facsimile +45 6313-5090
> **********************************************************
> 
> Bill Thoen <[EMAIL PROTECTED]> on 21-09-99 01:22:36
> 
> To:   MapInfo-L <[EMAIL PROTECTED]>
> cc:
> Subject:  MI Another bug for the collection.
> 
> 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]
----------------------------------------------------------------------
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