Exemple #1
0
 private bool TryParseMultiPoint(JsonObject obj, out object result)
 {
     var coordinates = obj["coordinates"] as JsonArray;
     Coordinate[] co;
     if (coordinates != null && TryParseCoordinateArray(coordinates, out co))
     {
         result = new MultiPoint(co.Select(x => new Point(x)));
         return true;
     }
     result = null;
     return false;
 }
Exemple #2
0
        private void AppendMultiPoint(StringBuilder builder, MultiPoint multiPoint)
        {
            builder.Append("MULTIPOINT");
            if (multiPoint.IsEmpty)
            {
                builder.Append(" EMPTY");
                return;
            }

            AppendDimensions(builder, multiPoint);
            builder.Append(" (");
            for (var i = 0; i < multiPoint.Geometries.Count; i++)
            {
                if (i > 0)
                    builder.Append(", ");
                AppendPointInner(builder, (Point)multiPoint.Geometries[i]);
            }
            builder.Append(")");
        }
Exemple #3
0
 private Dictionary<string, object> WriteMultiPoint(MultiPoint multiPoint)
 {
     return new Dictionary<string, object>
     {
         { "type", "MultiPoint" },
         { "coordinates", multiPoint.Geometries.Cast<Point>().Select(WriteCoordinate).ToArray() }
     };
 }
Exemple #4
0
 private void WriteMultiPoint(MultiPoint multipoint, WkbBinaryWriter writer)
 {
     WriteEncoding(writer, _settings.Encoding);
     WriteGeometryType(multipoint, WkbGeometryType.MultiPoint, writer);
     var points = multipoint.Geometries.Cast<Point>().Where(x => !x.IsEmpty).ToList();
     writer.Write((uint)points.Count);
     foreach (var point in points)
         Write(point, writer);
 }
Exemple #5
0
 public void MultiPoint()
 {
     var reader = new GeoJsonReader();
     var geo = new MultiPoint(new Point(0, 0));
     Assert.AreEqual(@"{""type"":""MultiPoint"",""coordinates"":[[0,0]]}",
         geo.ToGeoJson());
     Assert.AreEqual(geo, reader.Read(geo.ToGeoJson()));
 }