IMS Queries
Web pages created with the Manifold map server can utilize queries that operate on the component being published. If any queries exist in the
project they will be made available in the Queries pane of the Export Web Page dialog.
For example, if our project contains three queries as seen above, launching File - Export - Web Page will show them in the Queries pane as seen below:
Checking a query's checkbox will cause it to appear in the Queries pane of the generated web page. If we check all boxes in the Export Web Page dialog all three queries will appear in the web page:
Two of the queries are parameter queries - they allow user entry of a parameter and so are equipped with an edit box
allowing user entry. The third query takes no parameter and so has no edit box.
Entering a value into a query edit box and pressing Query will launch the query.
The result is a table that lists the output of the query. Tables will appear
either in a new browser window or in a frame in the same browser window
depending on which template was used to create the web page. Any URL columns will
have hyperlinks created for their entries in the table.
Optional templates used within the Export Web Page dialog will create different pages. The configuration seen in the browser
window depends on choices made in the dialog. The illustrations shown in this
topic use the Standard template, which is designed for use with newer browsers. The Compatible with 4.x browsers template uses a simpler style.
Tables in sites created with the Compatible template will be displayed in the same browser window, thus requiring a back command in the browser to go back to the map page.
Captions
The names of the queries are used for the text strings that appear in the Queries pane in the web page. The captions for the edit boxes are simply the name
of the parameter variable used in the parameter query.
For example, the States with population query shown above contains the following SQL:
PARAMETERS exceeding LONG;
SELECT NAME, POP1990 FROM [States Drawing] WHERE
POP1990 > exceeding;
The parameter variable exceeding is accepts user entry and is used within the query to process the SQL
statements.
Manifold will use the name of the query, States with population, together with the name of the parameter variable, exceeding, to construct the captions for the query. When creating a Manifold project
for publication to the web it therefore is important to think ahead when naming
queries and parameter variables so that the resulting captions are reasonably
well self-documenting.
Rules
When using queries in web pages the following rules must be observed:
- All queries in the project will be listed in the Queries pane in the Export Web Page dialog, even those that cannot legally be used within a map server site. It
is the Manifold operator's responsibility to know the contents of the queries
and to choose acceptable queries.
- Only SELECT queries may be chosen for use in the generated site.
- The Manifold operator is responsible for selecting queries that operate within
the component being published. For example, if a project contains a query
that reference a drawing that is not part of a map that was published, the query
should not be chosen for use in the site.
- Queries output a maximum of 200 records to a table on the web page.
- Launching a new query will eliminate the results of the previous query.
To avoid errors, it is strongly recommended that projects used with the map
server contain no unnecessary or unusable components.
Examples
The States matching query seen in the illustration at the beginning of this topic contains:
PARAMETERS pattern TEXT;
SELECT NAME FROM [States Drawing] WHERE NAME LIKEX pattern;
It uses the LIKEX operator to find the names of states matching the pattern provided by the
user.
The 10 longest roads query contains:
SELECT TOP 10 LENGTH, TYPE, ROUTE FROM [Roads Drawing]
ORDER BY LENGTH;
There is no parameter used in this query. It simply always selects the ten
longest roads based on the contents of the Length field.
Panning to Selected Objects / Suppression of ID Field
Objects are not selected by queries in Manifold unless the ID system field is selected by the query. For example, if we have a drawing of
provinces that each has a name, the SQL fragment …
SELECT Name from [Provinces Table] WHERE…
… will create a table, but it will not select the objects associated with the
records that appear in that table. In contrast, the fragment…
SELECT ID, Name from [Provinces Table] WHERE…
… will select the objects as well as creating the table.
If the first SQL fragment is part of a query that is used in a Manifold IMS
web site the output of the query will be a table, but the IMS map window will not
be panned or zoomed. If the second IMS fragment is used, a table will be
created, the objects will be selected, and the IMS map window will pan to the
center of the selected set of objects and will zoom to fit the selection.
Since we normally do not want to show internal system fields such as the ID field to people browsing our web site, the ID field will not be displayed as part of a table created by an IMS query.
Geocoding and Queries
The Manifold geocoder is accessed in IMS applications by using queries
utilizing the geocoding SQL extensions. Manifold SQL includes geocoding SQL extensions that operate with Manifold's geocoding engine to perform spatial operations based upon an address string or zip code.
Geocoding queries will not function unless either Manifold's US streets
geocoding database is installed or Microsoft's MapPoint program is installed. If
MapPoint is used, performance will be lower but coverage will extend to all
countries covered by the MapPoint editions (North America and/or Europe) installed.
See the Geocoding with MapPoint topic if MapPoint is to be used. Note that Internet access permissions must
be adjusted (see below) if MapPoint is called from IMS.
Geocoding extensions will not work with Manifold IMS using the Manifold US
streets geocoding database unless the geocoding database is installed within the
Manifold application installation folder (normally, C:\Program Files\Manifold System). Therefore, the US streets geocoding database should be installed in the
Manifold application installation folder on machines on which Manifold IMS
operates. Geocoding queries using MapPoint will work so long as MapPoint is
correctly installed on the server system regardless of the installation directory used.
Drawings must be projected for geocoding extensions to function correctly.
Boolean CloseToAddress(Number ID, String Address, Number Distance, [String
Unit])
Given an object ID, an address string, a distance and an optional distance
unit determine if the object lies within the specified distance of the address.
Boolean CloseToZip(Number ID, String Zip, Number Distance, [String Unit])
Given an object ID, a ZIP code string, a distance and an optional distance
unit determine if the object lies within the specified distance of the zip code
centroid.
Number DistanceToAddress(Number ID, String Address, [String Unit])
Given an object ID, an address string, and an optional distance unit computes
the distance between the object and the address.
Number DistanceToZip(Number ID, String Zip, [String Unit])
Given an object ID, a ZIP code string, and an optional distance unit computes
the distance between the object and the zip code centroid.
Notes on usage:
- If an object is a line or an area the object's centroid is used for distance
calculations.
- If an address string produces more than one match, the system automatically
selects the closest of the building-level matches (possibly with an "unknown
street name, possible misspelling" error).
- If an address string produces no building-level matches, CloseToAddress returns False and DistanceToAddress returns -1.
- If a zip code string is invalid (no matches in the geocoding database) CloseToZip returns False and DistanceToZip returns -1.
- If the optional distance unit is omitted, the system will use the native
measurement unit of the drawing or meters if the drawing is not projected.
- Distances are great circle distances computed over a WGS84 ellipsoid and are
accurate to 1 meter.
- The geocoding functions cache returned geocoding data between subsequent
calls.
- Functions can be used from IMS as long as the geocoding database is located
within the Manifold application installation folder (usually C:\Program Files\Manifold System).
Geocoding Function Examples
SELECT * FROM Dealers
WHERE CloseToAddress(ID, "330 Lytton Ave, Palo Alto, CA, 94301", 10, "mi")
SELECT * FROM Dealers
WHERE DistanceToAddress(ID, "330 Lytton Ave, Palo Alto, CA, 94301", "mi") <= 10
SELECT * FROM Dealers
WHERE CloseToZip(ID, "94301", 10, "mi")
SELECT * FROM Dealers
WHERE DistanceToZip(ID, "94301", "mi") <= 10
All four examples have a similar function. The first query selects all objects
in Dealers that are within 10 miles of the given address using the CloseToAddress function, while the second example performs the same task using the DistanceToAddress function. The third and fourth examples perform the same functions using the 94301 ZIP code.
To keep the user interface simple and to avoid the complication of dealing
with possible user errors when entering address information into forms, many web
applications with IMS will use the CloseToZip or DistanceToZip functions since these require the user to merely enter the ZIP code
correctly. For many applications, such as locating a dealer, finding the closest
objects to the ZIP centroid provides acceptable accuracy.
See the Units topic for a list of unit abbreviations that may be used to specify optional
distance units.
MapPoint and IMS
MapPoint geocoding will normally not work from IMS unless we map anonymous
Internet connections to a user account that has more enhanced permissions than the
default Internet access IUSR_xxx account.
To enhance permissions for the Internet access account:
-
Create a regular user account with default permissions that is a member of
the Users group.
Open Control Panel - Administrative Tools - Internet Information Services (or the equivalent dialog in your version of Windows).
Right click the folder that contains the published website, select Properties, switch to Directory Security and click Edit under Anonymous access and authentication control.
Set the user account used for anonymous access to the account created in step 1 above.
See the Geocoding with MapPoint topic for use of MapPoint as an auxiliary geocoder.
Tech Tip
When developing on one machine and publishing on a different machine, make
sure the machine that is actually running the map server is a fully up-to-date
Windows machine with all required updates in place just like the machine that was
used to create and test the project.
For example, Manifold System requires that Microsoft Internet Explorer 5.5 or
later (preferably the most recent IE version) has been installed to make sure
that all Windows components, including scripting components, have been updated.
Occasionally, server machines used as IIS hosts might not have IE installed or
might not have the latest version of IE installed because the server is not
used interactively to browse the web.
In such cases a Manifold project and web page might work fine on the
development machine but then not work correctly (queries fail, etc.) when installed on
the server. If this happens, check the server machine to make sure Windows is
fully updated as required by your Manifold System installation notes.
Also make sure to verify that the web server machine has all required Manifold
licensing and accessories installed. For example, if an IMS web site uses a
project that depends upon Enterprise Edition features the web server machine must also have a license for Enterprise
Edition and the project must be correctly configured in the web server so it can
connect to the Enterprise server it uses. Likewise, if geocoding queries are used
the web server machine must have the Manifold geocoding database installed and
be licensed for its use.
Troubleshooting
See the troubleshooting topic Problems with the Internet Map Server for detailed checklists of what might be wrong.
The number one problem with IMS reported to tech support is that users neglect
to add the IUSR_ account with access permissions to the .map file in use. Using Windows Explorer (do not just depend on the IIS management console or other server management
console), right click on the .map file, choose Properties and verify in the Security that the IUSR_ account for the system has necessary read and execute permissions.
See Also
Queries
Map Server Overview
Creating a Web Site
Publishing Multiple Pages
Optimizing Performance
Spatial Extensions
Geocoding Extensions
Street Address Geocoding
Geocoding with MapPoint
Back to Manifold Home Page