/// <exception cref="System.Exception"/> private static com.epl.geometry.Geometry ImportFromJsonMultiPoint(com.epl.geometry.JsonReader parser, com.epl.geometry.AttributeStreamOfDbl @as, com.epl.geometry.AttributeStreamOfDbl bs) { if (parser.CurrentToken() != com.epl.geometry.JsonReader.Token.START_ARRAY) { throw new com.epl.geometry.GeometryException("failed to parse multipoint: array of vertices is expected"); } int point_count = 0; com.epl.geometry.MultiPoint multipoint; multipoint = new com.epl.geometry.MultiPoint(); com.epl.geometry.AttributeStreamOfDbl position = (com.epl.geometry.AttributeStreamOfDbl)(com.epl.geometry.AttributeStreamBase.CreateDoubleStream(2, 0)); // At start of rings int sz; double[] buf = new double[4]; while (parser.NextToken() != com.epl.geometry.JsonReader.Token.END_ARRAY) { if (parser.CurrentToken() != com.epl.geometry.JsonReader.Token.START_ARRAY) { throw new com.epl.geometry.GeometryException("failed to parse multipoint: array is expected, multipoint vertices consist of arrays of cooridinates"); } sz = 0; while (parser.NextToken() != com.epl.geometry.JsonReader.Token.END_ARRAY) { buf[sz++] = ReadDouble(parser); } if (sz < 2) { throw new com.epl.geometry.GeometryException("failed to parse multipoint: each vertex array has to have at least 2 elements"); } if (position.Size() == 2 * point_count) { int c = point_count * 3; if (c % 2 != 0) { c++; } // have to be even position.Resize(c); } position.Write(2 * point_count, buf[0]); position.Write(2 * point_count + 1, buf[1]); if (@as.Size() == point_count) { int c = (point_count * 3) / 2; if (c < 4) { c = 4; } else { if (c < 16) { c = 16; } } @as.Resize(c); } if (sz > 2) { @as.Write(point_count, buf[2]); } else { @as.Write(point_count, com.epl.geometry.NumberUtils.NaN()); } if (bs.Size() == point_count) { int c = (point_count * 3) / 2; if (c < 4) { c = 4; } else { if (c < 16) { c = 16; } } bs.Resize(c); } if (sz > 3) { bs.Write(point_count, buf[3]); } else { bs.Write(point_count, com.epl.geometry.NumberUtils.NaN()); } point_count++; } if (point_count != 0) { com.epl.geometry.MultiPointImpl mp_impl = (com.epl.geometry.MultiPointImpl)multipoint._getImpl(); mp_impl.Resize(point_count); mp_impl.SetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.POSITION, position); } return(multipoint); }
/// <summary>Resizes the multipoint to have the given size.</summary> /// <param name="pointCount">- The number of points in this multipoint.</param> public virtual void Resize(int pointCount) { m_impl.Resize(pointCount); }