private static PointPolygon ToPointPolygon(Polygon polygon, GeoIndexes indexes)
 {
     return(new PointPolygon
     {
         Points = ToPoints(polygon, indexes).ToArray()
     });
 }
示例#2
0
        public NearestEnumerator(GeoIndexes indexes, Distance resolution)
        {
            this.indexes = indexes ?? throw new ArgumentNullException(nameof(indexes));

            if (resolution <= Distance.FromMetres(0))
            {
                throw new ArgumentOutOfRangeException(nameof(resolution));
            }

            this.resolution = resolution;
        }
        public GeoMapIndex(GeoPoint southWest, GeoPoint northEast, Distance resolution)
        {
            this.resolution = resolution;
            indexes         = new GeoIndexes(southWest, northEast, resolution);
            enumerator      = new NearestEnumerator(indexes, resolution);

            suburbs = new List <Suburb> [indexes.LatitudeIntervalCount][];
            for (var i = 0; i < indexes.LatitudeIntervalCount; i++)
            {
                suburbs[i] = new List <Suburb> [indexes.LongitudeIntervalCount];
            }
        }
        private static IEnumerable <Point> ToPoints(Polygon polygon, GeoIndexes indexes)
        {
            var previous = new Point(-1, -1);

            foreach (var current in polygon.Select(indexes.GetIndex).Select(index => new Point(index.X, index.Y)))
            {
                if (current != previous)
                {
                    yield return(current);
                }
                previous = current;
            }
        }
        public GeoMapIndex(GeoMapData data)
        {
            indexes    = new GeoIndexes(data.GeoIndexes);
            resolution = Distance.FromMetres(data.ResolutionInMetres);
            enumerator = new NearestEnumerator(indexes, resolution);

            suburbs = new List <Suburb> [indexes.LatitudeIntervalCount][];
            for (var i = 0; i < indexes.LatitudeIntervalCount; i++)
            {
                suburbs[i] = new List <Suburb> [indexes.LongitudeIntervalCount];
            }

            PopulateSuburbs(data);
        }
        public void TestCreateFromGeoIndexesData()
        {
            var data = new GeoIndexesData
            {
                LatitudeInterval       = 1.0,
                LongitudeInterval      = 2.0,
                LatitudeIntervalCount  = 1,
                LongitudeIntervalCount = 2,
                SouthWest = new GeoPoint(3, 4)
            };

            var indexes = new GeoIndexes(data);

            Assert.AreEqual(JsonConvert.SerializeObject(data), JsonConvert.SerializeObject(indexes.Dump()));
        }
示例#7
0
 public GeoMapIndexTests()
 {
     indexes    = new GeoIndexes(GeoMapBuilderOptions.AustraliaSouthWest, GeoMapBuilderOptions.AustraliaNorthEast, Distance.FromKilometres(1));
     resolution = Distance.FromKilometres(1);
 }
示例#8
0
 public GeoMapDataDumper(GeoIndexes indexes, Distance resolution, List <Suburb>[][] suburbs)
 {
     this.indexes    = indexes;
     this.resolution = resolution;
     this.suburbs    = suburbs;
 }