Table of Contents

Class Transformations

Namespace
SpatialNET
Assembly
SpatialNET.Extensions.dll

Coordinate transformations with geometric results (ADR 0025): Translate, Scale, Rotate and the general Transform. Every vertex is mapped, X and Y by the transformation, Z and M are kept (unless Transform changes them). Results are created through the factory and restricted to what it supports (SupportsZ, SupportsM).

public static class Transformations

Inheritance

Inherited Members

Methods

Rotate(IPoint2D, double, Coordinate?, IGeometryFactory?)

Rotates a point by angle (radians, counter-clockwise) about origin; Z and M stay. Multiples of a quarter turn are exact (no rounding error from sine and cosine).

public static IPoint2D Rotate(this IPoint2D point, double angle, Coordinate? origin = null, IGeometryFactory? factory = null)

Parameters

point IPoint2D

The point.

angle double

The angle in radians, counter-clockwise; finite.

origin Coordinate?

The centre of the rotation; null = (0, 0).

factory IGeometryFactory?

The factory; null = SpatialNET.GeometryFactory.Default.

Returns

IPoint2D

Exceptions

ArgumentNullException

point is null.

ArgumentOutOfRangeException

The angle or the origin is NaN or infinite.

InvalidOperationException

No factory available, or a coordinate leaves the range of System.Double.

Rotate(IMultiPoint2D, double, Coordinate?, IGeometryFactory?)

Rotates a multipoint (see SpatialNET.Transformations.Rotate(SpatialNET.IPoint2D,System.Double,System.Nullable{SpatialNET.Coordinate},SpatialNET.IGeometryFactory)).

public static IMultiPoint2D Rotate(this IMultiPoint2D multiPoint, double angle, Coordinate? origin = null, IGeometryFactory? factory = null)

Parameters

multiPoint IMultiPoint2D

The multipoint.

angle double

The angle in radians, counter-clockwise; finite.

origin Coordinate?

The centre of the rotation; null = (0, 0).

factory IGeometryFactory?

The factory; null = SpatialNET.GeometryFactory.Default.

Returns

IMultiPoint2D

Exceptions

ArgumentNullException

multiPoint is null.

ArgumentOutOfRangeException

The angle or the origin is NaN or infinite.

InvalidOperationException

No factory available, or a coordinate leaves the range of System.Double.

Rotate(IPolyline2D, double, Coordinate?, IGeometryFactory?)

Rotates a polyline (see SpatialNET.Transformations.Rotate(SpatialNET.IPoint2D,System.Double,System.Nullable{SpatialNET.Coordinate},SpatialNET.IGeometryFactory)).

public static IPolyline2D Rotate(this IPolyline2D line, double angle, Coordinate? origin = null, IGeometryFactory? factory = null)

Parameters

line IPolyline2D

The polyline.

angle double

The angle in radians, counter-clockwise; finite.

origin Coordinate?

The centre of the rotation; null = (0, 0).

factory IGeometryFactory?

The factory; null = SpatialNET.GeometryFactory.Default.

Returns

IPolyline2D

Exceptions

ArgumentNullException

line is null.

ArgumentOutOfRangeException

The angle or the origin is NaN or infinite.

InvalidOperationException

No factory available, or a coordinate leaves the range of System.Double.

Rotate(IPolygon2D, double, Coordinate?, IGeometryFactory?)

Rotates a polygon (see SpatialNET.Transformations.Rotate(SpatialNET.IPoint2D,System.Double,System.Nullable{SpatialNET.Coordinate},SpatialNET.IGeometryFactory)).

public static IPolygon2D Rotate(this IPolygon2D polygon, double angle, Coordinate? origin = null, IGeometryFactory? factory = null)

Parameters

polygon IPolygon2D

The polygon.

angle double

The angle in radians, counter-clockwise; finite.

origin Coordinate?

The centre of the rotation; null = (0, 0).

factory IGeometryFactory?

The factory; null = SpatialNET.GeometryFactory.Default.

Returns

IPolygon2D

Exceptions

ArgumentNullException

polygon is null.

ArgumentOutOfRangeException

The angle or the origin is NaN or infinite.

InvalidOperationException

No factory available, or a coordinate leaves the range of System.Double.

Rotate(IGeometry2D, double, Coordinate?, IGeometryFactory?)

Rotates any geometry (see SpatialNET.Transformations.Rotate(SpatialNET.IPoint2D,System.Double,System.Nullable{SpatialNET.Coordinate},SpatialNET.IGeometryFactory)).

