示例#1
0
        private void btnLoad_Click(object sender, EventArgs e)
        {
            var openFileDialog1 = new OpenFileDialog
            {
                InitialDirectory = "c:\\",
                Filter           = "map files (*.map)|*.map|All files (*.*)|*.*",
                FilterIndex      = 2,
                RestoreDirectory = true
            };

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    _mapTileDownloadManager.Stop();
                    GC.Collect();
                    string fileName = openFileDialog1.FileName;
                    var    localMapTileFileReader = new MapTileStoredDataSource(fileName);

                    _mapTileDownloadManager = new MapTileDownloadManager(this, localMapTileFileReader);
                    _mapTileDownloadManager.Start();
                    GeoLatLng center = _rasterMap.GetScreenCenter();
                    int       zoom   = _rasterMap.GetZoom();

                    _rasterMap = new RasterMap(768, 768, _mapType, _mapTileDownloadManager);
                    _rasterMap.SetCenter(center, zoom);
                    _rasterMap.SetMapDrawingListener(this);
                    _rasterMap.SetGeocodingListener(this);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }
        }
示例#2
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * get all records based on given rectangle.
         * @param rectGeo the boundary..
         * @return a hashtable array Contains of all matched record.
         *  the key is the mapInfo ID. the value is the MBR of map object.
         * @
         */
        public Hashtable[] Search(GeoLatLngBounds rectGeo)
        {
            lock (_mapFeatureLayers)
            {
                Hashtable[] retTable = new Hashtable[_mapFeatureLayers.Count];
                GeoLatLng   pt1      = new GeoLatLng(rectGeo.Y, rectGeo.X);
                GeoLatLng   pt2      = new GeoLatLng(rectGeo.Y + rectGeo.Height,
                                                     rectGeo.X + rectGeo.Width);
                double distance = GeoLatLng.Distance(pt1, pt2);

                if (_mapUnit == MAPUNIT_MILE)
                {
                    distance /= 1.632;
                }

                for (int i = 0; i < _mapFeatureLayers.Count; i++)
                {
                    MapFeatureLayer mapLayer = (MapFeatureLayer)_mapFeatureLayers[i];
                    if (mapLayer.CanBeShown(distance))
                    {
                        retTable[i] = mapLayer.Search(rectGeo);
                    }
                    else
                    {
                        retTable[i] = new Hashtable();
                    }
                }
                return(retTable);
            }
        }
示例#3
0
 public Location GetLoLa(double ALo, double ALa, int AX = 0, int AY = 0)
 {
     if (_geoType != GeoType.WGS84)
     {
         if (_geoType == GeoType.GCJ02)
         {
             GeoLatLng gcj02 = GPSTool.wgs84togcj02(ALo, ALa);
             return(new Location(gcj02.latitude, gcj02.longitude));
         }
         else if (_geoType == GeoType.BD09)
         {
             //GeoLatLng gcj02 = GPSTool.wgs84togcj02(ALo, ALa);
             //GeoLatLng bd09 = GPSTool.gcj02tobd09(gcj02.longitude, gcj02.latitude);
             GeoLatLng bd09 = GPSTool.bd09togcj02(ALo, ALa);
             return(new Location(bd09.latitude, bd09.longitude));
         }
         else
         {
             return(new Location(ALa, ALo));
         }
         //return new Location(ALa + AY / 1000000.0, ALo + AX / 1000000.0);
     }
     else
     {
         return(new Location(ALa, ALo));
     }
 }
示例#4
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 18JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Resize the map to a level that include given bounds
         * @param bounds new bound.
         */
        public virtual void Resize(GeoLatLngBounds bounds)
        {
            lock (_syncObject)
            {
                GeoLatLng sw     = bounds.GetSouthWest();
                GeoLatLng ne     = bounds.GetNorthEast();
                GeoLatLng center = new GeoLatLng {
                    X = (sw.X + ne.X) / 2.0, Y = (sw.Y + ne.Y) / 2.0
                };
                GeoPoint pt1, pt2;
                for (int i = MAX_ZOOMLEVEL; i >= MIN_ZOOMLEVEL; i--)
                {
                    pt1 = FromLatLngToPixel(sw, i);
                    pt2 = FromLatLngToPixel(ne, i);
                    double dblWidth  = Math.Abs(pt1.X - pt2.X);
                    double dblHeight = Math.Abs(pt1.Y - pt2.Y);
                    if (dblWidth < _mapSize.Width && dblHeight < _mapSize.Height)
                    {
                        _mapZoomLevel = i;
                        SetCenter(center, i);
                        break;
                    }
                }
            }
        }
