Official Content

Returns the distance, in meters, between two Geography attributes or variables.

Syntax

GeographyAttOrVar1.Distance(GeographyAttOrVar2)

Where:

GeographyAttOrVar1
   
Must be an attribute or variable based on the Geography data type.

GeographyAttOrVar2
   
Must be an attribute or variable based on the Geography data type.


Type Returned:
Numeric

Scope

Generators: AppleAndroid
Level: AttributeVariable (Geography data type)

Description

The distance between two points is calculated, but the method accepts geographies and assumes centers or equidistance in the case of calculating it based on GeoLines or GeoPolygon.

Samples

Consider the following Transaction object:

Place
{
  PlaceId*
  PlaceName
  PlaceGeo
}

and the following Structured Data Type (SDT) object:

NearPlacesSDTCollection

In this example of 'Places NearBy', the places that are within 1km of the center of the Map are loaded in the &NearPlaces variable (based on the NearPlaces SDT). To do so, the following Procedure object was defined:

Rule:
Parm(&Center);

Variables:
&Center: Geography
&Radius: Numeric(4)
&NearPlaces: NearPlaces (SDT)
&Place: NearPlaces.NearPlacesItem

Source:
&Radius = 1000
For each Place
    where PlaceGeo.Distance(&Center) <= &Radius
     &Place = new()
     &Place.PlaceName = PlaceName
     &Place.PlaceDistance = PlaceGeo.Distance(&Center)/1000  // distance in Kilometers 
     &NearPlaces.Add(&Place)
endfor

  

Last update: March 2025 | © GeneXus. All rights reserved. GeneXus Powered by Globant