Exemplo n.º 1
0
 private static void SubmitMessage(Common.DataSphereClient client, double[] coordinate)
 {
     if (coordinate != null)
     {
         Console.WriteLine("GRAPHING COORDINATE: " + coordinate);
         var dataPoint = new DataPointViewModel()
         {
             color          = new DataPointColor(),
             declination    = (float)coordinate[0] / 360.0f,
             rightAscension = (float)(coordinate[1]) / 90.0f
         };
         var message = JsonConvert.SerializeObject(dataPoint);
         client.SendMessageToServerTaskAsync(message);
     }
 }
Exemplo n.º 2
0
        public static void Main(string[] args)
        {
            string filter = String.Empty;

            while (String.IsNullOrWhiteSpace(filter))
            {
                Console.WriteLine("What do you want to display? ");
                filter = Console.ReadLine();
            }

            Common.DataSphereClient client = new Common.DataSphereClient("127.0.0.1", 9001);
            Auth.SetUserCredentials(args[0], args[1], args[2], args[3]);

            var stream = Stream.CreateFilteredStream();

            stream.AddTrack(filter);
            stream.MatchingTweetReceived += (sender, message) =>
            {
                //Console.WriteLine("A tweet containing " + filter + " has been found; the tweet is '" + message.Tweet + "'");
                var tweet = JsonConvert.DeserializeObject <TweetViewModel>(message.Json);
                if (tweet?.place?.boundingBox != null)
                {
                    foreach (var box in tweet.place.boundingBox.coordinates)
                    {
                        foreach (var coordinate in box)
                        {
                            SubmitMessage(client, coordinate);
                            break;
                        }
                    }
                }
                //foreach (var location in message.MatchingLocations)
                //{
                //    SubmitMessage(client, location.Coordinate1);
                //    SubmitMessage(client, location.Coordinate2);
                //}
            };
            stream.StartStreamMatchingAllConditions();

            while (true)
            {
                Task.Delay(1000);
                Console.WriteLine("Waiting...");
            }
        }
Exemplo n.º 3
0
        public static void Main(string[] args)
        {
            Common.DataSphereClient client = new Common.DataSphereClient("127.0.0.1", 9001);
            double    rightAscensionSpeed  = 0.33f;
            double    declinationSpeed     = 0.1f;
            double    rightAscension       = 0;
            double    declination          = -1;
            Stopwatch stopwatch            = new Stopwatch();

            stopwatch.Start();
            Task.Run(async() =>
            {
                while (true)
                {
                    var elapsed = stopwatch.Elapsed;
                    stopwatch.Restart();

                    rightAscension += elapsed.TotalSeconds * rightAscensionSpeed;
                    declination    += elapsed.TotalSeconds * declinationSpeed;

                    while (rightAscension > 1)
                    {
                        rightAscension -= 1;
                    }
                    while (declination > 1)
                    {
                        declination -= 2;
                    }

                    var dataPoint = new DataPointViewModel()
                    {
                        color          = new DataPointColor(),
                        rightAscension = (float)rightAscension,
                        declination    = (float)declination
                    };
                    var message = JsonConvert.SerializeObject(dataPoint);
                    Console.WriteLine("Sending message {0}", message);
                    await client.SendMessageToServerTaskAsync(message);
                }
            }).Wait();
        }