Esempio n. 1
0
        /// <summary>
        /// Calls XAML Service
        ///     Initializes input parameters
        ///     Calls Asynch service
        /// </summary>
        /// <remarks>
        ///     Provides Viewport Area of Interest
        ///     Reduce factor is only used for levels 1-8
        /// </remarks>
        public void ShowLayersXAML()
        {
            // get list of checked layers
            List <string> layers = GetLayers();

            layerCnt = layers.Count;
            if (layers.Count > 0)
            {
                totalFeatures = 0;
                totalPoints   = 0;
                totalByteSize = 0;

                string queryType = null;
                string area      = null;
                double radius    = 0.0;
                double reduce    = 4000 - MainMap.ZoomLevel * 500;
                if (reduce < 0)
                {
                    reduce = 0;
                }

                queryType = "bbox";
                StringBuilder sb     = new StringBuilder();
                LocationRect  bounds = MainMap.BoundingRectangle;
                // check for hemisphere overrun
                if (WithinHemisphere(bounds.Southeast, bounds.Northwest))
                {
                    sb.Append(bounds.Southeast.Longitude + " ");
                    sb.Append(bounds.Southeast.Latitude + ",");
                    sb.Append(bounds.Northeast.Longitude + " ");
                    sb.Append(bounds.Northeast.Latitude + ",");
                    sb.Append(bounds.Northwest.Longitude + " ");
                    sb.Append(bounds.Northwest.Latitude + ",");
                    sb.Append(bounds.Southwest.Longitude + " ");
                    sb.Append(bounds.Southwest.Latitude + ",");
                    sb.Append(bounds.Southeast.Longitude + " ");
                    sb.Append(bounds.Southeast.Latitude);
                    area = sb.ToString();
                }
                if (area != null)
                {
                    // disable side menu and start load spinner until call returns
                    SidePanelBorder.IsHitTestVisible = false;
                    loaderStart();

                    foreach (string layer in layers)
                    {
                        XAMLClient svc = new XAMLClient("CustomBinding_IXAML");
                        svc.GetSQLDataXAMLCompleted += new EventHandler <GetSQLDataXAMLCompletedEventArgs>(XAMLService_GetSQLDataXAMLCompleted);
                        XAMLParameters parameters = new XAMLParameters();
                        parameters.table     = layer.Replace("layer", "").ToLower();
                        parameters.querytype = queryType;
                        parameters.reduce    = reduce;
                        parameters.radius    = radius;
                        parameters.points    = area;
                        svc.GetSQLDataXAMLAsync(parameters, layer);
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Calls WKT Service 
        ///     Initializes input parameters
        ///     Calls Asynch service
        /// </summary>
        /// <remarks>
        /// Drawtools leaves the area of interest definition on MapLayer 'layerDraw'
        /// </remarks>
        public void ShowLayers()
        {
            // get list of checked layers
            List<string> layers = GetLayers();
            layerCnt = layers.Count;
            if (layers.Count > 0)
            {
                totalFeatures = 0;
                totalPoints = 0;
                totalByteSize = 0;

                string queryType = null;
                string area = null;
                double radius = 0.0;
                double reduce = 4000 - MainMap.ZoomLevel * 500;
                if (reduce < 0) reduce = 0;
                if ((bool)drawtools.Proximity.IsChecked)
                {
                    queryType = "buffer";
                    Ellipse pt = (Ellipse)layerDraw.FindName("Proximity");
                    if (pt != null && pt.Tag != null)
                    {
                        Location loc = MapLayer.GetPosition(pt);
                        //radius(meters) longitude,latitude
                        if (pt.Tag != null) radius = Double.Parse(pt.Tag.ToString());
                        else radius = 1.0;
                        area = loc.Longitude + " " + loc.Latitude;
                    }
                }
                else if ((bool)drawtools.PolyBuffer.IsChecked)
                {
                    queryType = "buffer";
                    //buffer width(meters)  lon,lat lon,lat ... lon,lat
                    MapPolyline poly = (MapPolyline)layerDraw.FindName("Buffer");
                    if (poly != null)
                    {
                        Slider s = (Slider)drawtools.FindName("BufferSlider");
                        radius = (s.Value * 1000);
                        StringBuilder sb = new StringBuilder();
                        bool first = true;
                        foreach (Location l in poly.Locations)
                        {
                            if (!first) sb.Append(",");
                            sb.Append(l.Longitude + " " + l.Latitude);
                            first = false;
                        }
                        area = sb.ToString();
                    }
                }
                else if ((bool)drawtools.AOI.IsChecked)
                {
                    queryType = "bbox";
                    StringBuilder sb = new StringBuilder();
                    MapPolygon drawrect = ((MapPolygon)layerDraw.FindName("AOI"));

                    if (drawrect != null)
                    {
                        // check for hemisphere overrun
                        if (validAOI(drawrect.Locations[0], drawrect.Locations[2]) && 
                            WithinHemisphere(drawrect.Locations[0], drawrect.Locations[2]))
                        {
                            foreach (Location l in drawrect.Locations)
                            {
                                sb.Append(l.Longitude + " " + l.Latitude + ",");
                            }
                            sb.Append(drawrect.Locations[0].Longitude + " " + drawrect.Locations[0].Latitude);
                            area = sb.ToString();
                        }
                        else
                        {
                            drawtools.draw = true;
                        }
                    }
                }
                else if ((bool)drawtools.Viewport.IsChecked)
                {
                    queryType = "bbox";
                    StringBuilder sb = new StringBuilder();
                    LocationRect bounds = MainMap.BoundingRectangle;
                    // check for hemisphere overrun
                    if (validAOI(bounds.Southeast, bounds.Northwest) && 
                        WithinHemisphere(bounds.Southeast, bounds.Northwest))
                    {
                        sb.Append(bounds.Southeast.Longitude + " ");
                        sb.Append(bounds.Southeast.Latitude + ",");
                        sb.Append(bounds.Northeast.Longitude + " ");
                        sb.Append(bounds.Northeast.Latitude + ",");
                        sb.Append(bounds.Northwest.Longitude + " ");
                        sb.Append(bounds.Northwest.Latitude + ",");
                        sb.Append(bounds.Southwest.Longitude + " ");
                        sb.Append(bounds.Southwest.Latitude + ",");
                        sb.Append(bounds.Southeast.Longitude + " ");
                        sb.Append(bounds.Southeast.Latitude);
                        area = sb.ToString();
                    }
                    else
                    {
                        drawtools.draw = true;
                    }
                }
                if (area != null)
                {
                    // disable side menu and start load spinner until call returns
                    SidePanelBorder.IsHitTestVisible = false;
                    loaderStart();

                    foreach (string layer in layers)
                    {
                        XAMLClient svc = new XAMLClient("CustomBinding_IXAML");
                        svc.GetSQLDataXAMLCompleted += new EventHandler<GetSQLDataXAMLCompletedEventArgs>(XAMLService_GetSQLDataXAMLCompleted);
                        XAMLParameters parameters = new XAMLParameters();
                        parameters.table = layer.Replace("layer", "").ToLower();
                        parameters.querytype = queryType;
                        parameters.reduce = reduce;
                        parameters.radius = radius;
                        parameters.points = area;
                        svc.GetSQLDataXAMLAsync(parameters,layer);
                    }
                }
            }
            else
            {
                drawtools.draw = true;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// let's query our Xaml Service, we need the querytype, the draw type is just to  chen the number of points
        /// we also can say what table we are querying 
        /// finally we pass the locations and the distance that the buffer has.
        /// </summary>
        /// 
        private void makeQuery(string querytype, string drawtype, string table, LocationCollection points, double radius)
        {
            IsBusy = true;
            double reduce = 5000 - CurrentZoomLevel * 500;
            switch (drawtype)
            {
                case "Proximity":
                    {
                        if (points[0] != null)
                            area = points[0].Longitude + " " + points[0].Latitude;
                    }
                    break;
                case "Buffer":
                    {
                        if (points[0] != null)
                        {
                            StringBuilder sb = new StringBuilder();
                            bool first = true;
                            foreach (Location l in points)
                            {
                                if (!first) sb.Append(",");
                                sb.Append(l.Longitude + " " + l.Latitude);
                                first = false;
                            }
                            area = sb.ToString();
                        }
                    }
                    break;
                default:
                    break;
            }

            if (area != null)
            {
                //have to show load animation
                SpatialServices.XAMLService.GetSQLDataXAMLCompleted += new EventHandler<GetSQLDataXAMLCompletedEventArgs>(XAMLService_GetSQLDataXAMLCompleted);
                XAMLParameters parameters = new XAMLParameters();
                parameters.table = table;
                parameters.querytype = querytype;
                parameters.reduce = reduce;
                parameters.radius = radius;
                parameters.points = area;
                SpatialServices.XAMLService.GetSQLDataXAMLAsync(parameters, new object());
            }
        }
Esempio n. 4
0
 private void makeQueryCountry(string querytype, string drawtype, string table, string country)
 {
     IsBusy = true;
     double reduce = 5000 - CurrentZoomLevel * 500;
     SpatialServices.XAMLService.GetSQLDataXAMLCompleted += new EventHandler<GetSQLDataXAMLCompletedEventArgs>(XAMLService_GetSQLDataXAMLCompleted);
     XAMLParameters parameters = new XAMLParameters();
     parameters.table = table;
     parameters.reduce = reduce;
     parameters.querytype = querytype;
     parameters.points = country;
     SpatialServices.XAMLService.GetSQLDataXAMLAsync(parameters, new object());
 }
Esempio n. 5
0
        /// <summary>
        /// Calls XAML Service 
        ///     Initializes input parameters
        ///     Calls Asynch service
        /// </summary>
        /// <remarks>
        ///     Provides Viewport Area of Interest 
        ///     Reduce factor is only used for levels 1-8
        /// </remarks>
        public void ShowLayersXAML()
        {
            // get list of checked layers
            List<string> layers = GetLayers();
            layerCnt = layers.Count;
            if (layers.Count > 0)
            {
                totalFeatures = 0;
                totalPoints = 0;
                totalByteSize = 0;

                string queryType = null;
                string area = null;
                double radius = 0.0;
                double reduce = 4000 - MainMap.ZoomLevel * 500;
                if (reduce < 0) reduce = 0;

                queryType = "bbox";
                StringBuilder sb = new StringBuilder();
                LocationRect bounds = MainMap.BoundingRectangle;
                // check for hemisphere overrun
                if (WithinHemisphere(bounds.Southeast, bounds.Northwest))
                {
                    sb.Append(bounds.Southeast.Longitude + " ");
                    sb.Append(bounds.Southeast.Latitude + ",");
                    sb.Append(bounds.Northeast.Longitude + " ");
                    sb.Append(bounds.Northeast.Latitude + ",");
                    sb.Append(bounds.Northwest.Longitude + " ");
                    sb.Append(bounds.Northwest.Latitude + ",");
                    sb.Append(bounds.Southwest.Longitude + " ");
                    sb.Append(bounds.Southwest.Latitude + ",");
                    sb.Append(bounds.Southeast.Longitude + " ");
                    sb.Append(bounds.Southeast.Latitude);
                    area = sb.ToString();
                }
                if (area != null)
                {
                    // disable side menu and start load spinner until call returns
                    SidePanelBorder.IsHitTestVisible = false;
                    loaderStart();

                    foreach (string layer in layers)
                    {
                        XAMLClient svc = new XAMLClient("CustomBinding_IXAML");
                        svc.GetSQLDataXAMLCompleted += new EventHandler<GetSQLDataXAMLCompletedEventArgs>(XAMLService_GetSQLDataXAMLCompleted);
                        XAMLParameters parameters = new XAMLParameters();
                        parameters.table = layer.Replace("layer", "").ToLower();
                        parameters.querytype = queryType;
                        parameters.reduce = reduce;
                        parameters.radius = radius;
                        parameters.points = area;
                        svc.GetSQLDataXAMLAsync(parameters,layer);
                    }
                }
            }

        }