Nearest Neighbor REST Call (v3.70.00+)

Overview

The EasyTerritory Nearest Neighbor is a REST endpoint that provides information about locations managed in an EasyTerritory project. For instance, a developer could make a query and retrieve information for the nearest store location based on a supplied latitude and longitude. With the March 2022 release, the Nearest Neighbor endpoint also includes the distance (meters) in the response JSON.

Step 1: Build an EasyTerritory project containing points and set up the Project Points Plugin following these instructions.

Step 2: Follow these instructions to authenticate with EasyTerritory and receive an ‘oitoken’.

Step 3: Call the EasyTerritory Nearest Neighbor Lookup REST Call:

https://apps.easyterritory.com/{InstanceGuid}/{InstanceType}/REST/ProjectPointLayer/{project Guid}/nearest

GET Nearest returns one or more (nearest-neighbor) locations based on a supplied latitude and longitude

?lat={latitude of location}
&lon={longitude of location}
&layerId={optional layer id in project – defaults to querying all custom point layers in the project}&
&top={optional number of nearest features to return – defaults to one}
&whereCol={optional where column to filter on}
&whereVal={optional where value to filter on }
&oiToken={optional oi token which can alternatively be passed as a cookie}

Note: if whereCol and whereVal are supplied the filter uses an equivalence test.

Step 4: Response JSON

[DataMember(Name = “distance”)]

public double Distance { get; set; } // v3.117.00+, in meters

[DataMember(Name = “primaryKey”)]

public long PrimaryKey { get; set; }

[DataMember(Name = “wkt”)]

public string Wkt { get; set; }

[DataMember(Name = “projectId”)]

public string ProjectId { get; set; }

[DataMember(Name = “layerId”)]

public string LayerId { get; set; }

[DataMember(Name = “itemId”)]

public string ItemId { get; set; }

[DataMember(Name = “name”)]

public string Name { get; set; }

[DataMember(Name = “fullAddress”)]

public string FullAddress { get; set; }

[DataMember(Name = “markupTag”)]

public string MarkupTag { get; set; }

[DataMember(Name = “geostreet”)]

public string GeoStreet { get; set; }

[DataMember(Name = “geocity”)]

public string GeoCity { get; set; }

[DataMember(Name = “geostate”)]

public string GeoState { get; set; }

[DataMember(Name = “geopostal”)]

public string GeoPostal { get; set; }

[DataMember(Name = “geocountry”)]

public string GeoCountry { get; set; }

[DataMember(Name = “geoquality”)]

public string GeoQuality { get; set; }

[DataMember(Name = “geolatitude”)]

public decimal GeoLatitude { get; set; }

[DataMember(Name = “geolongitude”)]

public decimal GeoLongitude { get; set; }

[DataMember(Name = “stat1”)]

public double Stat1 { get; set; }

[DataMember(Name = “stat2”)]

public double Stat2 { get; set; } 

[DataMember(Name = “stat3”)]

public double Stat3 { get; set; }

[DataMember(Name = “stat4”)]

public double Stat4 { get; set; }

[DataMember(Name = “stat5”)]

public double Stat5 { get; set; }

[DataMember(Name = “stat6”)]

public double Stat6 { get; set; }

[DataMember(Name = “stat7”)]

public double Stat7 { get; set; }

[DataMember(Name = “stat8”)]

public double Stat8 { get; set; }