public override void Init(MarbleDataBase database)
        {
            base.Init(database);

            var locations = from d in database.Locationdesc
                            select d;
            foreach (Locationdesc location in locations)
            {
                _locationMap.Add(location.Name, location.LocationdescID);
            }

            var images = from d in database.Imagedata
                         select d;
            foreach (ImageData image in images)
            {
                _imageMap.Add(image.Lowresurl, image.ImageDataID);
            }

            var features = from d in database.Featuredesc
                           select d;
            foreach (Featuredesc feature in features)
            {
                _featureMap.Add(feature.LocationID.ToString() + feature.Name, feature.FeaturedescID);
            }
        }
Esempio n. 2
0
        public override void Init(MarbleDataBase database)
        {
            base.Init(database);

            var locations = from d in database.Locationdesc
                           select d;
            _locationSource = locations.ToList();
        }
        public override void Init(MarbleDataBase database)
        {
            base.Init(database);

            var missions = from d in database.Dataset
                           select d;
            _dataSetList = missions.ToList();
        }
Esempio n. 4
0
        public static void FixInvalidHighResUri()
        {
            MarbleDataBase db = new MarbleDataBase();
            var allImages = from image in db.Imagedata select image;

            foreach (ImageData iData in allImages)
            {
                if (!doesUriExist(iData.Highresurl))
                {
                    Console.WriteLine("HighRes url doesn't exist: " + iData.Highresurl);
                    iData.Highresurl = iData.Lowresurl;
                }
            }

            db.SaveChanges();
            Console.WriteLine("Saved changes from UriChecker");
        }
Esempio n. 5
0
        public override void ProcessRecord(string[] tokens)
        {
            currentCount++;

            string locationdesc = tokens[9];
            string featuredesc = tokens[10];

            //this should throw if it doesn't find anything - should never happen
            int locationId = GetLocationID(locationdesc);

            if (!features.Exists(f => f.LocationID == locationId && f.Name == featuredesc))
            {
                Featuredesc feature = new Featuredesc
                {
                    LocationID = locationId,
                    Name = featuredesc
                };

                features.Add(feature);
                _database.Featuredesc.Add(feature);

                if (currentCount > commitCount)
                {
                    _database.SaveChanges();

                    _database.Dispose();
                    _database = new MarbleDataBase();
                    _database.Configuration.AutoDetectChangesEnabled = false;

                    var featurecheck = from f in _database.Featuredesc
                                         where f.FeaturedescID == feature.FeaturedescID
                                         select f;

                    foreach (Featuredesc fcheck in featurecheck)
                    {
                        Console.WriteLine("{0} {1} {2}", fcheck.FeaturedescID, fcheck.LocationID, fcheck.Name);
                    }

                    currentCount = 0;
                }
            }
        }
        public override void ProcessRecord(string[] tokens)
        {
            currentCount++;

            string locationdesc = tokens[9];
            string featuredesc = tokens[10];
            string lowresurl = tokens[11];

            int locationId = _locationMap[locationdesc];

            featuredesc = locationId.ToString() + featuredesc;
            int featureId = _featureMap[featuredesc];

            int imageId = _imageMap[lowresurl];
            _imageMap.Remove(lowresurl);

            Imagexfeature imagexfeature = new Imagexfeature
            {
                ImageDataID = imageId,
                FeaturedescID = featureId,
                Priority = 0
            };

            _database.Imagexfeature.Add(imagexfeature);

            if (currentCount > commitCount)
            {
                _database.SaveChanges();

                _database.Dispose();
                _database = new MarbleDataBase();
                _database.Configuration.AutoDetectChangesEnabled = false;

                Console.WriteLine("{0} {1} {2}", imagexfeature.ImagexfeatureID, imagexfeature.ImageDataID, imagexfeature.FeaturedescID);

                currentCount = 0;
            }
        }
 public AnimationController()
 {
     _database = new MarbleDataBase();
     _gifImageRange = 10; //defaulting to 10
 }
Esempio n. 8
0
 public virtual void Init(MarbleDataBase database)
 {
     _database = database;
 }
 public DatasetController()
 {
     _database = new MarbleDataBase();
 }
