コード例 #1
0
ファイル: MapPlotter.cs プロジェクト: ackratos/USTCMap
        public Point geoToView(double lat, double lon, iustc.map.data.Rectangle rect)
        {
            if (geoToViewRect != rect)
            {
                geoToViewRect = rect;
                Point p1 = Toolkit.geoToView(rect.north, rect.west);
                Point p2 = Toolkit.geoToView(rect.south, rect.east);
                geoToViewX1 = p1.X;
                geoToViewY1 = p1.Y;
                geoToViewX2 = p2.X;
                geoToViewY2 = p2.Y;
            }

            Point p = Toolkit.geoToView(lat, lon);
            float x = (float)((p.X - geoToViewX1) / (geoToViewX2 - geoToViewX1));
            float y = (float)((p.Y - geoToViewY1) / (geoToViewY2 - geoToViewY1));
            return new Point(x * size, y * size);
        }
コード例 #2
0
ファイル: Rectangle.cs プロジェクト: ackratos/USTCMap
 public bool intersects(Rectangle rect)
 {
     return !(south > rect.north || north < rect.south || west > rect.east || east < rect.west);
 }
コード例 #3
0
ファイル: MainPage.xaml.cs プロジェクト: ackratos/USTCMap
        // 构造函数
        public MainPage()
        {
            InitializeComponent();

            this.lat = 0.0;
            this.lon = 0.0;
            this.zoomlevel = MIN_ZOOM_LEVEL;
            this.targetZoomLevel = 19;
            this.scale = 1;
            this.threshold = getDPI() * 0.06f;

            this.hasTarget = false;
            this.isTracking = false;
            this.hasPosition = false;

            plotterHelper = new PlotterHelper();
            westCampus = new iustc.map.data.Rectangle(31.836497, 31.844080, 117.245445, 117.255058);
            eastCamput = new iustc.map.data.Rectangle(31.834236, 31.844189, 117.258920, 117.267889);
            arrowUri = new Uri("/iUSTCMap;component/resources/map_location_arrow.png", UriKind.Relative);
            dotUri = new Uri("/iUSTCMap;component/resources/map_location_dot.png", UriKind.Relative);
            arrowBitmap = new BitmapImage(arrowUri);
            dotBitmap = new BitmapImage(dotUri);

            if (cm == null)
                cm = new CacheManager(CACHE_CAPACITY, this);
            if (pThread == null)
                pThread = new PlotterThread(cm);

            watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); // using high accuracy

            LayoutRoot.Background = new SolidColorBrush(Color.FromArgb(255, 236, 236, 236));

            isoFile = IsolatedStorageFile.GetUserStoreForApplication();
            if (!isoFile.DirectoryExists("cache"))
            {
                isoFile.CreateDirectory("cache");
            }
            #region appBar
            appBar = new ApplicationBar();
            appBar.Opacity = 0.5;
            locateButton = new ApplicationBarIconButton(new Uri("resources/appbar.locate.rest.png", UriKind.Relative));
            locateButton.Text = "定位";
            locateButton.Click += new EventHandler(locateButton_Click);
            appBar.Buttons.Add(locateButton);

            zoomInButton = new ApplicationBarIconButton(new Uri("resources/appbar.new.rest.png", UriKind.Relative));
            zoomInButton.Text = "放大";
            zoomInButton.Click += new EventHandler(zoomInButton_Click);
            appBar.Buttons.Add(zoomInButton);

            zoomOutButton = new ApplicationBarIconButton(new Uri("resources/appbar.minus.rest.png", UriKind.Relative));
            zoomOutButton.Text = "缩小";
            zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
            appBar.Buttons.Add(zoomOutButton);

            selectCampusButton = new ApplicationBarIconButton(new Uri("resources/appbar.east.rest.png", UriKind.Relative));
            selectCampusButton.Text = "东校区";
            selectCampusButton.Click += new EventHandler(selectCampusButton_Click);
            appBar.Buttons.Add(selectCampusButton);

            ApplicationBar = appBar;
            #endregion
        }
コード例 #4
0
ファイル: MainPage.xaml.cs プロジェクト: ackratos/USTCMap
 public iustc.map.data.Rectangle getView(double lat, double lon, int level, float scale)
 {
     Point p = Toolkit.geoToView(lat, lon);
     double size = fullTileSize(level, scale);
     double dw = this.getWidth() * 0.5 / size;
     double dh = this.getHeight() * 0.5 / size;
     GeoPoint g1 = Toolkit.viewToGeo(p.X - dw, p.Y - dh);
     GeoPoint g2 = Toolkit.viewToGeo(p.X + dw, p.Y + dh);
     iustc.map.data.Rectangle rect = new iustc.map.data.Rectangle(g2.lat, g1.lat, g1.lon, g2.lon);
     return rect;
 }