public override VectorElement BuildClusterElement(MapPos pos, VectorElementVector elements)
        {
            BalloonPopupStyle style = balloonPopupStyleBuilder.BuildStyle();
            var popup = new BalloonPopup(pos, style, elements.Count.ToString(), "");

            return popup;
        }
        public void ShowRoute(MapPos startPos, MapPos stopPos)
        {
            // Run routing in background
            System.Threading.Tasks.Task.Run(() =>
            {
                long time = DateTime.Now.Millisecond;

                RoutingResult result = Routing.GetResult(startPos, stopPos);

                // Update response in UI thread
                InvokeOnMainThread(() =>
                {
                    if (result == null)
                    {
                        Alert("Routing failed");
                        return;
                    }

                    Alert(Routing.GetMessage(result, time, DateTime.Now.Millisecond));

                    Color darkGray = new Carto.Graphics.Color(50, 50, 50, 255);
                    Routing.Show(result, darkGray);
                });
            });
        }
        // Map View manipulation handlers
        public override void OnMapClicked(MapClickInfo mapClickInfo)
        {
            if (mapClickInfo.ClickType == ClickType.ClickTypeLong)
            {
                MapPos clickPos = mapClickInfo.ClickPos;

                if (startPos == null)
                {
                    // Set start, or start again
                    startPos = clickPos;

                    if (StartPositionClicked != null) {
                        StartPositionClicked(new object(), new RouteMapEventArgs { ClickPosition = clickPos });
                    }
                }
                else if (stopPos == null)
                {
                    // Set stop and calculate
                    stopPos = clickPos;

                    if (StartPositionClicked != null)
                    {
                        StopPositionClicked(new object(), new RouteMapEventArgs {
                            ClickPosition = clickPos,
                            StartPosition = startPos,
                            StopPosition = stopPos
                        });
                    }

                    // Restart to force new route next time
                    startPos = null;
                    stopPos = null;
                }
            }
        }
