コード例 #1
0
        public void AddCoordinates(List <coordinate> coords)
        {
            // Reset Coords
            Coords.Clear();

            // Add each Site
            foreach (var coord in coords)
            {
                _coord c = new _coord();
                c.id      = coord.ID;
                c.placeId = coord.idPlaceInMap;
                double.TryParse(coord.longitude, out c._x);
                double.TryParse(coord.latitude, out c._y);
                c.x = coord.longitude.ToString();
                c.y = coord.latitude.ToString();
                // add to Coords
                Coords.Add(c);

                // Adjust Site's Coord List
                _site site = getSite(coord.idPlaceInMap);
                // assert site is valid
                //Debug.Assert(site != null);
                site.coords.Add(c);
            }

            // prepare Json String for Coordinations
            prepare_Coord_JsonString();
        }
コード例 #2
0
 public void AddCoordinates(Point xy)
 {
     if (!Coords.Contains(xy))
     {
         Coords.Add(xy);
     }
 }
コード例 #3
0
        private void Solver_ResultProduced(SimpleGnssResult entity, ObsFileProcessStreamer <MultiSiteEpochInfo, SimpleGnssResult> streamer)
        {
            if (entity == null)
            {
                return;
            }


            if (entity is SingleSiteGnssResult)
            {
                SingleSiteGnssResult result = entity as SingleSiteGnssResult;
                this.Coords.Add(new NamedRmsXyz(entity.Name, new RmsedXYZ(result.EstimatedXyz, result.EstimatedXyzRms)));
            }

            if (entity is IEstimatedBaseline)
            {
                var result = entity as IEstimatedBaseline;
                this.Coords.Add(new NamedRmsXyz(entity.Name, new RmsedXYZ(result.EstimatedXyzOfRov, XYZ.Parse(entity.ResultMatrix.Estimated.GetRmsVector()))));
            }
            if (this.Coords.Count == 0)
            {
                foreach (var item in streamer.Current)
                {
                    Coords.Add(new NamedRmsXyz(item.SiteName, new RmsedXYZ(item.SiteInfo.ApproxXyz, XYZ.Zero)));
                }
            }
        }
コード例 #4
0
 /// <summary>
 /// 添加一个到序列末尾。
 /// </summary>
 /// <param name="coord"></param>
 public void Add(ICoordinate coord)
 {
     Coords.Add(coord);
     if (SequenceChanged != null)
     {
         SequenceChanged(this, new EventArgs());
     }
 }
コード例 #5
0
 /*Setting up marker for current position*/
 private void SetMarker(LatLng coord, string title)
 {
     GMap.AddMarker(new MarkerOptions()
                    .SetPosition(coord)
                    .SetTitle(title));
     Coords.Add(coord);
     AddNewMarker(coord.Latitude, coord.Longitude);
 }
コード例 #6
0
        public void Triangle(COMApi.InwSimpleVertex v1,
                             COMApi.InwSimpleVertex v2,
                             COMApi.InwSimpleVertex v3)
        {
            Array array_v1 = (Array)(object)v1.coord;
            float v1_x     = (float)(array_v1.GetValue(1));
            float v1_y     = (float)(array_v1.GetValue(2));
            float v1_z     = (float)(array_v1.GetValue(3));

            Array array_v2 = (Array)(object)v2.coord;
            float v2_x     = (float)(array_v2.GetValue(1));
            float v2_y     = (float)(array_v2.GetValue(2));
            float v2_z     = (float)(array_v2.GetValue(3));

            Array array_v3 = (Array)(object)v3.coord;
            float v3_x     = (float)(array_v3.GetValue(1));
            float v3_y     = (float)(array_v3.GetValue(2));
            float v3_z     = (float)(array_v3.GetValue(3));

            //Matrix

            float w1 = matrix[3] * v1_x + matrix[7] * v1_y + matrix[11] * v1_z + matrix[15];

            var v1__x = (matrix[0] * v1_x + matrix[4] * v1_y + matrix[8] * v1_z + matrix[12]) / w1;
            var v1__y = (matrix[1] * v1_x + matrix[5] * v1_y + matrix[9] * v1_z + matrix[13]) / w1;
            var v1__z = (matrix[2] * v1_x + matrix[6] * v1_y + matrix[10] * v1_z + matrix[14]) / w1;


            float w2 = matrix[3] * v2_x + matrix[7] * v2_y + matrix[11] * v2_z + matrix[15];

            var v2__x = (matrix[0] * v2_x + matrix[4] * v2_y + matrix[8] * v2_z + matrix[12]) / w2;
            var v2__y = (matrix[1] * v2_x + matrix[5] * v2_y + matrix[9] * v2_z + matrix[13]) / w2;
            var v2__z = (matrix[2] * v2_x + matrix[6] * v2_y + matrix[10] * v2_z + matrix[14]) / w2;

            float w3 = matrix[3] * v3_x + matrix[7] * v3_y + matrix[11] * v3_z + matrix[15];

            var v3__x = (matrix[0] * v3_x + matrix[4] * v3_y + matrix[8] * v3_z + matrix[12]) / w3;
            var v3__y = (matrix[1] * v3_x + matrix[5] * v3_y + matrix[9] * v3_z + matrix[13]) / w3;
            var v3__z = (matrix[2] * v3_x + matrix[6] * v3_y + matrix[10] * v3_z + matrix[14]) / w3;



            Coords.Add((float)v1__x);
            Coords.Add((float)v1__y);
            Coords.Add((float)v1__z);

            Coords.Add((float)v2__x);
            Coords.Add((float)v2__y);
            Coords.Add((float)v2__z);

            Coords.Add((float)v3__x);
            Coords.Add((float)v3__y);
            Coords.Add((float)v3__z);
        }
