- Current topic: docs
- usermanual
- expressions
- geometrytransformations
Introduction
Each Symbolizer has a property GeometryExpression that allows specifying which geometry attribute will be used in rendering. Being an expression, this property can be used to compute feature geometry utilizing one of the supported transformation functions. The return value of transformation function is a Geometry object.
Supported Transformations
- CenterLine
- CenterPoint
- CentroidPoint
- Clip
- ConstructPoints
- ConvexHull
- Densify
- EndPoint
- Envelope
- MBR
- MBRLongestAxis
- Offset
- OffsetCurve
- Simplify
- Smooth
- StartOffset
- StartPoint
- VertexAnchoredSegments
- Vertices
- ViewTransformation
CenterLine
CenterPoint
Returns the center point of a curve.
Syntax
GeometryTransformations.CenterPoint([geom_field])
Example

CentroidPoint
Returns the centroid point of a geometry.
Syntax
GeometryTransformations.CentroidPoint([geom_field])
Example

ConvexHull
Returns the convex hull or convex envelope of the points that form the given geometry object.
Syntax
GeometryTransformations.ConvexHull([geom_field])
Example

Densify
Inserts extra vertices along the line segments that describe the geometry. The distance between these points is defined by distanceTolerance parameter.
Syntax
GeometryTransformations.Densify([geom_field], distanceTolerance)
Example

EndPoint
Returns the end point of a geometry.
Syntax
GeometryTransformations.EndPoint([geom_field]) blue - end points, purple - start points, green - inner points.
Example

Envelope
Returns a bounding box of the geometry object.
Syntax
GeometryTransformations.Envelope([geom_field])
Example

MBR
Returns the minimum bounding rectangle (MBR) of the geometry object.
Syntax
GeometryTransformations.MBR([geom_field])
Example

MBRLongestAxis
Returns the longest axis of the minimum bounding rectangle.
Syntax
GeometryTransformations.MBRLongestAxis([geom_field])
Example

Offset
Translates the geometry to a new location by adding offset parameters deltaX and deltaY to each coordinate.
Syntax
GeometryTransformations.Offset([geom_field], deltaX, deltaY)
Example

OffsetCurve
Computes the offsetting (inflating/deflating) of both open and closed paths using a number of different join types and end types (Square = 0, Round = 1, Miter = 2).
Syntax
GeometryTransformations.OffsetCurve([geom_field], offset, endType)
Example

StartPoint
Returns the start point of a geometry.
Syntax
GeometryTransformations.StartPoint([geom_field])
Example

Vertices
Returns a list of vertices that form the geometry object.
Syntax
GeometryTransformations.Vertices([geom_field])
Example

ViewTransformation
Returns a new geometry object with coordinates transformed to the map view coordinate system that is normally measured in map units (for example, pixels). This function helps to operate with other functions such as OffsetCurve that have parameters measured in map units.
Syntax
GeometryTransformations.ViewTransformation([geom_field], [ViewTransformation])
Custom Transformations
You can extend the list of supported geometry transformations with your own functions. This can be accomplished by implementing a custom function class inherited from GeometryTransformationFunction class defined in MapSurfer.Geometries.TransformationFunctions namespace (MapSurfer.Geometries.dll). This class should have an overriden TransformGeometry function that contains the logic of the function. The parameters of a constructor will be used as parameters of the function. For example, the constructor MyFunc(double deltaX, double deltaY) corresponds to the function GeometryTransformations.MyFunc(Geometry, double, double). In order to give a unique name to the function, you need to add PluginDescription attribute to the class and provide a name as the first parameter of its constructor. See example below
using System;
using GeoAPI.Geometries;
using MapSurfer.Configuration;
namespace MapSurfer.Geometries.TransformationFunctions
{
[PluginDescription("EndPoint")]
public class EndPointTranformationFunction : GeometryTransformationFunction
{
public EndPointTranformationFunction()
{
}
protected override Geometry TransformGeometry(Geometry geom)
{
ICoordinate[] coords = geom.Coordinates;
return new Point((ICoordinate)coords[coords.Length - 1].Clone());
}
}
}
Once you have an assembly containing custom geometry functions, you need to copy it to the folder ..\Core\Plugins\Algorithms\GeometryTransformations. Next, you need to clear the cache of assemblies used by MapSurfer.NET to speed up loading. This cache is normally located in C:\Users\YOURUSER\AppData\Local\MapSurfer.NET\YOURVERSION\Core\UserCache, where YOURUSER is the user name for which the framework with the version YOURVERSION was installed.