예제 #1
0
        public void Initialise()
        {
            // A dictionary of week-events
            Events = new EventCollection();

            // Read in the Week 32 logs
            KMLReader w32_reader = new KMLReader(ROOT_DIR + "data\\L_wk32_drops.kml");

            Events.AddRange(w32_reader.GetCallLogs());

            // Read in the Week 33 logs
            KMLReader w33_reader = new KMLReader(ROOT_DIR + "data\\L_wk33_drops.kml");

            Events.AddRange(w33_reader.GetCallLogs());

            // Read in the Week 34 logs
            KMLReader w34_reader = new KMLReader(ROOT_DIR + "data\\L_wk34_drops.kml");

            Events.AddRange(w34_reader.GetCallLogs());

            // Read in the Week 35 logs
            KMLReader w35_reader = new KMLReader(ROOT_DIR + "data\\L_wk35_drops.kml");

            Events.AddRange(w35_reader.GetCallLogs());

            // Initialise the Multi-Product Analysis Object
            Analysis = new MultiProductAnalysis();
            Analysis.AddRange(Events);

            // Cluster the data
            Analysis.Cluster(EPS, MIN_POINTS);

            // Analyse all weeks
            Analysis.AnalyseProducts();
        }
예제 #2
0
        /// <summary>
        /// This method will analyse a given directory. It will firstly scan the
        /// directoy for all kml files. The analysis will produce an output KML
        /// file and a number of output JSON analysis files, depending upon the
        /// runtime options supplied.
        /// </summary>
        private static void AnalyseDirectory()
        {
            String directory = InputArguments["source"];

            EventCollection collection = new EventCollection();

            // Only continue if the input directory exists
            if (!Directory.Exists(directory))
            {
                return;
            }

            // Get a list of all the KML file names within the directory
            String[] files = Directory.GetFiles(directory, "*.kml", SearchOption.TopDirectoryOnly);

            // Loop over each of the file and add to the data
            foreach (String file in files)
            {
                // Parse the KML file
                KMLReader reader = new KMLReader(file);
                // Add the data to the known events
                collection.AddRange(reader.GetCallLogs());
            }

            // Perform the analysis
            PerformAnalysis(collection);
        }
예제 #3
0
        /// <summary>
        /// This is a helper method, to reduce repeating code throughout this Test
        /// class. The objective of this method is to parse a given KML file, and
        /// return an EventCollection object.
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        private EventCollection ReadKMLFile(String file)
        {
            // Create a new KML reader object to read the data
            KMLReader reader = new KMLReader(file);

            // Return a collection of events from the KML file
            return(reader.GetCallLogs());
        }
예제 #4
0
        //Os fluxos abaixo foram executados na ordem em que se apresentam

        //Step 1
        //Busca uma lista de coordenadas no arquivo KML
        //Para cada coordenada busca dados de lugares na api do Foursquare (Parametro true para salvar respostas das consultas no banco de dados, ou nada, para não salvar)
        //Converte o resultado da consulta em um objeto do sistema, verifica se ele já existe no banco e insere (ou não) no banco de dados
        private static void RequestAndStorePlaces(IVenueService venueService)
        {
            IList <string> coordinates = KMLReader.GetCoordiates();

            foreach (var latLon in coordinates)
            {
                RawVanuesData rawVenues = FoursquareClient.GetVenues(latLon, true);
                foreach (var rawVenue in rawVenues.Response.Venues)
                {
                    venueService.Insert(new Venue(rawVenue));
                }
            }
        }
예제 #5
0
        /// <summary>
        /// This method will analyse a given kml file. The analysis will produce
        /// an output KML file and a number of output JSON analysis files,
        /// depending upon the runtime options supplied.
        /// </summary>
        /// <param name="file">The KML file to analyse</param>
        private static void AnalyseFile(String file)
        {
            // Ensure the file exists
            if (!File.Exists(file))
            {
                throw new FileNotFoundException("File does not exist", file);
            }

            // Read in all the known events from the input file
            KMLReader       reader     = new KMLReader(file);
            EventCollection collection = reader.GetCallLogs();

            // Perform the analysis
            PerformAnalysis(collection);
        }
        public void TestZ()
        {
            string kml       = "<Point><coordinates>1.0,1.0,50.0</coordinates></Point>";
            var    kmlReader = new KMLReader();

            try
            {
                var parsedGeometry = kmlReader.Read(kml);
                Assert.AreEqual(50.0, parsedGeometry.Coordinate.Z, "Wrong Z");
            }
            catch (ParseException e)
            {
                throw new AssertionException($"ParseException: {e.Message}", e);
            }
        }