示例#5
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * get a map pline object at given index.
         */
        private MapPline GetMapPline(RecordIndex recordIndex)
        {
            MapPline mapPline = new MapPline
            {
                PenStyle =
                {
                    Pattern = recordIndex.Param1,
                    Width   = recordIndex.Param2,
                    Color   = recordIndex.Param3
                },
                Bounds =
                {
                    X      = recordIndex.MinX / DOUBLE_PRECISION,
                    Y      = recordIndex.MinY / DOUBLE_PRECISION,
                    Width  = (recordIndex.MaxX - recordIndex.MinX) / DOUBLE_PRECISION,
                    Height = (recordIndex.MaxY - recordIndex.MinY) / DOUBLE_PRECISION
                }
            };
            int numberOfPoints = DataReader.ReadInt(_reader);

            GeoLatLng[] latLngs = new GeoLatLng[numberOfPoints];
            for (int i = 0; i < numberOfPoints; i++)
            {
                int x = DataReader.ReadInt(_reader);
                int y = DataReader.ReadInt(_reader);
                latLngs[i] = new GeoLatLng(y / DOUBLE_PRECISION,
                                           x / DOUBLE_PRECISION);
            }
            mapPline.Pline = new GeoPolyline(latLngs, mapPline.PenStyle.Color,
                                             mapPline.PenStyle.Width, mapPline.PenStyle.Pattern);
            return(mapPline);
        }
示例#6
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 18JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Computes the pixel coordinates of the given geographical point .
         * @param latLng  latitude,longitude pair of give point
         * @param zoomLevel   current zoom level
         * @return the pixel coordinates.
         */
        public static GeoPoint FromLatLngToPixel(GeoLatLng latLng, int zoomLevel)
        {
            //double latitude = latLng.Lat();
            //double longitude = latLng.Lng();
            //double power = 8 + zoomLevel;
            //double mapsize = MathEx.Pow(2, power);
            //double origin = mapsize / 2;
            //double longdeg = MathEx.Abs(-180 - longitude);
            //double longppd = mapsize / 360;
            //double longppdrad = mapsize / (2 * Math.PI);
            //double pixelx = longdeg * longppd;
            //double e = MathEx.Sin(latitude * (1 / 180.0 * MathEx.PI));
            //if (e > 0.9999)
            //{
            //    e = 0.9999;
            //}
            //if (e < -0.9999)
            //{
            //    e = -0.9999;
            //}

            //double pixely = origin + 0.5 * MathEx.Log2((1 + e) / (1 - e)) * (-longppdrad);
            //return new GeoPoint(pixelx, pixely);
            int pixelX, pixelY;

            TileSystem.LatLongToPixelXY(latLng.Lat(), latLng.Lng(), zoomLevel, out pixelX, out pixelY);
            return(new GeoPoint(pixelX, pixelY));
        }
        private GeoLatLng Intersect(GeoLatLng p0, GeoLatLng p1)
        {
            GeoLatLng r = new GeoLatLng(0, 0);
            GeoLatLng d;

            switch (_intDirection)
            {
            case 1:
            case 3:
                d = new GeoLatLng(p1.Y - p0.Y, p1.X - p0.X);
                double xslope = d.X / d.Y;
                r.Y = _dblY;
                r.X = p0.X + xslope * (_dblY - p0.Y);
                break;

            case 2:
            case 4:
                d = new GeoLatLng(p1.Y - p0.Y, p1.X - p0.X);
                double yslope = d.Y / d.X;
                r.X = _dblX;
                r.Y = p0.Y + yslope * (_dblX - p0.X);
                break;
            }
            return(r);
        }
 // 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);
     }
 }
示例#9
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 18JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Copy constructor.
         * @param mapPoint     map object copy from.
         */
        public MapPoint(MapPoint mapPoint)
            : base(mapPoint)
        {
            SetMapObjectType(POINT);
            SymbolType = new MapSymbol(mapPoint.SymbolType);
            Point      = new GeoLatLng(mapPoint.Point);
        }
示例#10
0
        private void MainWindow_Load(object sender, EventArgs e)
        {
            var center = new GeoLatLng(32.0176410, 118.7273120);

            _rasterMap.SetCenter(center, 2, _rasterMap.GetMapType());
            btnReset_Click(sender, e);
        }
示例#11
0
        private void btnReset_Click(object sender, EventArgs e)
        {
            GeoLatLng latLng = _rasterMap.FromScreenPixelToLatLng(_topLeft);
            GeoPoint  pt     = MapLayer.FromLatLngToPixel(latLng, _rasterMap.GetZoom());

            _rasterMap.PanDirection((int)(pt.X % 256), (int)(pt.Y % 256));
        }