コード例 #7
0
            public void Update(TCoord coord, TBot bot)
            {
                if (Coords == null)
                {
                    return;
                }

                if (Coords.Contains(coord))
                {
                    throw new InvalidStateException($"bot {bot.Bid} interferes with other bots at {coord}");
                }

                Coords.Add(coord);
            }
コード例 #8
0
ファイル: Region.cs プロジェクト: tier6tank/DFWV
        internal override void Plus(XDocument xdoc)
        {
            foreach (var element in xdoc.Root.Elements())
            {
                var val = element.Value;
                int valI;
                int.TryParse(val, out valI);

                switch (element.Name.LocalName)
                {
                case "id":
                case "type":
                    break;

                case "coords":
                    if (Coords == null)
                    {
                        Coords = new List <Point>();
                    }
                    foreach (var coordSplit in val.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(coord => coord.Split(',')).Where(coordSplit => coordSplit.Length == 2))
                    {
                        Coords.Add(new Point(Convert.ToInt32(coordSplit[0]), Convert.ToInt32(coordSplit[1])));
                    }
                    break;

                case "population":
                    if (Populations == null)
                    {
                        Populations = new Dictionary <Race, int>();
                    }
                    foreach (var popSplit in val.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(pop => pop.Split(',')).Where(popSplit => popSplit.Length == 3))
                    {
                        if (Populations.ContainsKey(World.Races[Convert.ToInt32(popSplit[0])]))
                        {
                            Populations[World.Races[Convert.ToInt32(popSplit[0])]] += Convert.ToInt32(popSplit[1]);
                        }
                        else
                        {
                            Populations.Add(World.Races[Convert.ToInt32(popSplit[0])], Convert.ToInt32(popSplit[1]));
                        }
                    }
                    break;

                default:
                    DFXMLParser.UnexpectedXmlElement(xdoc.Root.Name.LocalName + "\t" + "Region", element, xdoc.Root.ToString());
                    break;
                }
            }
        }
コード例 #9
0
        public override List <Coords> GenerateCoords()
        {
            while (Coords.Count == 0)
            {
                var generatedCoord = new Coords(Random.Next(0, 9), Random.Next(0, 9)); // Genearte new coordinate

                if (CheckCoordinateOnMap(generatedCoord))
                {
                    continue;                 // Check this coordinate on map
                }
                SetBusyCells(generatedCoord); // Set the cells on the map as busy around the coordinate

                SetShipCells(generatedCoord); // Set coordinate on map to ship

                Coords.Add(generatedCoord);
            }

            return(Coords);
        }
コード例 #10
0
        internal override sealed void Plus(XDocument xdoc)
        {
            foreach (var element in xdoc.Root.Elements())
            {
                var val = element.Value;
                int valI;
                int.TryParse(val, out valI);

                switch (element.Name.LocalName)
                {
                case "id":
                    break;

                case "name":
                    Name = val;
                    break;

                case "coords":
                    if (Coords == null)
                    {
                        Coords = new List <Point>();
                    }
                    foreach (var coordSplit in val.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(coord => coord.Split(',')).Where(coordSplit => coordSplit.Length == 2))
                    {
                        Coords.Add(new Point(Convert.ToInt32(coordSplit[0]), Convert.ToInt32(coordSplit[1])));
                    }
                    break;

                case "type":
                    if (!Types.Contains(val))
                    {
                        Types.Add(val);
                    }
                    Type = Types.IndexOf(val);
                    break;

                default:
                    DFXMLParser.UnexpectedXmlElement(xdoc.Root.Name.LocalName + "\t", element, xdoc.Root.ToString());
                    break;
                }
            }
        }
