private static void ReadPointTest(SpatialFormatter<TextReader, TextWriter> formatter, TextReader input, PositionData expected, CoordinateSystem expectedCoordinateSystem = null) { var p = formatter.Read<Geography>(input); Assert.IsNotNull(p); p.VerifyAsPoint(expected); if (expectedCoordinateSystem != null) { Assert.AreEqual(p.CoordinateSystem, expectedCoordinateSystem); } }
private void ReadPolygonTest(string input, CoordinateSystem expectedReference, params PositionData[][] expected) { var p = this.d4Formatter.Read<Geography>(new StringReader(input)); Assert.IsNotNull(p); p.VerifyAsPolygon(expected); if (expectedReference != null) { Assert.AreEqual(p.CoordinateSystem, expectedReference); } }
internal GeographyPointImplementation(CoordinateSystem coordinateSystem, SpatialImplementation creator, double latitude, double longitude, double? zvalue, double? mvalue) : base(coordinateSystem, creator) { if (double.IsNaN(latitude) || double.IsInfinity(latitude)) { throw new ArgumentException(Strings.InvalidPointCoordinate(latitude, "latitude")); } if (double.IsNaN(longitude) || double.IsInfinity(longitude)) { throw new ArgumentException(Strings.InvalidPointCoordinate(longitude, "longitude")); } this.latitude = latitude; this.longitude = longitude; this.z = zvalue; this.m = mvalue; }
internal GeometryPointImplementation(CoordinateSystem coordinateSystem, SpatialImplementation creator, double x, double y, double? z, double? m) : base(coordinateSystem, creator) { if (double.IsNaN(x) || double.IsInfinity(x)) { throw new ArgumentException(Strings.InvalidPointCoordinate(x, "x")); } if (double.IsNaN(y) || double.IsInfinity(y)) { throw new ArgumentException(Strings.InvalidPointCoordinate(y, "y")); } this.x = x; this.y = y; this.z = z; this.m = m; }
/// <summary>Initializes a new instance of the <see cref="T:Microsoft.Spatial.GeographyMultiLineString" /> class.</summary> /// <param name="coordinateSystem">The coordinate system of this instance.</param> /// <param name="creator">The implementation that created this instance.</param> protected GeographyMultiLineString(CoordinateSystem coordinateSystem, SpatialImplementation creator) : base(coordinateSystem, creator) { }
/// <summary> /// Sets the coordinate system. /// </summary> /// <param name="coordinateSystem">The coordinate system.</param> public override void SetCoordinateSystem(CoordinateSystem coordinateSystem) { this.Destination.SetCoordinateSystem(coordinateSystem); }
/// <summary> /// Get or create a CoordinateSystem with ID /// </summary> /// <param name = "epsgId">The SRID</param> /// <param name = "topology">The topology.</param> /// <returns> /// A CoordinateSystem object /// </returns> private static CoordinateSystem GetOrCreate(int epsgId, Topology topology) { CoordinateSystem r; lock (referencesLock) { if (References.TryGetValue(KeyFor(epsgId, topology), out r)) { return r; } r = new CoordinateSystem(epsgId, "ID " + epsgId, topology); AddRef(r); } return r; }
/// <summary> /// Constructor /// </summary> /// <param name="coordinateSystem">The CoordinateSystem</param> /// <param name="creator">The implementation that created this instance.</param> /// <param name="polygons">Polygons</param> internal GeographyMultiPolygonImplementation(CoordinateSystem coordinateSystem, SpatialImplementation creator, params GeographyPolygon[] polygons) : base(coordinateSystem, creator) { this.polygons = polygons; }
/// <summary> /// Constructor /// </summary> /// <param name="coordinateSystem">The CoordinateSystem</param> /// <param name="creator">The implementation that created this instance.</param> /// <param name="lineStrings">Line Strings</param> internal GeographyMultiLineStringImplementation(CoordinateSystem coordinateSystem, SpatialImplementation creator, params GeographyLineString[] lineStrings) : base(coordinateSystem, creator) { this.lineStrings = lineStrings ?? new GeographyLineString[0]; }
/// <summary>Initializes a new instance of the <see cref="Microsoft.Spatial.GeographyMultiPolygon" /> class.</summary> /// <param name="coordinateSystem">The coordinate system of this instance.</param> /// <param name="creator">The implementation that created this instance.</param> protected GeographyMultiPolygon(CoordinateSystem coordinateSystem, SpatialImplementation creator) : base(coordinateSystem, creator) { }
public override void SetCoordinateSystem(CoordinateSystem coordinateSystem) { parent.GeographySetCoordinateSystemWasCalled = true; }
private static void AddCoordinateSystem(IDictionary<String, Object> jsonObject, CoordinateSystem crs) { IDictionary<String, Object> crsObject = new Dictionary<String, Object>(); IDictionary<String, Object> properties = new Dictionary<String, Object>(); properties.Add("name", "EPSG:" + crs.Id); crsObject.Add("type", "name"); crsObject.Add("properties", properties); // we may have already added a CRS jsonObject["crs"] = crsObject; }
/// <summary> /// Empty Point constructor /// </summary> /// <param name="coordinateSystem">CoordinateSystem</param> /// <param name="creator">The implementation that created this instance.</param> internal GeometryPointImplementation(CoordinateSystem coordinateSystem, SpatialImplementation creator) : base(coordinateSystem, creator) { this.x = double.NaN; this.y = double.NaN; }
/// <summary> /// Set the coordinate system /// </summary> /// <param name="coordinateSystem">The CoordinateSystem</param> /// <returns> /// the coordinate system to be passed down the pipeline /// </returns> protected override CoordinateSystem OnSetCoordinateSystem(CoordinateSystem coordinateSystem) { WriteCoordinateSystem(coordinateSystem); return(coordinateSystem); }
/// <summary> /// Set the coordinate system /// </summary> /// <param name="coordinateSystem">The CoordinateSystem</param> public override void SetCoordinateSystem(CoordinateSystem coordinateSystem) { }
/// <summary> /// Set the system reference to be used by this run of the pipeline /// </summary> /// <param name="coordinateSystem">the coordinate reference system</param> public override void SetCoordinateSystem(CoordinateSystem coordinateSystem) { DoAction(val => Current.SetCoordinateSystem(val), val => Next.SetCoordinateSystem(val), coordinateSystem); }
/// <summary> /// Constructor /// </summary> /// <param name="coordinateSystem">The CoordinateSystem</param> /// <param name="creator">The implementation that created this instance.</param> /// <param name="points">Points</param> internal GeographyMultiPointImplementation(CoordinateSystem coordinateSystem, SpatialImplementation creator, params GeographyPoint[] points) : base(coordinateSystem, creator) { this.points = points ?? new GeographyPoint[0]; }
/// <summary> /// Create a empty point /// </summary> /// <param name="coordinateSystem">CoordinateSystem</param> /// <param name="creator">The implementation that created this instance.</param> internal GeographyPointImplementation(CoordinateSystem coordinateSystem, SpatialImplementation creator) : base(coordinateSystem, creator) { this.latitude = double.NaN; this.longitude = double.NaN; }
/// <summary> /// Constructor /// </summary> /// <param name="coordinateSystem">The CoordinateSystem</param> /// <param name="creator">The implementation that created this instance.</param> /// <param name="geometry">Collection of Geometry instances</param> internal GeometryCollectionImplementation(CoordinateSystem coordinateSystem, SpatialImplementation creator, params Geometry[] geometry) : base(coordinateSystem, creator) { this.geometryArray = geometry ?? new Geometry[0]; }
public override void SetCoordinateSystem(CoordinateSystem coordinateSystem) { }
/// <summary> /// Set the coordinate system /// </summary> /// <param name="coordinateSystem">The CoordinateSystem</param> /// <returns> /// the coordinate system to be passed down the pipeline /// </returns> protected override CoordinateSystem OnSetCoordinateSystem(CoordinateSystem coordinateSystem) { WriteCoordinateSystem(coordinateSystem); return coordinateSystem; }
private static void WriteGeoJsonTest(Action<TypeWashedPipeline> pipelineCalls, IDictionary<String, Object> expectedJsonObject, bool isGeometry, CoordinateSystem crs) { var w = new GeoJsonObjectWriter(); TypeWashedPipeline p = isGeometry ? (TypeWashedPipeline)new TypeWashedToGeographyLongLatPipeline(new ForwardingSegment(w)) : new TypeWashedToGeometryPipeline(new ForwardingSegment(w)); p.SetCoordinateSystem(crs.EpsgId.Value); pipelineCalls(p); var actualObject = w.JsonObject; AddCoordinateSystem(expectedJsonObject, crs); AssertJsonObjectEquals(expectedJsonObject, actualObject); }
/// <summary>Initializes a new instance of the <see cref="T:Microsoft.Spatial.GeographyLineString" /> class.</summary> /// <param name="coordinateSystem">The coordinate system of this instance.</param> /// <param name="creator">The implementation that created this instance.</param> protected GeographyLineString(CoordinateSystem coordinateSystem, SpatialImplementation creator) : base(coordinateSystem, creator) { }
/// <summary>Initializes a new instance of the <see cref="T:Microsoft.Spatial.GeometryPolygon" /> class.</summary> /// <param name="coordinateSystem">The CoordinateSystem.</param> /// <param name="creator">The implementation that created this instance.</param> protected GeometryPolygon(CoordinateSystem coordinateSystem, SpatialImplementation creator) : base(coordinateSystem, creator) { }
/// <summary> /// Returns a new empty instance each time it is called. /// </summary> /// <returns></returns> internal static GeographyPointImplementation PointGEmpty(CoordinateSystem crs = null) { crs = crs ?? CoordinateSystem.DefaultGeography; return new GeographyPointImplementation(crs, SpatialImplementation.CurrentImplementation); }
/// <summary>Initializes a new instance of the <see cref="T:Microsoft.Spatial.GeographyMultiPolygon" /> class.</summary> /// <param name="coordinateSystem">The coordinate system of this instance.</param> /// <param name="creator">The implementation that created this instance.</param> protected GeographyMultiPolygon(CoordinateSystem coordinateSystem, SpatialImplementation creator) : base(coordinateSystem, creator) { }
/// <summary> /// Returns a new instance each time it is called. Defaults any values you don't override. /// </summary> /// <returns></returns> internal static GeometryPointImplementation PointM(double x = 1.0, double y = 2.0, double? z = 3.0, double? m = 4.0, CoordinateSystem coords = null) { coords = coords ?? CoordinateSystem.Geometry(1234); return new GeometryPointImplementation(coords, SpatialImplementation.CurrentImplementation, x, y, z, m); }
/// <summary> /// Write the coordinate system /// </summary> /// <param name="coordinateSystem">The CoordinateSystem</param> private void WriteCoordinateSystem(CoordinateSystem coordinateSystem) { if (!this.coordinateSystemWritten) { // SRID can only be set once in WKT, but can be set once per BeginGeo in collection types this.writer.Write(WellKnownTextConstants.WktSrid); this.writer.Write(WellKnownTextConstants.WktEquals); this.writer.Write(coordinateSystem.Id); this.writer.Write(WellKnownTextConstants.WktSemiColon); this.coordinateSystemWritten = true; } }
/// <summary> /// Returns a new instance each time it is called. Defaults any values you don't override. /// </summary> /// <returns></returns> internal static GeographyFullGlobeImplementation FullGlobe(CoordinateSystem crs = null) { crs = crs ?? CoordinateSystem.Geography(1234); return new GeographyFullGlobeImplementation(crs, SpatialImplementation.CurrentImplementation); }
private static CoordinateSystem Coords(int epsgId = 99, string name = "usual name", CoordinateSystem.Topology topology = Geography) { return new CoordinateSystem(epsgId, name, topology); }
/// <summary> /// Returns a new empty instance each time it is called. /// </summary> /// <param name = "crs">The CRS.</param> /// <returns></returns> internal static GeometryLineStringImplementation LineStringMEmpty(CoordinateSystem crs = null) { crs = crs ?? CoordinateSystem.DefaultGeometry; return new GeometryLineStringImplementation(crs, SpatialImplementation.CurrentImplementation); }
/// <summary>Indicates the Equals overload.</summary> /// <returns>True if equal.</returns> /// <param name="other">The other CoordinateSystem.</param> public bool Equals(CoordinateSystem other) { if (ReferenceEquals(null, other)) { return false; } if (ReferenceEquals(this, other)) { return true; } return Equals(other.topology, this.topology) && other.EpsgId.Equals(this.EpsgId); }
/// <summary> /// Returns a new empty instance each time it is called. /// </summary> /// <param name = "crs">The CRS.</param> /// <returns></returns> internal static GeometryPolygonImplementation PolygonMEmpty(CoordinateSystem crs = null) { crs = crs ?? CoordinateSystem.DefaultGeometry; return new GeometryPolygonImplementation(crs, SpatialImplementation.CurrentImplementation); }
/// <summary> /// Remember this coordinate system in the references dictionary. /// </summary> /// <param name = "coords">The coords.</param> private static void AddRef(CoordinateSystem coords) { References.Add(KeyFor(coords.EpsgId.Value, coords.topology), coords); }
/// <summary> /// Implemented by a subclass to handle the setting of a coordinate system /// </summary> /// <param name="coordinateSystem">the new coordinate system</param> /// <returns>the coordinate system to be passed down the pipeline</returns> protected override CoordinateSystem OnSetCoordinateSystem(CoordinateSystem coordinateSystem) { ValidatorState currentState = this.stack.Peek(); Execute(PipelineCall.SetCoordinateSystem); if (currentState == CoordinateSystem) { this.validationCoordinateSystem = coordinateSystem; } else if (this.validationCoordinateSystem != coordinateSystem) { throw new FormatException(Strings.Validator_SridMismatch); } return coordinateSystem; }
/// <summary> /// Constructor /// </summary> /// <param name="coordinateSystem">The CoordinateSystem</param> /// <param name="creator">The implementation that created this instance.</param> /// <param name="points">Points</param> internal GeometryMultiPointImplementation(CoordinateSystem coordinateSystem, SpatialImplementation creator, params GeometryPoint[] points) : base(coordinateSystem, creator) { this.points = points ?? new GeometryPoint[0]; }
/// <summary> /// initialize the object to a fresh clean smelling state /// </summary> private void InitializeObject() { this.depth = default(int); this.initialFirstCoordinate = default(double); this.initialSecondCoordinate = default(double); this.mostRecentFirstCoordinate = default(double); this.mostRecentSecondCoordinate = default(double); this.pointCount = default(int); this.validationCoordinateSystem = null; this.ringCount = default(int); this.stack.Clear(); this.stack.Push(CoordinateSystem); }
/// <summary> /// Constructor /// </summary> /// <param name="coordinateSystem">The CoordinateSystem</param> /// <param name="creator">The implementation that created this instance.</param> internal GeographyFullGlobeImplementation(CoordinateSystem coordinateSystem, SpatialImplementation creator) : base(coordinateSystem, creator) { }
/// <summary> /// Constructor /// </summary> /// <param name="coordinateSystem">The CoordinateSystem</param> /// <param name="creator">The implementation that created this instance.</param> /// <param name="polygons">Polygons</param> internal GeometryMultiPolygonImplementation(CoordinateSystem coordinateSystem, SpatialImplementation creator, params GeometryPolygon[] polygons) : base(coordinateSystem, creator) { this.polygons = polygons; }