Esempio n. 1
0
        void rbSearch_Click(object sender, EventArgs e)
        {
            //there must be at least one layer in the map
            if (App.Map.Layers.Count == 0)
            {
                MessageBox.Show("Please add at least one layer to the map.");
                return;
            }

            //reproject the area parameter to wgs84 and then run search.
            if (SearchSettings.Instance.AreaSettings.Polygons != null)
            {
                Extent extentInWgs84 = AreaHelper.ReprojectExtentToWGS84(SearchSettings.Instance.AreaSettings.Polygons.Extent, App.Map.Projection);
                fsc.SetSearchParameters(extentInWgs84, SearchSettings.Instance.DateSettings.StartDate, SearchSettings.Instance.DateSettings.EndDate);
                fsc.InitializeFacetedSearch();
            }
            else if (SearchSettings.Instance.AreaSettings.AreaRectangle != null)
            {
                Extent areaRectangleExtent        = new Extent(SearchSettings.Instance.AreaSettings.AreaRectangle.XMin, SearchSettings.Instance.AreaSettings.AreaRectangle.YMin, SearchSettings.Instance.AreaSettings.AreaRectangle.XMax, SearchSettings.Instance.AreaSettings.AreaRectangle.YMax);
                Extent areaRectangelExtentInWgs84 = AreaHelper.ReprojectExtentToWGS84(areaRectangleExtent, App.Map.Projection);

                fsc.SetSearchParameters(areaRectangelExtentInWgs84, SearchSettings.Instance.DateSettings.StartDate, SearchSettings.Instance.DateSettings.EndDate);
                fsc.InitializeFacetedSearch();
            }
            else
            {
                MessageBox.Show("Please specify spatial and temporal constraints prior to initializing faceted search.");
            }
        }
Esempio n. 2
0
        void rbAttribute_Click(object sender, EventArgs e)
        {
            CurrentAreaSelectMode = AreaSelectMode.SelectAttribute;

            DeactivateDrawBox();
            DeactivateSelectAreaByPolygon();

            AreaHelper.SelectFirstVisiblePolygonLayer((Map)App.Map, false);
            SelectAreaByAttributeDialog.ShowDialog((Map)App.Map);
            Map_SelectionChanged(this, EventArgs.Empty);
        }
Esempio n. 3
0
        void rbSelect_Click(object sender, EventArgs e)
        {
            CurrentAreaSelectMode = AreaSelectMode.SelectPolygons;

            DeactivateDrawBox();

            App.Map.FunctionMode = FunctionMode.Select;

            var isWorldTemplate = App.SerializationManager.GetCustomSetting("world_template", "false");

            AreaHelper.SelectFirstVisiblePolygonLayer((Map)App.Map, Convert.ToBoolean(isWorldTemplate));
            //App.Map.MapFrame.IsSelected = true;
        }
Esempio n. 4
0
        /// <summary>
        /// 验证行政区划
        /// </summary>
        /// <param name="code"></param>
        /// <param name="validLimit"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        protected virtual bool ValidArea(string code, AreaValidLimit?validLimit, TResult result)
        {
            var  areaNumber = this.GetAreaNumber(code);
            var  area       = AreaHelper.GetDeepestArea(areaNumber, this.Dictionary);
            bool valid      = !validLimit.HasValue || (area != null && area.GetDepth() >= (int)validLimit);

            result.RecognizableArea = area;
            result.AreaNumber       = areaNumber;
            if (!valid)
            {
                result.AddErrorMessage(ErrorMessage.InvalidArea);
            }
            return(valid);
        }