示例#12
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Get the map objects in the screen area whose center is given point
         * @param pt center of the screen.
         * @return the map objects in the screen area.
         * @
         */
        public Hashtable[] GetScreenObjects(GeoLatLng pt)
        {
            _mapCenterPt.X = pt.X;
            _mapCenterPt.Y = pt.Y;
            GeoLatLngBounds rectGeo = GetScreenBounds(_mapCenterPt);

            return(_geoSet.Search(rectGeo));
        }
示例#13
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- 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;
        }
示例#14
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 18JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Changes the center point of the map to the given point.
         * @param center a new center point of the map.
         */
        public virtual void PanTo(GeoLatLng center)
        {
            lock (_syncObject)
            {
                _mapCenterPt.X = center.X;
                _mapCenterPt.Y = center.Y;
                DrawMapCanvas();
            }
        }
示例#15
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- 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);
        }
            private static void SearchResponse(GClientGeocoder geoCoder, Response response)
            {
                MapPoint[] mapPoints = null;
                Exception  ex        = response.GetException();

                if (ex != null || response.GetCode() != HttpStatusCode.OK)
                {
                    if (geoCoder._listener != null)
                    {
                        geoCoder._listener.done(geoCoder._searchAddress, null);
                    }
                    return;
                }
                try
                {
                    Result result = response.GetResult();
                    result.GetAsString("name");
                    int resultCount = result.GetSizeOfArray("Placemark");
                    if (resultCount > 0)
                    {
                        mapPoints = new MapPoint[resultCount];
                        for (int i = 0; i < resultCount; i++)
                        {
                            mapPoints[i] = new MapPoint
                            {
                                Name = result.GetAsString("Placemark[" + i + "].address")
                            };
                            string    location = result.GetAsString("Placemark[" + i + "].Point.coordinates");
                            GeoLatLng latLng   = MapLayer.FromStringToLatLng(location);
                            mapPoints[i].SetPoint(latLng);
                        }
                        if (geoCoder._addressCache.Count > 24)
                        {
                            int         j    = 0;
                            ICollection keys = geoCoder._addressCache.Keys;
                            foreach (string key1 in keys)
                            {
                                geoCoder._addressCache.Remove(key1);
                                j++;
                                if (j > 12)
                                {
                                    break;
                                }
                            }
                        }
                        geoCoder._addressCache.Add(mapPoints[0].Name, mapPoints[0]);
                    }
                }
                catch (Exception)
                {
                }
                if (geoCoder._listener != null)
                {
                    geoCoder._listener.done(geoCoder._searchAddress, mapPoints);
                }
            }
示例#17
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 18JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Sets the map view to the given center.
         * @param center the center latitude,longitude of the map.
         * @param zoomLevel the zoom Level of the map [0,17].
         */
        public virtual void SetCenter(GeoLatLng center, int zoomLevel)
        {
            lock (_syncObject)
            {
                _mapZoomLevel  = zoomLevel;
                _mapCenterPt.X = center.X;
                _mapCenterPt.Y = center.Y;
                DrawMapCanvas();
            }
        }
示例#18
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 18JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Copy constructor.
         * @param mapPoints     map object copy from.
         */
        public MapMultiPoint(MapMultiPoint mapPoints)
            : base(mapPoints)
        {
            SetMapObjectType(MULTIPOINT);
            SymbolType = new MapSymbol(mapPoints.SymbolType);
            Points     = new GeoLatLng[mapPoints.Points.Length];
            for (int i = 0; i < Points.Length; i++)
            {
                Points[i] = new GeoLatLng(mapPoints.Points[i]);
            }
        }
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Computes the pixel coordinates of the given geographical point in the map.
         * @param latlng the geographical coordinates.
         * @return the pixel coordinates in the map.
         */

        protected GeoPoint FromLatLngToMapPixel(GeoLatLng latlng)
        {
            GeoPoint center  = MapLayer.FromLatLngToPixel(_mapCenterPt, _mapZoomLevel);
            GeoPoint topLeft = new GeoPoint(center.X - _mapSize.Width / 2.0,
                                            center.Y - _mapSize.Height / 2.0);
            GeoPoint pointPos = MapLayer.FromLatLngToPixel(latlng, _mapZoomLevel);

            pointPos.X -= topLeft.X;
            pointPos.Y -= topLeft.Y;
            return(new GeoPoint((int)(pointPos.X + 0.5), (int)(pointPos.Y + 0.5)));
        }
