Expressions.expr-primary-region

Region attribute: Region clauses are flagged with a Region attribute.

REGION <geometry definition>

Format

The Geometry definition format is defined as follows:

For a circular region:

REGION { 'Location string' | ? | ( LocationExpr ) } RADIUS { RadiusMeters | ? | ( RadiusExpr ) }

For a rectangular region:

REGION { 'Top left Location string' | ? | ( TopLeftLocationExpr ) } TO { 'Bottom right Location string' | ? | ( BottomRightLocationExpr ) }

The Location string format is defined as follows:

Latitude, Longitude

The geometry definition for a region does not support any additional components within the location string.

Type Format
Latitude, Longitude

Degrees as a decimal number, for example: 10.14563, 51.2368

RadiusMeters Meters, the radius of the region defines the size of the circle.

The latitude, longitude and radius all use the English decimal point (a dot).

Remarks

Regions are defined using the REGION keyword followed by a geometry definition of the region.

The geometry definition can be either a position and a radius (circular) or two positions (rectangular).

Each position part can be one of the following:

  • A string literal
  • A parameter marker
  • A string expression enclosed in parentheses that evaluates to a string containing the standard region format

    For example: WHERE LOCATION '12.34, 56.78' WITHIN REGION (Obj.GEOPosition) TO '10,50'

The radius part can be one of the following:

  • A real literal
  • An integer literal
  • A parameter marker
  • A numeric expression enclosed in parentheses.

The following example locates points within a circular region:

SELECT * FROM CDBPOINT WHERE GEOPOSITION WITHIN REGION '0,0' RADIUS 2000000

The following example locates points within a rectangular region:

SELECT * FROM CDBPOINT WHERE GEOPOSITION WITHIN REGION '0,0' TO '90,90'

The following example lists objects and their distance (in kilometers) from the center of a circular Region.

SELECT

NAME, GEOPOSITION, DISTANCE( LOCATION '51,0' TO GEOPOSITION ) / 1000.0 AS "Distance In Km"

FROM

CDBOBJECT

WHERE

GEOPOSITION WITHIN REGION '51,0' RADIUS 10000000

 

This produces a list similar to that shown below:

Row Name GEOPOSITION Distance In Km
0 Direct Outstation Set 25, 0 2891.0680927
1 Analog Input Point 01 30, 0 2335.0934595
2 Analog Input Point 02 32, 0 2112.7036062
3 Analog Input Point 03 35, 0 1779.1188263