public void Equals_GetHashCode_Contract()
        {
            var rnd = new System.Random();
            var offset = rnd.NextDouble() * 60;
            if (rnd.NextDouble() < 0.5)
            {
                offset *= -1;
            }

            var left = new MultiPoint(GetPoints(offset));
            var right = new MultiPoint(GetPoints(offset));

            Assert.AreEqual(left, right);
            Assert.AreEqual(right, left);

            Assert.IsTrue(left.Equals(right));
            Assert.IsTrue(left.Equals(left));
            Assert.IsTrue(right.Equals(left));
            Assert.IsTrue(right.Equals(right));

            Assert.IsTrue(left == right);
            Assert.IsTrue(right == left);

            Assert.AreEqual(left.GetHashCode(), right.GetHashCode());
        }
		private static void Internal_FillGeometryBuilder(SqlGeometryBuilder gb, MultiPoint multiPoint)
		{
			gb.BeginGeometry(OpenGisGeometryType.MultiPoint);
			List<Point> coords = multiPoint.Coordinates as List<Point>;
			foreach (var coord in coords)
			{
				GeographicPosition pos = coord.Coordinates as GeographicPosition;
				gb.BeginGeometry(OpenGisGeometryType.Point);
				gb.BeginFigure(pos.Longitude, pos.Latitude);
				gb.EndFigure();
				gb.EndGeometry();
			}
			gb.EndGeometry();
		}
        public void Can_Deserialize()
        {
            var points = new List<Point>
            {
                new Point(new GeographicPosition(39.57422, -105.01621)),
                new Point(new GeographicPosition(35.0539943, -80.6665134)),
            };

            var expectedMultiPoint = new MultiPoint(points);

            var json = GetExpectedJson();
            var actualMultiPoint = JsonConvert.DeserializeObject<MultiPoint>(json);

            Assert.AreEqual(expectedMultiPoint, actualMultiPoint);
        }
        public void Can_Serialize()
        {
            var points = new List<Point>
            {
                new Point(new GeographicPosition(52.370725881211314, 4.889259338378906)),
                new Point(new GeographicPosition(52.3711451105601, 4.895267486572266)),
                new Point(new GeographicPosition(52.36931095278263, 4.892091751098633)),
                new Point(new GeographicPosition(52.370725881211314, 4.889259338378906))
            };

            var multiPoint = new MultiPoint(points);

            var actualJson = JsonConvert.SerializeObject(multiPoint);

            JsonAssert.AreEqual(GetExpectedJson(), actualJson);
        }
		private IGeometryObject ConstructGeometryPart(SinkGeometry<OpenGisGeographyType> geomPart)
		{

			IGeometryObject geometry = null;

			switch (geomPart.GeometryType)
			{
				case OpenGisGeographyType.Point:
					geometry = new Point(geomPart[0][0]);
					break;
				case OpenGisGeographyType.MultiPoint:
					MultiPoint mp = new MultiPoint(geomPart.Select(g => new Point(g[0])).ToList());
					geometry = mp;
					break;
				case OpenGisGeographyType.LineString:
					geometry = new LineString(geomPart[0]);
					break;
				case OpenGisGeographyType.MultiLineString:
					geometry = new MultiLineString(geomPart.Select(line => new LineString(line))
																																		.ToList()
																															);
					break;
				case OpenGisGeographyType.Polygon:
					geometry = new Polygon(geomPart.Select(line => new LineString(line))
																																		.ToList()
																															);
					break;

				default:
					throw new NotSupportedException("Geometry type " + geomPart.GeometryType.ToString() + " is not supported yet.");
			}

			return geometry;
		}
		private IGeometryObject GeometryFromSinkGeometryCollection(SinkGeometryCollection<OpenGisGeographyType> sinkCollection)
		{

			IGeometryObject _geometry = null;

			switch (sinkCollection.GeometryType)
			{
				case OpenGisGeographyType.Point:
					_geometry = ConstructGeometryPart(sinkCollection[0]);
					((Point)_geometry).BoundingBoxes = this.BoundingBox;
					break;
				case OpenGisGeographyType.MultiPoint:
					_geometry = new MultiPoint(sinkCollection.Skip(1)
																										.Select(g => (Point)ConstructGeometryPart(g))
																										.ToList());
					((MultiPoint)_geometry).BoundingBoxes = this.BoundingBox;
					break;
				case OpenGisGeographyType.LineString:
					_geometry = ConstructGeometryPart(sinkCollection[0]);
					((LineString)_geometry).BoundingBoxes = this.BoundingBox;
					break;
				case OpenGisGeographyType.MultiLineString:
					_geometry = new MultiLineString(sinkCollection.Skip(1)
																												.Select(g => (LineString)ConstructGeometryPart(g))
																												.ToList());
					((MultiLineString)_geometry).BoundingBoxes = this.BoundingBox;
					break;
				case OpenGisGeographyType.Polygon:
					_geometry = ConstructGeometryPart(sinkCollection.First());
					((Polygon)_geometry).BoundingBoxes = this.BoundingBox;
					break;
				case OpenGisGeographyType.MultiPolygon:
					_geometry = new MultiPolygon(sinkCollection.Skip(1)
																												.Select(g => (Polygon)ConstructGeometryPart(g))
																												.ToList());
					((MultiPolygon)_geometry).BoundingBoxes = this.BoundingBox;
					break;
				default:
					throw new NotSupportedException("Geometry type " + sinkCollection.GeometryType.ToString() + " is not possible in GetConstructedGeometry.");
			}

			return _geometry;

		}
		public ToSqlGeometryTests()
		{
			point = new Point(new GeographicPosition(53.2455662, 90.65464646));

			multiPoint = new MultiPoint(new List<Point>
                {
                    new Point(new GeographicPosition(52.379790828551016, 5.3173828125)),
                    new Point(new GeographicPosition(52.36721467920585, 5.456085205078125)),
                    new Point(new GeographicPosition(52.303440474272755, 5.386047363281249, 4.23))
                });
			lineString = new LineString(new List<IPosition>
                {
                    new GeographicPosition(52.379790828551016, 5.3173828125),
                    new GeographicPosition(52.36721467920585, 5.456085205078125),
                    new GeographicPosition(52.303440474272755, 5.386047363281249, 4.23)
                });
			multiLineString = new MultiLineString(new List<LineString>
                {
                    new LineString(new List<IPosition>
                    {
                        new GeographicPosition(52.379790828551016, 5.3173828125),
                        new GeographicPosition(52.36721467920585, 5.456085205078125),
                        new GeographicPosition(52.303440474272755, 5.386047363281249, 4.23)
                    }),
                    new LineString(new List<IPosition>
                    {
                        new GeographicPosition(52.379790828551016, 5.3273828125),
                        new GeographicPosition(52.36721467920585, 5.486085205078125),
                        new GeographicPosition(52.303440474272755, 5.426047363281249, 4.23)
                    })
                });

			polygonWithHole = new Polygon(new List<LineString>
                {
                    new LineString(new List<GeographicPosition>
                    {
											new GeographicPosition(0.516357421875, 47.6415668949958),
											new GeographicPosition(0.516357421875, 47.34463879017405),
											new GeographicPosition(0.977783203125, 47.22539733216678),
											new GeographicPosition(1.175537109375, 47.463611506072866),
											new GeographicPosition(0.516357421875, 47.6415668949958)
                    }),
										 new LineString(new List<GeographicPosition>
											{
												new GeographicPosition(0.630340576171875, 47.54944962456812),
												new GeographicPosition(0.630340576171875, 47.49380564962583),
												new GeographicPosition(0.729217529296875, 47.482669772098674),
												new GeographicPosition(0.731964111328125, 47.53276262898896),
												new GeographicPosition(0.630340576171875, 47.54944962456812)
											})
								});
			polygon = new Polygon(new List<LineString>
                {
                    new LineString(new List<GeographicPosition>
                    {
                        new GeographicPosition(52.379790828551016, 5.3173828125),
                        new GeographicPosition(52.36721467920585, 5.456085205078125),
                        new GeographicPosition(52.303440474272755, 5.386047363281249, 4.23),
                        new GeographicPosition(52.379790828551016, 5.3173828125)
                    })
                });

			multiPolygon = new MultiPolygon(new List<Polygon>
                {
                    new Polygon(new List<LineString>
                    {
                        new LineString(new List<IPosition>
                        {
                            new GeographicPosition(52.959676831105995, -2.6797102391514338),
                            new GeographicPosition(52.9608756693609, -2.6769029474483279),
                            new GeographicPosition(52.908449372833715, -2.6079763270327119),
                            new GeographicPosition(52.891287242948195, -2.5815104708998668),
                            new GeographicPosition(52.875476700983896, -2.5851645010668989),
                            new GeographicPosition(52.882954723868622, -2.6050779098387191),
                            new GeographicPosition(52.875255907042678, -2.6373482332006359),
                            new GeographicPosition(52.878791122091066, -2.6932445076063951),
                            new GeographicPosition(52.89564268523565, -2.6931334629377890),
                            new GeographicPosition(52.930592009390175, -2.6548779332193022),
                            new GeographicPosition(52.959676831105995, -2.6797102391514338)
                        })
                    }),
                    new Polygon(new List<LineString>
                    {
                        new LineString(new List<IPosition>
                        {
                            new GeographicPosition(52.89610842810761, -2.69628632041613),
                            new GeographicPosition(52.8894641454077, -2.75901233808515),
                            new GeographicPosition(52.89938894657412, -2.7663172788742449),
                            new GeographicPosition(52.90253773227807, -2.804554822840895),
                            new GeographicPosition(52.929801009654575, -2.83848602260174),
                            new GeographicPosition(52.94013913205788, -2.838979264607087),
                            new GeographicPosition(52.937353122653533, -2.7978187468478741),
                            new GeographicPosition(52.920394929466184, -2.772273870352612),
                            new GeographicPosition(52.926572918779222, -2.6996509024137052),
                            new GeographicPosition(52.89610842810761, -2.69628632041613)
                        })
                    })
                });

			geomCollection = new GeometryCollection(new List<IGeometryObject>
                {
                    point,
                    multiPoint,
                    lineString,
                    multiLineString,
                    polygon,
                    multiPolygon
                });

			feature = new Feature.Feature(polygon, new Dictionary<string, object>() { { "Key", "Value" } }, "Id");

			featureCollection = new FeatureCollection(new List<Feature.Feature> {
					feature, new Feature.Feature(multiPolygon, null)
			});

		}
Beispiel #8
0
 protected bool Equals(MultiPoint other)
 {
     return base.Equals(other) && Coordinates.SequenceEqual(other.Coordinates);
 }
 private static IGeometryObject GetPointGeometry(List<GeographicPosition> pointList)
 {
     IGeometryObject geom;
     if (pointList.Count == 1)
     {
         geom = new Point(pointList[0]);
     }
     else
     {
         var pnts = pointList.Select(p => new Point(p)).ToList();
         geom = new MultiPoint(pnts);
     }
     return geom;
 }