Search Results for

    Show / Hide Table of Contents

    Class GeometryFactory

    Supplies a set of utility methods for building Geometry objects from lists of Coordinates.

    Inheritance
    object
    GeometryFactory
    GeometryFactoryEx
    OgcCompliantGeometryFactory
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: NetTopologySuite.Geometries
    Assembly: NetTopologySuite.dll
    Syntax
    [Serializable]
    public class GeometryFactory
    Remarks

    Note that the factory constructor methods do not change the input coordinates in any way. In particular, they are not rounded to the supplied PrecisionModel. It is assumed that input Coordinates meet the given precision.

    Instances of this class are thread-safe.

    Constructors

    | Edit this page View Source

    GeometryFactory()

    Constructs a GeometryFactory that generates Geometries having a floating PrecisionModel and a spatial-reference ID of 0.

    Declaration
    public GeometryFactory()
    | Edit this page View Source

    GeometryFactory(CoordinateSequenceFactory)

    Constructs a GeometryFactory that generates Geometries having the given CoordinateSequence implementation, a double-precision floating PrecisionModel and a spatial-reference ID of 0.

    Declaration
    public GeometryFactory(CoordinateSequenceFactory coordinateSequenceFactory)
    Parameters
    Type Name Description
    CoordinateSequenceFactory coordinateSequenceFactory
    | Edit this page View Source

    GeometryFactory(PrecisionModel)

    Constructs a GeometryFactory that generates Geometries having the given {PrecisionModel} and the default CoordinateSequence implementation.

    Declaration
    public GeometryFactory(PrecisionModel precisionModel)
    Parameters
    Type Name Description
    PrecisionModel precisionModel

    The PrecisionModel to use.

    | Edit this page View Source

    GeometryFactory(PrecisionModel, ElevationModel, int, CoordinateSequenceFactory, NtsGeometryServices)

    Constructs a GeometryFactory that generates Geometries having the given precisionModel, elevationModel, srid, coordinateSequenceFactory and services.

    Declaration
    public GeometryFactory(PrecisionModel precisionModel, ElevationModel elevationModel, int srid, CoordinateSequenceFactory coordinateSequenceFactory, NtsGeometryServices services)
    Parameters
    Type Name Description
    PrecisionModel precisionModel

    A precision model

    ElevationModel elevationModel

    An elevation model. May be null

    int srid

    A spatial reference id

    CoordinateSequenceFactory coordinateSequenceFactory

    A coordinate sequence factory

    NtsGeometryServices services

    NtsGeometryServices object creating this factory

    | Edit this page View Source

    GeometryFactory(PrecisionModel, int)

    Constructs a GeometryFactory that generates Geometries having the given PrecisionModel and spatial-reference ID, and the default CoordinateSequence implementation.

    Declaration
    public GeometryFactory(PrecisionModel precisionModel, int srid)
    Parameters
    Type Name Description
    PrecisionModel precisionModel

    The PrecisionModel to use.

    int srid

    The SRID to use.

    | Edit this page View Source

    GeometryFactory(PrecisionModel, int, CoordinateSequenceFactory)

    Constructs a GeometryFactory that generates Geometries having the given PrecisionModel, spatial-reference ID, and CoordinateSequence implementation.

    Declaration
    public GeometryFactory(PrecisionModel precisionModel, int srid, CoordinateSequenceFactory coordinateSequenceFactory)
    Parameters
    Type Name Description
    PrecisionModel precisionModel
    int srid
    CoordinateSequenceFactory coordinateSequenceFactory
    | Edit this page View Source

    GeometryFactory(PrecisionModel, int, CoordinateSequenceFactory, NtsGeometryServices)

    Constructs a GeometryFactory that generates Geometries having the given precisionModel, srid, coordinateSequenceFactory and services.

    Declaration
    public GeometryFactory(PrecisionModel precisionModel, int srid, CoordinateSequenceFactory coordinateSequenceFactory, NtsGeometryServices services)
    Parameters
    Type Name Description
    PrecisionModel precisionModel

    A precision model

    int srid

    A spatial reference id

    CoordinateSequenceFactory coordinateSequenceFactory

    A coordinate sequence factory

    NtsGeometryServices services

    NtsGeometryServices object creating this factory

    Fields

    | Edit this page View Source

    Default

    A predefined GeometryFactory with PrecisionModelc == Floating.

    Declaration
    public static readonly GeometryFactory Default
    Field Value
    Type Description
    GeometryFactory
    | Edit this page View Source

    Fixed

    A predefined GeometryFactory with PrecisionModel == Fixed.

    Declaration
    public static readonly GeometryFactory Fixed
    Field Value
    Type Description
    GeometryFactory
    | Edit this page View Source

    Floating

    A predefined GeometryFactory with PrecisionModel == Floating.

    Declaration
    public static readonly GeometryFactory Floating
    Field Value
    Type Description
    GeometryFactory
    Remarks

    A shortcut for Default.

    | Edit this page View Source

    FloatingSingle

    A predefined GeometryFactory with PrecisionModel == FloatingSingle.

    Declaration
    public static readonly GeometryFactory FloatingSingle
    Field Value
    Type Description
    GeometryFactory

    Properties

    | Edit this page View Source

    CoordinateSequenceFactory

    Gets a value indicating the factory to use for creating CoordinateSequences

    Declaration
    public CoordinateSequenceFactory CoordinateSequenceFactory { get; }
    Property Value
    Type Description
    CoordinateSequenceFactory
    | Edit this page View Source

    ElevationModel

    Gets a value indicating the elevation model that is attached to this geometry factory

    Declaration
    public ElevationModel ElevationModel { get; }
    Property Value
    Type Description
    ElevationModel
    | Edit this page View Source

    GeometryServices

    Gets a value indicating the NtsGeometryServices object that created this factory.

    Declaration
    public NtsGeometryServices GeometryServices { get; }
    Property Value
    Type Description
    NtsGeometryServices
    | Edit this page View Source

    PrecisionModel

    Returns the PrecisionModel that Geometries created by this factory will be associated with.

    Declaration
    public PrecisionModel PrecisionModel { get; }
    Property Value
    Type Description
    PrecisionModel
    | Edit this page View Source

    SRID

    The SRID value defined for this factory.

    Declaration
    public int SRID { get; }
    Property Value
    Type Description
    int

    Methods

    | Edit this page View Source

    BuildGeometry(IEnumerable<Geometry>)

    Build an appropriate Geometry, MultiGeometry, or GeometryCollection to contain the Geometrys in it.

    Declaration
    public virtual Geometry BuildGeometry(IEnumerable<Geometry> geomList)
    Parameters
    Type Name Description
    IEnumerable<Geometry> geomList

    The Geometry to combine.

    Returns
    Type Description
    Geometry

    A Geometry of the "smallest", "most type-specific" class that can contain the elements of geomList.

    Remarks

    If geomList contains a single Polygon, the Polygon is returned.
    If geomList contains several Polygons, a MultiPolygon is returned.
    If geomList contains some Polygons and some LineStrings, a GeometryCollection is returned.
    If geomList is empty, an empty GeometryCollection is returned. Note that this method does not "flatten" Geometries in the input, and hence if any MultiGeometries are contained in the input a GeometryCollection containing them will be returned.

    | Edit this page View Source

    CreateEmpty(Dimension)

    Creates an empty atomic geometry of the given dimension. If passed a dimension of False will create an empty GeometryCollection.

    Declaration
    public Geometry CreateEmpty(Dimension dimension)
    Parameters
    Type Name Description
    Dimension dimension

    The required dimension (False, Point, Curve or Surface)

    Returns
    Type Description
    Geometry

    An empty atomic geometry of given dimension

    | Edit this page View Source

    CreateGeometry(Geometry)

    Creates a deep copy of the input Geometry. The CoordinateSequenceFactory defined for this factory is used to copy the CoordinateSequences of the input geometry.

    This is a convenient way to change the CoordinateSequence used to represent a geometry, or to change the factory used for a geometry.

    Copy() can also be used to make a deep copy, but it does not allow changing the CoordinateSequence type.
    Declaration
    public virtual Geometry CreateGeometry(Geometry g)
    Parameters
    Type Name Description
    Geometry g

    The geometry

    Returns
    Type Description
    Geometry

    A deep copy of the input geometry, using the CoordinateSequence type of this factory

    See Also
    Copy()
    | Edit this page View Source

    CreateGeometryCollection()

    Creates an empty GeometryCollection

    Declaration
    public GeometryCollection CreateGeometryCollection()
    Returns
    Type Description
    GeometryCollection

    An empty GeometryCollection

    | Edit this page View Source

    CreateGeometryCollection(Geometry[])

    Creates a GeometryCollection using the given Geometries; a null or empty array will create an empty GeometryCollection.

    Declaration
    public virtual GeometryCollection CreateGeometryCollection(Geometry[] geometries)
    Parameters
    Type Name Description
    Geometry[] geometries

    an array of Geometries, each of which may be empty but not null, or null

    Returns
    Type Description
    GeometryCollection

    A GeometryCollection object

    | Edit this page View Source

    CreateLineString()

    Creates an empty LineString

    Declaration
    public LineString CreateLineString()
    Returns
    Type Description
    LineString

    An empty LineString

    | Edit this page View Source

    CreateLineString(CoordinateSequence)

    Creates a LineString using the given CoordinateSequence. A null or empty CoordinateSequence creates an empty LineString.

    Declaration
    public virtual LineString CreateLineString(CoordinateSequence coordinates)
    Parameters
    Type Name Description
    CoordinateSequence coordinates

    A CoordinateSequence (possibly empty), or null.

    Returns
    Type Description
    LineString

    A LineString object

    | Edit this page View Source

    CreateLineString(Coordinate[])

    Creates a LineString using the given Coordinates. A null or empty array creates an empty LineString.

    Declaration
    public LineString CreateLineString(Coordinate[] coordinates)
    Parameters
    Type Name Description
    Coordinate[] coordinates

    An array without null elements, or an empty array, or null.

    Returns
    Type Description
    LineString

    A LineString object

    | Edit this page View Source

    CreateLinearRing()

    Creates an empty LinearRing

    Declaration
    public LinearRing CreateLinearRing()
    Returns
    Type Description
    LinearRing

    An empty LinearRing

    | Edit this page View Source

    CreateLinearRing(CoordinateSequence)

    Creates a LinearRing using the given CoordinateSequence; a null or empty CoordinateSequence creates an empty LinearRing. The points must form a closed and simple linestring. Consecutive points must not be equal.

    Declaration
    public virtual LinearRing CreateLinearRing(CoordinateSequence coordinates)
    Parameters
    Type Name Description
    CoordinateSequence coordinates

    A CoordinateSequence (possibly empty), or null.

    Returns
    Type Description
    LinearRing

    A LinearRing object

    Exceptions
    Type Condition
    ArgumentException

    If the ring is not closed, or has too few points

    | Edit this page View Source

    CreateLinearRing(Coordinate[])

    Creates a LinearRing using the given Coordinates; a null or empty array creates an empty LinearRing. The points must form a closed and simple linestring. Consecutive points must not be equal.

    Declaration
    public LinearRing CreateLinearRing(Coordinate[] coordinates)
    Parameters
    Type Name Description
    Coordinate[] coordinates

    An array without null elements, or an empty array, or null.

    Returns
    Type Description
    LinearRing

    A LinearRing object

    Exceptions
    Type Condition
    ArgumentException

    If the ring is not closed, or has too few points

    | Edit this page View Source

    CreateMultiLineString()

    Creates an empty MultiLineString

    Declaration
    public MultiLineString CreateMultiLineString()
    Returns
    Type Description
    MultiLineString

    An empty MultiLineString

    | Edit this page View Source

    CreateMultiLineString(LineString[])

    Creates a MultiLineString using the given LineStrings; a null or empty array will create an empty MultiLineString.

    Declaration
    public virtual MultiLineString CreateMultiLineString(LineString[] lineStrings)
    Parameters
    Type Name Description
    LineString[] lineStrings

    LineStrings, each of which may be empty but not null-

    Returns
    Type Description
    MultiLineString

    A MultiLineString object

    | Edit this page View Source

    CreateMultiPoint()

    Creates an empty MultiPoint

    Declaration
    public MultiPoint CreateMultiPoint()
    Returns
    Type Description
    MultiPoint

    An empty MultiPoint

    | Edit this page View Source

    CreateMultiPoint(CoordinateSequence)

    Creates a MultiPoint using the given CoordinateSequence. A null or empty CoordinateSequence will create an empty MultiPoint.

    Declaration
    public MultiPoint CreateMultiPoint(CoordinateSequence coordinates)
    Parameters
    Type Name Description
    CoordinateSequence coordinates

    A CoordinateSequence (possibly empty), or null.

    Returns
    Type Description
    MultiPoint

    A MultiPoint object

    | Edit this page View Source

    CreateMultiPoint(Point[])

    Creates a MultiPoint using the given Points. A null or empty array will create an empty MultiPoint.

    Declaration
    public virtual MultiPoint CreateMultiPoint(Point[] point)
    Parameters
    Type Name Description
    Point[] point

    An array (without null elements), or an empty array, or null.

    Returns
    Type Description
    MultiPoint

    A MultiPoint object

    | Edit this page View Source

    CreateMultiPointFromCoords(Coordinate[])

    Creates a MultiPoint using the given Coordinates. A null or empty array will create an empty MultiPoint.

    Declaration
    public MultiPoint CreateMultiPointFromCoords(Coordinate[] coordinates)
    Parameters
    Type Name Description
    Coordinate[] coordinates

    An array (without null elements), or an empty array, or null

    Returns
    Type Description
    MultiPoint

    A MultiPoint object

    | Edit this page View Source

    CreateMultiPolygon()

    Creates an empty MultiPolygon

    Declaration
    public MultiPolygon CreateMultiPolygon()
    Returns
    Type Description
    MultiPolygon

    An empty MultiPolygon

    | Edit this page View Source

    CreateMultiPolygon(Polygon[])

    Creates a MultiPolygon using the given Polygons; a null or empty array will create an empty Polygon. The polygons must conform to the assertions specified in the http://www.opengis.org/techno/specs.htm OpenGIS Simple Features Specification for SQL.

    Declaration
    public virtual MultiPolygon CreateMultiPolygon(Polygon[] polygons)
    Parameters
    Type Name Description
    Polygon[] polygons

    Polygons, each of which may be empty but not null.

    Returns
    Type Description
    MultiPolygon

    A MultiPolygon object

    | Edit this page View Source

    CreatePoint()

    Creates an empty Point

    Declaration
    public Point CreatePoint()
    Returns
    Type Description
    Point

    An empty Point

    | Edit this page View Source

    CreatePoint(Coordinate)

    Creates a Point using the given Coordinate. A null coordinate creates an empty Geometry.

    Declaration
    public Point CreatePoint(Coordinate coordinate)
    Parameters
    Type Name Description
    Coordinate coordinate

    a Coordinate, or null

    Returns
    Type Description
    Point

    A Point object

    | Edit this page View Source

    CreatePoint(CoordinateSequence)

    Creates a Point using the given CoordinateSequence; a null or empty CoordinateSequence will create an empty Point.

    Declaration
    public virtual Point CreatePoint(CoordinateSequence coordinates)
    Parameters
    Type Name Description
    CoordinateSequence coordinates

    a CoordinateSequence (possibly empty), or null

    Returns
    Type Description
    Point

    A Point object

    | Edit this page View Source

    CreatePointFromInternalCoord(Coordinate, Geometry)

    Declaration
    public static Point CreatePointFromInternalCoord(Coordinate coord, Geometry exemplar)
    Parameters
    Type Name Description
    Coordinate coord
    Geometry exemplar
    Returns
    Type Description
    Point
    | Edit this page View Source

    CreatePolygon()

    Creates an empty Polygon

    Declaration
    public Polygon CreatePolygon()
    Returns
    Type Description
    Polygon

    An empty Polygon

    | Edit this page View Source

    CreatePolygon(CoordinateSequence)

    Constructs a Polygon with the given exterior boundary.

    Declaration
    public virtual Polygon CreatePolygon(CoordinateSequence coordinates)
    Parameters
    Type Name Description
    CoordinateSequence coordinates

    the outer boundary of the new Polygon, or null or an empty LinearRing if the empty geometry is to be created.

    Returns
    Type Description
    Polygon

    A Polygon object

    Exceptions
    Type Condition
    ArgumentException

    If the boundary ring is invalid

    | Edit this page View Source

    CreatePolygon(Coordinate[])

    Constructs a Polygon with the given exterior boundary.

    Declaration
    public virtual Polygon CreatePolygon(Coordinate[] coordinates)
    Parameters
    Type Name Description
    Coordinate[] coordinates

    the outer boundary of the new Polygon, or null or an empty LinearRing if the empty geometry is to be created.

    Returns
    Type Description
    Polygon

    A Polygon object

    Exceptions
    Type Condition
    ArgumentException

    If the boundary ring is invalid

    | Edit this page View Source

    CreatePolygon(LinearRing)

    Constructs a Polygon with the given exterior boundary.

    Declaration
    public virtual Polygon CreatePolygon(LinearRing shell)
    Parameters
    Type Name Description
    LinearRing shell

    the outer boundary of the new Polygon, or null or an empty LinearRing if the empty geometry is to be created.

    Returns
    Type Description
    Polygon

    the created Polygon

    Exceptions
    Type Condition
    ArgumentException

    If the boundary ring is invalid

    | Edit this page View Source

    CreatePolygon(LinearRing, LinearRing[])

    Constructs a Polygon with the given exterior boundary and interior boundaries.

    Declaration
    public virtual Polygon CreatePolygon(LinearRing shell, LinearRing[] holes)
    Parameters
    Type Name Description
    LinearRing shell

    The outer boundary of the new Polygon, or null or an empty LinearRing if the empty point is to be created.

    LinearRing[] holes

    The inner boundaries of the new Polygon, or null or empty LinearRing s if the empty point is to be created.

    Returns
    Type Description
    Polygon

    A Polygon object

    | Edit this page View Source

    OnDeserialized(StreamingContext)

    Declaration
    [OnDeserialized]
    protected void OnDeserialized(StreamingContext context)
    Parameters
    Type Name Description
    StreamingContext context
    | Edit this page View Source

    ToGeometry(Envelope)

    Creates a Geometry with the same extent as the given envelope.

    Declaration
    public virtual Geometry ToGeometry(Envelope envelope)
    Parameters
    Type Name Description
    Envelope envelope

    The Envelope

    Returns
    Type Description
    Geometry

    An empty Point (for null Envelopes), a Point (when min x = max x and min y = max y) or a Polygon (in all other cases)

    Remarks

    The Geometry returned is guaranteed to be valid. To provide this behavior, the following cases occur:

    If the Envelope is:

    • null returns an empty Point
    • a point returns a non-empty Point
    • a line returns a two-point LineString
    • a rectangle returns a Polygon whose points are (minx, maxy), (minx, maxy), (maxx, maxy), (maxx, miny).
    | Edit this page View Source

    ToGeometryArray(IEnumerable<Geometry>)

    Converts the IEnumerable to an array.

    Declaration
    public static Geometry[] ToGeometryArray(IEnumerable<Geometry> geometries)
    Parameters
    Type Name Description
    IEnumerable<Geometry> geometries

    The IEnumerable of Geometry's to convert.

    Returns
    Type Description
    Geometry[]

    The IEnumerable in array format.

    | Edit this page View Source

    ToLineStringArray(IEnumerable<Geometry>)

    Converts the IEnumerable to an array.

    Declaration
    public static LineString[] ToLineStringArray(IEnumerable<Geometry> lineStrings)
    Parameters
    Type Name Description
    IEnumerable<Geometry> lineStrings

    The IEnumerable of LineStrings to convert.

    Returns
    Type Description
    LineString[]

    The IEnumerable in array format.

    | Edit this page View Source

    ToLinearRingArray(IEnumerable<Geometry>)

    Converts the IEnumerable to an array.

    Declaration
    public static LinearRing[] ToLinearRingArray(IEnumerable<Geometry> linearRings)
    Parameters
    Type Name Description
    IEnumerable<Geometry> linearRings

    The IEnumerable of LinearRings to convert.

    Returns
    Type Description
    LinearRing[]

    The IEnumerable in array format.

    | Edit this page View Source

    ToMultiLineStringArray(IEnumerable<Geometry>)

    Converts the IEnumerable to an array.

    Declaration
    public static MultiLineString[] ToMultiLineStringArray(IEnumerable<Geometry> multiLineStrings)
    Parameters
    Type Name Description
    IEnumerable<Geometry> multiLineStrings

    The IEnumerable of MultiLineStrings to convert.

    Returns
    Type Description
    MultiLineString[]

    The IEnumerable in array format.

    | Edit this page View Source

    ToMultiPointArray(IEnumerable<Geometry>)

    Converts the IEnumerable to an array.

    Declaration
    public static MultiPoint[] ToMultiPointArray(IEnumerable<Geometry> multiPoints)
    Parameters
    Type Name Description
    IEnumerable<Geometry> multiPoints

    The IEnumerable of MultiPoints to convert.

    Returns
    Type Description
    MultiPoint[]

    The IEnumerable in array format.

    | Edit this page View Source

    ToMultiPolygonArray(IEnumerable<Geometry>)

    Converts the IEnumerable to an array.

    Declaration
    public static MultiPolygon[] ToMultiPolygonArray(IEnumerable<Geometry> multiPolygons)
    Parameters
    Type Name Description
    IEnumerable<Geometry> multiPolygons

    The IEnumerable of MultiPolygons to convert.

    Returns
    Type Description
    MultiPolygon[]

    The IEnumerable in array format.

    | Edit this page View Source

    ToPointArray(IEnumerable<Geometry>)

    Converts the IEnumerable to an array.

    Declaration
    public static Point[] ToPointArray(IEnumerable<Geometry> points)
    Parameters
    Type Name Description
    IEnumerable<Geometry> points

    The IEnumerable of Points to convert.

    Returns
    Type Description
    Point[]

    The IEnumerable in array format.

    | Edit this page View Source

    ToPolygonArray(IEnumerable<Geometry>)

    Converts the IEnumerable to an array.

    Declaration
    public static Polygon[] ToPolygonArray(IEnumerable<Geometry> polygons)
    Parameters
    Type Name Description
    IEnumerable<Geometry> polygons

    The IEnumerable of Polygons to convert.

    Returns
    Type Description
    Polygon[]

    The IEnumerable in array format.

    | Edit this page View Source

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    string
    Overrides
    object.ToString()
    | Edit this page View Source

    WithSRID(int)

    Returns a new GeometryFactory whose SRID is the given value and whose other values and behavior are, as near as we possibly can make it, the same as our own.

    Declaration
    public virtual GeometryFactory WithSRID(int srid)
    Parameters
    Type Name Description
    int srid

    The SRID for the result.

    Returns
    Type Description
    GeometryFactory

    The cloned instance.

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