public static IGeometry2D Rotate(this IGeometry2D geometry, double angle, Coordinate? origin = null, IGeometryFactory? factory = null)

Parameters

geometry IGeometry2D

The geometry.

angle double

The angle in radians, counter-clockwise; finite.

origin Coordinate?

The centre of the rotation; null = (0, 0).

factory IGeometryFactory?

The factory; null = SpatialNET.GeometryFactory.Default.

Returns

IGeometry2D

Exceptions

ArgumentNullException

geometry is null.

ArgumentOutOfRangeException

The angle or the origin is NaN or infinite.

NotSupportedException

geometry is not a known geometry kind.

InvalidOperationException

No factory available, or a coordinate leaves the range of System.Double.

Scale(IPoint2D, double, double, Coordinate?, IGeometryFactory?)

Scales a point by sx and sy about origin; Z and M stay. A negative factor mirrors, a factor of 0 collapses the geometry onto a line or a point.

public static IPoint2D Scale(this IPoint2D point, double sx, double sy, Coordinate? origin = null, IGeometryFactory? factory = null)

Parameters

point IPoint2D

The point.

sx double

The factor in X; finite.

sy double

The factor in Y; finite.

origin Coordinate?

The fixed point of the scaling; null = (0, 0).

factory IGeometryFactory?

The factory; null = SpatialNET.GeometryFactory.Default.

Returns

IPoint2D

Exceptions

ArgumentNullException

point is null.

ArgumentOutOfRangeException

A factor or the origin is NaN or infinite.

InvalidOperationException

No factory available, or a coordinate leaves the range of System.Double.

Scale(IMultiPoint2D, double, double, Coordinate?, IGeometryFactory?)

Scales a multipoint (see SpatialNET.Transformations.Scale(SpatialNET.IPoint2D,System.Double,System.Double,System.Nullable{SpatialNET.Coordinate},SpatialNET.IGeometryFactory)).

public static IMultiPoint2D Scale(this IMultiPoint2D multiPoint, double sx, double sy, Coordinate? origin = null, IGeometryFactory? factory = null)

Parameters

multiPoint IMultiPoint2D

The multipoint.

sx double

The factor in X; finite.

sy double

The factor in Y; finite.

origin Coordinate?

The fixed point of the scaling; null = (0, 0).

factory IGeometryFactory?

The factory; null = SpatialNET.GeometryFactory.Default.

Returns

IMultiPoint2D

Exceptions

ArgumentNullException

multiPoint is null.

ArgumentOutOfRangeException

A factor or the origin is NaN or infinite.

InvalidOperationException

No factory available, or a coordinate leaves the range of System.Double.

Scale(IPolyline2D, double, double, Coordinate?, IGeometryFactory?)

Scales a polyline (see SpatialNET.Transformations.Scale(SpatialNET.IPoint2D,System.Double,System.Double,System.Nullable{SpatialNET.Coordinate},SpatialNET.IGeometryFactory)).

public static IPolyline2D Scale(this IPolyline2D line, double sx, double sy, Coordinate? origin = null, IGeometryFactory? factory = null)

Parameters

line IPolyline2D

The polyline.

sx double

The factor in X; finite.

sy double

The factor in Y; finite.

origin Coordinate?

The fixed point of the scaling; null = (0, 0).

factory IGeometryFactory?

The factory; null = SpatialNET.GeometryFactory.Default.

Returns

IPolyline2D

Exceptions

ArgumentNullException

line is null.

ArgumentOutOfRangeException

A factor or the origin is NaN or infinite.

InvalidOperationException

No factory available, or a coordinate leaves the range of System.Double.

Scale(IPolygon2D, double, double, Coordinate?, IGeometryFactory?)

Scales a polygon; the orientation of the rings is restored after a mirroring scale (see SpatialNET.Transformations.Scale(SpatialNET.IPoint2D,System.Double,System.Double,System.Nullable{SpatialNET.Coordinate},SpatialNET.IGeometryFactory)).

public static IPolygon2D Scale(this IPolygon2D polygon, double sx, double sy, Coordinate? origin = null, IGeometryFactory? factory = null)

Parameters

polygon IPolygon2D

The polygon.

sx double

The factor in X; finite.

sy double

The factor in Y; finite.

origin Coordinate?

The fixed point of the scaling; null = (0, 0).

factory IGeometryFactory?

The factory; null = SpatialNET.GeometryFactory.Default.

Returns

IPolygon2D

Exceptions

ArgumentNullException

polygon is null.

ArgumentOutOfRangeException

A factor or the origin is NaN or infinite.