Esempio n. 5
0
        public async void Delete(int?areaID, long merchantID)
        {
            await Task.Run(() =>
            {
                if (!areaID.HasValue || areaID < 100000)
                {
                    var layer = MerchantProvider.GetAreaLayer(merchantID);

                    var cacheOpenAreas = CacheCollection.OpenAreaCache.Value();

                    areaID = AreaHelper.GetOpenAreaID(layer, cacheOpenAreas);
                }

                AreaIndexManager.Instance.Delete(Enums.IndexDataType.Merchant, areaID.Value, merchantID);
                MerchantIndexManager.Instance.Delete(Enums.IndexDataType.Merchant, areaID.Value, merchantID);
            });
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            string url  = GlobalConstants.UrlArea;
            string html = HtmlHelper.GetHtmlContent(url);

            Console.WriteLine("开始抓取数据...");
            List <Area> areaList = AreaHelper.GetAreaList(html);
            List <Area> result   = AreaHelper.ProcessArea(areaList);

            Console.WriteLine("抓取数据完毕!");

            string directory = AppDomain.CurrentDomain.BaseDirectory + @"data\";

            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }

            JsonSerializerSettings jsonSetting = new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            };
            string json = JsonConvert.SerializeObject(result, Formatting.Indented, jsonSetting);

            using (StreamWriter sw = new StreamWriter(directory + "json.txt"))
            {
                sw.WriteLine(json);
            }

            string mySql = SqlHelper.GetMySqlInsert(result);

            using (StreamWriter sw = new StreamWriter(directory + "mysql.txt"))
            {
                sw.WriteLine(mySql);
            }

            string sqlServer = SqlHelper.GetSqlServerInsert(result);

            using (StreamWriter sw = new StreamWriter(directory + "sqlserver.txt"))
            {
                sw.WriteLine(sqlServer);
            }


            Console.Read();
        }
        /// <summary>
        /// 验证行政区划
        /// </summary>
        /// <param name="code"></param>
        /// <param name="validLimit"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        protected override bool ValidArea(string code, AreaValidLimit?validLimit, RegistrationNo15ValidationResult result)
        {
            var areaNumber = this.GetAreaNumber(code);
            var area       = AreaHelper.GetDeepestArea(result.AreaNumber, this.AdministrationDictionary);

            result.AreaNumber = areaNumber;
            var valid = true;

            if (area != null)
            {
                result.RecognizableArea = area;
            }
            else
            {
                valid = base.ValidArea(code, validLimit, result);
            }
            return(valid);
        }
Esempio n. 8
0
        public async Task <bool> DeleteAsync(int?areaID, long productID)
        {
            return(await Task.Run(() =>
            {
                if (!areaID.HasValue || areaID < 100000)
                {
                    var layer = MerchantProductProvider.GetProductAreaLayer(productID);

                    var cacheOpenAreas = CacheCollection.OpenAreaCache.Value();

                    areaID = AreaHelper.GetOpenAreaID(layer, cacheOpenAreas);
                }

                AreaIndexManager.Instance.Delete(Enums.IndexDataType.MerchantProduct, areaID.Value, productID);
                MerchantProductIndexManager.Instance.Delete(Enums.IndexDataType.MerchantProduct, areaID.Value, productID);

                return true;
            }));
        }
        /// <summary>
        /// Rafraichit les différentes variables affichés sur la map
        /// </summary>
        public void RefreshMarkers()
        {
            /*if (ZonePolygon == null || ZonePolygon.Points.Count == 0)
             * {
             *  CountOfPointsTextView.Text = "0";
             *  SurfaceTextView.Text = string.Format("0 {0}", Resources.GetString(Resource.String.unit_squarre));
             *  //BottomLayout.Visibility = ViewStates.Gone;
             *  ExplanationTextView.Visibility = ViewStates.Visible;
             *  return;
             * }
             * BottomLayout.Visibility = ViewStates.Visible;
             * ExplanationTextView.Visibility = ViewStates.Gone;
             *
             * if (ZonePolygon.Points.Count == 1) CountOfPointsTextView.Text = "1";
             * else CountOfPointsTextView.Text = (ZonePolygon.Points.Count - 1).ToString();
             */
            var surface = AreaHelper.CalculateAreaOfGPSPolygonOnEarthInSquareMeters(ZonePolygon.Points.ToList());

            SurfaceTextView.Text = AreaHelper.SerializeArea(surface);
        }
        /// <summary>
        ///
        /// </summary>
        private void InitializeSurfaceStatTextView()
        {
            if (ZonePolygon == null)
            {
                return;
            }
            if (SurfaceStatTextView == null)
            {
                return;
            }

            var surface         = AreaHelper.CalculateAreaOfGPSPolygonOnEarthInSquareMeters(ZonePolygon.Points.ToList());
            var surfaceStat     = AreaHelper.SerializeArea(surface);
            var textSurfaceStat = string.Format(Resources.GetString(Resource.String.modeZone_surfaceStr), surfaceStat);

            var resultTuple = SeekiosApp.Helper.StringHelper.GetStartAndEndIndexOfNumberInString(textSurfaceStat);
            var formattedTextSurfaceStat = new SpannableString(textSurfaceStat);

            formattedTextSurfaceStat.SetSpan(new ForegroundColorSpan(Color.ParseColor(App.MainColor)), resultTuple.Item1, resultTuple.Item2, 0);
            SurfaceStatTextView.SetText(formattedTextSurfaceStat, TextView.BufferType.Spannable);
        }
