//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 18JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Copy constructor. * @param region map object copy from. */ public MapRegion(MapRegion region) : base(region) { SetMapObjectType(REGION); PenStyle = new MapPen(region.PenStyle); BrushStyle = new MapBrush(region.BrushStyle); Region = new GeoPolygon(region.Region); CenterPt = new GeoLatLng(region.CenterPt); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 18JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Copy constructor. * @param multiRegion map object copy from. */ public MapMultiRegion(MapMultiRegion multiRegion) : base(multiRegion) { SetMapObjectType(MULTIREGION); PenStyle = new MapPen(multiRegion.PenStyle); BrushStyle = new MapBrush(multiRegion.BrushStyle); Regions = new GeoPolygon[multiRegion.Regions.Length]; for (int i = 0; i < Regions.Length; i++) { Regions[i] = new GeoPolygon(multiRegion.Regions[i]); } CenterPt = new GeoLatLng(multiRegion.CenterPt); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 18JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Creates a polygon from encoded strings of aggregated points and _levels. * _zoomFactor and _numLevels these two values determine the precision * of the _levels within an encoded polygon. * @param _strokeColor the color of the polygon. * @param _strokeWeight Width of the line in pixels. * @param _strokeOpacity the opacity of the polygon. * @param _fillColor the inner color of the polygon. * @param _fillOpacity the inner opacity of the polygon. * @param points a string containing the encoded latitude and longitude * coordinates. * @param _zoomFactor the magnification between adjacent sets of zoom _levels * in the encoded _levels string. * @param _levels a string containing the encoded polygon zoom level groups. * @param _numLevels the number of zoom _levels contained in the encoded _levels string. * @return Geo polygon object. */ public static GeoPolygon FromEncoded(int strokeColor, int strokeWeight, double strokeOpacity, int fillColor, double fillOpacity, String points, int zoomFactor, String levels, int numLevels) { ArrayList trk = PolylineEncoder.CreateDecodings(points); GeoLatLng[] array = new GeoLatLng[trk.Count]; var temp = trk.ToArray(); for (int i = 0; i < temp.Length; i++) { array[i] = (GeoLatLng)temp[i]; } GeoPolygon polygon = new GeoPolygon(array, strokeColor, strokeWeight, strokeOpacity, fillColor, fillOpacity); polygon._levels = PolylineEncoder.DecodeLevel(levels); polygon._zoomFactor = zoomFactor; polygon._numLevels = numLevels; return(polygon); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 18JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * copy constructor. * @param polygon polygon object copied from. */ public GeoPolygon(GeoPolygon polygon) { if (polygon._latlngs != null) { _latlngs = new GeoLatLng[polygon._latlngs.Length]; Array.Copy(_latlngs, 0, _latlngs, 0, _latlngs.Length); _levels = new int[polygon._levels.Length]; for (int i = 0; i < _levels.Length; i++) { _levels[i] = polygon._levels[i]; } _bounds = new GeoLatLngBounds(polygon._bounds); } _strokeColor = polygon._strokeColor; _strokeOpacity = polygon._strokeOpacity; _strokeWeight = polygon._strokeWeight; _fillColor = polygon._fillColor; _fillOpacity = polygon._fillOpacity; _zoomFactor = polygon._zoomFactor; _numLevels = polygon._numLevels; _visible = polygon._visible; }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 18JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * default constructor. */ public MapRegion() { SetMapObjectType(REGION); PenStyle = new MapPen(); BrushStyle = new MapBrush(); CenterPt = new GeoLatLng(); Region = null; }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 18JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Set GeoPolygon of the map Region. * @param region the GeoPolygon object. */ public void SetRegion(GeoPolygon region) { Region = region; }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 21JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * draw a region. * @param mapPen pen for the border of the region. * @param mapBrush brush to fill the region. * @param region the polygon object. */ private void DrawRegion(MapPen mapPen, MapBrush mapBrush, GeoPolygon region) { Pen pen = new Pen(new Color(mapPen.Color,false), mapPen.Width); TextureBrush brush = GetImagePatternBrush(mapBrush); ArrayList clippedPts = _sutherlandHodgman.ClipRegion(region.GetPoints()); GeoPoint[] screenPts = FromLatLngToMapPixel(clippedPts); if (screenPts.Length > 2) { { int[] xpoints = new int[screenPts.Length]; int[] ypoints = new int[screenPts.Length]; for (int i = 0; i < screenPts.Length; i++) { xpoints[i] = (int)screenPts[i].X; ypoints[i] = (int)screenPts[i].Y; } Polygon polygon = new Polygon { Xpoints = xpoints, Ypoints = ypoints, NumOfNpoints = xpoints.Length }; if (mapBrush.Pattern == 2) { SharedGraphics2D.SetPenAndBrush(pen, brush); SharedGraphics2D.DrawPolygon(null, polygon); SharedGraphics2D.FillPolygon(null, polygon); } else { SharedGraphics2D.SetDefaultPen(pen); SharedGraphics2D.DrawPolygon(null, polygon); } } } }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 18JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Set GeoPolygon array of the map Region. * @param regions the GeoPolygon object array. */ public void SetRegions(GeoPolygon[] regions) { Regions = regions; }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 18JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Creates a polygon from encoded strings of aggregated points and _levels. * _zoomFactor and _numLevels these two values determine the precision * of the _levels within an encoded polygon. * @param _strokeColor the color of the polygon. * @param _strokeWeight Width of the line in pixels. * @param _strokeOpacity the opacity of the polygon. * @param _fillColor the inner color of the polygon. * @param _fillOpacity the inner opacity of the polygon. * @param points a string containing the encoded latitude and longitude * coordinates. * @param _zoomFactor the magnification between adjacent sets of zoom _levels * in the encoded _levels string. * @param _levels a string containing the encoded polygon zoom level groups. * @param _numLevels the number of zoom _levels contained in the encoded _levels string. * @return Geo polygon object. */ public static GeoPolygon FromEncoded(int strokeColor, int strokeWeight, double strokeOpacity, int fillColor, double fillOpacity, String points, int zoomFactor, String levels, int numLevels) { ArrayList trk = PolylineEncoder.CreateDecodings(points); GeoLatLng[] array = new GeoLatLng[trk.Count]; var temp = trk.ToArray(); for (int i = 0; i < temp.Length; i++) { array[i] = (GeoLatLng)temp[i]; } GeoPolygon polygon = new GeoPolygon(array, strokeColor, strokeWeight, strokeOpacity, fillColor, fillOpacity); polygon._levels = PolylineEncoder.DecodeLevel(levels); polygon._zoomFactor = zoomFactor; polygon._numLevels = numLevels; return polygon; }
private void DrawRegion(MapPen mapPen, MapBrush mapBrush, GeoPolygon region) { Pen pen = new Pen(Color.FromArgb((int)(mapPen.Color | 0xFF000000)), mapPen.Width); Brush brush = GetBrush(mapBrush); GeoBounds bounds = new GeoBounds(118.808451, 31.907395, 0.003907, 0.0035); ArrayList clippedPts = _sutherlandHodgman.ClipRegion(region.GetPoints()); GeoPoint[] screenPts = FromLatLngToMapPixel(clippedPts); if (screenPts.Length > 2) { { int[] xpoints = new int[screenPts.Length]; int[] ypoints = new int[screenPts.Length]; for (int i = 0; i < screenPts.Length; i++) { xpoints[i] = (int)screenPts[i].X; ypoints[i] = (int)screenPts[i].Y; } Point[] points = new Point[xpoints.Length]; for (int i = 0; i < points.Length; i++) { points[i] = new Point(xpoints[i], ypoints[i]); } SharedGraphics2D.Graphics.DrawPolygon(pen, points); SharedGraphics2D.Graphics.FillPolygon(brush, points); } } }