Search Results for

    Show / Hide Table of Contents

    Class GeometryTransformer

    A framework for processes which transform an input Geometry into an output Geometry, possibly changing its structure and type(s).

    Inheritance
    object
    GeometryTransformer
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: NetTopologySuite.Geometries.Utilities
    Assembly: NetTopologySuite.dll
    Syntax
    public class GeometryTransformer
    Remarks

    This class is a framework for implementing subclasses which perform transformations on various different Geometry subclasses.

    It provides an easy way of applying specific transformations to given point types, while allowing unhandled types to be simply copied. Also, the framework handles ensuring that if subcomponents change type the parent geometries types change appropriately to maintain valid structure. Subclasses will override whichever TransformX methods they need to to handle particular Geometry types.

    A typically usage would be a transformation that may transform Polygons into Polygons, LineStrings or Points, depending on the geometry of the input (For instance, a simplification operation). This class would likely need to override the TransformMultiPolygon(MultiPolygon, Geometry) method to ensure that if input Polygons change type the result is a GeometryCollection, not a MultiPolygon.

    The default behaviour of this class is simply to recursively transform each Geometry component into an identical object by deep copying down to the level of, but not including, coordinates.

    Note that all TransformXXX methods may return null, to avoid creating empty point objects. This will be handled correctly by the transformer. TransformXXX methods should always return valid geometry - if they cannot do this they should return null (for instance, it may not be possible for a transformLineString implementation to return at least two points - in this case, it should return null). The Transform(Geometry) method itself will always return a non-null Geometry object (but this may be empty).

    Fields

    | Edit this page View Source

    Factory

    The geometry factory

    Declaration
    protected GeometryFactory Factory
    Field Value
    Type Description
    GeometryFactory

    Properties

    | Edit this page View Source

    InputGeometry

    Makes the input geometry available

    Declaration
    public Geometry InputGeometry { get; }
    Property Value
    Type Description
    Geometry

    Methods

    | Edit this page View Source

    Copy(CoordinateSequence)

    Convenience method which provides a standard way of copying CoordinateSequences.

    Declaration
    protected virtual CoordinateSequence Copy(CoordinateSequence seq)
    Parameters
    Type Name Description
    CoordinateSequence seq

    The sequence to copy.

    Returns
    Type Description
    CoordinateSequence

    A deep copy of the sequence.

    | Edit this page View Source

    CreateCoordinateSequence(Coordinate[])

    Convenience method which provides standard way of creating a CoordinateSequence.

    Declaration
    protected virtual CoordinateSequence CreateCoordinateSequence(Coordinate[] coords)
    Parameters
    Type Name Description
    Coordinate[] coords

    The coordinate array to copy.

    Returns
    Type Description
    CoordinateSequence

    A coordinate sequence for the array.

    | Edit this page View Source

    Transform(Geometry)

    Declaration
    public Geometry Transform(Geometry inputGeom)
    Parameters
    Type Name Description
    Geometry inputGeom
    Returns
    Type Description
    Geometry
    | Edit this page View Source

    TransformCoordinates(CoordinateSequence, Geometry)

    Transforms a CoordinateSequence. This method should always return a valid coordinate list for the desired result type. (E.g. a coordinate list for a LineString must have 0 or at least 2 points). If this is not possible, return an empty sequence - this will be pruned out.

    Declaration
    protected virtual CoordinateSequence TransformCoordinates(CoordinateSequence coords, Geometry parent)
    Parameters
    Type Name Description
    CoordinateSequence coords

    The coordinates to transform

    Geometry parent

    The parent geometry

    Returns
    Type Description
    CoordinateSequence

    The transformed coordinates

    | Edit this page View Source

    TransformGeometryCollection(GeometryCollection, Geometry)

    Transforms a GeometryCollection geometry.

    Declaration
    protected virtual Geometry TransformGeometryCollection(GeometryCollection geom, Geometry parent)
    Parameters
    Type Name Description
    GeometryCollection geom

    The GeometryCollection to transform

    Geometry parent

    The parent geometry

    Returns
    Type Description
    Geometry

    A GeometryCollection

    | Edit this page View Source

    TransformLineString(LineString, Geometry)

    Transforms a LineString geometry.

    Declaration
    protected virtual Geometry TransformLineString(LineString geom, Geometry parent)
    Parameters
    Type Name Description
    LineString geom

    The LineString to transform

    Geometry parent

    The parent geometry

    Returns
    Type Description
    Geometry

    A LineString

    | Edit this page View Source

    TransformLinearRing(LinearRing, Geometry)

    Transforms a LinearRing.

    The transformation of a LinearRing may result in a coordinate sequence which does not form a structurally valid ring (i.e. a degenerate ring of 3 or fewer points). In this case a LineString is returned. Subclasses may wish to override this method and check for this situation (e.g.a subclass may choose to eliminate degenerate linear rings)
    Declaration
    protected virtual Geometry TransformLinearRing(LinearRing geom, Geometry parent)
    Parameters
    Type Name Description
    LinearRing geom

    The LinearRing to transform

    Geometry parent

    The parent geometry

    Returns
    Type Description
    Geometry

    A LinearRing if the transformation resulted in a structurally valid ring, otherwise, if the transformation caused the LinearRing to collapse to 3 or fewer points, a LineString

    | Edit this page View Source

    TransformMultiLineString(MultiLineString, Geometry)

    Transforms a MultiLineString geometry.

    Declaration
    protected virtual Geometry TransformMultiLineString(MultiLineString geom, Geometry parent)
    Parameters
    Type Name Description
    MultiLineString geom

    The MultiLineString to transform

    Geometry parent

    The parent geometry

    Returns
    Type Description
    Geometry

    A MultiLineString

    | Edit this page View Source

    TransformMultiPoint(MultiPoint, Geometry)

    Transforms a MultiPoint geometry.

    Declaration
    protected virtual Geometry TransformMultiPoint(MultiPoint geom, Geometry parent)
    Parameters
    Type Name Description
    MultiPoint geom

    The MultiPoint to transform

    Geometry parent

    The parent geometry

    Returns
    Type Description
    Geometry

    A MultiPoint

    | Edit this page View Source

    TransformMultiPolygon(MultiPolygon, Geometry)

    Transforms a MultiPolygon geometry.

    Declaration
    protected virtual Geometry TransformMultiPolygon(MultiPolygon geom, Geometry parent)
    Parameters
    Type Name Description
    MultiPolygon geom

    The MultiPolygon to transform

    Geometry parent

    The parent geometry

    Returns
    Type Description
    Geometry

    A MultiPolygon

    | Edit this page View Source

    TransformPoint(Point, Geometry)

    Transforms a Point geometry.

    Declaration
    protected virtual Geometry TransformPoint(Point geom, Geometry parent)
    Parameters
    Type Name Description
    Point geom

    The Point to transform

    Geometry parent

    The parent geometry

    Returns
    Type Description
    Geometry

    A Point

    | Edit this page View Source

    TransformPolygon(Polygon, Geometry)

    Transforms a Polygon geometry.

    Declaration
    protected virtual Geometry TransformPolygon(Polygon geom, Geometry parent)
    Parameters
    Type Name Description
    Polygon geom

    The Polygon to transform

    Geometry parent

    The parent geometry

    Returns
    Type Description
    Geometry

    A Polygon

    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX