Esempio n. 1
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Open the map.
         * @
         */
        public void Open()
        {
            lock (_mapFeatureLayers)
            {
                int layerCount = _mapFeatureLayers.Count;


                if (layerCount > 0)
                {
                    ((MapFeatureLayer)_mapFeatureLayers[0]).Open();
                    _bounds = ((MapFeatureLayer)_mapFeatureLayers[0]).Bounds;
                }
                else
                {
                    _bounds = new GeoLatLngBounds();
                }

                for (int i = 1; i < layerCount; i++)
                {
                    MapFeatureLayer mapLayer = (MapFeatureLayer)_mapFeatureLayers[i];
                    mapLayer.Open();
                    GeoBounds.Union(mapLayer.Bounds, _bounds, _bounds);
                }
            }
        }
Esempio n. 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);
            }
        }
Esempio n. 3
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;
                    }
                }
            }
        }
Esempio n. 4
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)
        {
            if (_geoSet != null)
            {
                return(_geoSet.Search(rectGeo));
            }
            return(null);
        }
Esempio n. 5
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 03JAN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Copy constructor.
         * @param mapObject map object copy from.
         */
        protected MapObject(MapObject mapObject)
        {
            MapInfoID       = mapObject.MapInfoID;
            Name            = mapObject.Name;
            Bounds          = new GeoLatLngBounds(mapObject.Bounds);
            _mapObjectType  = mapObject._mapObjectType;
            CacheAccessTime = mapObject.CacheAccessTime;
        }
Esempio n. 6
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 18JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Empty constuctor.
         */
        protected MapObject()
        {
            _mapObjectType  = UNKOWN;
            MapInfoID       = -1;
            Name            = "Unknown";
            Bounds          = new GeoLatLngBounds();
            CacheAccessTime = new DateTime();
        }
Esempio n. 7
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * get all records based on given rectangle in give map layer.
         * @param index the index of given map layer.
         * @param rectGeo the boundary..
         * @return a hashtable of all matched record.the key is the mapInfo ID.
         * @
         */
        public Hashtable Search(int index, GeoLatLngBounds rectGeo)
        {
            if (_geoSet != null)
            {
                return(_geoSet.Search(index, rectGeo));
            }
            return(null);
        }
Esempio n. 8
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));
        }
Esempio n. 9
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * get all records based on given rectangle in give map layer.
         * @param index the index of given map layer.
         * @param rectGeo the boundary..
         * @return a hashtable of all matched record.the key is the mapInfo ID.
         * @
         */
        public Hashtable Search(int index, GeoLatLngBounds rectGeo)
        {
            lock (_mapFeatureLayers)
            {
                MapFeatureLayer mapLayer = GetMapFeatureLayer(index);
                if (mapLayer != null)
                {
                    return(mapLayer.Search(rectGeo));
                }
                return(null);
            }
        }
Esempio n. 10
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 override void Resize(GeoLatLngBounds bounds)
        {
            lock (_mapLayers)
            {
                for (int i = 0; i < _mapLayers.Count; i++)
                {
                    MapLayer mapLayer = (MapLayer)_mapLayers[i];
                    mapLayer.Resize(bounds);
                }
            }
            base.Resize(bounds);
        }
Esempio n. 11
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Open the map layer.
         */
        public void Open()
        {
            if (!_opened)
            {
                _opened = true;
                _mapFile.Open();
                DataTable = new DataTable(_mapFile.TabularData, _mapFile.Header.Fields,
                                          _mapFile.Header.RecordCount);
                int foundName = -1;
                for (int i = 0; i < _mapFile.Header.Fields.Length; i++)
                {
                    KeyField = _mapFile.Header.Fields[i];
                    if (KeyField.GetName().ToLower().StartsWith("name"))
                    {
                        foundName      = i;
                        _keyFieldIndex = i;
                        break;
                    }
                }
                if (foundName == -1)
                {
                    for (int i = 0; i < _mapFile.Header.Fields.Length; i++)
                    {
                        KeyField = _mapFile.Header.Fields[i];
                        if (KeyField.GetFieldType() == DataField.TYPE_CHAR)
                        {
                            foundName      = i;
                            _keyFieldIndex = i;
                            break;
                        }
                    }
                }
                if (foundName == -1)
                {
                    KeyField       = _mapFile.Header.Fields[0];
                    _keyFieldIndex = 0;
                }
                if (_mapFile.Header.DominantType.ToUpper().Equals("POINT"))
                {
                    PredominantFeatureType = FEATURE_TYPE_POINT;
                }
                else if (_mapFile.Header.DominantType.ToUpper().Equals("PLINE"))
                {
                    PredominantFeatureType = FEATURE_TYPE_PLINE;
                }
                else
                {
                    PredominantFeatureType = FEATURE_TYPE_REGION;
                }
                Bounds = _mapFile.Header.MapBounds;
            }
        }
Esempio n. 12
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21DEC2008  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * get all records based on given rectangle.
         * @param rectGeo the boundary..
         * @return a hashtable of all matched record.the key is the mapInfo ID.
         */
        public Hashtable SearchMapObjectsInRect(GeoLatLngBounds rectGeo)
        {
            Point pt1, pt2;

            pt1 = new Point(new[] {
                (int)(rectGeo.X * DOUBLE_PRECISION + 0.5),
                (int)(rectGeo.Y * DOUBLE_PRECISION + 0.5)
            });
            pt2 = new Point(new int[] {
                (int)((rectGeo.X + rectGeo.Width) * DOUBLE_PRECISION + 0.5),
                (int)((rectGeo.Y + rectGeo.Height) * DOUBLE_PRECISION + 0.5)
            });
            HyperCube h1 = new HyperCube(pt1, pt2);
            Hashtable retArrayList = new Hashtable();
            Point     p11, p12;

            for (IEnumeration e1 = _tree.Intersection(h1); e1.HasMoreElements();)
            {
                AbstractNode node = (AbstractNode)(e1.NextElement());
                if (node.IsLeaf())
                {
                    int         index = 0;
                    HyperCube[] data  = node.GetHyperCubes();
                    HyperCube   cube;
                    for (int cubeIndex = 0; cubeIndex < data.Length; cubeIndex++)
                    {
                        cube = data[cubeIndex];
                        if (cube.Intersection(h1))
                        {
                            p11 = cube.GetP1();
                            p12 = cube.GetP2();
                            int             mapinfoId = ((Leaf)node).GetDataPointer(index);
                            int             mapInfoId = mapinfoId;
                            GeoLatLngBounds mbr       = new GeoLatLngBounds();
                            mbr.X      = p11.GetFloatCoordinate(0) / DOUBLE_PRECISION;
                            mbr.Y      = p11.GetFloatCoordinate(1) / DOUBLE_PRECISION;
                            mbr.Width  = ((p12.GetFloatCoordinate(0) - p11.GetFloatCoordinate(0))) / DOUBLE_PRECISION;
                            mbr.Height = ((p12.GetFloatCoordinate(1) - p11.GetFloatCoordinate(1))) / DOUBLE_PRECISION;
                            if (!retArrayList.Contains(mapInfoId))
                            {
                                retArrayList.Add(mapInfoId, mbr);
                            }
                        }
                        index++;
                    }
                }
            }
            return(retArrayList);
        }
Esempio n. 13
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 20JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Open the map file.
         * @throws IOException
         */
        public void Open()
        {
            if (_opened)
            {
                return;
            }

            _opened = true;
            DataReader.Seek(_reader, 0);
            DataReader.ReadString(_reader);
            DataReader.Seek(_reader, 16);
            DataReader.ReadString(_reader);

            DataReader.Seek(_reader, 32);
            string mapTile = DataReader.ReadString(_reader);

            if (!mapTile.ToUpper().Equals("TILE"))
            {
                throw new IOException("Invalid map format!");
            }
            DataReader.Seek(_reader, 48);
            MapType = DataReader.ReadInt(_reader);
            int    numOfLevel = DataReader.ReadInt(_reader);
            double minY       = DataReader.ReadDouble(_reader);
            double minX       = DataReader.ReadDouble(_reader);
            double maxY       = DataReader.ReadDouble(_reader);
            double maxX       = DataReader.ReadDouble(_reader);

            Bounds = new GeoLatLngBounds(minX, minY, maxX - minX, maxY - minY);
            DataReader.Seek(_reader, HEADSIZE);
            _levelInfos = new LevelInfo[numOfLevel];
            for (int i = 0; i < numOfLevel; i++)
            {
                _levelInfos[i] = new LevelInfo
                {
                    LevelNo = DataReader.ReadInt(_reader),
                    MinX    = DataReader.ReadInt(_reader),
                    MinY    = DataReader.ReadInt(_reader),
                    MaxX    = DataReader.ReadInt(_reader),
                    MaxY    = DataReader.ReadInt(_reader),
                    Offset  = DataReader.ReadInt(_reader),
                    Length  = DataReader.ReadInt(_reader)
                };
            }
        }
Esempio n. 14
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 18JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Get the image at given X,Y zoom level.
         * @param X  X index of the map tile
         * @param Y  Y index of the map tile.
         * @param zoomLevel zoom level of the map tile
         * @return the given image.
         */
        public IImage GetImage(int x, int y, int zoomLevel)
        {
            MapDirection mapDirection = GetMapDirection();

            if (mapDirection != null)
            {
                try
                {
                    const int shiftWidth = 4;
                    GeoPoint  pt1        = new GeoPoint(x * MapLayer.MAP_TILE_WIDTH - shiftWidth,
                                                        y * MapLayer.MAP_TILE_WIDTH - shiftWidth);
                    GeoPoint pt2 = new GeoPoint((x + 1) * MapLayer.MAP_TILE_WIDTH + shiftWidth,
                                                (y + 1) * MapLayer.MAP_TILE_WIDTH + shiftWidth);
                    GeoLatLng       latLng1   = MapLayer.FromPixelToLatLng(pt1, zoomLevel);
                    GeoLatLng       latLng2   = MapLayer.FromPixelToLatLng(pt2, zoomLevel);
                    double          minY      = Math.Min(latLng1.Lat(), latLng2.Lat());
                    double          maxY      = Math.Max(latLng1.Lat(), latLng2.Lat());
                    double          minX      = Math.Min(latLng1.Lng(), latLng2.Lng());
                    double          maxX      = Math.Max(latLng1.Lng(), latLng2.Lng());
                    GeoLatLngBounds geoBounds = new GeoLatLngBounds(minX, minY,
                                                                    maxX - minX, maxY - minY);
                    GeoLatLng centerPt = geoBounds.GetCenter();
                    _mapDirectionLayer.SetCenter(centerPt, zoomLevel);
                    _mapDirectionLayer._screenBounds = geoBounds;
                    _mapTileGraphics.SetColor(TRANSPARENCY);
                    _mapTileGraphics.FillRect(0, 0, MapLayer.MAP_TILE_WIDTH,
                                              MapLayer.MAP_TILE_WIDTH);
                    _mapDirectionLayer.Paint(_mapTileGraphics);
                    IsImagevalid = true;
                    if (_readListener != null)
                    {
                        _readListener.readProgress(16, 16);
                    }
                    return(_mapTileImage.ModifyAlpha(160,
                                                     TRANSPARENCY));
                }
                catch (Exception)
                {
                }
            }
            return(null);
        }
Esempio n. 15
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 20JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Open the map.
         * @throws IOException if there's problem opening the map.
         */
        public void Open()
        {
            lock (_mapTiledZones)
            {
                int layerCount = _mapTiledZones.Count;
                if (layerCount > 0)
                {
                    ((MapTiledZone)_mapTiledZones[0]).Open();
                    _bounds = ((MapTiledZone)_mapTiledZones[0]).Bounds;
                }
                else
                {
                    _bounds = new GeoLatLngBounds();
                }
                for (int i = 1; i < layerCount; i++)
                {
                    MapTiledZone mapTiledZone = (MapTiledZone)_mapTiledZones[i];
                    mapTiledZone.Open();
                    GeoBounds.Union(mapTiledZone.Bounds, _bounds, _bounds);
                }
            }
        }
Esempio n. 16
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 18JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Tests if the interior of the IShape entirely Contains the specified
  * rectangular area.
  * @param other  the given rectangle.
  * @return  true if the interior of the IShape entirely Contains the
  * specified rectangular area;
  */
 public bool ContainsBounds(GeoLatLngBounds other)
 {
     return Contains(other.X, other.Y, other.Width, other.Height);
 }
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * @inheritDoc
         */
        public override void GetImage(int mtype, int x, int y, int zoomLevel)
        {
            lock (VectorMapAbstractCanvas.GRAPHICS_MUTEX)
            {
                int      shiftWidth = 32;
                GeoPoint pt1        = new GeoPoint(x * MapLayer.MAP_TILE_WIDTH - shiftWidth,
                                                   y * MapLayer.MAP_TILE_WIDTH - shiftWidth);
                GeoPoint pt2 = new GeoPoint((x + 1) * MapLayer.MAP_TILE_WIDTH + shiftWidth,
                                            (y + 1) * MapLayer.MAP_TILE_WIDTH + shiftWidth);
                GeoLatLng latLng1 = MapLayer.FromPixelToLatLng(pt1, zoomLevel);
                GeoLatLng latLng2 = MapLayer.FromPixelToLatLng(pt2, zoomLevel);
                double    minY    = Math.Min(latLng1.Lat(), latLng2.Lat());
                double    maxY    = Math.Max(latLng1.Lat(), latLng2.Lat());
                double    minX    = Math.Min(latLng1.Lng(), latLng2.Lng());
                double    maxX    = Math.Max(latLng1.Lng(), latLng2.Lng());
                double    width   = 0.00;
                double    height  = 0.00;

                //width = width < 0.06 ? 0.06 : width;
                //height = height < 0.06 ? 0.06 : height;

                GeoLatLngBounds geoBounds = new GeoLatLngBounds(minX - width / 2.0, minY - height / 2.0,
                                                                maxX - minX + width, maxY - minY + height);

                try
                {
                    Hashtable[] mapFeatures = _geoSet.Search(geoBounds);
                    int         totalSize   = 0;
                    for (int i = 0; i < mapFeatures.Length; i++)
                    {
                        Hashtable mapFeaturesInLayer = mapFeatures[i];
                        totalSize += mapFeaturesInLayer.Count;
                    }
                    totalSize += 1;
                    int mapObjectIndex = 0;
                    _vectorMapCanvas.ClearCanvas(0xffffff);

                    for (int i = 0; i < mapFeatures.Length; i++)
                    {
                        int             zOrder             = mapFeatures.Length - 1 - i;
                        Hashtable       mapFeaturesInLayer = mapFeatures[zOrder];
                        ICollection     enuKeys            = mapFeaturesInLayer.Keys;
                        MapFeatureLayer mapLayer           = _geoSet.GetMapFeatureLayer(zOrder);

                        foreach (var o in enuKeys)
                        {
                            int        mapInfoID  = (int)o;
                            MapFeature mapFeature = mapLayer
                                                    .GetMapFeatureByID(mapInfoID);
                            mapObjectIndex++;
                            _vectorMapCanvas.SetFont(GetFont(mapLayer.FontName));
                            _vectorMapCanvas.SetFontColor(mapLayer.FontColor);
                            _vectorMapCanvas.DrawMapObject(mapFeature.MapObject,
                                                           geoBounds, zoomLevel);
                            if (_readListener != null)
                            {
                                _readListener.readProgress(mapObjectIndex,
                                                           totalSize);
                            }
                        }
                    }
                    _vectorMapCanvas.DrawMapText();
                    ImageArray = PNGEncoder.GetPngrgb(MapLayer.MAP_TILE_WIDTH,
                                                      MapLayer.MAP_TILE_WIDTH,
                                                      _vectorMapCanvas.GetRGB());
                    ImageArraySize = ImageArray.Length;
                    IsImagevalid   = true;

                    if (ImageArraySize == 1933)
                    {
                        ImageArray     = null;
                        IsImagevalid   = false;
                        ImageArraySize = 0;
                    }


                    if (_readListener != null)
                    {
                        _readListener.readProgress(totalSize, totalSize);
                    }
                }
                catch (Exception e)
                {
                }
            }
        }
Esempio n. 18
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 of all matched record.the key is the mapInfo ID. the
         * value is the matched MapObject's MBR.
         */
        public Hashtable Search(GeoLatLngBounds rectGeo)
        {
            return(_mapFile.SearchMapObjectsInRect(rectGeo));
        }
Esempio n. 19
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * draw a map object.
         * @param mapObject the map object to be drawing.
         * @param drawBoundary the drawing boundry.
         * @param zoomLevel the current zoomLevel.
         */
        public override void DrawMapObject(MapObject mapObject, GeoLatLngBounds drawBoundary,
                                           int zoomLevel)
        {
            GeoLatLng drawPt = new GeoLatLng();

            _sutherlandHodgman = new SutherlandHodgman(drawBoundary);
            _mapZoomLevel      = zoomLevel;
            _mapCenterPt.X     = drawBoundary.GetCenterX();
            _mapCenterPt.Y     = drawBoundary.GetCenterY();
            bool pointFound = false;

            Point[] plinePoints = null;
            switch (mapObject.GetMapObjectType())
            {
            case MapObject.NONE:
                break;

            case MapObject.POINT:
            {
                MapPoint mapPoint = (MapPoint)mapObject;
                DrawPoint(mapPoint);
                drawPt.X   = mapPoint.Point.X;
                drawPt.Y   = mapPoint.Point.Y;
                pointFound = true;
            }
            break;

            case MapObject.MULTIPOINT:
            {
                MapMultiPoint mapMultiPoint = (MapMultiPoint)mapObject;
                for (int i = 0; i < mapMultiPoint.Points.Length; i++)
                {
                    MapPoint mapPoint = new MapPoint
                    {
                        SymbolType = mapMultiPoint.SymbolType,
                        Point      = new GeoLatLng(mapMultiPoint.Points[i])
                    };
                    DrawPoint(mapPoint);
                }
                for (int i = 0; i < mapMultiPoint.Points.Length; i++)
                {
                    if (drawBoundary.Contains(mapMultiPoint.Points[i]))
                    {
                        drawPt.X   = mapMultiPoint.Points[i].X;
                        drawPt.Y   = mapMultiPoint.Points[i].Y;
                        pointFound = true;
                        break;
                    }
                }
            }
            break;

            case MapObject.PLINE:
            {
                MapPline mapPline = (MapPline)mapObject;
                plinePoints = DrawPline(mapPline.PenStyle, mapPline.Pline);
                for (int i = 0; i < mapPline.Pline.GetVertexCount(); i++)
                {
                    if (drawBoundary.Contains(mapPline.Pline.GetVertex(i)))
                    {
                        drawPt.X   = mapPline.Pline.GetVertex(i).X;
                        drawPt.Y   = mapPline.Pline.GetVertex(i).Y;
                        pointFound = true;
                        break;
                    }
                }
            }
            break;

            case MapObject.MULTIPLINE:
            {
                MapMultiPline mapMultiPline = (MapMultiPline)mapObject;
                for (int i = 0; i < mapMultiPline.Plines.Length; i++)
                {
                    DrawPline(mapMultiPline.PenStyle,
                              mapMultiPline.Plines[i]);
                    for (int j = 0; j < mapMultiPline.Plines[i].GetVertexCount(); j++)
                    {
                        if (drawBoundary.Contains(mapMultiPline.Plines[i].GetVertex(j)))
                        {
                            drawPt.X   = mapMultiPline.Plines[i].GetVertex(j).X;
                            drawPt.Y   = mapMultiPline.Plines[i].GetVertex(j).Y;
                            pointFound = true;
                            break;
                        }
                    }
                }
            }
            break;

            case MapObject.REGION:
            {
                MapRegion mapRegion = (MapRegion)mapObject;
                DrawRegion(mapRegion.PenStyle, mapRegion.BrushStyle,
                           mapRegion.Region);
                drawPt.X   = mapRegion.CenterPt.X;
                drawPt.Y   = mapRegion.CenterPt.Y;
                pointFound = true;
            }
            break;

            case MapObject.MULTIREGION:
            {
                MapMultiRegion mapMultiRegion = (MapMultiRegion)mapObject;
                for (int i = 0; i < mapMultiRegion.Regions.Length; i++)
                {
                    DrawRegion(mapMultiRegion.PenStyle,
                               mapMultiRegion.BrushStyle,
                               mapMultiRegion.Regions[i]);
                }
                drawPt.X   = mapMultiRegion.CenterPt.X;
                drawPt.Y   = mapMultiRegion.CenterPt.Y;
                pointFound = true;
            }
            break;

            case MapObject.COLLECTION:
            {
                MapCollection mapCollection = (MapCollection)mapObject;
                if (mapCollection.MultiRegion != null)
                {
                    MapMultiRegion mapMultiRegion = mapCollection.MultiRegion;
                    for (int i = 0; i < mapMultiRegion.Regions.Length; i++)
                    {
                        DrawRegion(mapMultiRegion.PenStyle,
                                   mapMultiRegion.BrushStyle,
                                   mapMultiRegion.Regions[i]);
                    }
                }
                if (mapCollection.MultiPline != null)
                {
                    MapMultiPline mapMultiPline = mapCollection.MultiPline;
                    for (int i = 0; i < mapMultiPline.Plines.Length; i++)
                    {
                        DrawPline(mapMultiPline.PenStyle,
                                  mapMultiPline.Plines[i]);
                    }
                }
                if (mapCollection.MultiPoint != null)
                {
                    MapMultiPoint mapMultiPoint = mapCollection.MultiPoint;
                    for (int i = 0; i < mapMultiPoint.Points.Length; i++)
                    {
                        MapPoint mapPoint = new MapPoint
                        {
                            SymbolType = mapMultiPoint.SymbolType,
                            Point      = new GeoLatLng(mapMultiPoint.Points[i])
                        };
                        DrawPoint(mapPoint);
                    }
                }
                pointFound = true;
                drawPt.X   = mapCollection.Bounds.X + mapCollection.Bounds.Width / 2;
                drawPt.Y   = mapCollection.Bounds.Y + mapCollection.Bounds.Height / 2;
            }
            break;

            case MapObject.TEXT:
            {
                MapText mapText = (MapText)mapObject;
                drawPt.X   = mapText.Point.X;
                drawPt.Y   = mapText.Point.Y;
                pointFound = true;
            }
            break;
            }
            if (!(mapObject.Name.ToLower().Equals("unknown") || mapObject.Name.Length == 0) && pointFound)
            {
                MapText mapName = new MapText {
                    Font = _font
                };
                mapName.SetForeColor(_fontColor);
                mapName.TextString = mapObject.Name;
                GeoPoint screenPt = FromLatLngToMapPixel(drawPt);
                mapName.Point.X  = screenPt.X;
                mapName.Point.Y  = screenPt.Y;
                mapName.Bounds.X = mapName.Point.X;
                mapName.Bounds.Y = mapName.Point.Y;
                Font font = null;
                if (_font != null)
                {
                    font = (Font)_font.GetNativeFont();
                    SizeF sizeF = SharedGraphics2D.Graphics.MeasureString(mapName.TextString, font);
                    mapName.Bounds.Height = sizeF.Height;
                    mapName.Bounds.Width  = sizeF.Width;
                }
                TextPosInfo textPosInfo = new TextPosInfo();
                textPosInfo._mapText = mapName;
                if (mapObject.GetMapObjectType() == MapObject.PLINE)
                {
                    if (plinePoints != null)
                    {
                        GraphicsPath graphicsPath = new GraphicsPath();
                        graphicsPath.AddLines(plinePoints);
                        RectangleF [] rectangleF;
                        double        angle = GetAngle(plinePoints[0], plinePoints[plinePoints.Length - 1]);
                        if (angle < 180)
                        {
                            graphicsPath.Reverse();
                        }
                        angle = GetAngle(plinePoints[0], plinePoints[plinePoints.Length - 1]);

                        float rotateAngle = GetRotateAngle(angle);
                        rectangleF = SharedGraphics2D.Graphics.MeasureString(mapName.TextString, font,
                                                                             new SolidBrush(
                                                                                 Color.FromArgb(_fontColor)),
                                                                             TextPathAlign.Center,
                                                                             TextPathPosition.CenterPath, 100, rotateAngle,
                                                                             graphicsPath);

                        textPosInfo._graphicsPath = graphicsPath;
                        textPosInfo._rectangles   = rectangleF;



                        if (rectangleF.Length == mapName.TextString.Length)
                        {
                            //RectangleF[] rectangleFs = new RectangleF[rectangleF.Length];
                            //Array.Copy(rectangleF, rectangleFs, rectangleF.Length);
                            //for (int i = 0; i < rectangleFs.Length;i++ )
                            //{
                            //    for(int j=0;j<rectangleF.Length;j++)
                            //    {
                            //        if(i!=j)
                            //        {
                            //            if(rectangleFs[i].IntersectsWith(rectangleF[j]))
                            //            {
                            //                return;
                            //            }
                            //        }
                            //    }
                            //}


                            AddMapName(textPosInfo);
                        }
                    }
                }
                else
                {
                    textPosInfo._graphicsPath = null;
                    textPosInfo._rectangles   = new[] { new RectangleF((float)textPosInfo._mapText.Bounds.X, (float)textPosInfo._mapText.Bounds.Y,
                                                                       (float)textPosInfo._mapText.Bounds.Width,
                                                                       (float)textPosInfo._mapText.Bounds.Height) };
                    AddMapName(textPosInfo);
                }
            }
        }
Esempio n. 20
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 18JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Set the out bound of the map object.
         * @param bounds   the out bound
         */
        public void SetBound(GeoLatLngBounds bounds)
        {
            Bounds = new GeoLatLngBounds(bounds);
        }
Esempio n. 21
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 18JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Constructs a new <code>GeoBounds</code>, initialized to match
         * the values of the specified <code>GeoBounds</code>.
         * @param r  the <code>GeoBounds</code> from which to copy initial values
         *           to a newly constructed <code>GeoBounds</code>
         */
        public GeoLatLngBounds(GeoLatLngBounds r)
            : this(r.X, r.Y, r.Width, r.Height)
        {
        }
Esempio n. 22
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 18JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Tests if the interior of the IShape entirely Contains the specified
         * rectangular area.
         * @param other  the given rectangle.
         * @return  true if the interior of the IShape entirely Contains the
         * specified rectangular area;
         */
        public bool ContainsBounds(GeoLatLngBounds other)
        {
            return(Contains(other.X, other.Y, other.Width, other.Height));
        }
Esempio n. 23
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 18JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Tests if the interior of the IShape Intersects the interior of a
  * specified rectangular area.
  * @param other  the given rectangle.
  * @return  true if the interior of the IShape and the interior of the
  * rectangular area Intersect.
  */
 public bool Intersects(GeoLatLngBounds other)
 {
     return Intersects(other.X, other.Y, other.Width, other.Height);
 }
Esempio n. 24
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 18JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Constructs a new <code>GeoBounds</code>, initialized to match
  * the values of the specified <code>GeoBounds</code>.
  * @param r  the <code>GeoBounds</code> from which to copy initial values
  *           to a newly constructed <code>GeoBounds</code>
  */
 public GeoLatLngBounds(GeoLatLngBounds r)
     : this(r.X, r.Y, r.Width, r.Height)
 {
 }
Esempio n. 25
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 18JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Tests if the interior of the IShape Intersects the interior of a
         * specified rectangular area.
         * @param other  the given rectangle.
         * @return  true if the interior of the IShape and the interior of the
         * rectangular area Intersect.
         */
        public bool Intersects(GeoLatLngBounds other)
        {
            return(Intersects(other.X, other.Y, other.Width, other.Height));
        }