Esempio n. 1
0
        public void query_gemini_records()
        {
            IDocumentStore store = new DocumentStore {
                Url = RavenUrl
            }.Initialize();

            RavenUtility.WaitForIndexing(store);

            string peakDistrictBbox = BoundingBoxUtility.ToWkt(new BoundingBox
            {
                North = 53.6m,
                South = 53.0m,
                East  = -1.52m,
                West  = -2.14m
            });

            Stopwatch watch = Stopwatch.StartNew();

            using (IDocumentSession db = store.OpenSession())
            {
                List <Record> results = db.Query <Record, RecordSpatialIndex>()
                                        .Customize(x => x.RelatesToShape(FieldNames.Spatial, peakDistrictBbox, SpatialRelation.Intersects))
                                        .Where(i => i.Gemini.Title.StartsWith("GA"))
                                        //.Take(10)
                                        .ToList();

                //results.Count().Should().Be(10);
                Console.WriteLine(results.Count);
            }

            Console.WriteLine(watch.ElapsedMilliseconds);
        }
Esempio n. 2
0
        public void load_gemini_records()
        {
            string     dir = @"C:\Users\PETMON\Downloads\nbn-gemini2";
            XNamespace gmd = "http://www.isotc211.org/2005/gmd";

            var q = (from f in Directory.GetFiles(dir, "*.xml")
                     where File.ReadLines(f).Any()
                     let xml = XDocument.Load(f)
                               let p = new
            {
                North = (decimal)xml.Descendants(gmd + "northBoundLatitude").Single(),
                South = (decimal)xml.Descendants(gmd + "southBoundLatitude").Single(),
                East = (decimal)xml.Descendants(gmd + "eastBoundLongitude").Single(),
                West = (decimal)xml.Descendants(gmd + "westBoundLongitude").Single(),
            }
                     where p.North < 61 && p.South > 50 && p.East <2 && p.West> -12
                     // ignore bad data
                     select new
            {
                File = Path.GetFileName(f),
                Wkt = BoundingBoxUtility.ToWkt(new BoundingBox
                {
                    North = p.North,
                    South = p.South,
                    East = p.East,
                    West = p.West,
                })
            })
                    .ToList();

            Console.WriteLine(q.Count());
            q.ForEach(Console.WriteLine);


            IDocumentStore store = new DocumentStore {
                Url = RavenUrl
            }.Initialize();

            using (IDocumentSession db = store.OpenSession())
            {
                foreach (var x in q)
                {
                    var item = new Record
                    {
                        Gemini = new Metadata
                        {
                            Title = x.File,
                        },
                        Wkt = x.Wkt,
                    };

                    db.Store(item);
                }

                db.SaveChanges();
            }

            IndexCreation.CreateIndexes(typeof(Record).Assembly, store);
        }
Esempio n. 3
0
 private static void PerformDenormalizations(Record record)
 {
     // we store the bounding box as wkt so we can index it
     if (!BoundingBoxUtility.IsBlank(record.Gemini.BoundingBox))
     {
         record.Wkt = BoundingBoxUtility.ToWkt(record.Gemini.BoundingBox);
     }
 }
Esempio n. 4
0
        public void should_store_bounding_box_as_wkt()
        {
            var database = Mock.Of <IDocumentSession>();
            var service  = new RecordService(database, ValidatorStub());

            var e      = Library.Example();
            var record = new Record
            {
                Gemini = e,
                Footer = new Footer()
            };

            service.Update(record, TestUser);

            string expectedWkt = BoundingBoxUtility.ToWkt(e.BoundingBox);

            Mock.Get(database).Verify(db => db.Store(It.Is((Record r) => r.Wkt == expectedWkt)));
        }