Maptitude GISDK Help |
To run this Caliper Script macro, you need to:
Open the geographic file hartford.cdf in the Tutorial folder.
Choose Tools>Locate>Index Locations and create a new Location index based on the Hartford Streets layer, using All Features, with two ranges and postal code districts, and save it in hartford.idx in the Tutorial folder.
Copy the following macro to a text file, with the extension .rsc.
Choose Tools>GIS Developer's Kit>GISDK Toolbar, and compile and test the macro. For more information, see Compiling and Testing with the GISDK toolbox.
The macro will display four dialog boxes, using the ShowArray() function, that show the results from:
The Get Rule Files macro
The Get Location Index Properties macro
The attempt to locate 1450 Asylum Ave, correctly spelled
The attempt to locate 1450 Asilium Avenue, an incorrect spelling
Macro "Test Location Index"
// The geocoding macros are located in the geocode UI:
SetAlternateInterface("geocode")
// To be safe, unload any existing Location index from memory:
RunMacro("GISDK Drop All Location Indexes")
// List all the rule files stored in the program directory:
{ rule_descriptions , rule_files } = RunMacro("GISDK Get Rule Files")
ShowArray({ "rule descriptions" , rule_descriptions ,
"rule files" , rule_files})
// List properties for Location index file Hartford.idx
// in the Tutorial folder.
folder = RunMacro("G30 Tutorial Folder")
index_file = folder + "hartford.idx"
if GetFileInfo(index_file) = null then do
ShowMessage("Cannot find the Location index file: " +index_file + "\n" +
"Please make it by choosing: Tools - Locate - Index Locations.")
Return()
end
index_properties = RunMacro("GISDK Get Location Index Properties",index_file)
ShowArray({"index file", index_file, "index properties", index_properties})
// Make sure the corresponding street layer is in the current workspace or map.
layer_name = "Hartford Streets"
if ArrayPosition(GetLayerNames(),{layer_name},) < 1 then do
ShowMessage("Please open a map with the 'Hartford Streets' layer: Hartford.cdf in the Tutorial folder")
Return()
end
// Load Location index into memory.
offset = 25.0
offset_units = "Miles"
index_handle = RunMacro("GISDK Get Location Index",index_file,
layer_name,
index_properties,
offset,
offset_units)
if index_handle < 1 then do
ShowMessage("Cannot load index file " + index_file + " in memory.")
Return()
end
// Locate one address using the Location index.
//
address = "1450 Asylum Ave"
zip_code = "06105"
city = null
get_zips_from_map = null
default_street_number = 0
interactive = null
result_array = RunMacro("GISDK Find With Location Index",
index_handle,
address,
default_street_number,
zip_code,
city,
layer_name,
get_zips_from_map,
interactive)
ShowArray({"Input Address (Name Exact)", address,zip_code,
"GISDK Find With Location Index", result_array})
// Try another address, with typo error in the street name.
//
address = "1450 Asilium Avenue"
zip_code = "06105"
city = null
get_zips_from_map = null
default_street_number = 0
interactive = null
result_array = RunMacro("GISDK Find With Location Index",
index_handle,
address,
default_street_number,
zip_code,
city,
layer_name,
get_zips_from_map,
interactive)
ShowArray({"Input Address (Name Not Spelled Correctly)",address,zip_code,
"GISDK Find With Location Index",result_array})
// When done with this Location index, do not forget to
// unload the Location index from memory!
RunMacro("GISDK Drop Location Index",index_handle)
// To be safe, when all geocoding is done,
// unload all Location indexes from memory!
RunMacro("GISDK Drop All Location Indexes")
// Clear Geocode from being the alternate UI.
SetAlternateInterface(null)
endMacro
©2025 Caliper Corporation | www.caliper.com |