Ejemplo n.º 4
0
        public static async void AddMarkerToPosition(this MapView map, MapPos position)
        {
            await ThreadPool.RunAsync(delegate
            {
                // Initialize a local vector data source
                Projection projection = map.Options.BaseProjection;
                LocalVectorDataSource datasource = new LocalVectorDataSource(projection);

                // Initialize a vector layer with the previous data source
                VectorLayer layer = new VectorLayer(datasource);

                // Add layer to map
                map.Layers.Add(layer);

                MarkerStyleBuilder builder = new MarkerStyleBuilder();
                builder.Size = 15;
                builder.Color = new Carto.Graphics.Color(0, 255, 0, 255);
                
                MarkerStyle style = builder.BuildStyle();

                // Create marker and add it to the source
                Marker marker = new Marker(position, style);
                datasource.Add(marker);
            });
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Calculates the screen position corresponding to a map position, using the current view parameters.
 /// </summary>
 /// <param name="mapPos">The map position in base projection coordinate system.</param>
 /// <returns>The calculated screen position. Can be off-screen.</returns>
 public ScreenPos MapToScreen(MapPos mapPos)
 {
     return(_baseMapView.MapToScreen(mapPos));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Zooms the view relative to the current zoom value. Positive values zoom in, negative values zoom out.
 /// The new calculated zoom value will be clamped to the range of [0 .. 24] and to the range set by Options::setZoomRange.
 ///
 /// Zooming is done towards the specified target position, keeping it at the same location on the screen.
 ///
 /// If durationSeconds &gt; 0 the zooming operation will be animated over time. If the previous zooming animation has not
 /// finished by the time this method is called, it will be stopped.
 /// </summary>
 /// <param name="deltaZoom">The delta zoom value.</param>
 /// <param name="targetPos">The zooming target position in the coordinate system of the base projection.</param>
 /// <param name="durationSeconds">The duration in which the zooming operation will be completed in seconds.</param>
 public void SetRelativeZoom(float deltaZoom, MapPos targetPos, float durationSeconds)
 {
     _baseMapView.Zoom(deltaZoom, targetPos, durationSeconds);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Rotates the view relative to the current rotation value. Positive values rotate clockwise, negative values counterclockwise.
 /// The new calculated rotation value will be wrapped to the range of (-180 .. 180]. Rotations are ignored if Options::setRotatable
 /// is set to false.
 ///
 /// Rotating is done around the specified target position, keeping it at the same location on the screen.
 ///
 /// If durationSeconds &gt; 0 the rotating operation will be animated over time. If the previous rotating animation has not
 /// finished by the time this method is called, it will be stopped.
 /// </summary>
 /// <param name="deltaAngle">The delta angle value in degrees.</param>
 /// <param name="targetPos">The zooming target position in the coordinate system of the base projection.</param>
 /// <param name="durationSeconds">The duration in which the zooming operation will be completed in seconds.</param>
 public void Rotate(float deltaAngle, MapPos targetPos, float durationSeconds)
 {
     _baseMapView.Rotate(deltaAngle, targetPos, durationSeconds);
 }
Ejemplo n.º 8
0
 public void AddTurret(Turret turret, MapPos position, ProjectileManager projectiles)
 {
     Turrets.Add(new TurretInstance(turret, position, LevelDesc, projectiles));
 }
        void OnPermissionGranted()
        {
            if (!MapView.FocusPos.Equals(position))
            {
                position = MapView.FocusPos;
                number++;

                Android.Graphics.Bitmap image = BitmapUtils.CreateAndroidBitmapFromBitmap(bitmap);

                string folder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
                string filename = number + ".png";

                string path = Path.Combine(folder, filename);

                string message = null;

                try
                {
                    using (var stream = new FileStream(path, FileMode.Create))
                    {
                        image.Compress(Android.Graphics.Bitmap.CompressFormat.Jpeg, 100, stream);
                    }
                }
                catch (Exception e)
                {
                    message = e.Message;
                }

                Share(path);

                if (message == null)
                {
                    Alert("Great success! Screenshot saved to: " + path);
                }
                else {
                    Alert("Error! " + message);
                }
            }
        }
Ejemplo n.º 10
0
 public void SetStopMarker(MapPos pos)
 {
     stopMarker.SetPos(pos);
     stopMarker.Visible = true;
 }
Ejemplo n.º 11
0
        public void CreateRoutePoint(MapPos pos, RoutingInstruction instruction, LocalVectorDataSource source)
        {
            MarkerStyle style = instructionUp;
            string      str   = "";

            switch (instruction.Action)
            {
            case RoutingAction.RoutingActionHeadOn:
                str = "head on";
                break;

            case RoutingAction.RoutingActionFinish:
                str = "finish";
                break;

            case RoutingAction.RoutingActionTurnLeft:
                style = instructionLeft;
                str   = "turn left";
                break;

            case RoutingAction.RoutingActionTurnRight:
                style = instructionRight;
                str   = "turn right";
                break;

            case RoutingAction.RoutingActionUturn:
                str = "u turn";
                break;

            case RoutingAction.RoutingActionNoTurn:
            case RoutingAction.RoutingActionGoStraight:
                //style = instructionUp;
                //str = "continue";
                break;

            case RoutingAction.RoutingActionReachViaLocation:
                style = instructionUp;
                str   = "stopover";
                break;

            case RoutingAction.RoutingActionEnterAgainstAllowedDirection:
                str = "enter against allowed direction";
                break;

            case RoutingAction.RoutingActionLeaveAgainstAllowedDirection:
                break;

            case RoutingAction.RoutingActionEnterRoundabout:
                str = "enter roundabout";
                break;

            case RoutingAction.RoutingActionStayOnRoundabout:
                str = "stay on roundabout";
                break;

            case RoutingAction.RoutingActionLeaveRoundabout:
                str = "leave roundabout";
                break;

            case RoutingAction.RoutingActionStartAtEndOfStreet:
                str = "start at end of street";
                break;
            }

            if (str != "")
            {
                Marker       marker = new Marker(pos, style);
                BalloonPopup popup2 = new BalloonPopup(marker, balloonBuilder.BuildStyle(), str, "");

                source.Add(popup2);
                source.Add(marker);
            }
        }
        int CheckCastleSpot(Game game, Player player, MapPos position, int intelligence)
        {
            var map = game.Map;

            int treeCount         = map.FindInArea(position, 5, FindTree, 1).Count;
            int stoneCount        = map.FindInArea(position, 5, FindStone, 1).Count;
            int fishCount         = map.FindInArea(position, 7, FindFish, 1).Count;
            int mountainCountNear = map.FindInArea(position, 3, FindMountain, 0).Count;
            int mountainCountFar  = map.FindInArea(position, 9, FindMountain, 4).Count;
            int desertCount       = map.FindInArea(position, 6, FindDesert, 0).Count;
            int waterCount        = map.FindInArea(position, 6, FindWater, 0).Count;

            int numLargeSpots         = 3;
            int numSmallSpots         = 3;
            int keepDistanceToEnemies = 30 - (aggressivity / 2) * 10;

            if (player.InitialSupplies < 5)
            {
                // we need coal and iron close enough when starting with low supplies
                var minerals = map.FindInArea(position, 9, FindMineral, 1).Select(m => (KeyValuePair <Map.Minerals, uint>)m);

                int ironCount = minerals.Where(m => m.Key == Map.Minerals.Iron).Select(m => (int)m.Value).Sum();
                int coalCount = minerals.Where(m => m.Key == Map.Minerals.Coal).Select(m => (int)m.Value).Sum();

                if (ironCount == 0 || coalCount == 0)
                {
                    return(-1);
                }
            }
            else // good amount of starting resources
            {
                if (map.Size > 5)
                {
                    if (treeCount < 12 || stoneCount < 6)
                    {
                        return(-1);
                    }
                }
                else if (map.Size == 5)
                {
                    if (treeCount < 9 || stoneCount < 5)
                    {
                        return(-1);
                    }
                }
                else if (map.Size == 4)
                {
                    if (treeCount < 7 || stoneCount < 4)
                    {
                        return(-1);
                    }
                }
            }

            // if we tried too often we will only assure that there is a bit of trees and stones
            if (numTries >= 25 + map.Size * 5)
            {
                if (treeCount < 5 || stoneCount < 2)
                {
                    return(-1);
                }

                if (numTries < 500)            // after 500 tries, just place it somewhere
                {
                    if (mountainCountNear > 7) // too close to mountain
                    {
                        return(-1);
                    }

                    if (desertCount > 6) // too much desert
                    {
                        return(-1);
                    }

                    if (waterCount > 8) // too much water
                    {
                        return(-1);
                    }

                    if (player.InitialSupplies < 3) // with 3 or more we have 1 iron ore and 1 coal
                    {
                        if (fishCount == 0 || stoneCount < 2 || treeCount < 5)
                        {
                            return(-1);
                        }
                    }

                    numLargeSpots = 2; // the toolmaker can be build when we have expanded the land

                    if (numTries >= 80 && player.InitialSupplies > 4)
                    {
                        numLargeSpots = 1; // we need to expand the territory to build the sawmill
                    }
                    if (game.Map.Size < 5)
                    {
                        // in small maps we no longer force enemy distance after many tries
                        if (numTries >= 120)
                        {
                            keepDistanceToEnemies = 0;
                        }
                        else if (numTries >= 80)
                        {
                            keepDistanceToEnemies = 15;
                        }
                    }
                    else if (numTries >= 200) // if tried very long we will have mercy in any case
                    {
                        keepDistanceToEnemies = 0;
                    }
                }
            }
            else
            {
                if (mountainCountNear > 4) // too close to mountain
                {
                    return(-1);
                }

                if (desertCount > 3) // too much desert
                {
                    return(-1);
                }

                if (desertCount + waterCount + mountainCountNear + mountainCountFar > 10) // too much desert/water/mountain
                {
                    return(-1);
                }

                var minerals = map.FindInArea(position, 9, FindMineral, 1).Select(m => (KeyValuePair <Map.Minerals, uint>)m);

                int stoneOreCount = minerals.Where(m => m.Key == Map.Minerals.Stone).Select(m => (int)m.Value).Sum();
                int goldCount     = minerals.Where(m => m.Key == Map.Minerals.Gold).Select(m => (int)m.Value).Sum();
                int ironCount     = minerals.Where(m => m.Key == Map.Minerals.Iron).Select(m => (int)m.Value).Sum();
                int coalCount     = minerals.Where(m => m.Key == Map.Minerals.Coal).Select(m => (int)m.Value).Sum();

                if (player.InitialSupplies < 5)
                {
                    if (treeCount < 8 || stoneCount < 4 || fishCount < 1 || ironCount == 0 || coalCount == 0)
                    {
                        return(-1);
                    }
                }

                // low intelligence will treat half the mountains as the right mineral without checking
                int halfMountainCount = (mountainCountNear + mountainCountFar) / 2;

                int minConstructionCount = 3 + intelligence / 10 + Math.Max(buildingFocus, constructionMaterialFocus) * 5;

                if (treeCount + stoneCount + Math.Max(halfMountainCount, stoneOreCount) < minConstructionCount)
                {
                    return(-1);
                }

                int minFishCount = foodFocus * 5 + (player.InitialSupplies < 5 ? 1 : 0);

                if (fishCount < minFishCount)
                {
                    return(-1);
                }

                int minSteelCount = Math.Max(steelFocus, militaryFocus / 2) * 2;
                int steelOreCount = (intelligence < 20) ? Math.Max(halfMountainCount, ironCount + coalCount) : ironCount + coalCount;

                if (steelOreCount < minSteelCount)
                {
                    return(-1);
                }

                int minGoldCount = goldFocus / 2;
                int goldOreCount = (intelligence < 20) ? Math.Max(halfMountainCount, goldCount) : ironCount + coalCount;

                if (goldCount < minGoldCount)
                {
                    return(-1);
                }
            }

            if (keepDistanceToEnemies > 0 && numTries < 1000)
            {
                for (uint i = 0; i < game.PlayerCount; ++i)
                {
                    var enemy = game.GetPlayer(i);

                    if (enemy == player || !enemy.HasCastle)
                    {
                        continue;
                    }

                    int distance = Math.Min(Math.Abs(game.Map.DistanceX(position, enemy.CastlePosition)), Math.Abs(game.Map.DistanceY(position, enemy.CastlePosition)));

                    if (distance < keepDistanceToEnemies)
                    {
                        return(-1);
                    }
                }
            }

            // check if we can build at least: lumberjack, stonecutter, sawmill, toolmaker and one hut
            // -> 3 small and 2 large buildings
            // but we check the castle too, so 3 large buildings
            int         numSmall   = 0;
            int         numLarge   = 0;
            List <uint> largeSpots = new List <uint>();

            for (int i = 0; i < 100; ++i)
            {
                uint checkPosition = map.PositionAddSpirally(position, (uint)i);

                if (game.CanBuildLarge(checkPosition))
                {
                    ++numSmall;
                    ++numLarge;
                    largeSpots.Add(checkPosition);
                }
                else if (game.CanBuildSmall(checkPosition))
                {
                    ++numSmall;
                }

                // TODO: What if a building would block another building spot.
                if (numLarge >= numLargeSpots && (numSmall - numLargeSpots) >= numSmallSpots)
                {
                    return((int)largeSpots[0]);
                }
            }

            return(-1);
        }
Ejemplo n.º 13
0
        static Point GetPoint(Projection projection, MapPos position, Color color)
        {
            PointStyleBuilder pointStyleBuilder = new PointStyleBuilder();
            pointStyleBuilder.Color = color;
            pointStyleBuilder.Size = 16;

            return new Point(projection.FromWgs84(position), pointStyleBuilder.BuildStyle());
        }
Ejemplo n.º 14
0
        static Marker GetMarker(Projection projection, MapPos position, Bitmap image)
        {
            //TODO
            //Bitmap androidMarkerBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.marker);
            //com.carto.graphics.Bitmap markerBitmap = BitmapUtils.createBitmapFromAndroidBitmap(androidMarkerBitmap);

            // Create marker style
            MarkerStyleBuilder builder = new MarkerStyleBuilder();
            builder.Bitmap = image;
            builder.Size = 30;

            MarkerStyle style = builder.BuildStyle();

            // Create and return marker
            return new Marker(projection.FromWgs84(position), style);
        }
Ejemplo n.º 15
0
 bool FindMountainWithFlag(Map map, MapPos position)
 {
     return(FindMountain(map, position, true));
 }
Ejemplo n.º 16
0
 public DirectionCycleCCW(Direction start, MapPos length)
     : base(start, length)
 {
 }
Ejemplo n.º 17
0
 public static void AnimateZoomTo(this MapView map, MapPos position)
 {
     position = map.Options.BaseProjection.FromWgs84(new MapPos(24.650415, 59.428773));
     map.SetFocusPos(position, 2);
     map.Zoom = 14;
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Extract column from MapPos.
 /// </summary>
 /// <param name="position"></param>
 /// <returns></returns>
 public uint PositionColumn(MapPos position)
 {
     return(position & ColumnMask);
 }
Ejemplo n.º 19
0
        public RoutingResult GetResult(MapPos startPos, MapPos stopPos)
        {
            MapPosVector poses = new MapPosVector();

            poses.Add(startPos);
            poses.Add(stopPos);

            RoutingRequest request = new RoutingRequest(BaseProjection, poses);

            return Service.CalculateRoute(request);
        }
Ejemplo n.º 20
0
 /// <summary>
 /// Extract row from MapPos.
 /// </summary>
 /// <param name="position"></param>
 /// <returns></returns>
 public uint PositionRow(MapPos position)
 {
     return((position >> RowShift) & RowMask);
 }
Ejemplo n.º 21
0
        public void CreateRoutePoint(MapPos pos, RoutingInstruction instruction, LocalVectorDataSource source)
        {
            MarkerStyle style = instructionUp;
            string str = "";

            switch (instruction.Action)
            {
                case RoutingAction.RoutingActionHeadOn:
                    str = "head on";
                    break;
                case RoutingAction.RoutingActionFinish:
                    str = "finish";
                    break;
                case RoutingAction.RoutingActionTurnLeft:
                    style = instructionLeft;
                    str = "turn left";
                    break;
                case RoutingAction.RoutingActionTurnRight:
                    style = instructionRight;
                    str = "turn right";
                    break;
                case RoutingAction.RoutingActionUturn:
                    str = "u turn";
                    break;
                case RoutingAction.RoutingActionNoTurn:
                case RoutingAction.RoutingActionGoStraight:
                    //style = instructionUp;
                    //str = "continue";
                    break;
                case RoutingAction.RoutingActionReachViaLocation:
                    style = instructionUp;
                    str = "stopover";
                    break;
                case RoutingAction.RoutingActionEnterAgainstAllowedDirection:
                    str = "enter against allowed direction";
                    break;
                case RoutingAction.RoutingActionLeaveAgainstAllowedDirection:
                    break;
                case RoutingAction.RoutingActionEnterRoundabout:
                    str = "enter roundabout";
                    break;
                case RoutingAction.RoutingActionStayOnRoundabout:
                    str = "stay on roundabout";
                    break;
                case RoutingAction.RoutingActionLeaveRoundabout:
                    str = "leave roundabout";
                    break;
                case RoutingAction.RoutingActionStartAtEndOfStreet:
                    str = "start at end of street";
                    break;
            }

            if (str != "")
            {
                Marker marker = new Marker(pos, style);
                BalloonPopup popup2 = new BalloonPopup(marker, balloonBuilder.BuildStyle(), str, "");

                source.Add(popup2);
                source.Add(marker);
            }
        }
Ejemplo n.º 22
0
 /// <summary>
 /// Addition of two map positions.
 /// </summary>
 /// <param name="position"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <returns></returns>
 public MapPos PositionAdd(MapPos position, int x, int y)
 {
     return(Position((uint)((int)Columns + (int)PositionColumn(position) + x) & ColumnMask, (uint)((int)Rows + (int)PositionRow(position) + y) & RowMask));
 }
Ejemplo n.º 23
0
        private static void ThreeZoneIntercalibration(string [] args, ref SySal.DAQSystem.Scanning.IntercalibrationInfo intercal, bool rewrite)
        {
            int i, n;
            int MinMatches = Convert.ToInt32(args[11]);

            SySal.Processing.QuickMapping.QuickMapper   QMap = new SySal.Processing.QuickMapping.QuickMapper();
            SySal.Processing.QuickMapping.Configuration C    = (SySal.Processing.QuickMapping.Configuration)QMap.Config;
            C.PosTol    = Convert.ToDouble(args[8], System.Globalization.CultureInfo.InvariantCulture);
            C.SlopeTol  = Convert.ToDouble(args[9], System.Globalization.CultureInfo.InvariantCulture);
            QMap.Config = C;
            double ZProj     = Convert.ToDouble(args[7], System.Globalization.CultureInfo.InvariantCulture);
            double maxoffset = Convert.ToDouble(args[10], System.Globalization.CultureInfo.InvariantCulture);

            MapPos [] mappositions = new MapPos[3];

            SySal.Scanning.Plate.IO.OPERA.LinkedZone [] savezones = new SySal.Scanning.Plate.IO.OPERA.LinkedZone[3];
            for (n = 0; n < 3; n++)
            {
                SySal.Scanning.Plate.IO.OPERA.LinkedZone reflz   = (SySal.Scanning.Plate.IO.OPERA.LinkedZone)SySal.OperaPersistence.Restore(args[1 + n * 2], typeof(SySal.Scanning.Plate.IO.OPERA.LinkedZone));
                SySal.Tracking.MIPEmulsionTrackInfo []   refzone = new SySal.Tracking.MIPEmulsionTrackInfo[reflz.Length];
                for (i = 0; i < refzone.Length; i++)
                {
                    refzone[i] = reflz[i].Info;
                }
                reflz = null;
                SySal.Scanning.Plate.IO.OPERA.LinkedZone caliblz = (SySal.Scanning.Plate.IO.OPERA.LinkedZone)SySal.OperaPersistence.Restore(args[2 + n * 2], typeof(SySal.Scanning.Plate.IO.OPERA.LinkedZone));
                if (rewrite)
                {
                    savezones[n] = caliblz;
                }
                SySal.Tracking.MIPEmulsionTrackInfo [] calibzone = new SySal.Tracking.MIPEmulsionTrackInfo[caliblz.Length];
                for (i = 0; i < calibzone.Length; i++)
                {
                    calibzone[i] = caliblz[i].Info;
                }
                caliblz = null;
                GC.Collect();
                Console.Write("Zone #" + n.ToString() + " ");
                SySal.Scanning.PostProcessing.PatternMatching.TrackPair [] pairs = QMap.Match(refzone, calibzone, ZProj, maxoffset, maxoffset);
                if (pairs.Length < MinMatches)
                {
                    Console.Error.WriteLine("Too few matching tracks: " + MinMatches.ToString() + " required, " + pairs.Length + " obtained. Aborting.");
                    return;
                }
                Console.WriteLine("Matches: " + pairs.Length);
                mappositions[n].SetFromPairs(pairs);
                mappositions[n].X -= intercal.RX;
                mappositions[n].Y -= intercal.RY;
            }
            double x20 = mappositions[2].X - mappositions[0].X;
            double x10 = mappositions[1].X - mappositions[0].X;
            double y20 = mappositions[2].Y - mappositions[0].Y;
            double y10 = mappositions[1].Y - mappositions[0].Y;
            double det = 1.0 / (x10 * y20 - x20 * y10);
            double u20 = mappositions[2].DX - mappositions[0].DX;
            double v20 = mappositions[2].DY - mappositions[0].DY;
            double u10 = mappositions[1].DX - mappositions[0].DX;
            double v10 = mappositions[1].DY - mappositions[0].DY;

            intercal.MXX  = (u10 * y20 - u20 * y10) * det;
            intercal.MXY  = (u20 * x10 - u10 * x20) * det;
            intercal.MYX  = (v10 * y20 - v20 * y10) * det;
            intercal.MYY  = (v20 * x10 - v10 * x20) * det;
            intercal.TX   = mappositions[0].DX - intercal.MXX * mappositions[0].X - intercal.MXY * mappositions[0].Y;
            intercal.TY   = mappositions[0].DY - intercal.MYX * mappositions[0].X - intercal.MYY * mappositions[0].Y;
            intercal.MXX += 1.0;
            intercal.MYY += 1.0;
            CheckIntercalibration(intercal);
            if (rewrite)
            {
                MyTransformation.Transformation = intercal;
                for (n = 0; n < 3; n++)
                {
                    SySal.OperaPersistence.Persist(args[2 + n * 2], new LinkedZone(savezones[n]));
                }
            }
        }
Ejemplo n.º 24
0
 /// <summary>
 /// Addition of two map positions.
 /// </summary>
 /// <param name="position"></param>
 /// <param name="offset"></param>
 /// <returns></returns>
 public MapPos PositionAdd(MapPos position, MapPos offset)
 {
     return(Position((PositionColumn(position) + PositionColumn(offset)) & ColumnMask,
                     (PositionRow(position) + PositionRow(offset)) & RowMask));
 }
Ejemplo n.º 25
0
 /// <summary>
 /// Sets the new absolute focus position. The new focus position is expected to be in
 /// the coordinate system of the base projection. The new focus position will be clamped to
 /// the world bounds and to the bounds set by Options::setPanBounds.
 ///
 /// If durationSeconds &gt; 0 the panning operation will be animated over time. If the previous panning animation has not
 /// finished by the time this method is called, it will be stopped.
 /// </summary>
 /// <param name="pos">The new focus point position in base coordinate system.</param>
 /// <param name="durationSeconds">The duration in which the tilting operation will be completed in seconds.</param>
 public void SetFocusPos(MapPos pos, float durationSeconds)
 {
     _baseMapView.SetFocusPos(pos, durationSeconds);
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Shortest signed distance between map positions.
 /// </summary>
 /// <param name="position1"></param>
 /// <param name="position2"></param>
 /// <returns></returns>
 public int DistanceX(MapPos position1, MapPos position2)
 {
     return((int)Columns / 2 - (int)(((int)Columns / 2 + (int)PositionColumn(position1) - (int)PositionColumn(position2)) & ColumnMask));
 }
Ejemplo n.º 27
0
 /// <summary>
 /// Sets the new absolute rotation value. 0 means look north, 90 means west, -90 means east and 180 means south.
 /// The rotation value will be wrapped to the range of (-180 .. 180]. Rotations are ignored if Options::setRotatable
 /// is set to false.
 ///
 /// Rotating is done around the specified target position, keeping it at the same location on the screen.
 ///
 /// If durationSeconds &gt; 0 the rotating operation will be animated over time. If the previous rotating animation has not
 /// finished by the time this method is called, it will be stopped.
 /// </summary>
 /// <param name="angle">The new absolute rotation angle value in degrees.</param>
 /// <param name="targetPos">The zooming target position in the coordinate system of the base projection.</param>
 /// <param name="durationSeconds">The duration in which the zooming operation will be completed in seconds.</param>
 public void SetMapRotation(float angle, MapPos targetPos, float durationSeconds)
 {
     _baseMapView.SetRotation(angle, targetPos, durationSeconds);
 }
Ejemplo n.º 28
0
 public int DistanceY(MapPos position1, MapPos position2)
 {
     return((int)Rows / 2 - (int)(((int)Rows / 2 + (int)PositionRow(position1) - (int)PositionRow(position2)) & RowMask));
 }
Ejemplo n.º 29
0
 /// <summary>
 /// Sets the new absolute zoom value. The minimum zoom value is 0, which means absolutely zoomed out and the maximum
 /// zoom value is 24. The zoom value can be further constrained by the Options::setZoomRange method. Values
 /// exceeding these ranges will be clamped.
 ///
 /// Zooming is done towards the specified target position, keeping it at the same location on the screen.
 ///
 /// If durationSeconds &gt; 0, the zooming operation will be animated over time. If the previous zooming animation has not
 /// finished by the time this method is called, it will be stopped.
 /// </summary>
 /// <param name="zoom">The new absolute zoom value.</param>
 /// <param name="targetPos">The zooming target position in the coordinate system of the base projection.</param>
 /// <param name="durationSeconds">The duration in which the zooming operation will be completed in seconds.</param>
 public void SetZoom(float zoom, MapPos targetPos, float durationSeconds)
 {
     _baseMapView.SetZoom(zoom, targetPos, durationSeconds);
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Movement of map position according to directions.
 /// </summary>
 /// <param name="position"></param>
 /// <param name="direction"></param>
 /// <returns></returns>
 public MapPos Move(MapPos position, Direction direction)
 {
     return(PositionAdd(position, directions[(int)direction]));
 }
Ejemplo n.º 31
0
 bool FindMountain(Map map, MapPos position)
 {
     return(FindMountain(map, position, false));
 }
Ejemplo n.º 32
0
 public MapPos MoveRight(MapPos position)
 {
     return(Move(position, Direction.Right));
 }
        public static void ShowResult(this LocalVectorDataSource source, MapView map, GeocodingResult result, string title, string description, bool goToPosition)
        {
            source.Clear();

            var builder = new BalloonPopupStyleBuilder();

            builder.LeftMargins  = new BalloonPopupMargins(0, 0, 0, 0);
            builder.TitleMargins = new BalloonPopupMargins(6, 3, 6, 3);
            builder.CornerRadius = 5;
            // Make sure this label is shown on top of all other labels
            builder.PlacementPriority = 10;

            FeatureCollection collection = result.FeatureCollection;
            int count = collection.FeatureCount;

            MapPos   position = new MapPos();
            Geometry geometry;

            for (int i = 0; i < count; i++)
            {
                geometry = collection.GetFeature(i).Geometry;
                var color = new Carto.Graphics.Color(0, 100, 200, 150);

                var pointBuilder = new PointStyleBuilder();
                pointBuilder.Color = color;

                var lineBuilder = new LineStyleBuilder();
                lineBuilder.Color = color;

                var polygonBuilder = new PolygonStyleBuilder();
                polygonBuilder.Color = color;

                VectorElement element = null;

                if (geometry is PointGeometry)
                {
                    element = new Point(geometry as PointGeometry, pointBuilder.BuildStyle());
                }
                else if (geometry is LineGeometry)
                {
                    element = new Line(geometry as LineGeometry, lineBuilder.BuildStyle());
                }
                else if (geometry is PolygonGeometry)
                {
                    element = new Polygon(geometry as PolygonGeometry, polygonBuilder.BuildStyle());
                }
                else if (geometry is MultiGeometry)
                {
                    var collectionBuilder = new GeometryCollectionStyleBuilder();
                    collectionBuilder.PointStyle   = pointBuilder.BuildStyle();
                    collectionBuilder.LineStyle    = lineBuilder.BuildStyle();
                    collectionBuilder.PolygonStyle = polygonBuilder.BuildStyle();

                    element = new GeometryCollection(geometry as MultiGeometry, collectionBuilder.BuildStyle());
                }

                if (element != null)
                {
                    position = geometry.CenterPos;
                    source.Add(element);
                }
            }

            if (goToPosition)
            {
                map.SetFocusPos(position, 1.0f);
                map.SetZoom(16, 1.0f);
            }

            var popup = new BalloonPopup(position, builder.BuildStyle(), title, description);

            source.Add(popup);
        }
Ejemplo n.º 34
0
 public MapPos MoveDown(MapPos position)
 {
     return(Move(position, Direction.Down));
 }
Ejemplo n.º 35
0
 public static long CreateIndex(MapPos position, Direction direction)
 {
     return((((long)direction) << 32) | position);
 }
Ejemplo n.º 36
0
 public MapPos MoveLeft(MapPos position)
 {
     return(Move(position, Direction.Left));
 }
Ejemplo n.º 37
0
 public void SetStopMarker(MapPos pos)
 {
     stopMarker.SetPos(pos);
     stopMarker.Visible = true;
 }
Ejemplo n.º 38
0
 public MapPos MoveUp(MapPos position)
 {
     return(Move(position, Direction.Up));
 }
Ejemplo n.º 39
0
 public void SetStartMarker(MapPos startPos)
 {
     routeDataSource.Clear();
     stopMarker.Visible = false;
     startMarker.SetPos(startPos);
     startMarker.Visible = true;
 }
Ejemplo n.º 40
0
 public MapPos MoveRightN(MapPos position, int count)
 {
     return(PositionAdd(position, (MapPos)(directions[(int)Direction.Right] * count)));
 }
Ejemplo n.º 41
0
        // Creates a line from GraphHopper response
        protected Line CreatePolyline(MapPos start, MapPos end, RoutingResult result, Color darkGray)
        {
            LineStyleBuilder lineStyleBuilder = new LineStyleBuilder();
            lineStyleBuilder.Color = darkGray;
            lineStyleBuilder.Width = 12;

            return new Line(result.Points, lineStyleBuilder.BuildStyle());
        }
Ejemplo n.º 42
0
 public MapPos MoveDownN(MapPos position, int count)
 {
     return(PositionAdd(position, (MapPos)(directions[(int)Direction.Down] * count)));
 }
Ejemplo n.º 43
0
 public override void SetCenter(MapPos mapPos)
 {
     mapView.SetFocusPos(mapView.Options.BaseProjection.FromWgs84(mapPos), 1.0f);
 }
 public void ZoomTo(MapPos position)
 {
     MapView.FocusPos = MapView.Options.BaseProjection.FromWgs84(position);
     MapView.SetZoom(12, 2);
 }