示例#20
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 18JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Starts a pan with given Distance in pixels.
         * directions. +1 is right and down, -1 is left and up, respectively.
         * @param dx X offset.
         * @param dy Y offset.
         */
        public virtual void PanDirection(int dx, int dy)
        {
            lock (_syncObject)
            {
                GeoPoint center = FromLatLngToPixel(_mapCenterPt, _mapZoomLevel);
                center.X += dx;
                center.Y += dy;
                GeoLatLng newCenter = FromPixelToLatLng(center, _mapZoomLevel);
                PanTo(newCenter);
            }
        }
示例#21
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 18JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Sets the map view to the given center.
         * @param center the center latitude,longitude of the map.
         * @param zoomLevel the zoom Level of the map [0,17].
         */
        public override void SetCenter(GeoLatLng center, int zoomLevel)
        {
            lock (_mapLayers)
            {
                for (int i = 0; i < _mapLayers.Count; i++)
                {
                    MapLayer mapLayer = (MapLayer)_mapLayers[i];
                    mapLayer.SetCenter(center, zoomLevel);
                }
            }
            base.SetCenter(center, zoomLevel);
        }
示例#22
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 18JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Changes the center point of the map to the given point.
         * @param center a new center point of the map.
         */
        public override void PanTo(GeoLatLng center)
        {
            lock (_mapLayers)
            {
                for (int i = 0; i < _mapLayers.Count; i++)
                {
                    MapLayer mapLayer = (MapLayer)_mapLayers[i];
                    mapLayer.PanTo(center);
                }
            }
            base.PanTo(center);
        }
示例#23
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- 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);
        }
示例#24
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 18JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Computes the geographical coordinates from pixel coordinates in the map.
         * @param pt pixel coordinates in the map.
         * @return the the geographical coordinates.
         */
        public GeoLatLng FromMapPixelToLatLng(GeoPoint pt)
        {
            GeoPoint center  = FromLatLngToPixel(_mapCenterPt, _mapZoomLevel);
            GeoPoint topLeft = new GeoPoint(center.X - _mapSize.Width / 2.0,
                                            center.Y - _mapSize.Height / 2.0);
            GeoPoint pointPos = new GeoPoint(pt.X, pt.Y);

            pointPos.X += topLeft.X;
            pointPos.Y += topLeft.Y;
            GeoLatLng latLng = FromPixelToLatLng(pointPos, _mapZoomLevel);

            return(latLng);
        }
示例#25
0
        private void btnServer_Click(object sender, EventArgs e)
        {
            _mapTileDownloadManager.Stop();
            _mapTileDownloadManager = new MapTileDownloadManager(this);
            _mapTileDownloadManager.Start();
            GeoLatLng center = _rasterMap.GetScreenCenter();
            int       zoom   = _rasterMap.GetZoom();

            _rasterMap = new RasterMap(768, 768, _mapType, _mapTileDownloadManager);
            _rasterMap.SetCenter(center, zoom);
            _rasterMap.SetMapDrawingListener(this);
            _rasterMap.SetGeocodingListener(this);
        }
        private static double CrossMulti(Object object1, Object object2, Object object0)
        {
            double    x1, y1, x2, y2;
            GeoLatLng p1 = (GeoLatLng)object1;
            GeoLatLng p2 = (GeoLatLng)object2;
            GeoLatLng p0 = (GeoLatLng)object0;

            x1 = p1.X - p0.X;
            y1 = p1.Y - p0.Y;
            x2 = p2.X - p0.X;
            y2 = p2.Y - p0.Y;
            return(x1 * y2 - x2 * y1);
        }
示例#27
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 18JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Copy constructor.
         * @param mapText     map object copy from.
         */
        public MapText(MapText mapText)
            : base(mapText)
        {
            SetMapObjectType(TEXT);
            Point         = new GeoLatLng(mapText.Point);
            Angle         = mapText.Angle;
            BackColor     = mapText.BackColor;
            ForeColor     = mapText.ForeColor;
            Justification = mapText.Justification;
            Spacing       = mapText.Spacing;
            LineType      = mapText.LineType;
            TextString    = mapText.TextString;
            Font          = mapText.Font;
        }
示例#28
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 18JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Convert to MapInfo string.
         * @return a MapInfo MIF string.
         */
        public override string ToString()
        {
            string retStr = "PLINE";

            retStr += "  " + Pline.GetVertexCount() + CRLF;
            for (int i = 0; i < Pline.GetVertexCount(); i++)
            {
                GeoLatLng latLng = Pline.GetVertex(i);
                retStr += latLng.X + " " + latLng.Y + CRLF;
            }
            retStr += "\t" + "PEN(" + PenStyle.Width + "," + PenStyle.Pattern + ","
                      + PenStyle.Color + ")" + CRLF;
            return(retStr);
        }
