Exemple #1
0
        public void Tag()
        {
            var points   = JsonConvert.DeserializeObject <FeatureCollection>(Tools.GetResource("tagPoints.geojson"));
            var polygons = JsonConvert.DeserializeObject <FeatureCollection>(Tools.GetResource("tagPolygons.geojson"));

            var taggedPoints = Turf.Tag(points, polygons, "polyID", "containingPolyID");

            Assert.AreEqual(taggedPoints.Features.Count, points.Features.Count,
                            "tagged points should have the same length as the input points");

            var count = taggedPoints.Features.Where(x =>
            {
                object val;
                x.Properties.TryGetValue("containingPolyID", out val);
                return(val != null && int.Parse(val.ToString()) == 4);
            }).Count();

            Assert.AreEqual(count, 6, "polygon 4 should have tagged 6 points");
        }