private void writeJSON(double[,] y)
        {
            string          output;
            List <tickJSON> List = new List <tickJSON>();

            for (int a = 0; a < y.GetLength(0); a++)
            {
                if (y[a, 3] >= 0)
                {
                    tickJSON tick = new tickJSON();
                    tick.Tick = a.ToString();

                    PointJSON Point = new PointJSON();
                    Point.X = y[a, 1];
                    Point.Y = -y[a, 2];
                    Point.Z = y[a, 3];

                    tick.Points = Point;
                    List.Add(tick);
                }
                else
                {
                    break;
                }
            }

            output = JsonConvert.SerializeObject(List, Formatting.Indented);
            string dir = Path.Combine(Directory.GetParent(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName).Parent.FullName, @"js\coor-map\CoordinateMapper\private\frisbeeValues.json");

            File.WriteAllText(dir, output);
        }
Example #2
0
 public PlayerJSON(List <SpawnPoint> _playerSpawnPoints)
 {
     playerSpawnPoints = new List <PointJSON>();
     foreach (SpawnPoint playerSpawnPoint in _playerSpawnPoints)
     {
         PointJSON pointJSON = new PointJSON(playerSpawnPoint);
         playerSpawnPoints.Add(pointJSON);
     }
 }
Example #3
0
 public PlayerJSON(string _name, List <SpawnPoint> _playerSpawnPoints)
 {
     playerSpawnPoints = new List <PointJSON>();
     name = _name;
     foreach (SpawnPoint playerSpawnPoint in _playerSpawnPoints)
     {
         PointJSON pointJSON = new PointJSON(playerSpawnPoint);
         playerSpawnPoints.Add(pointJSON);
     }
 }
Example #4
0
        public PointJSON GetFilteredList(PointJSON inputlist)
        {
            PointJSON list1 = new PointJSON();

            foreach (Resource resource in inputlist.resources)
            {
                if (filterList.Contains("Orange") && resource.Tags.Contains("Orange"))
                {
                    list1.resources.Add(resource);
                }
                if (filterList.Contains("Blue") && resource.Tags.Contains("Blue"))
                {
                    list1.resources.Add(resource);
                }
            }

            PointJSON list2 = new PointJSON();

            foreach (Resource resource in list1.resources)
            {
                if (filterList.Contains("Buy") && resource.Tags.Contains("Buy"))
                {
                    list2.resources.Add(resource);
                }
                if (filterList.Contains("Rent") && resource.Tags.Contains("Rent"))
                {
                    list2.resources.Add(resource);
                }
                if (filterList.Contains("Service") && resource.Tags.Contains("Service"))
                {
                    list2.resources.Add(resource);
                }
            }

            PointJSON list3 = new PointJSON();

            foreach (Resource resource in list2.resources)
            {
                if (filterList.Contains("Food") && resource.Tags.Contains("Food"))
                {
                    list3.resources.Add(resource);
                }
                if (filterList.Contains("Vehicle") && resource.Tags.Contains("Vehicle"))
                {
                    list3.resources.Add(resource);
                }
                if (filterList.Contains("Misc") && resource.Tags.Contains("Misc"))
                {
                    list3.resources.Add(resource);
                }
            }


            return(list3);
        }
Example #5
0
        public PlayerJSON(string _nombre, List <SpawnPoint> _spawnPoints)
        {
            nombre      = _nombre;
            spawnPoints = new List <PointJSON>();

            foreach (SpawnPoint punto in _spawnPoints)
            {
                PointJSON pjson = new PointJSON(punto);
                spawnPoints.Add(pjson);
            }
        }
Example #6
0
        public async Task <ActionResult> ListView(string city2, string cityLat, string cityLng)
        {
            string radius;

            if (Session["rangevalue"] == null)
            {
                radius = "1000";
            }
            else
            {
                radius = (string)Session["rangevalue"];
            }

            if (cityLat == null || cityLng == null)
            {
                if (Session["sessionlat"] == null || Session["sessionlng"] == null)
                {
                    cityLat = "63.8181";
                    cityLng = "20.3073";
                }
                else
                {
                    cityLat = (string)Session["sessionlat"];
                    cityLng = (string)Session["sessionlng"];
                }
            }
            else
            {
                Session["sessionlat"]  = cityLat;
                Session["sessionlng"]  = cityLng;
                Session["sessioncity"] = city2;
            }
            PointJSON unfilteredList = await service.GetPoints(cityLat, cityLng, radius, new List <string>());

            PointJSON pointsList = GetFilteredList(unfilteredList);

            System.Diagnostics.Debug.WriteLine(pointsList);

            foreach (Resource item in pointsList.resources)
            {
                string distancetopoint = Distance(cityLng, cityLat, item.Location.Longitude, item.Location.Latitude);
                item.Distance = distancetopoint;
            }

            PointJSON sortlist = new PointJSON();

            sortlist.resources = pointsList.resources.OrderBy(o => double.Parse(o.Distance)).ToList();


            ViewBag.Lat = cityLat;
            ViewBag.Lng = cityLng;

            return(View("ListView", model: sortlist.resources));
        }
