Esempio n. 1
0
 /// <exception cref="java.io.ObjectStreamException"/>
 public virtual void SetGeometryByValue(com.epl.geometry.Point point)
 {
     try
     {
         attribs = null;
         if (point == null)
         {
             descriptionBitMask = 1;
         }
         com.epl.geometry.VertexDescription vd = point.GetDescription();
         descriptionBitMask = vd.m_semanticsBitArray;
         if (point.IsEmpty())
         {
             return;
         }
         attribs    = new double[vd.GetTotalComponentCount()];
         attribs[0] = point.GetX();
         attribs[1] = point.GetY();
         int index = 2;
         for (int i = 1, n = vd.GetAttributeCount(); i < n; i++)
         {
             int semantics = vd.GetSemantics(i);
             int comps     = com.epl.geometry.VertexDescription.GetComponentCount(semantics);
             for (int ord = 0; ord < comps; ord++)
             {
                 attribs[index++] = point.GetAttributeAsDbl(semantics, ord);
             }
         }
     }
     catch (System.Exception)
     {
         throw new System.IO.InvalidDataException("Cannot serialize this geometry");
     }
 }
 public override void SetPointByVal(int index, com.epl.geometry.Point src)
 {
     if (index < 0 || index >= m_pointCount)
     {
         throw new com.epl.geometry.GeometryException("index out of bounds");
     }
     com.epl.geometry.Point point = src;
     if (src.IsEmpty())
     {
         // can not assign an empty point to a multipoint
         // vertex
         throw new System.ArgumentException();
     }
     _verifyAllStreams();
     // verify all allocated streams are of necessary
     // size.
     com.epl.geometry.VertexDescription vdin = point.GetDescription();
     for (int attributeIndex = 0; attributeIndex < vdin.GetAttributeCount(); attributeIndex++)
     {
         int semantics = vdin._getSemanticsImpl(attributeIndex);
         int ncomp     = com.epl.geometry.VertexDescription.GetComponentCount(semantics);
         for (int icomp = 0; icomp < ncomp; icomp++)
         {
             double v = point.GetAttributeAsDbl(semantics, icomp);
             SetAttribute(semantics, index, icomp, v);
         }
     }
 }
Esempio n. 3
0
        public void InsertPoint(int beforePointIndex, com.epl.geometry.Point pt)
        {
            if (beforePointIndex > GetPointCount())
            {
                throw new com.epl.geometry.GeometryException("index out of bounds");
            }
            if (beforePointIndex < 0)
            {
                beforePointIndex = GetPointCount();
            }
            MergeVertexDescription(pt.GetDescription());
            int oldPointCount = m_pointCount;

            _resizeImpl(m_pointCount + 1);
            _verifyAllStreams();
            for (int iattr = 0, nattr = m_description.GetAttributeCount(); iattr < nattr; iattr++)
            {
                int semantics = m_description._getSemanticsImpl(iattr);
                int comp      = com.epl.geometry.VertexDescription.GetComponentCount(semantics);
                com.epl.geometry.AttributeStreamBase stream = com.epl.geometry.AttributeStreamBase.CreateAttributeStreamWithSemantics(semantics, 1);
                if (pt.HasAttribute(semantics))
                {
                    m_vertexAttributes[iattr].InsertAttributes(comp * beforePointIndex, pt, semantics, comp * oldPointCount);
                }
                else
                {
                    // Need to make room for the attribute, so we copy a default
                    // value in
                    double v = com.epl.geometry.VertexDescription.GetDefaultValue(semantics);
                    m_vertexAttributes[iattr].InsertRange(comp * beforePointIndex, v, comp, comp * oldPointCount);
                }
            }
            NotifyModified(com.epl.geometry.MultiVertexGeometryImpl.DirtyFlags.DirtyCoordinates);
        }
Esempio n. 4
0
 private void _set(int endPoint, com.epl.geometry.Point src)
 {
     _touch();
     com.epl.geometry.Point point = src;
     if (src.IsEmptyImpl())
     {
         // can not assign an empty point
         throw new com.epl.geometry.GeometryException("empty_Geometry");
     }
     com.epl.geometry.VertexDescription vdin = point.GetDescription();
     for (int attributeIndex = 0, nattrib = vdin.GetAttributeCount(); attributeIndex < nattrib; attributeIndex++)
     {
         int semantics = vdin._getSemanticsImpl(attributeIndex);
         int ncomp     = com.epl.geometry.VertexDescription.GetComponentCount(semantics);
         for (int icomp = 0; icomp < ncomp; icomp++)
         {
             double v = point.GetAttributeAsDbl(semantics, icomp);
             _setAttribute(endPoint, semantics, icomp, v);
         }
     }
 }
