// Append the vertex to the output container. public override void HandleVertex(GeoLatLng pnt) { if (_pDest.Count == 0 || !pnt.Equals(_pDest[_pDest.Count - 1])) { _pDest.Add(pnt); } }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date name Tracking # Description // --------- ------------------- ------------- ---------------------- // 14JAN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * clip the a pline. * @param input the pline to be clipped. * @return the clipped pline. */ public ArrayList ClipPline(GeoLatLng[] input) { ArrayList clipped = new ArrayList(); GeoLatLng p, prev = null; bool isInsidePrev = false; clipped.Clear(); for (int i = 0; i < input.Length; i++) { p = input[i]; bool isInside = _rectBounds.Contains(p); if (isInside) { if (!isInsidePrev && (((clipped.Count != 0) && (!prev.Equals(clipped[clipped.Count - 1]))) || ((clipped.Count == 0 && (prev != null))))) { clipped.Add(prev); } clipped.Add(p); } else if (isInsidePrev) { clipped.Add(p); } else if (prev != null) { GeoLatLngBounds rect = new GeoLatLngBounds(Math.Min(p.X, prev.X), Math.Min(p.Y, prev.Y), Math.Max(p.X, prev.X) - Math.Min(p.X, prev.X), Math.Max(p.Y, prev.Y) - Math.Min(p.Y, prev.Y)); if (rect.Intersects(_rectBounds)) { ArrayList line1 = new ArrayList(); line1.Add(prev); line1.Add(p); ArrayList line2 = new ArrayList(); line2.Add(new GeoLatLng(_rectBounds.Y, _rectBounds.X)); line2.Add(new GeoLatLng( (_rectBounds.Y + _rectBounds.Height), (_rectBounds.X + _rectBounds.Width))); ArrayList line3 = new ArrayList(); line3.Add(new GeoLatLng((_rectBounds.Y + _rectBounds.Height), _rectBounds.X)); line3.Add(new GeoLatLng( _rectBounds.Y, (_rectBounds.X + _rectBounds.Width))); if (IsLineInter(line1, line2) || IsLineInter(line1, line3)) { clipped.Add(prev); clipped.Add(p); } } } isInsidePrev = isInside; prev = p; } return(clipped); }