Esempio n. 11
0
        /// <summary>
        /// 验证行政区划
        /// </summary>
        /// <param name="idNumber"></param>
        /// <param name="validLimit"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        protected virtual bool ValidArea(string idNumber, AreaValidLimit validLimit, IDValidationResult result)
        {
            int  areaNumber = this.GetAreaNumber(idNumber);
            var  area       = AreaHelper.GetDeepestArea(areaNumber, this.Dictionary);
            bool valid      = area != null && area.GetDepth() >= (int)validLimit;

            result.RecognizableArea = area;
            result.AreaNumber       = areaNumber;
            if (!valid)
            {
                if (area == null)
                {
                    result.AddErrorMessage(ErrorMessage.InvalidArea);
                }
                else
                {
                    result.AddErrorMessage(ErrorMessage.AreaLimitOutOfRange, validLimit);
                }
            }
            return(valid);
        }
Esempio n. 12
0
        void Map_SelectionChanged(object sender, EventArgs e)
        {
            if (CurrentAreaSelectMode == AreaSelectMode.SelectPolygons ||
                CurrentAreaSelectMode == AreaSelectMode.SelectAttribute)
            {
                var polygonLayer = AreaHelper.GetAllSelectedPolygonLayers((Map)App.Map).FirstOrDefault();
                if (polygonLayer == null)
                {
                    //special case: if the map layers or the group is selected
                    if (App.Map.MapFrame.IsSelected)
                    {
                        IEnumerable <IMapPolygonLayer> polygonLayers = AreaHelper.GetAllPolygonLayers((Map)App.Map).Reverse();
                        foreach (IMapPolygonLayer polyLayer in polygonLayers)
                        {
                            if (polyLayer.IsVisible && polyLayer.Selection.Count > 0)
                            {
                                var polyFs2 = new FeatureSet(DotSpatial.Topology.FeatureType.Polygon);
                                foreach (var f in polyLayer.Selection.ToFeatureList())
                                {
                                    polyFs2.Features.Add(f);
                                }
                                polyFs2.Projection = App.Map.Projection;
                                SearchSettings.Instance.AreaSettings.Polygons = polyFs2;
                                return;
                            }
                        }
                    }
                    return;
                }

                var polyFs = new FeatureSet(DotSpatial.Topology.FeatureType.Polygon);
                foreach (var f in polygonLayer.Selection.ToFeatureList())
                {
                    polyFs.Features.Add(f);
                }
                polyFs.Projection = App.Map.Projection;
                SearchSettings.Instance.AreaSettings.Polygons = polyFs;
            }
        }
        public override Android.Views.View GetView(int position, Android.Views.View convertView, ViewGroup parent)
        {
            // item en cours de traitement
            var item = App.CurrentUserEnvironment.LsFavoriteArea[position];

            // pas de vue à utiliser ? création d'une vue
            FavoriteAreaViewHolder holder = null;

            if (!_alreadyCreatedViews.ContainsKey(item.IdfavoriteArea))
            {
                _alreadyCreatedViews.Add(item.IdfavoriteArea, null);
            }
            Android.Views.View view = _alreadyCreatedViews[item.IdfavoriteArea];
            // Si on a récupéré la vue on récupère le holder dans son tag
            if (view != null)
            {
                holder = view.Tag as FavoriteAreaViewHolder;
            }
            // Si le holder n'est pas défini, on le fait et on crée la vue
            if (holder == null)
            {
                holder   = new FavoriteAreaViewHolder();
                view     = _context.LayoutInflater.Inflate(Resource.Layout.ZoneFavoriteRow, null);
                view.Tag = holder;
                // récupération des objets de la vue
                holder.AreaName     = view.FindViewById <TextView>(Resource.Id.favoriteArea_areaName);
                holder.PointsCount  = view.FindViewById <TextView>(Resource.Id.favoriteArea_pointsCount);
                holder.AreaGeodesic = view.FindViewById <TextView>(Resource.Id.favoriteArea_area);
                holder.DeleteAlerte = view.FindViewById <XamSvg.SvgImageView>(Resource.Id.favoriteArea_delete);
                holder.RootGrid     = view.FindViewById <GridLayout>(Resource.Id.favoriteArea_rootGrid);

                // boutton supprimer
                holder.DeleteAlerte.Click += new EventHandler(async(o, e) =>
                {
                    await App.Locator.ModeZone.DeleteFavoriteArea(item);
                    if (_refresh != null)
                    {
                        _refresh.Invoke();
                    }
                });

                // clique sur l'item (root)
                holder.RootGrid.Click += new EventHandler((o, e) =>
                {
                    App.Locator.ModeZone.SelectedFavoriteArea = item;
                    if (_dismiss != null)
                    {
                        // quitte la popup (dismiss)
                        _dismiss.Invoke();
                    }
                });
                _alreadyCreatedViews[item.IdfavoriteArea] = view;
            }

            // initialisation des variables de la vue
            holder.AreaName.Text     = item.AreaName;
            holder.PointsCount.Text  = string.Format("{0} points", item.PointsCount);
            holder.AreaGeodesic.Text = AreaHelper.SerializeArea(item.AreaGeodesic);

            return(view);
        }