Esempio n. 5
0
 public virtual void TestPoint()
 {
     com.epl.geometry.Point pt = new com.epl.geometry.Point();
     pt.SetXY(100, 200);
     NUnit.Framework.Assert.IsFalse(pt.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M));
     pt.AddAttribute(com.epl.geometry.VertexDescription.Semantics.M);
     NUnit.Framework.Assert.IsTrue(pt.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M));
     NUnit.Framework.Assert.IsTrue(double.IsNaN(pt.GetM()));
     pt.SetAttribute(com.epl.geometry.VertexDescription.Semantics.M, 0, 13);
     NUnit.Framework.Assert.IsTrue(pt.GetM() == 13);
     pt.AddAttribute(com.epl.geometry.VertexDescription.Semantics.Z);
     NUnit.Framework.Assert.IsTrue(pt.GetZ() == 0);
     NUnit.Framework.Assert.IsTrue(pt.GetM() == 13);
     pt.SetAttribute(com.epl.geometry.VertexDescription.Semantics.Z, 0, 11);
     NUnit.Framework.Assert.IsTrue(pt.GetZ() == 11);
     NUnit.Framework.Assert.IsTrue(pt.GetM() == 13);
     pt.AddAttribute(com.epl.geometry.VertexDescription.Semantics.ID);
     NUnit.Framework.Assert.IsTrue(pt.GetID() == 0);
     NUnit.Framework.Assert.IsTrue(pt.GetZ() == 11);
     NUnit.Framework.Assert.IsTrue(pt.GetM() == 13);
     pt.SetAttribute(com.epl.geometry.VertexDescription.Semantics.ID, 0, 1);
     NUnit.Framework.Assert.IsTrue(pt.GetID() == 1);
     NUnit.Framework.Assert.IsTrue(pt.GetZ() == 11);
     NUnit.Framework.Assert.IsTrue(pt.GetM() == 13);
     pt.DropAttribute(com.epl.geometry.VertexDescription.Semantics.M);
     NUnit.Framework.Assert.IsTrue(pt.GetID() == 1);
     NUnit.Framework.Assert.IsTrue(pt.GetZ() == 11);
     NUnit.Framework.Assert.IsFalse(pt.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M));
     com.epl.geometry.Point pt1 = new com.epl.geometry.Point();
     NUnit.Framework.Assert.IsFalse(pt1.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M));
     NUnit.Framework.Assert.IsFalse(pt1.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z));
     NUnit.Framework.Assert.IsFalse(pt1.HasAttribute(com.epl.geometry.VertexDescription.Semantics.ID));
     pt1.MergeVertexDescription(pt.GetDescription());
     NUnit.Framework.Assert.IsFalse(pt1.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M));
     NUnit.Framework.Assert.IsTrue(pt1.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z));
     NUnit.Framework.Assert.IsTrue(pt1.HasAttribute(com.epl.geometry.VertexDescription.Semantics.ID));
 }
Esempio n. 6
0
 /// <summary>Creates a polyline with one line segment.</summary>
 public Polyline(com.epl.geometry.Point start, com.epl.geometry.Point end)
 {
     m_impl = new com.epl.geometry.MultiPathImpl(false, start.GetDescription());
     StartPath(start);
     LineTo(end);
 }
        internal static com.epl.geometry.Geometry PointSymDiffPoint_(com.epl.geometry.Point point_a, com.epl.geometry.Point point_b, double tolerance, com.epl.geometry.ProgressTracker progress_tracker)
        {
            double tolerance_cluster    = tolerance * System.Math.Sqrt(2.0) * 1.00001;
            double tolerance_cluster_sq = tolerance_cluster * tolerance_cluster;

            com.epl.geometry.Point2D    pt_a        = point_a.GetXY();
            com.epl.geometry.Point2D    pt_b        = point_b.GetXY();
            com.epl.geometry.MultiPoint multi_point = new com.epl.geometry.MultiPoint(point_a.GetDescription());
            if (com.epl.geometry.Point2D.SqrDistance(pt_a, pt_b) > tolerance_cluster_sq)
            {
                multi_point.Add(point_a);
                multi_point.Add(point_b);
            }
            return(multi_point);
        }