InvalidOperationException

No factory available, or a coordinate leaves the range of System.Double.

Scale(IGeometry2D, double, double, Coordinate?, IGeometryFactory?)

Scales any geometry (see SpatialNET.Transformations.Scale(SpatialNET.IPoint2D,System.Double,System.Double,System.Nullable{SpatialNET.Coordinate},SpatialNET.IGeometryFactory)).

public static IGeometry2D Scale(this IGeometry2D geometry, double sx, double sy, Coordinate? origin = null, IGeometryFactory? factory = null)

Parameters

geometry IGeometry2D

The geometry.

sx double

The factor in X; finite.

sy double

The factor in Y; finite.

origin Coordinate?

The fixed point of the scaling; null = (0, 0).

factory IGeometryFactory?

The factory; null = SpatialNET.GeometryFactory.Default.

Returns

IGeometry2D

Exceptions

ArgumentNullException

geometry is null.

ArgumentOutOfRangeException

A factor or the origin is NaN or infinite.

NotSupportedException

geometry is not a known geometry kind.

InvalidOperationException

No factory available, or a coordinate leaves the range of System.Double.

Transform(IPoint2D, Func<Coordinate, Coordinate>, IGeometryFactory?)

Maps every vertex of a point through transform. Z and M of the result are those the function returns.

public static IPoint2D Transform(this IPoint2D point, Func<Coordinate, Coordinate> transform, IGeometryFactory? factory = null)

Parameters

point IPoint2D

The point.

transform Func<Coordinate, Coordinate>

The mapping; X and Y of its result must be finite.

factory IGeometryFactory?

The factory; null = SpatialNET.GeometryFactory.Default.

Returns

IPoint2D

Exceptions

ArgumentNullException

point or transform is null.

InvalidOperationException

No factory available, or the mapping returned a coordinate with a NaN or infinite X or Y.

Transform(IMultiPoint2D, Func<Coordinate, Coordinate>, IGeometryFactory?)

Maps every vertex of a multipoint through transform (see SpatialNET.Transformations.Transform(SpatialNET.IPoint2D,System.Func{SpatialNET.Coordinate,SpatialNET.Coordinate},SpatialNET.IGeometryFactory)).

public static IMultiPoint2D Transform(this IMultiPoint2D multiPoint, Func<Coordinate, Coordinate> transform, IGeometryFactory? factory = null)

Parameters

multiPoint IMultiPoint2D

The multipoint.

transform Func<Coordinate, Coordinate>

The mapping; X and Y of its result must be finite.

factory IGeometryFactory?

The factory; null = SpatialNET.GeometryFactory.Default.

Returns

IMultiPoint2D

Exceptions

ArgumentNullException

multiPoint or transform is null.

InvalidOperationException

No factory available, or the mapping returned a coordinate with a NaN or infinite X or Y.

Transform(IPolyline2D, Func<Coordinate, Coordinate>, IGeometryFactory?)

Maps every vertex of a polyline through transform (see SpatialNET.Transformations.Transform(SpatialNET.IPoint2D,System.Func{SpatialNET.Coordinate,SpatialNET.Coordinate},SpatialNET.IGeometryFactory)).

public static IPolyline2D Transform(this IPolyline2D line, Func<Coordinate, Coordinate> transform, IGeometryFactory? factory = null)

Parameters

line IPolyline2D

The polyline.

transform Func<Coordinate, Coordinate>

The mapping; X and Y of its result must be finite.

factory IGeometryFactory?

The factory; null = SpatialNET.GeometryFactory.Default.

Returns

IPolyline2D

Exceptions

ArgumentNullException

line or transform is null.

InvalidOperationException

No factory available, or the mapping returned a coordinate with a NaN or infinite X or Y.

Transform(IPolygon2D, Func<Coordinate, Coordinate>, IGeometryFactory?)

Maps every vertex of a polygon through transform. The rings are normalized first and the orientation is restored afterwards (shells counter-clockwise, holes clockwise, ADR 0003), so a mirroring mapping does not flip the polygon inside out. A mapping that is not one-to-one and continuous can make the result invalid.

public static IPolygon2D Transform(this IPolygon2D polygon, Func<Coordinate, Coordinate> transform, IGeometryFactory? factory = null)

Parameters

polygon IPolygon2D

The polygon.

transform Func<Coordinate, Coordinate>

The mapping; X and Y of its result must be finite.

factory IGeometryFactory?

The factory; null = SpatialNET.GeometryFactory.Default.

Returns

IPolygon2D

Exceptions