Esempio n. 14
0
 public void GetDeepestArea_Error()
 {
     Assert.Throws <ArgumentNullException>(() => AreaHelper.GetDeepestArea(10, null));
     Assert.Throws <ArgumentException>(() => AreaHelper.GetDeepestArea(1, GBT2260_2013.Singleton));
 }
Esempio n. 15
0
        /// <summary>
        /// Initialise la popup de l'ajout d'une zone en favoris
        /// </summary>
        private void BuildAreaAddFavorisPopup()
        {
            // création d'une alerte dialog
            _addModeZoneFavorisAlertDialog = new AlertDialog.Builder(this);

            var editText       = new EditText(this);
            var editTextLayout = new LinearLayout(this);

            var editTextParam = new Android.Widget.LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);

            editTextParam.SetMargins(25, 5, 25, 5);
            editText.InputType = Android.Text.InputTypes.TextVariationUri;
            editText.SetHint(Resource.String.addFavoriteArea_areaName);
            editText.SetTextColor(Android.Graphics.Color.ParseColor("#cccccc"));     // TODO : dans fichier ressource
            editText.SetHintTextColor(Android.Graphics.Color.ParseColor("#888888")); // TODO : dans fichier ressource
            editText.LayoutParameters = editTextParam;

            var editTextLayoutParam = new Android.Widget.LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);

            editTextLayoutParam.SetMargins(20, 5, 20, 5);
            editTextLayout.LayoutParameters = editTextLayoutParam;
            editTextLayout.AddView(editText);

            // titre de l'alerte
            _addModeZoneFavorisAlertDialog.SetTitle(Resource.String.modeZone_addAreaFavorisTitle);

            // bouton ajouter
            _addModeZoneFavorisAlertDialog.SetPositiveButton(Resource.String.popup_add, async(o, e) =>
            {
                if (string.IsNullOrEmpty(editText.Text))
                {
                    return;
                }

                var pointCount = 0;

                if (_mapControlManager.ZonePolygon != null)
                {
                    if (_mapControlManager.ZonePolygon.Points.Count == 1)
                    {
                        pointCount = 1;
                    }
                    else
                    {
                        pointCount = _mapControlManager.ZonePolygon.Points.Count - 1;
                    }
                    var trame = GetTrame(_mapControlManager.ZonePolygon.Points.ToList());

                    var surface = AreaHelper.CalculateAreaOfGPSPolygonOnEarthInSquareMeters(_mapControlManager.ZonePolygon.Points.ToList());

                    LoadingLayout.Visibility = ViewStates.Visible;
                    var result = await App.Locator.ModeZone.AddFavoriteArea(new FavoriteAreaDTO
                    {
                        Trame        = trame,
                        PointsCount  = pointCount,
                        AreaGeodesic = surface,
                        AreaName     = editText.Text.ToUpperCaseFirst(),
                    });
                    if (result)
                    {
                        var textAddedAreaToast = string.Format(Resources.GetString(Resource.String.modeZone_toast_AddedArea), editText.Text.ToUpperCaseFirst());
                        Toast.MakeText(this, textAddedAreaToast, ToastLength.Long).Show();
                    }
                    LoadingLayout.Visibility = ViewStates.Gone;
                }
                else
                {
                    string error             = Resources.GetString(Resource.String.addFavoriteArea_errorZone);
                    AlertDialog alertMessage = new AlertDialog.Builder(this).Create();
                    alertMessage.SetTitle("Error: ");
                    alertMessage.SetMessage(error);
                    alertMessage.Show();
                }
                _addModeZoneFavorisDialog.Dismiss();
            });

            // bouton annuler
            _addModeZoneFavorisAlertDialog.SetNegativeButton(Resource.String.popup_cancelled, (o, e) =>
            {
                _addModeZoneFavorisDialog.Dismiss();
            });

            // ajout de la vue dans l'alerte
            _addModeZoneFavorisAlertDialog.SetView(editTextLayout);

            // instatiation de notre popup dans un objet dialog
            _addModeZoneFavorisDialog = _addModeZoneFavorisAlertDialog.Create();
            _addModeZoneFavorisAlertDialog.Show();
        }