Exemplo n.º 1
0
        public void MemoryDatasource_Add()
        {
            var options        = new Dictionary <string, object>();
            MemoryDatasource d = new MemoryDatasource(options);

            d.Add(1, 2);
            Featureset fs       = d.Featureset();
            Feature    f        = fs.Next();
            string     expected = @"{""type"":""Feature"",""id"":1,""geometry"":{""type"":""Point"",""coordinates"":[1,2]},""properties"":{}}";
            string     json     = f.ToJSON();

            Assert.AreEqual(expected, json);
            // should only have 1 feature
            f = fs.Next();
            Assert.IsNull(f);
        }
Exemplo n.º 2
0
        public void MemoryDatasource_AddWithProps()
        {
            var options        = new Dictionary <string, object>();
            MemoryDatasource d = new MemoryDatasource(options);
            var props          = new Dictionary <string, object>()
            {
                { "string_field", "text" },
                { "int_field", 1 },
                { "double_field", .124 }
            };

            d.Add(1, 2, props);
            Featureset fs       = d.Featureset();
            Feature    f        = fs.Next();
            string     expected = @"{""type"":""Feature"",""id"":1,""geometry"":{""type"":""Point"",""coordinates"":[1,2]},""properties"":{""double_field"":0.124,""int_field"":1,""string_field"":""text""}}";
            string     json     = f.ToJSON();

            Assert.AreEqual(expected, json);
            // should only have 1 feature
            f = fs.Next();
            Assert.IsNull(f);
        }
Exemplo n.º 3
0
        public void Featureset_Creation()
        {
            Mapnik.RegisterDatasource(Path.Combine(Mapnik.Paths["InputPlugins"], "shape.input"));
            Dictionary <string, object> options = new Dictionary <string, object>()
            {
                { "type", "shape" },
                { "file", @".\data\world_merc.shp" }
            };

            Datasource d       = new Datasource(options);
            Featureset fs      = d.Featureset();
            Feature    feature = fs.Next();
            Dictionary <string, object> attr         = new Dictionary <string, object>(feature.Attributes());
            Dictionary <string, object> expectedAttr = new Dictionary <string, object>()
            {
                { "AREA", 44L },
                { "FIPS", "AC" },
                { "ISO2", "AG" },
                { "ISO3", "ATG" },
                { "LAT", 17.078 },
                { "LON", -61.783 },
                { "NAME", "Antigua and Barbuda" },
                { "POP2005", 83039L },
                { "REGION", 19L },
                { "SUBREGION", 29L },
                { "UN", 28L }
            };

            CollectionAssert.AreEquivalent(attr, expectedAttr);

            int count = 1;

            while (fs.Next() != null)
            {
                count++;
            }
            Assert.AreEqual(count, 245);
        }