Esempio n. 10
0
        private static void executeRowImportProcessor()
        {
            string csvFile = Directory.GetCurrentDirectory() + @"\images.csv";

            Console.WriteLine("CSV File: {0}", csvFile);
            List<ImageData> images = new List<ImageData>();
            DatasetImporter dataSetImporter = new DatasetImporter();
            ImageDataImporter imageDataImporter = new ImageDataImporter();
            LocationImporter locationImporter = new LocationImporter();
            FeatureImporter featureImporter = new FeatureImporter();
            ImageXFeatureImporter imagexFeatureImporter = new ImageXFeatureImporter();

            STARTPROCESSING:
            StreamReader reader = new StreamReader(csvFile);
            MarbleDataBase database = new MarbleDataBase();
            try
            {
                //don't need this line
                string header = reader.ReadLine();

                //this speeds it up
                database.Configuration.AutoDetectChangesEnabled = false;

                //init processor
                switch (ProcessingType)
                {
                    case ProcessorType.DataSet:
                        Console.WriteLine("Data Set Init");
                        dataSetImporter.Init(database);
                        break;
                    case ProcessorType.ImageData:
                        Console.WriteLine("Image Data Init");
                        imageDataImporter.Init(database);
                        break;
                    case ProcessorType.Location:
                        Console.WriteLine("Location Init");
                        locationImporter.Init(database);
                        break;
                    case ProcessorType.Feature:
                        Console.WriteLine("Feature Init");
                        featureImporter.Init(database);
                        break;
                    case ProcessorType.ImageXFeature:
                        Console.WriteLine("Imagexfeature Init");
                        imagexFeatureImporter.Init(database);
                        break;
                }

                do
                {
                    try
                    {
                        string nextLine = reader.ReadLine();
                        string[] tokens = nextLine.Split(',');

                        if (tokens.Length != 12)
                        {
                            Console.WriteLine("Not enough tokens, skipping line: " + tokens.ToString());
                            continue;
                        }
                        string missionDesc = tokens[0];

                        //process data record
                        switch (ProcessingType)
                        {
                            case ProcessorType.DataSet:
                                dataSetImporter.ProcessRecord(tokens);
                                break;
                            case ProcessorType.ImageData:
                                imageDataImporter.ProcessRecord(tokens);
                                break;
                            case ProcessorType.Location:
                                locationImporter.ProcessRecord(tokens);
                                break;
                            case ProcessorType.Feature:
                                featureImporter.ProcessRecord(tokens);
                                break;
                            case ProcessorType.ImageXFeature:
                                imagexFeatureImporter.ProcessRecord(tokens);
                                break;
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(string.Format("Import of row failed with error '{0}'", ex.ToString()));
                    }
                } while (reader.Peek() >= 0);
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR, terminating importer");
                Console.WriteLine(ex);
            }
            finally
            {
                reader.Close();

                //finalize data record
                switch (ProcessingType)
                {
                    case ProcessorType.DataSet:
                        Console.WriteLine("Close up dataset");
                        dataSetImporter.CloseUp();
                        break;
                    case ProcessorType.ImageData:
                        Console.WriteLine("Close up image");
                        imageDataImporter.CloseUp();
                        break;
                    case ProcessorType.Location:
                        Console.WriteLine("Close up locations");
                        locationImporter.CloseUp();
                        break;
                    case ProcessorType.Feature:
                        Console.WriteLine("Close up features");
                        featureImporter.CloseUp();
                        break;
                    case ProcessorType.ImageXFeature:
                        Console.WriteLine("Close up imagexfeature");
                        imagexFeatureImporter.CloseUp();
                        break;
                }

                database.Dispose();
            }

            if (ProcessingType == ProcessorType.DataSet)
            {
                ProcessingType = ProcessorType.ImageData;
                goto STARTPROCESSING;
            }
            if (ProcessingType == ProcessorType.ImageData)
            {
                ProcessingType = ProcessorType.Location;
                goto STARTPROCESSING;
            }
            if (ProcessingType == ProcessorType.Location)
            {
                ProcessingType = ProcessorType.Feature;
                goto STARTPROCESSING;
            }
            if (ProcessingType == ProcessorType.Feature)
            {
                ProcessingType = ProcessorType.ImageXFeature;
                goto STARTPROCESSING;
            }
        }
Esempio n. 11
0
 /// <summary>
 /// Constructor for FeatureController
 /// </summary>
 public FeatureController()
 {
     _database = new MarbleDataBase();
 }
Esempio n. 12
0
        double _defaultRange; // default range of miles used when searching for images using a street address

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Constructor for ImageController
        /// </summary>
        public ImageController()
        {
            _database = new MarbleDataBase();
            _defaultRange = 100; //defaulting to 100 miles
        }
 public LocationController()
 {
     _database = new MarbleDataBase();
 }