Class GeometryFactory
Supplies a set of utility methods for building Geometry objects from lists of Coordinates.
Inherited Members
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.
Constructors
| Edit this page View SourceGeometryFactory()
Constructs a GeometryFactory that generates Geometries having a floating PrecisionModel and a spatial-reference ID of 0.
Declaration
public GeometryFactory()
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 |
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. |
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 |
| int | srid | A spatial reference id |
| CoordinateSequenceFactory | coordinateSequenceFactory | A coordinate sequence factory |
| NtsGeometryServices | services |
|
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. |
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 |
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 |
|
Fields
| Edit this page View SourceDefault
A predefined GeometryFactory with PrecisionModelc
== Floating.
Declaration
public static readonly GeometryFactory Default
Field Value
| Type | Description |
|---|---|
| GeometryFactory |
Fixed
A predefined GeometryFactory with PrecisionModel
== Fixed.
Declaration
public static readonly GeometryFactory Fixed
Field Value
| Type | Description |
|---|---|
| GeometryFactory |
Floating
A predefined GeometryFactory with PrecisionModel
== Floating.
Declaration
public static readonly GeometryFactory Floating
Field Value
| Type | Description |
|---|---|
| GeometryFactory |
Remarks
A shortcut for Default.
FloatingSingle
A predefined GeometryFactory with PrecisionModel
== FloatingSingle.
Declaration
public static readonly GeometryFactory FloatingSingle
Field Value
| Type | Description |
|---|---|
| GeometryFactory |
Properties
| Edit this page View SourceCoordinateSequenceFactory
Gets a value indicating the factory to use for creating CoordinateSequences
Declaration
public CoordinateSequenceFactory CoordinateSequenceFactory { get; }
Property Value
| Type | Description |
|---|---|
| CoordinateSequenceFactory |
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 |
GeometryServices
Gets a value indicating the NtsGeometryServices object that created this factory.
Declaration
public NtsGeometryServices GeometryServices { get; }
Property Value
| Type | Description |
|---|---|
| NtsGeometryServices |
PrecisionModel
Returns the PrecisionModel that Geometries created by this factory will be associated with.
Declaration
public PrecisionModel PrecisionModel { get; }
Property Value
| Type | Description |
|---|---|
| PrecisionModel |
SRID
The SRID value defined for this factory.
Declaration
public int SRID { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
| Edit this page View SourceBuildGeometry(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 |
Returns
| Type | Description |
|---|---|
| Geometry | A Geometry of the "smallest", "most type-specific"
class that can contain the elements of |
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.
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 |
Returns
| Type | Description |
|---|---|
| Geometry | An empty atomic geometry of given dimension |
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
CreateGeometryCollection()
Creates an empty GeometryCollection
Declaration
public GeometryCollection CreateGeometryCollection()
Returns
| Type | Description |
|---|---|
| GeometryCollection | An empty GeometryCollection |
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 |
CreateLineString()
Creates an empty LineString
Declaration
public LineString CreateLineString()
Returns
| Type | Description |
|---|---|
| LineString | An empty LineString |
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 |
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 |
CreateLinearRing()
Creates an empty LinearRing
Declaration
public LinearRing CreateLinearRing()
Returns
| Type | Description |
|---|---|
| LinearRing | An empty LinearRing |
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 |
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 |
CreateMultiLineString()
Creates an empty MultiLineString
Declaration
public MultiLineString CreateMultiLineString()
Returns
| Type | Description |
|---|---|
| MultiLineString | An empty MultiLineString |
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 |
CreateMultiPoint()
Creates an empty MultiPoint
Declaration
public MultiPoint CreateMultiPoint()
Returns
| Type | Description |
|---|---|
| MultiPoint | An empty MultiPoint |
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 |
Returns
| Type | Description |
|---|---|
| MultiPoint | A MultiPoint object |
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 |
Returns
| Type | Description |
|---|---|
| MultiPoint | A MultiPoint object |
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 |
Returns
| Type | Description |
|---|---|
| MultiPoint | A MultiPoint object |
CreateMultiPolygon()
Creates an empty MultiPolygon
Declaration
public MultiPolygon CreateMultiPolygon()
Returns
| Type | Description |
|---|---|
| MultiPolygon | An empty MultiPolygon |
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 |
CreatePoint()
Creates an empty Point
Declaration
public Point CreatePoint()
Returns
| Type | Description |
|---|---|
| Point | An empty Point |
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 |
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 |
CreatePointFromInternalCoord(Coordinate, Geometry)
Declaration
public static Point CreatePointFromInternalCoord(Coordinate coord, Geometry exemplar)
Parameters
| Type | Name | Description |
|---|---|---|
| Coordinate | coord | |
| Geometry | exemplar |
Returns
| Type | Description |
|---|---|
| Point |
CreatePolygon()
Creates an empty Polygon
Declaration
public Polygon CreatePolygon()
Returns
| Type | Description |
|---|---|
| Polygon | An empty Polygon |
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 |
Returns
| Type | Description |
|---|---|
| Polygon | A Polygon object |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | If the boundary ring is invalid |
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 |
Returns
| Type | Description |
|---|---|
| Polygon | A Polygon object |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | If the boundary ring is invalid |
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 |
Returns
| Type | Description |
|---|---|
| Polygon | the created Polygon |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | If the boundary ring is invalid |
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 |
| LinearRing[] | holes | The inner boundaries of the new |
Returns
| Type | Description |
|---|---|
| Polygon | A Polygon object |
OnDeserialized(StreamingContext)
Declaration
[OnDeserialized]
protected void OnDeserialized(StreamingContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| StreamingContext | context |
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 |
Returns
| Type | Description |
|---|---|
| Geometry | An empty |
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).
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 |
Returns
| Type | Description |
|---|---|
| Geometry[] | The |
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 |
Returns
| Type | Description |
|---|---|
| LineString[] | The |
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 |
Returns
| Type | Description |
|---|---|
| LinearRing[] | The |
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 |
Returns
| Type | Description |
|---|---|
| MultiLineString[] | The |
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 |
Returns
| Type | Description |
|---|---|
| MultiPoint[] | The |
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 |
Returns
| Type | Description |
|---|---|
| MultiPolygon[] | The |
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 |
Returns
| Type | Description |
|---|---|
| Point[] | The |
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 |
Returns
| Type | Description |
|---|---|
| Polygon[] | The |
ToString()
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string |
Overrides
| Edit this page View SourceWithSRID(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. |