In mapbasic, how to determine if a table contains spatial objects

42 views
Skip to first unread message

Nicholas G Lawrence

unread,
May 4, 2021, 6:10:24 PM5/4/21
to mapi...@googlegroups.com

Hello all,

 

I am scripting a MabBasic tool to do an audit of several thousand mapinfo tables.

One thing I am trying to capture is the min and max extents of the spatial objects in the table

But, some tables have no spatial objects at all and thus the command TableInfo(table_id,TAB_INFO_MINX) returns an error.

This is at a step where I have already confirmed that the table is a native mapinfo table, is mappable, I have captured the coordsys clause and the table does have a non-zero number of rows.

 

Is there a mapbasic command that can determine if a table contains spatial objects?

 

Nick Lawrence
Senior Spatial Science Officer | Geospatial Technologies
Engineering & Technology | Transport and Main Roads

 

Floor 19 | 313 Adelaide Street | Brisbane City Qld 4000
GPO Box 1412 | Brisbane City Qld 4001
P: (07) 30667977
E: nicholas....@tmr.qld.gov.au
W:
www.tmr.qld.gov.au

 

***********************************************************************
WARNING: This email (including any attachments) may contain legally
privileged, confidential or private information and may be protected by
copyright. You may only use it if you are the person(s) it was
intended to be sent to and if you use it in an authorised way. No one
is allowed to use, review, alter, transmit, disclose, distribute, print
or copy this email without appropriate authority.

If this email was not intended for you and was sent to you by mistake,
please telephone or email me immediately, destroy any hardcopies of
this email and delete it and any copies of it from your computer
system. Any right which the sender may have under copyright law, and
any legal privilege and confidentiality attached to this email is not
waived or destroyed by that mistake.

It is your responsibility to ensure that this email does not contain
and is not affected by computer viruses, defects or interference by
third parties or replication problems (including incompatibility with
your computer system).

Opinions contained in this email do not necessarily reflect the
opinions of the Department of Transport and Main Roads,
or endorsed organisations utilising the same infrastructure.
***********************************************************************

fjavier.gar...@gmail.com

unread,
May 5, 2021, 4:54:45 AM5/5/21
to MapInfo-L
Hi,
You can use the attribute TAB_INFO_MAPPABLE in  TableInfo( ) function

Example:

dim mappeable as logical
mappeable = tableinfo(table_name, TAB_INFO_MAPPABLE )

If the table es mappeable you check  the records with geometry

Select * from table_name where obj

or the records without geometry

Select * from table_name where not obj

Regards,
Javier

Peter Horsbøll Møller

unread,
May 5, 2021, 7:25:20 AM5/5/21
to mapi...@googlegroups.com

And you might want to just count the records with or without objects which might be faster.

 

Select Count(*) "nrecs" from parcels

where obj

into _q noselect hide

 

Now _q.nrecs will tell you the number of records with spatial objects

 

A quick test with a table holding around 100,000 records shows a slight improvement in performance.

1.8 – 2.4 secs for the grouped compared to 2.2 – 3.2 secs for the non-grouped query

 

Not really that big a difference

 

Peter Horsbøll Møller

www.precisely.com

 

Peter Horsbøll Møller
Principal Sales Engineer - Distinguished Engineer

 

From: mapi...@googlegroups.com <mapi...@googlegroups.com> On Behalf Of fjavier.gar...@gmail.com
Sent: 5. maj 2021 10:55
To: MapInfo-L <mapi...@googlegroups.com>
Subject: [MI-L] Re: In mapbasic, how to determine if a table contains spatial objects

 

This message originated Externally. Use proper judgement and caution with attachments, links, or responses.

 

--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en

---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapinfo-l+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mapinfo-l/672d9055-0732-451a-9985-c4a78722fe6bn%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages