Пример #1
0
        /// <summary>
        /// Constructs a new <c>MultiSegmentGeometry</c>
        /// </summary>
        /// <param name="start">The point at the start of the connection.</param>
        /// <param name="end">The point at the end of the connection.</param>
        /// <param name="positions">The ground positions to pack. The first & last positions must exactly
        /// match the position of the supplied end points.</param>
        internal MultiSegmentGeometry(ITerminal start, ITerminal end, IPointGeometry[] positions)
            : base(start, end)
        {
            if (positions == null || positions.Length == 0)
            {
                throw new ArgumentNullException();
            }

            if (positions.Length <= 2)
            {
                throw new ArgumentException("Not enough points for a multi-segment");
            }

            if (!start.IsCoincident(positions[0]))
            {
                throw new ArgumentException("Start point doesn't coincide with first position");
            }

            if (!end.IsCoincident(positions[positions.Length - 1]))
            {
                throw new ArgumentException("End point doesn't coincide with last position");
            }

            m_Data   = positions;
            m_Extent = LineStringGeometry.GetExtent(this);
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MultiSegmentGeometry"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal MultiSegmentGeometry(EditDeserializer editDeserializer)
            : base(editDeserializer)
        {
            // LineString assumes 2D, with X preceding Y. Each coordinate pair is separated
            // with a comma, with a space between each X and Y (e.g. "123 345,124 349,129 341")

            string s = editDeserializer.ReadString(DataField.LineString);

            string[] xys = s.Split(',');
            m_Data = new IPointGeometry[xys.Length];

            for (int i = 0; i < xys.Length; i++)
            {
                string xy = xys[i].Trim();

                int blankPos = xy.IndexOf(' ');
                if (blankPos <= 0)
                {
                    throw new FormatException();
                }

                double x = Double.Parse(xy.Substring(0, blankPos));
                double y = Double.Parse(xy.Substring(blankPos + 1));
                m_Data[i] = new PointGeometry(x, y);
            }

            m_Extent = LineStringGeometry.GetExtent(this);
        }
Пример #3
0
        private void ribbonButton51_Click(object sender, EventArgs e)
        {
            if (featurePrimitiveLineString == null)
            {
                LineStringGeometry lineString = new LineStringGeometry();
                Vec3d vec3d1 = new Vec3d();
                vec3d1.set(-74, 40.714, 0);
                Vec3d vec3d2 = new Vec3d();
                vec3d2.set(139.75, 35.68, 0);
                lineString.push_back(vec3d1);
                lineString.push_back(vec3d2);

                Feature feature = new Feature();
                feature.setGeometry(lineString);
                featurePrimitiveLineString = new FeaturePrimitive();
                featurePrimitiveLineString.setFeature(feature);
                m_earthRoot.addChild(featurePrimitiveLineString);
            }
        }
Пример #4
0
        private ArcFeature ImportArc(Ntx.Line line, Operation creator, ILength tol)
        {
            Debug.Assert(line.IsCurve);
            IEntity what = GetEntityType(line, SpatialType.Line);

            // Get positions defining the arc
            PointGeometry[] pts = GetPositions(line);

            // Ignore zero-length lines
            if (HasZeroLength(pts))
            {
                return(null);
            }

            // Add a point at the center of the circle
            Ntx.Position  pos    = line.Center;
            PointGeometry pc     = new PointGeometry(pos.Easting, pos.Northing);
            PointFeature  center = EnsurePointExists(pc, tol, creator);

            // Calculate exact positions for the arc endpoints
            double          radius = line.Radius;
            ICircleGeometry cg     = new CircleGeometry(pc, radius);
            IPosition       bc     = CircleGeometry.GetClosestPosition(cg, pts[0]);
            IPosition       ec     = CircleGeometry.GetClosestPosition(cg, pts[pts.Length - 1]);

            // Round off to nearest micron
            PointGeometry bcg = PointGeometry.Create(bc);
            PointGeometry ecg = PointGeometry.Create(ec);

            // Ensure point features exist at both ends of the line.
            PointFeature ps = GetArcEndPoint(bcg, tol, creator);
            PointFeature pe = GetArcEndPoint(ecg, tol, creator);

            // Try to find a circle that's already been added by this import.
            Circle c = EnsureCircleExists(center, radius, tol, creator);

            // Determine which way the arc is directed
            bool iscw = LineStringGeometry.IsClockwise(pts, center);

            InternalIdValue id  = CadastralMapModel.Current.WorkingSession.AllocateNextId();
            ArcFeature      arc = new ArcFeature(creator, id, what, c, ps, pe, iscw);

            // The toological status of the incoming arc may override the status that the
            // constructor derived from the entity type
            arc.SetTopology(line.IsTopologicalArc);

            #if DEBUG
            // Confirm the NTX data was valid (ensure it's consistent with what we've imported)...

            double readRad = c.Radius;
            double calcRad = BasicGeom.Distance(c.Center, ps);
            Debug.Assert(Math.Abs(readRad - calcRad) < tol.Meters);

            foreach (IPointGeometry pg in pts)
            {
                ILength check = arc.Geometry.Distance(pg);
                Debug.Assert(check.Meters < tol.Meters);
            }
            #endif

            return(arc);
        }
Пример #5
0
        internal override ILength GetLength(IPosition asFarAs)
        {
            ILength tol = new Length(Constants.XYTOL);

            return(LineStringGeometry.GetLength(this, asFarAs, tol));
        }
Пример #6
0
 internal override void Render(ISpatialDisplay display, IDrawStyle style)
 {
     LineStringGeometry.Render(this, display, style);
 }
Пример #7
0
 public override ILength Distance(IPosition point)
 {
     return(LineStringGeometry.GetDistance(this, point));
 }
Пример #8
0
        private void ribbonButton51_Click(object sender, EventArgs e)
        {
            if (featurePrimitiveLineString == null)
            {
                LineStringGeometry lineString = new LineStringGeometry();
                Vec3d vec3d1 = new Vec3d();
                vec3d1.set(-74, 40.714, 0);
                Vec3d vec3d2 = new Vec3d();
                vec3d2.set(139.75, 35.68, 0);
                lineString.push_back(vec3d1);
                lineString.push_back(vec3d2);

                Feature feature = new Feature();
                feature.setGeometry( lineString );
                featurePrimitiveLineString = new FeaturePrimitive();
                featurePrimitiveLineString.setFeature( feature );
                m_earthRoot.addChild( featurePrimitiveLineString );
            }
        }