コード例 #11
0
ファイル: River.cs プロジェクト: tier6tank/DFWV
        public River(XDocument xdoc, World world)
            : base(xdoc, world)
        {
            foreach (var element in xdoc.Root.Elements())
            {
                var val = element.Value.Trim();
                switch (element.Name.LocalName)
                {
                case "id":
                    break;

                case "name":
                    Name = val;
                    break;

                case "name2":
                    AltName = val;
                    break;

                case "coords":
                    if (Coords == null)
                    {
                        Coords = new List <Point3>();
                    }
                    foreach (var coordSplit in val.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(coord => coord.Split(',')).Where(coordSplit => coordSplit.Length == 3))
                    {
                        Coords.Add(new Point3(Convert.ToInt32(coordSplit[0]), Convert.ToInt32(coordSplit[1]), Convert.ToInt32(coordSplit[2])));
                    }
                    break;

                case "elevation":
                    Elevation = val.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(x => Convert.ToInt32(x)).ToList();
                    break;

                default:
                    DFXMLParser.UnexpectedXmlElement(xdoc.Root.Name.LocalName, element, xdoc.Root.ToString());
                    break;
                }
            }
        }
コード例 #12
0
ファイル: Entity.cs プロジェクト: tier6tank/DFWV
        internal override void Plus(XDocument xdoc)
        {
            foreach (var element in xdoc.Root.Elements())
            {
                var val = element.Value;
                int valI;
                int.TryParse(val, out valI);

                switch (element.Name.LocalName)
                {
                case "id":
                    break;

                case "race_id":
                    if (valI != -1 && World.Races.ContainsKey(valI))
                    {
                        Race = World.Races[valI];
                    }
                    break;

                case "type":
                    if (!Types.Contains(val))
                    {
                        Types.Add(val);
                    }
                    _entityType = (short)Types.IndexOf(val);
                    break;

                case "site_link":
                    var newSl = new EntitySiteLink(element, this);
                    if (SiteLinks == null)
                    {
                        SiteLinks = new Dictionary <int, List <EntitySiteLink> >();
                    }
                    if (!SiteLinks.ContainsKey(newSl.LinkType))
                    {
                        SiteLinks.Add(newSl.LinkType, new List <EntitySiteLink>());
                    }
                    SiteLinks[newSl.LinkType].Add(newSl);
                    break;

                case "entity_link":
                    var newEl = new EntityEntityLink(element, this);
                    if (EntityLinks == null)
                    {
                        EntityLinks = new Dictionary <int, List <EntityEntityLink> >();
                    }
                    if (!EntityLinks.ContainsKey(newEl.LinkType))
                    {
                        EntityLinks.Add(newEl.LinkType, new List <EntityEntityLink>());
                    }
                    EntityLinks[newEl.LinkType].Add(newEl);
                    break;

                case "children":
                    ChildrenIDs = val.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => Convert.ToInt32(x)).ToList();
                    break;

                case "worship_id":
                    WorshipHfid = valI;
                    break;

                case "coords":
                    if (Coords == null)
                    {
                        Coords = new List <Point>();
                    }
                    foreach (var coordSplit in val.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(coord => coord.Split(',')).Where(coordSplit => coordSplit.Length == 2))
                    {
                        Coords.Add(new Point(Convert.ToInt32(coordSplit[0]), Convert.ToInt32(coordSplit[1])));
                    }
                    break;

                case "claims":
                    Claims = val.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)
                             .Select(coord => coord.Split(','))
                             .Where(coordSplit => coordSplit.Length == 2)
                             .Select(split => new Point(Convert.ToInt32(split[0]), Convert.ToInt32(split[1])))
                             .ToList();
                    break;

                case "entity_position":
                    var newPosition = new EntityPosition(element, this);
                    if (Positions == null)
                    {
                        Positions = new List <EntityPosition>();
                    }
                    Positions.Add(newPosition);
                    break;

                case "entity_position_assignment":
                    var newPositionAssignment = new EntityPositionAssignment(element, this);
                    if (PositionAssignments == null)
                    {
                        PositionAssignments = new List <EntityPositionAssignment>();
                    }
                    PositionAssignments.Add(newPositionAssignment);
                    break;

                case "histfig_id":
                    if (MemberHfids == null)
                    {
                        MemberHfids = new List <int>();
                    }
                    MemberHfids.Add(valI);
                    break;

                case "histfig_ids":
                    MemberHfids = val.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => Convert.ToInt32(x)).ToList();
                    break;

                case "occasion":
                    var newOccasion = new EntityOccasion(element, this);
                    if (Occasions == null)
                    {
                        Occasions = new List <EntityOccasion>();
                    }
                    Occasions.Add(newOccasion);
                    break;

                default:
                    DFXMLParser.UnexpectedXmlElement(xdoc.Root.Name.LocalName + "\t", element, xdoc.Root.ToString());
                    break;
                }
            }
        }
