public FeatureCacheController(TopologyMap map) { var polyFeatures = new List <Feature>(); var lineFeatures = new List <Feature>(); Debug.WriteLine("Generating FeatureObject"); var sw = Stopwatch.StartNew(); for (var i = 0; i < map.Arcs.Length; i++) { lineFeatures.Add(new Feature(map, i)); } Debug.WriteLine("LineFeature: " + sw.ElapsedMilliseconds + "ms"); LineFeatures = lineFeatures.ToArray(); sw.Restart(); foreach (var i in map.Polygons) { polyFeatures.Add(new Feature(map, LineFeatures, i)); } Debug.WriteLine("PolyFeature: " + sw.ElapsedMilliseconds + "ms"); polyFeatures.AddRange(LineFeatures); Features = polyFeatures.ToArray(); }
public static Location[] ToLocations(this IntVector[] points, TopologyMap map) { var result = new Location[points.Length]; double x = 0; double y = 0; for (var i = 0; i < result.Length; i++) { result[i] = new Location((float)((x += points[i].X) * map.Scale.X + map.Translate.X), (float)((y += points[i].Y) * map.Scale.Y + map.Translate.Y)); } return(result); }
public Feature(TopologyMap map, int index) { Type = map.Arcs[index].IsCoastline ? FeatureType.Coastline : FeatureType.AdminBoundary; //map.Polygons.Count(p => p.Arcs.Any(i => (i < 0 ? Math.Abs(i) - 1 : i) == index)) > 1 ? FeatureType.AdminBoundary : FeatureType.Coastline; Points = map.Arcs[index].Arc.ToLocations(map); IsClosed = Math.Abs(Points[0].Latitude - Points[^ 1].Latitude) < 0.001 &&