예제 #7
0
        public void Initalise()
        {
            // Read in a Sample KML File
            KMLReader reader = new KMLReader(ROOT_DIR + "data\\L_wk32_drops.kml");
            // Obtain all the events
            EventCollection collection = reader.GetCallLogs();
            // Cluster the Events
            DBSCAN scan = new DBSCAN(collection);

            scan.Analyse();
            // Get a copy of the Clustered Events
            Clusters = scan.Clusters;
            // Get a copy of the Noise Events
            Noise = scan.Noise;
            // Make a new TEMP dir
            Directory.CreateDirectory(OUTPUT_DIR);
        }
        public void TestPrecisionAndSRID()
        {
            string kml             = "<Point><altitudeMode>absolute</altitudeMode><coordinates>1.385093,1.436456</coordinates></Point>";
            var    geometryFactory = new GeometryFactory(new PrecisionModel(1000.0), 4326);
            var    kmlReader       = new KMLReader(geometryFactory);

            try
            {
                var parsedGeometry = kmlReader.Read(kml);
                Assert.AreEqual(geometryFactory.SRID, parsedGeometry.SRID, "Wrong SRID");
                Assert.AreEqual("POINT (1.385 1.436)", parsedGeometry.AsText(), "Wrong precision");
            }
            catch (ParseException e)
            {
                throw new AssertionException($"ParseException: {e.Message}", e);
            }
        }
예제 #9
0
        public void Initialise()
        {
            // Create a new KML Reader
            KMLReader reader = new KMLReader(ROOT_DIR + "data\\L_wk32_drops.kml");

            // Read in all call logs
            EventCollection collection = reader.GetCallLogs();

            // Cluster the call logs
            DBSCAN scan = new DBSCAN(collection);

            scan.Analyse();

            // Initialise the cluster
            Cluster = new EventCollection(scan.Clusters.OrderBy(col => col.Count).Last());

            // Initialise the Cluster analysis
            Analysis = new DropAnalysis(Cluster);
        }
        public void Initialise()
        {
            // Create a new KML Reader
            KMLReader reader = new KMLReader(ROOT_DIR + "data\\L_wk32_drops.kml");

            // Read in all call logs
            EventCollection collection = reader.GetCallLogs();

            // Cluster the call logs
            DBSCAN scan = new DBSCAN(collection);

            scan.Analyse();

            // Initialise the clusters
            Clusters = scan.Clusters;

            // Initialise the analysis
            Analysis = new WeekAnalysis(Clusters, WEEK);
        }
        public void Initialise()
        {
            // Create a new KML Reader
            KMLReader reader = new KMLReader(ROOT_DIR + "data\\L_wk32_drops.kml");

            // Read in all call logs
            EventCollection collection = reader.GetCallLogs();

            collection.ForEach(evt => evt.Device = DEVICE);

            // Cluster the call logs
            DBSCAN scan = new DBSCAN(collection);

            scan.Analyse();

            // Initialise the clusters
            Clusters = scan.Clusters;

            // Initialise the analysis
            Analysis = new ProductAnalysis(Clusters, DEVICE);
        }
        public void Initialise()
        {
            // A dictionary of week-events
            Events = new Dictionary <int, EventCollection>();

            // Read in the Week 32 logs
            KMLReader w32_reader = new KMLReader(ROOT_DIR + "data\\L_wk32_drops.kml");

            Events[32] = w32_reader.GetCallLogs();

            // Read in the Week 33 logs
            KMLReader w33_reader = new KMLReader(ROOT_DIR + "data\\L_wk33_drops.kml");

            Events[33] = w33_reader.GetCallLogs();

            // Read in the Week 34 logs
            KMLReader w34_reader = new KMLReader(ROOT_DIR + "data\\L_wk34_drops.kml");

            Events[34] = w34_reader.GetCallLogs();

            // Read in the Week 35 logs
            KMLReader w35_reader = new KMLReader(ROOT_DIR + "data\\L_wk35_drops.kml");

            Events[35] = w35_reader.GetCallLogs();

            // Initialise the Multi-Week Analysis Object
            Analysis = new MultiWeekAnalysis();
            Analysis.AddRange(Events[32]);
            Analysis.AddRange(Events[33]);
            Analysis.AddRange(Events[34]);
            Analysis.AddRange(Events[35]);

            // Cluster the data
            Analysis.Cluster(EPS, MIN_POINTS);

            // Analyse all weeks
            Analysis.AnalyseWeeks();
        }
        public IHttpActionResult Search([FromUri] SOWTrackSearchFilter filter)
        {
            string accessType = "TaskRoute_ViewAll";

            ThrowIfUserHasNoRole(accessType);
            if (filter == null)
            {
                throw new KairosException("Missing search filter parameter");
            }

            using (var trackSearch = new SOWTrackSearch(Db))
            {
                var data   = trackSearch.GetDataByFilter(filter);
                var xml    = string.Empty;
                var result = new object();

                if (data.Records.Count > 0)
                {
                    xml = data.Records[0].Route;
                    var kml = KMLReader.ConvertToKML(xml);

                    if (filter.Format == 0)
                    {
                        result = kml.GetCoordinates();
                    }
                    else
                    {
                        result = kml;
                    }
                }
                else
                {
                    result = new List <object>();
                }
                return(Ok(result));
            }
        }