ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / Managing databases / HFSQL / Spatial data management
  • Properties specific to Polygon2D variables
  • Functions that use the Polygon2D type
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
The Polygon2D type is used to define all the advanced characteristics of a 2D polygon. You can define and change the characteristics of this polygon using different WLanguage properties.
Characteristics of a 2D polygon:
A 2D polygon consists of:
  • a boundary, which is a simple, closed 2D linestring.
  • one or more optional holes, which are also simple, closed 2D linestrings.
    Holes can't be nested, nor can they intersect with each other or with boundaries.
To be considered valid, a polygon must meet certain criteria:
  • Its boundary is a simple and closed linestring, i.e., it does not intersect itself and its last and first points are equal.
  • The points of the boundary must be ordered clockwise.
  • Holes must be oriented counterclockwise.
  • Holes are also simple and closed.
  • The holes of a polygon cannot cross. They can intersect, but cannot have points of their interiors in common. Therefore, intersections (if any) occur at a tangent point. This also applies to intersections between the boundary and holes of a polygon.
  • A polygon cannot have spikes or lines without an interior.
  • The interior of a polygon is a connected set of points. It should always be possible to go from one point of the interior of the polygon to another without crossing the boundary. This means that a hole should never split the interior of a polygon into more parts.
Remark: For more details on the declaration of this type of variable and the use of WLanguage properties, see Declaring a variable.
Example
// Standard syntax
// Create a square
p is Polygon2D
Linestring2DAddPoint(p.Outline, 0, 0)
Linestring2DAddPoint(p.Outline, 1, 0)
Linestring2DAddPoint(p.Outline, 1, 1)
Linestring2DAddPoint(p.Outline, 0, 1)
// Close the polygon, adding the first point at the end of the boundary
Linestring2DAddPoint(p.Outline, 0, 0) 

// Add a hole
AHole is Linestring2D
Linestring2DAddPoint(AHole, 0.4, 0.4)
Linestring2DAddPoint(AHole, 0.4, 0.6)
Linestring2DAddPoint(AHole, 0.6, 0.6)
Linestring2DAddPoint(AHole, 0.6, 0.4)
// Close the hole, adding the first point at the end
Linestring2DAddPoint(AHole, 0.4, 0.4)
p.Hole.Add(AHole)
// Prefix syntax
// Create a square
p is Polygon2D
p.Outline.AddPoint(0, 0)
p.Outline.AddPoint(1, 0)
p.Outline.AddPoint(1, 1)
p.Outline.AddPoint(0, 1)
// Close the polygon, adding the first point at the end of the boundary
p.Outline.AddPoint(0, 0)

// Add a hole
AHole is Linestring2D
AHole.AddPoint(0.4, 0.4)
AHole.AddPoint(0.4, 0.6)
AHole.AddPoint(0.6, 0.6)
AHole.AddPoint(0.6, 0.4)
// Close the hole, adding the first point at the end
AHole.AddPoint(0.4, 0.4)
p.Hole.Add(AHole)
Properties

Properties specific to Polygon2D variables

The following properties can be used to manipulate a 2D polygon:
Property nameType usedEffect
OutlineLinestring2DExterior ring of the polygon. This outline is a simple, closed linestring defined in 2D coordinates.
HoleArray of Linestring2DSimple, closed linestrings (defined in 2D coordinates) inside the exterior ring of the polygon.
TypeInteger constantType of the current geometry. For a 2D polygon, corresponds to the gtPolygon2D constant.
Remark: Until version 2024 Update 2, this constant was named stPolygon2D.
This property is available in read-only.
Remarks

Functions that use the Polygon2D type

The following functions use Polygon2D variables:
GeometryAreaCalculates the area of a given geometry.
GeometryContainDetermines if geometry A contains geometry B.
GeometryConvexHullCalculates the convex hull of the specified geometry.
GeometryCorrectReturns a corrected version of the specified geometry.
GeometryCoverDetermines if geometry A covers geometry B.
GeometryCoveredByDetermines if every point of geometry A lies inside or on the boundary of geometry B.
GeometryCrossCompares two geometries and determines if their intersection spatially crosses.
GeometryDifferenceReturns a geometry representing the difference between two geometries.
GeometryDisjointDetermines whether two geometries are disjoint, i.e. whether their intersection is empty.
GeometryDistanceCalculates the distance between two geometries.
GeometryEqualDetermines whether two geometries are spatially equal, i.e. whether the first geometry is included in the second, and vice versa.
GeometryIntersectChecks whether two geometries have a non-empty intersection.
GeometryIntersectionReturns a geometry representing the intersection of two geometries.
GeometryIsValidChecks whether the specified geometry is valid according to the OGC rules.
GeometryLengthCalculates the length of a given geometry.
GeometryOverlapDetermines whether two geometries overlap.
GeometryPerimeterCalculates the perimeter of a given geometry (polygon or multipolygon).
GeometrySerializeDSVSerializes a geometry using the specified DSV format.
GeometrySerializeWKTSerializes a geometry using the Well-Known Text (WKT) format.
GeometrySymmetricDifferenceCalculates the symmetric difference between two geometries.
GeometryTouchDetermines whether two geometries touch.
GeometryUnionReturns a geometry corresponding to the union of two geometries.
GeometryWithinDetermines whether geometry A is completely within geometry B (i.e., geometry B completely contains geometry A).
Minimum version required
  • Version 2024
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/29/2024

Send a report | Local help