Пример #1
0
        private void CreateContours(double[,] points, double[] contourX, double[] contourY, double[] contourZ, int gridSize, int steps, ContourType contourType)
        {
            Dictionary <Vector2, List <Vector2> >[] contours = new Dictionary <Vector2, List <Vector2> > [contourZ.Length];

            for (int heightCount = 0; heightCount < contourZ.Length; ++heightCount) //Loop through the different Z height segments
            {
                contours[heightCount] = new Dictionary <Vector2, List <Vector2> >();
            }

            Conrec.Contour(points, contourX, contourY, contourZ, contours); //Get contours for the points. Returns an array of contours for the different heights.

            foreach (Dictionary <Vector2, List <Vector2> > contourList in contours)
            {
                List <List <Vector2> > contourChains = Chains.Process(contourList);
                contourChains = Chains.Simplify(contourChains);

                foreach (List <Vector2> chains in contourChains)
                {
                    List <OSMWayND>  wayPaths = new List <OSMWayND>();
                    List <OSMWayTag> wayTags  = new List <OSMWayTag>();

                    foreach (Vector2 node in chains)
                    {
                        osmNodes.Add(CreateNode(unindexedNodeOffset++, new Vector3((node.x - gridSize) - ((steps * gridSize) / 2), 0, (node.y - gridSize) - ((steps * gridSize) / 2))));
                        wayPaths.Add(new OSMWayND {
                            @ref = (uint)unindexedNodeOffset - 1
                        });
                    }

                    wayPaths.Add(new OSMWayND {
                        @ref = (uint)(unindexedNodeOffset - chains.Count)
                    });                                                                               //Back to the first chain

                    switch (contourType)
                    {
                    case ContourType.Ground:
                        wayTags.Add(new OSMWayTag {
                            k = "natural", v = "coastline"
                        });
                        break;

                    case ContourType.Water:
                        wayTags.Add(new OSMWayTag {
                            k = "natural", v = "water"
                        });
                        break;
                    }

                    osmWays.Add(new OSMWay {
                        changeset = 50000000, id = (uint)unindexedWayOffset++, timestamp = DateTime.Now, user = "******", nd = wayPaths.ToArray(), tag = wayTags.ToArray(), version = 1
                    });
                }
            }
        }