コード例 #13
0
 public void AddBoatAt(int[] coord)
 {
     Coords.Add(coord);
 }
コード例 #14
0
ファイル: Water.cs プロジェクト: Alan-Baylis/WorldGenerator-1
        public void Add(Position pos, float score)
        {
            if (pos.X == 0 && pos.Z == 0)
            {
                return;
            }

            if (!Coords.Contains(pos))
            {
                Coords.Add(pos);
            }
            _emptyCoords.Remove(pos);
            _heights.Remove(pos);

            var newWaterBlock = false;
            var block         = worldInstance.GetBlock(pos.X, pos.Y, pos.Z);

            switch (block.Type)
            {
            case BlockType.Water1: block = new Block(BlockType.Water4); break;

            case BlockType.Water2: block = new Block(BlockType.Water4); break;

            case BlockType.Water3: block = new Block(BlockType.Water4); break;

            case BlockType.Water4: block = new Block(BlockType.Water7); break;

            case BlockType.Water5: block = new Block(BlockType.Water7); break;

            case BlockType.Water6: block = new Block(BlockType.Water7); break;

            case BlockType.Water7: block = new Block(BlockType.Water); break;

            default:
                block         = new Block(BlockType.Water1);
                newWaterBlock = true;
                break;
            }
            //Log.WriteInfo ($"[Water.Add] Adding {pos}");
            worldInstance.SetBlock(pos.X, pos.Y, pos.Z, block);
            if (block.Type != BlockType.Water)
            {
                if (!_emptyCoords.Contains(pos))
                {
                    _emptyCoords.Add(pos);
                }

                var newScore = CalcScore(pos);
                if (!_heights.ContainsKey(pos))
                {
                    _heights.Add(pos, newScore);
                }
                if (newScore < _minScore)
                {
                    _minScore = newScore;
                    _minPos   = pos;
                }
            }

            if (newWaterBlock)
            {
                var below = worldInstance.GetBlock(pos.X, pos.Y - 1, pos.Z);
                if (below.Type == BlockType.Water)
                {
                    // Mark so we don't render it
                    // TODO - check surrounding blocks
                    worldInstance.SetBlock(pos.X, pos.Y - 1, pos.Z, new Block(BlockType.UnderWater));
                }
                var above = worldInstance.GetBlock(pos.X, pos.Y + 1, pos.Z);
                if (above.IsWater)
                {
                    worldInstance.SetBlock(pos.X, pos.Y, pos.Z, new Block(BlockType.Water));
                    _heights.Remove(pos);
                    _emptyCoords.Remove(pos);
                }

//                if (worldInstance.GetBlock(pos.X-1, pos.Y - 1, pos.Z).IsWater
//                    && worldInstance.GetBlock(pos.X+1, pos.Y - 1, pos.Z).IsWater
//                    && worldInstance.GetBlock(pos.X, pos.Y - 1, pos.Z-1).IsWater
//                    && worldInstance.GetBlock(pos.X, pos.Y - 1, pos.Z+1).IsWater)
//                {
//                    // Lake detected
//                }
            }

            ClearBlockAboveWater(pos.X, pos.Y + 1, pos.Z);
            ClearBlockAboveWater(pos.X, pos.Y + 2, pos.Z);
            ClearBlockAboveWater(pos.X + 1, pos.Y + 1, pos.Z);
            ClearBlockAboveWater(pos.X - 1, pos.Y + 1, pos.Z);
            ClearBlockAboveWater(pos.X, pos.Y + 1, pos.Z + 1);
            ClearBlockAboveWater(pos.X, pos.Y + 1, pos.Z - 1);
            ClearBlockAboveWater(pos.X + 1, pos.Y + 1, pos.Z + 1);
            ClearBlockAboveWater(pos.X + 1, pos.Y + 1, pos.Z - 1);
            ClearBlockAboveWater(pos.X - 1, pos.Y + 1, pos.Z + 1);
            ClearBlockAboveWater(pos.X - 1, pos.Y + 1, pos.Z - 1);

            worldInstance.GlobalMapTerrain.Set(pos.X, pos.Z, RIVER);
            //Log.WriteInfo($"[River.Add] Adding {pos}");

            AddIfEmpty(pos.X, pos.Y - 1, pos.Z);
            AddIfEmpty(pos.X + 1, pos.Y, pos.Z);
            AddIfEmpty(pos.X - 1, pos.Y, pos.Z);
            AddIfEmpty(pos.X, pos.Y, pos.Z + 1);
            AddIfEmpty(pos.X, pos.Y, pos.Z - 1);
            AddIfEmpty(pos.X, pos.Y + 1, pos.Z);

            if (_minPos == pos)
            {
                FindNextLowest();
            }
        }