User Tools

Site Tools


api:dk11:delphi:gisaddressmatching.tgis_addressmatching.match_string_tgis_objectlist

Table of Contents

TGIS_AddressMatching.Match method

DK11 for Delphi | GisAddressMatching.TGIS_AddressMatching.Match | Constructors | Methods | Properties

Matches given address string and address formulas.

Available also on: .NET | Java | ActiveX.

Syntax

// Delphi
public
  function Match(
    const _str : String;
    var _results : TGIS_ObjectList
  ) : Integer;
// C++ Builder
public:
  int Match(
    const UnicodeString _str,
    TGIS_ObjectList* &_results
  );

Parameters

Name Type Description
_str String address string
_results TGIS_ObjectList list containing all found matches; every string is a single match in form of 'fieldld1=value1#13#10field2=value2#13#10...'; if the reference equals nil, the object will be created ;

Result

Type Description
Integer Number of found matches (or 0 if nothing).

Remarks

Standardizes the input string:

  • removes leading and trailing spaces,
  • replaces single white characters by space characters,
  • replaces a group of white characters by one space character.

It uses regular expression engine for matching.

Does case-insensitive pattern matching.

If the formula is a good match, sets values for formula fields retrieving them from subexpressions.

If the retrieved value is a synonym or has synonyms, it is returned as an alternative of possible values: val1|val2|..|valN.

See the class definition to obtain information how the address formulas are built.

Found matches are returned as a list of TStrings-objects containing matches for an address formula. This is an example of returned match:

DIRPREFIX=N
STREETNAME=Adams
STREETTYPE=Ave

Example

This is a simple example how to use the address matching class.

Delphi

var
  //some declarations
  addressString     : String   ;
  resolvedAddresses : TObjectList ;
  matchMaker        : TGIS_AddressMatching ;
  iniFile           : TIniFile ;
  iniContents       : TStrings ;
  r                 : Integer  ;
begin
 
  // set address string that will be matched
  addressString := '120 Providence St';
 
  // initialize necessary objects
  matchMaker := TGIS_AddressMatching.Create;
  try
 
    // load address formulas
    iniFile := TIniFile.Create ( 'file-name' ) ;
    iniContents := TStringList.Create ;
    iniFile.GetStrings ( iniContents ) ;
    matchMaker.FormulasString := iniContents.Text;
 
    // match the input address
    r := matchMaker.Match ( addressString, resolvedAddresses );
    for i := 0 to r-1 do begin
      // something found
      // output data processing
 
      dosomething();
    end;
  finally
    iniContents.Free;
    iniFile.Free;
    resolvedAddresses.Free ;
    matchMaker.Free;
  end;
2019/08/13 10:48