示例#29
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 18JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Convert to MapInfo string.
         * @return a MapInfo MIF string.
         */
        public override string ToString()
        {
            string retStr = "REGION 1" + CRLF;

            retStr += "\t" + Region.GetVertexCount() + CRLF;
            for (int i = 0; i < Region.GetVertexCount(); i++)
            {
                GeoLatLng latLng = Region.GetVertex(i);
                retStr += latLng.X + " " + latLng.Y + CRLF;
            }
            retStr += "\t" + "PEN(" + PenStyle.Width + "," + PenStyle.Pattern + ","
                      + PenStyle.Color + ")" + CRLF;
            retStr += "\t" + "BRUSH(" + BrushStyle.Pattern + "," + BrushStyle.ForeColor + ","
                      + BrushStyle.BackColor + ")" + CRLF;
            retStr += "\tCENTER " + CenterPt.X + " " + CenterPt.Y + CRLF;
            return(retStr);
        }
示例#30
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * get a map multiregion object at given index.
         */
        private MapMultiRegion GetMapMultiRegion(RecordIndex recordIndex)
        {
            MapMultiRegion mapMultiRegion = new MapMultiRegion();

            mapMultiRegion.BrushStyle.Pattern   = recordIndex.Param1;
            mapMultiRegion.BrushStyle.ForeColor = recordIndex.Param2;
            mapMultiRegion.BrushStyle.BackColor = recordIndex.Param3;
            mapMultiRegion.PenStyle.Pattern     = DataReader.ReadInt(_reader);
            mapMultiRegion.PenStyle.Width       = DataReader.ReadInt(_reader);
            mapMultiRegion.PenStyle.Color       = DataReader.ReadInt(_reader);
            mapMultiRegion.Bounds.X             = recordIndex.MinX / DOUBLE_PRECISION;
            mapMultiRegion.Bounds.Y             = recordIndex.MinY / DOUBLE_PRECISION;
            mapMultiRegion.Bounds.Width         =
                (recordIndex.MaxX - recordIndex.MinX) / DOUBLE_PRECISION;
            mapMultiRegion.Bounds.Height =
                (recordIndex.MaxY - recordIndex.MinY) / DOUBLE_PRECISION;
            int centerX = DataReader.ReadInt(_reader);
            int centerY = DataReader.ReadInt(_reader);

            mapMultiRegion.CenterPt.X = centerX / DOUBLE_PRECISION;
            mapMultiRegion.CenterPt.Y = centerY / DOUBLE_PRECISION;
            int numberOfPart = DataReader.ReadInt(_reader);

            mapMultiRegion.Regions = new GeoPolygon[numberOfPart];
            for (int j = 0; j < numberOfPart; j++)
            {
                int         numberOfPoints = DataReader.ReadInt(_reader);
                GeoLatLng[] latLngs        = new GeoLatLng[numberOfPoints];
                for (int i = 0; i < numberOfPoints; i++)
                {
                    int x = DataReader.ReadInt(_reader);
                    int y = DataReader.ReadInt(_reader);
                    latLngs[i] = new GeoLatLng(y / DOUBLE_PRECISION,
                                               x / DOUBLE_PRECISION);
                }
                mapMultiRegion.Regions[j] = new GeoPolygon(latLngs,
                                                           mapMultiRegion.PenStyle.Color,
                                                           mapMultiRegion.PenStyle.Width,
                                                           mapMultiRegion.PenStyle.Pattern,
                                                           mapMultiRegion.BrushStyle.ForeColor,
                                                           mapMultiRegion.BrushStyle.Pattern);
            }
            return(mapMultiRegion);
        }
示例#31
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 18JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Enlarges this rectangle such that it Contains the given point.
  * @param latlng  the new GeoLatLng to Add to this rectangle.
  */
 public void Extend(GeoLatLng latlng)
 {
     Add(latlng.X, latlng.Y);
 }
示例#32
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 18JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Returns true if the geographical coordinates of the point lie within
  * this rectangle
  * @param latlng  the given point.
  * @return  if the geographical coordinates of the point lie within
  * this rectangle
  */
 public bool ContainsLatLng(GeoLatLng latlng)
 {
     return Contains(latlng.X, latlng.Y);
 }
示例#33
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 18JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Constructs a rectangle from the points at its south-west and north-east
  * corners.
  * @param sw  south-west point of the rectangle.
  * @param ne  north-east point of the rectangle.
  */
 public GeoLatLngBounds(GeoLatLng sw, GeoLatLng ne)
     : this(sw.X, sw.Y, ne.X - sw.X, ne.Y - sw.Y)
 {
 }