ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / Managing databases / HFSQL / Spatial data management
  • Special cases
  • Accessing spatial data using spatial indexes
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Determines whether two geometries overlap.
Two geometries overlap if they meet the following criteria:
  • The geometries have the same dimension (i.e., two 2D polygons).
  • The interiors of the geometries have a non-empty intersection of the same dimension as the input geometries.
  • Each geometry has at least one point inside the other.
Example
o2DPolygon_1 is Polygon2D
Linestring2DAddPoint(o2DPolygon_1.Outline, -4.38, 6.50)
Linestring2DAddPoint(o2DPolygon_1.Outline, -6.81, 1.51)
Linestring2DAddPoint(o2DPolygon_1.Outline, -1.42, -0.23)
Linestring2DAddPoint(o2DPolygon_1.Outline, 0.89, 4.19)
Linestring2DAddPoint(o2DPolygon_1.Outline, -4.38, 6.50)
o2DPolygon_1 = GeometryCorrect(o2DPolygon_1)

o2DPolygon_2 is Polygon2D
Linestring2DAddPoint(o2DPolygon_2.Outline, 2.35, 7.52)
Linestring2DAddPoint(o2DPolygon_2.Outline, -3.01, 4.47)
Linestring2DAddPoint(o2DPolygon_2.Outline, 1.82, 2.10)
Linestring2DAddPoint(o2DPolygon_2.Outline, 2.35, 7.52)
o2DPolygon_2 = GeometryCorrect(o2DPolygon_2)

Trace("GeometryOverlap(o2DPolygon_1, o2DPolygon_2) = " + GeometryOverlap(o2DPolygon_1, o2DPolygon_2))
Syntax
<Result> = GeometryOverlap(<Geometry A> , <Geometry B>)
<Result>: Boolean
  • True if the geometries overlap,
  • False otherwise.
If an error occurs, the ErrorOccurred variable is set to True. To get more details on the error, use ErrorInfo with the errMessage constant.
<Geometry A>: Variable containing spatial data
Variable corresponding to the first geometry. This geometry can correspond to one of the following variable types:
<Geometry B>: Variable containing spatial data
Variable corresponding to the second geometry. This geometry can correspond to one of the following variable types:
Remarks

Special cases

  • If geometry A is contained in geometry B, their intersection is equal to geometry A. In this case, GeometryOverlap returns False.
  • If the <Geometry A> and <Geometry B> parameters are identical, GeometryOverlap returns False.
  • If the input geometries are multipolygons, GeometryOverlap returns True if one of the polygons of geometry A overlaps one of the polygons of geometry B.

Accessing spatial data using spatial indexes

In a data file, you can apply a filter on spatial data and loop through the data file. For example, the filter can be based on the result of GeometryOverlap.
It is recommended to use the following syntax to apply a filter on spatial data:
FOR EACH File WHERE WLanguage_function(File.Spatial_item, Spatial_variable)

where:
  • WLanguage_function corresponds to GeometryOverlap.
  • Spatial_item is a spatial item in the data file. This item must:
    • be of type "Geographic data" or "Geometric data".
    • be defined as a "Spatial key".
  • Spatial_variable is a given spatial variable, used for comparison with the spatial item. This variable can be of type PolygonGeo, Polygon2D, etc.
Note: The "FOR EACH File" syntax is available but not recommended, as it doesn't use spatial indexes and is therefore not optimized. In this case, the entire data file is looped through and spatial indexes are not used.
FOR EACH File
IF WLanguage_function(File.Spatial_item, Spatial_variable) = True THEN
   ...
   END
END
Example:
// Define a triangle delimiting a geographic area
// Store this triangle in a variable of type PolygonGeo 
polyGeo is PolygonGeo
LinestringGeoAddPoint(polyGeo.Outline, 0n48.8187479172765, 0n1.9550104465229536)
LinestringGeoAddPoint(polyGeo.Outline, 0n48.685649220185574, 0n2.023674998054354)
LinestringGeoAddPoint(polyGeo.Outline, 0n48.82612543243871, 0n2.2106580854197566)
polyGeo = GeometryCorrect(polyGeo)

// Search for municipalities with territory within the specified triangle
NumberOfRecords is int
FOR EACH MunicipalityData where GeometryOverlap(MunicipalityData.Geometry_Item, polyGeo) 
	// Name of municipality in a trace window
	Trace(MunicipalityData.MunicipalityName)
END
Business / UI classification: Business Logic
Component: wd300hf.dll
Minimum version required
  • Version 2024
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/26/2024

Send a report | Local help