ArgumentNullException

polygon or transform is null.

InvalidOperationException

No factory available, or the mapping returned a coordinate with a NaN or infinite X or Y.

Transform(IGeometry2D, Func<Coordinate, Coordinate>, IGeometryFactory?)

Maps every vertex of any geometry through transform (see the overloads for the kinds).

public static IGeometry2D Transform(this IGeometry2D geometry, Func<Coordinate, Coordinate> transform, IGeometryFactory? factory = null)

Parameters

geometry IGeometry2D

The geometry.

transform Func<Coordinate, Coordinate>

The mapping; X and Y of its result must be finite.

factory IGeometryFactory?

The factory; null = SpatialNET.GeometryFactory.Default.

Returns

IGeometry2D

Exceptions

ArgumentNullException

geometry or transform is null.

NotSupportedException

geometry is not a known geometry kind.

InvalidOperationException

No factory available, or the mapping returned a coordinate with a NaN or infinite X or Y.

Translate(IPoint2D, double, double, IGeometryFactory?)

Moves a point by (dx, dy); Z and M stay.

public static IPoint2D Translate(this IPoint2D point, double dx, double dy, IGeometryFactory? factory = null)

Parameters

point IPoint2D

The point.

dx double

The shift in X; finite.

dy double

The shift in Y; finite.

factory IGeometryFactory?

The factory; null = SpatialNET.GeometryFactory.Default.

Returns

IPoint2D

Exceptions

ArgumentNullException

point is null.

ArgumentOutOfRangeException

A parameter is NaN or infinite.

InvalidOperationException

No factory available, or a coordinate leaves the range of System.Double.

Translate(IMultiPoint2D, double, double, IGeometryFactory?)

Moves a multipoint by (dx, dy); Z and M stay.

public static IMultiPoint2D Translate(this IMultiPoint2D multiPoint, double dx, double dy, IGeometryFactory? factory = null)

Parameters

multiPoint IMultiPoint2D

The multipoint.

dx double

The shift in X; finite.

dy double

The shift in Y; finite.

factory IGeometryFactory?

The factory; null = SpatialNET.GeometryFactory.Default.

Returns

IMultiPoint2D

Exceptions

ArgumentNullException

multiPoint is null.

ArgumentOutOfRangeException

A parameter is NaN or infinite.

InvalidOperationException

No factory available, or a coordinate leaves the range of System.Double.

Translate(IPolyline2D, double, double, IGeometryFactory?)

Moves a polyline by (dx, dy); Z and M stay.

public static IPolyline2D Translate(this IPolyline2D line, double dx, double dy, IGeometryFactory? factory = null)

Parameters

line IPolyline2D

The polyline.

dx double

The shift in X; finite.

dy double

The shift in Y; finite.

factory IGeometryFactory?

The factory; null = SpatialNET.GeometryFactory.Default.

Returns

IPolyline2D

Exceptions

ArgumentNullException

line is null.

ArgumentOutOfRangeException

A parameter is NaN or infinite.

InvalidOperationException

No factory available, or a coordinate leaves the range of System.Double.

Translate(IPolygon2D, double, double, IGeometryFactory?)

Moves a polygon by (dx, dy); Z and M stay.

public static IPolygon2D Translate(this IPolygon2D polygon, double dx, double dy, IGeometryFactory? factory = null)

Parameters

polygon IPolygon2D

The polygon.

dx double

The shift in X; finite.

dy double

The shift in Y; finite.

factory IGeometryFactory?

The factory; null = SpatialNET.GeometryFactory.Default.

Returns

IPolygon2D

Exceptions

ArgumentNullException

polygon is null.

ArgumentOutOfRangeException

A parameter is NaN or infinite.

InvalidOperationException

No factory available, or a coordinate leaves the range of System.Double.

Translate(IGeometry2D, double, double, IGeometryFactory?)

Moves any geometry by (dx, dy); Z and M stay.

public static IGeometry2D Translate(this IGeometry2D geometry, double dx, double dy, IGeometryFactory? factory = null)

Parameters

geometry IGeometry2D

The geometry.

dx double

The shift in X; finite.

dy double

The shift in Y; finite.

factory IGeometryFactory?

The factory; null = SpatialNET.GeometryFactory.Default.

Returns

IGeometry2D

Exceptions

ArgumentNullException

geometry is null.

ArgumentOutOfRangeException

A parameter is NaN or infinite.

NotSupportedException

geometry is not a known geometry kind.

InvalidOperationException

No factory available, or a coordinate leaves the range of System.Double.