Example #7
0
        public PlayerJSON(string _name, List <SpawnPoint> _palyerSpawnPoints, List <SpawnPoint> _enemySpawnPoints)
        {
            playerSpawnPoints = new List <PointJSON>();
            enemySpawnPoints  = new List <PointJSON>();
            name = _name;
            foreach (SpawnPoint playerSpawnPoint in _palyerSpawnPoints)
            {
                PointJSON pointJson = new PointJSON(playerSpawnPoint);
                playerSpawnPoints.Add(pointJson);
            }

            foreach (SpawnPoint enemySpawnPoint in _enemySpawnPoints)
            {
                PointJSON pointJson = new PointJSON(enemySpawnPoint);
                enemySpawnPoints.Add(pointJson);
            }
        }
 public PlayerJSON(string _name, string _pword, List <SpawnPoint> _playerSpawnPoints, List <SpawnPoint> _enemySpawnPoints)
 {
     playerSpawnPoints = new List <PointJSON>();
     enemySpawnPoints  = new List <PointJSON>();
     name  = _name;
     pword = _pword;
     foreach (SpawnPoint playerSpawnPoint in _playerSpawnPoints)
     {
         PointJSON pointJSON = new PointJSON(playerSpawnPoint);
         playerSpawnPoints.Add(pointJSON);
     }
     foreach (SpawnPoint enemySpawnPoint in _enemySpawnPoints)
     {
         PointJSON pointJSON = new PointJSON(enemySpawnPoint);
         enemySpawnPoints.Add(pointJSON);
     }
 }
Example #9
0
        public PlayerJSON(string _name, List <SpawnPoint> _playerSpawnPoints, List <SpawnPoint> _enemySpawnPoints)
        {
            playerSpawnPoints = new List <PointJSON>();
            enemySpawnPoints  = new List <PointJSON>();
            name = _name;
            foreach (SpawnPoint playerSpawnPoint in _playerSpawnPoints)
            {
                PointJSON pointJSON = new PointJSON(playerSpawnPoint);
                playerSpawnPoints.Add(pointJSON);
            }

            /*foreach (SpawnPoint enemySpawnPoint in _enemySpawnPoints)
             * {
             *  PointJSON pointJSON = new PointJSON(enemySpawnPoint);
             *  enemySpawnPoints.Add(pointJSON);
             * }*/
        }
Example #10
0
        public PlayerJSON(string _name, List <SpawnPoint> _playerSpawnPoints, List <SpawnPoint> _enemySpawnPoints, string _key, string _nonce)
        {
            playerSpawnPoints = new List <PointJSON>();
            enemySpawnPoints  = new List <PointJSON>();
            name      = _name;
            publicKey = _key;
            nonce     = _nonce;

            foreach (SpawnPoint playerSpawnPoint in _playerSpawnPoints)
            {
                PointJSON pointJSON = new PointJSON(playerSpawnPoint);
                playerSpawnPoints.Add(pointJSON);
            }

            foreach (SpawnPoint enemySpawnPoint in _enemySpawnPoints)
            {
                PointJSON pointJSON = new PointJSON(enemySpawnPoint);
                enemySpawnPoints.Add(pointJSON);
            }
        }
Example #11
0
        public async Task <ActionResult> Index(string city2, string cityLat, string cityLng)
        {
            string radius;

            if (Session["rangevalue"] == null)
            {
                radius = "1000";
            }
            else
            {
                radius = (string)Session["rangevalue"];
            }

            if (cityLat == null || cityLng == null)
            {
                if (Session["sessionlat"] == null || Session["sessionlng"] == null)
                {
                    cityLat = "63.8181";
                    cityLng = "20.3073";
                }
                else
                {
                    cityLat = (string)Session["sessionlat"];
                    cityLng = (string)Session["sessionlng"];
                }
            }
            else
            {
                Session["sessionlat"]  = cityLat;
                Session["sessionlng"]  = cityLng;
                Session["sessioncity"] = city2;
            }

            PointJSON unfilteredList = await service.GetPoints(cityLat, cityLng, radius, new List <string>());

            PointJSON pointsList = GetFilteredList(unfilteredList);

            MapPoints mapPoints = new MapPoints(pointsList.resources.Count);

            int counter = 0;

            foreach (var item in pointsList.resources)
            {
                mapPoints.Features[counter].Geometry.Type           = "Point";
                mapPoints.Features[counter].Geometry.Coordinates[0] = float.Parse(item.Location.Longitude, CultureInfo.InvariantCulture);
                mapPoints.Features[counter].Geometry.Coordinates[1] = float.Parse(item.Location.Latitude, CultureInfo.InvariantCulture);
                mapPoints.Features[counter].Type = "Feature";
                if (item.Tags != null && item.Tags.Count >= 3 &&
                    item.Tags[0] != null && item.Tags[1] != null && item.Tags[2] != null &&
                    (item.Tags[0] == "Orange" || item.Tags[0] == "Blue"))
                {
                    mapPoints.Features[counter].Properties.Category = item.Tags[0] + item.Tags[1] + item.Tags[2];
                    createImage(item.Tags[0], item.Tags[1], item.Tags[2]);
                }
                else
                {
                    mapPoints.Features[counter].Properties.Category = "Gray";
                }
                mapPoints.Features[counter].Properties.Hours       = "N/A";
                mapPoints.Features[counter].Properties.Description = ((item.Description != null) ? item.Description.ToString() : "N/A");
                mapPoints.Features[counter].Properties.Name        = ((item.Title != null) ? item.Title.ToString() : "N/A");
                mapPoints.Features[counter].Properties.Phone       = "N/A";
                counter++;
            }

            string jsonString = JsonConvert.SerializeObject(mapPoints);

            ViewBag.Lat    = cityLat;
            ViewBag.Lng    = cityLng;
            ViewBag.Radius = radius;

            return(View("Index", model: jsonString));
        }