Thanks,

I will incorporate your suggestion of creating the rectangle object
variable outside the function - might speed things up a tad.

Cheers,
Peter

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Friday, 2 August 2002 4:22 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: RE: MI-L MB - Select with object variables

Hi Peter,

Here is my version of your IsLayerVisible()

**********************************************************************
***************
Function LayerIsVisible(ByVal WinID as integer, ByVal s_Layer as
string) as
logical

Dim  Mx1, Mx2, My1, My2 as float,
     o_Rectangle as object

LayerIsVisible = FALSE

     '**I have added the Set Coordsys syntax
     Set CoordSys Window WinID
     Mx1 = MapperInfo(WinID, MAPPER_INFO_MINX)
     My1 = MapperInfo(WinID, MAPPER_INFO_MINY)
     Mx2 = MapperInfo(WinID, MAPPER_INFO_MAXX)
     My2 = MapperInfo(WinID, MAPPER_INFO_MAXY)

     Create Rect Into Variable o_Rectangle
                (Mx1, My1) (Mx2, My2)

     '**If you are not sure whether you might have records without
     '**objects you might be interested in starting with this SQL
     Select * From s_Layer
          Where OBJ
          Into EXISTING__OBJ NoSelect

     '**If you use the SQL above change the s_Layer to EXISTING__OBJ
     '**Selection objects from current layers within current vindow
area
     Select * From s_Layer
          Where OBJ Intersects o_Rectangle
          Into VISIBLE__OBJ NoSelect

     If TableInfo("VISIBLE__OBJ", TAB_INFO_NROWS) > 0 then
          LayerIsVisible = TRUE
     end if

End Function
**********************************************************************
***************

You might also move the extraction of the coordinates and the creation
of your o_Rectangle on level up, so
that you only have to create this object once for every Map window.
You can then send the object to the
LayerIsVisible procedure as a parameter in stead of the window id.

HTH,
Peter
----------------------------------------------------------------------
--------------------------
Peter Horsb�ll M�ller, GIS Udviklingskonsulent / GIS-Developer
Kampsax A/S - GIS Software & Solutions
Rugaardsvej 55, 5000 Odense, DK
tel: +45 6313 5013,  dir:+45 6313 5008,  fax: +45 6313 5090
mailto:[EMAIL PROTECTED]
www.kampsax-gis.dk and www.kampsax.dk
Authorized MapInfo Partner & Distributor in Denmark and Norway.
----------------------------------------------------------------------
--------------------------
Se mere om Dansk MapInfo Brugerkonference p�
http://www.kampsax-gis.dk/Default.asp?ID=296

Klik ind p� http://www.kortal.dk og se det hele lidt fra oven!
Check http://www.kortal.dk and have a look at Denmark from above!
----- Videresendt af Peter M�ller/Kampsax - 02-08-2002 08:11 -----

                    "Peter
                    Zyczynski"              Til:
<[EMAIL PROTECTED]>
                    <peterz@insightg        cc:
                    is.com.au>              Vedr.:  MI-L MB - Select
with object variables

                    02-08-2002 03:52
                    Besvar venligst
                    til peterz





Hi all,

I'm after some ideas.

I have about 40 tables of bus routes open in a single mapper window,
some are within view, some are not.

Out of the 40 layers I need to determine which ones are actually
visible in the current mapper.  Any ideas greatly appreciated.


MY ATTEMPT:
------------
I was thinking of creating a rectangle the size of the mapper window
into an object variable, and then running a query to see if my table
intersects the object variable - but it don't work - I don't even get
an error message!  Reason for using an object variable was to optimise
speed - I'm gona be evaluating a lot of workspaces with a lot layers.


Here's the failed attempt code:
--------------------------------
Declare Sub Main
Declare Function LayerIsVisible
(
ByVal WinID as integer,
ByVal s_Layer as string
)
as logical
--------------------------------
Sub Main

Dim
i, WinID as integer,
s_Layer as string

Print chr$(12)
WinID = FrontWindow()

for i = 1 to MapperInfo(WinID, MAPPER_INFO_LAYERS)
s_Layer = LayerInfo(WinID, i, LAYER_INFO_NAME)
If LayerIsVisible(WinID, s_Layer) then
           Print s_Layer
           End if
next

End Sub

--------------------------------
Function LayerIsVisible(
ByVal WinID as integer,
ByVal s_Layer as string
)
as logical

Dim
Mx1, Mx2, My1, My2 as float,
o_Rectangle as object

LayerIsVisible = FALSE
Mx1 = MapperInfo(WinID, MAPPER_INFO_MINX)
My1 = MapperInfo(WinID, MAPPER_INFO_MINY)
Mx2 = MapperInfo(WinID, MAPPER_INFO_MAXX)
My2 = MapperInfo(WinID, MAPPER_INFO_MAXY)

Create Rect Into Variable o_Rectangle
           (Mx1, My1) (Mx2, My2)

'*** The following bit must be wrong because
'*** it never evaluates to true.

If s_Layer intersects o_Rectangle then
LayerIsVisible = TRUE
end if

End Function
--------------------------------


Peter Zyczynski
Analyst Programmer
Insight GIS
Australia
Ph:  (03) 6244-7344
Fax: (03) 6244-7028
[EMAIL PROTECTED]
www.insightgis.com.au



---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail:
[EMAIL PROTECTED]
Message number: 2331




---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 2339

Reply via email to