Home ~ IIS 6 ~ My Books ~ Articles ~ Serving you

Using ESRI's MapObjects to Build Database Client Applications   (continued)
Page 3 of 5 Next Page ->

Problems have been discovered when the priority to the reference to DAO is lower then other references. DAO should be set to have the highest priority allowed. ESRI MapObjects should have its priority set below that of DAO but it should be above that of other controls. Please refer to Figure 2 for an example of the references priority in the application ARDemo.  

IIS 6: The Complete Reference is the most comprehensive book on IIS 6 - covering programming and administrative topics.

cover

IIS 6: The Complete Reference

Figure 2 - References Priority for ARDemo

Great C++ Book 

cover
C++ All-in-One Desk Reference For Dummies

Performing Spatial Queries

The Shapefile

In order to maintain a database table to be associated with a map, ESRI has produced a file structure called a shapefile. From the ESRI May 1997 white paper, Shapefile Technical Description, ESRI describes a shapefile using following definition:

A shapefile stores nontopological geometry and attribute information for the spatial features in a data set. Shapefiles can support point, line, and area features.

Please note that this specification was updated in July 1998. ESRI published the specifications behind the shapefile format and made them available at the ESRI web site at http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf.

A shapefile consists of 3 separate files: dBASE IV file, main file, and an index file. The shapefile used in this example is the country shapefile. The country shapefile consists of:

    • Country.dbf - dBASE IV file
    • Country.shp - main file
    • Country.shx - index file

A shapefile may be loaded into the MapObjects control. Once the shapefile is loaded into the MapObjects Map control an object is created called a MapLayer. Often times, depending on the context, shapefile and MapLayer are used interchangeably. For the purposes of this article however, MapLayer will only refer to a shapefile loaded into a MapObjects map control.

Great introduction to MySQL book

cover
MySQL: Your visual blueprint for for creating open source databases

How a Spatial Query is Produced

Every time the user, using the mouse and the left mouse button, stretches a rectangle over the map control and releases the button, the sample application ARDemo will produce a recordset of the records from the MapLayer selected in the Layers combo box. The map control in the sample application ARDemo is called momapMain. Please refer to the MouseDown event for this control Sub momapMain_MouseDown to observe the process that takes place in performing a spatial query.

Private Sub momapMain_MouseDown (Button As Integer, Shift As Integer, x As Single, y As Single)


Dim molLayer As MapObjects.MapLayer

Set molLayer = Me.momapMain(Me.cboLayer.Text)

'make certain a layer is choosen
If molLayer Is Nothing Then
    MsgBox "choose a layer"
    GoTo Sub_Exit
End If


'copy the tracking rectangle - rectangle stretched by user
'in the spatial query

Set mmorectSearchBounds = Me.momapMain.TrackRectangle

If mmorectSearchBounds Is Nothing Then GoTo Sub_Exit


'Reset the selection and execute the search
Set mmorstSelectedFeatures = Nothing

'Execute the selected SearchByShape method on selected layer.
'the search shape will be the rectangle stretched by the user,
'the moContaining is a constant indicating that shapes within,
'the search shape will be selected

Set mmorstSelectedFeatures = molLayer.SearchShape _
(mmorectSearchBounds, moContaining, "")


'trigger the AfterTrackingLayerDraw event
Me.momapMain.TrackingLayer.Refresh True

'fill grid with the new recordset generated from the
'molLayer.SearchShape utilized in this event

FillGridMORecordset mmorstSelectedFeatures

'generate a SQL statement form the new recordset
'generated from the molLayer.SearchShape utilized
'in this event

MakeSQL Me.cboTable.Text, mmorstSelectedFeatures

Sub_Exit:
    Exit Sub

sub_prematureExit:
    Set mmorstSelectedFeatures = Nothing
    GoTo Sub_Exit

End Sub

Fun and challenging C++ book.

cover
Windows Game Programming For Dummies®

The variable mmorectSearchBounds, local to the form frmMain in the sample application ARDemo, is declared as a MapObjects Rectangle and is used to store the rectangle the user stretched on the map control. This variable is utilized to redraw the user's generated spatial query rectangle every time the map control is refreshed.

'copy the tracking rectangle into variable - rectangle stretched by user
'in the spatial query

Set mmorectSearchBounds = Me.momapMain.TrackRectangle

If mmorectSearchBounds Is Nothing Then GoTo Sub_Exit

Introductory book to Access 2000

cover
Access 2000 For Dummies

 

The rectangle stretched by the user is passed as a parameter in the MapLayer SearchShape method along with the constant moContaining and a zero length string. There are many other constants available for use, which define varying search methods. The zero length string could be replaced by a where clause statement to limit the spatial query. An example of such a clause may be "OPEC IS NOT NULL" where OPEC is a field name in the country MapLayer.

'Execute the selected SearchByShape method on selected layer.
'the search shape will be the rectangle stretched by the user,
'the moContaining is a constant indicating that shapes within,
'the search shape will be selected

Set mmorstSelectedFeatures = molLayer.SearchShape(mmorectSearchBounds, moContaining, "")

Drawing on the map control occurs after one of the following map control events:

  • AfterLayerDraw,
  • AfterTrackingLayerDraw,
  • BeforeLayerDraw, and
  • BeforeTrackingLayerDraw.

To trigger any of these events, the respective MapLayer must be refreshed. In this example, the tracking layer is refreshed since it is the only layer in which a shape is being drawn. Me.momapMain.Refresh is a method that refreshes the entire map and all the loaded MapLayer objects.

'trigger the AfterTrackingLayerDraw event
Me.momapMain.TrackingLayer.Refresh True

Next Page ->

MySQL Bible For Dummies is a great all around book for using and administering MySQL.

cover
MySQL Bible For Dummies

Next Page ->

Home ~ IIS 6 ~ My Books ~ Articles ~ Serving you

© Copyright 2000 Scott Hofmann. All Rights Reserved. Distribution of this document unedited in it's entirety is encouraged.