Пример #1
0
        public Feature GetFeature(double longitude, double latitude, int level)
        {
            //Get the hexcode for the clicked area and try to find if its a feature on the map
            var hexCode = GeoHex.Encode(longitude, latitude, level);
            var feature = hexagonLayer.GetFeatureByHex(hexCode);

            return(feature);
        }
Пример #2
0
        private void MapControlMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (!isScoreAdding) //esto evita que abran el hexagono nuevamente mientras se está guardando un puntaje
            {
                if ((Current.Instance.TutorialStarted && tutorialCompletePhase1) || (Current.Instance.Tutorial2Started && tutorialCompletePhase2) || (!Current.Instance.TutorialStarted && !Current.Instance.Tutorial2Started))
                {
                    leftMouseButtonDown = true;

                    if (!layerHelper.FindLayer(Constants.Hexagonlayername).Enabled)
                    {
                        return;
                    }

                    var mousePos            = e.GetPosition(mapControl);
                    var sphericalCoordinate = mapControl.Viewport.ScreenToWorld(mousePos.X, mousePos.Y); //TODO: posicionar bien el tooltip
                    var lonLat = SphericalMercator.ToLonLat(sphericalCoordinate.X, sphericalCoordinate.Y);

                    var feature = hexagonInfo.GetFeature(lonLat.x, lonLat.y, 7);
                    var hexCode = GeoHex.Encode(lonLat.x, lonLat.y, 7);

                    if (feature == null)
                    {
                        // try on level 6...
                        hexCode = GeoHex.Encode(lonLat.x, lonLat.y, 6);
                    }

                    bool showHex = true;
                    if ((Current.Instance.TutorialStarted || Current.Instance.Tutorial2Started) && !selectedLand.GeohexKey.Equals(hexCode))
                    {
                        showHex = false;
                    }

                    if (showHex)
                    {
                        if (Current.Instance.TutorialStarted)
                        {
                            this.Tutorial5.Visibility      = System.Windows.Visibility.Collapsed;
                            this.Tutorial5Arrow.Visibility = System.Windows.Visibility.Collapsed;
                        }

                        if (Current.Instance.Tutorial2Started)
                        {
                            this.Tutorial23.Visibility     = System.Windows.Visibility.Collapsed;
                            this.Tutorial5Arrow.Visibility = System.Windows.Visibility.Collapsed;
                        }

                        hexagonInfo.ShowInfo(lonLat.x, lonLat.y);
                    }
                }
            }
        }
Пример #3
0
        public List <SatelliteImage> GetImagesByHexagon(double latitude, double longitude)
        {
            //Get the geohex locations
            string geoHexCode = GeoHex.Encode(longitude, latitude, 7);
            Zone   zone       = GeoHex.Decode(geoHexCode);

            Loc[] locs = zone.getHexCoords();

            //Create a Polygon
            IEnumerable <XY> pointCollection = GetPointCollection(locs);
            Polygon          polygon         = new Polygon(pointCollection);

            return(GetImagesByPolygon(polygon));
        }
Пример #4
0
        //Helpers
        public Feature GetFeature(double longitude, double latitude, int level)
        {
            //Get the hexcode for the clicked area and try to find if its a feature on the map
            var hexCode = GeoHex.Encode(longitude, latitude, level);

            Feature feature = null; //TEST

            if (first)
            {
                feature = bcLayer.GetFeatureByHex(hexCode); //TEST
                first   = false;
            }
            else
            {
                feature = hexagonLayer.GetFeatureByHex(hexCode);
            }

            return(feature);
        }
Пример #5
0
        public void ShowInfo(double lon, double lat)
        {
            // first try on level 7...
            var feature = GetFeature(lon, lat, 7);
            var hexCode = GeoHex.Encode(lon, lat, 7);

            if (feature == null)
            {
                // try on level 6...
                hexCode = GeoHex.Encode(lon, lat, 6);
                feature = GetFeature(lon, lat, 6);
                if (feature == null)
                {
                    return;
                }
            }

            UpdateInfo(hexCode, false);
            Move();
            isShown    = true;
            Visibility = Visibility.Visible;
        }
Пример #6
0
        public static List <Land> GenerateLands(PointD topLeft, PointD bottomRight, int level, int regionId)
        {
            var horaInicio = DateTime.Now;

            Console.WriteLine("Hora de inicio GenerateLands: " + horaInicio);
            var newLand = new List <Land>();

            //Tamaño Mediano (Salta)
            //const double increase = 0.0075;
            //level = 7;

            //Tamaño Grande (Chaco 10K Total - Las que no sirben)
            const double increase = 0.0175;

            level = 6;

            //Tamaño Chico
            //const double increase = 0.00175;
            //level = 8;

            int assignables   = 0;
            int unassignables = 0;

            for (var i = topLeft.X; i <= bottomRight.X; i += increase)
            {
                for (var j = topLeft.Y; j >= bottomRight.Y; j -= increase)
                {
                    var hexKey = GeoHex.Encode(i, j, level);
                    var land   = new Land();
                    land.Longitude  = i;
                    land.Latitude   = j;
                    land.GeohexKey  = hexKey;
                    land.RegionId   = regionId;
                    land.BasecampId = 999;       //FORMA FACIL DE IDENTIFICAR A LAS NUEVAS PARCELAS CREADAS PARA TEST
                    if ((!newLand.Any(l => l.GeohexKey == hexKey)))
                    {
                        if (_forestlaw != null)
                        {
                            if (ComputeLandThreat(land))
                            {
                                //ComputeBasecampIntersection(land);
                                newLand.Add(land);
                                assignables++;
                            }
                            else
                            {
                                unassignables++;
                            }
                        }
                        else
                        {
                            unassignables++;
                            newLand.Add(land);
                        }
                    }
                }
            }
            var horaFin = DateTime.Now;

            Console.WriteLine("Hora Fin GenerateLands: " + horaFin);
            Console.WriteLine("ASIGNABLES: " + assignables);
            Console.WriteLine("NO ASIGNABLES: " + unassignables);

            return(newLand);
        }