Example #1
0
        public TerrainCreator(Map map, IProjection projection, Elevation elevation,
                              Point offset, string modDir) : base(map, projection, elevation)
        {
            this.offset = offset;

            this.modDir          = modDir;
            satAbsoluteOutputDir = Path.Combine(modDir, satOutputDir);

            Utils.DeleteDirectoryContents(satAbsoluteOutputDir);

            ir = new ImageRetrieval
            {
                ImageFormat = MagickFormat.Dds,
                Labeled     = false
            };

            writeDefines = new DdsWriteDefines
            {
                Mipmaps     = 1,
                FastMipmaps = true,
            };

            satMat = MatFile.Open("Assets/sat_image_tmpl.mat");
            satMat.Attributes["aux[0]"][0] = XSize;
            satMat.Attributes["aux[0]"][1] = YSize;

            satTobj = Tobj.Open("Assets/sat_image_tmpl.tobj");
        }
Example #2
0
        /// <summary>
        /// Returns the coordinates of a way's nodes projected and with elevation.
        /// </summary>
        /// <param name="way"></param>
        /// <param name="offsetX"></param>
        /// <param name="offsetY"></param>
        /// <returns></returns>
        public static List<Vector3> ProjectWay(CompleteWay way, Point offset,
            IProjection projection, Elevation elevation, bool fetchElevation = true)
        {
            var nodes = new List<Vector3>();
            for (int i = 0; i < way.Nodes.Length; i++)
            {
                var node = way.Nodes[i];
                // convert to X/Y
                var projPos = projection.Project(node);

                // apply offset
                projPos.X -= offset.X;
                projPos.Y -= offset.Y;

                // flip vertically because Z is down
                projPos.Y *= -1;

                double el = 0;
                if (fetchElevation)
                    el = elevation.GetElevation(node.Latitude.Value, node.Longitude.Value);

                var vector = new Vector3((float)projPos.X, (float)el, (float)projPos.Y);
                nodes.Add(vector);
            }

            return nodes;
        }
Example #3
0
        private static void InitDemNetServices()
        {
            var services = new ServiceCollection().AddLogging(config =>
            {
                //config.AddConsole();
            }).AddDemNetCore().AddSingleton <Elevation>();
            var provider = services.BuildServiceProvider();

            elevation = provider.GetService <Elevation>();
        }
Example #4
0
        /// <summary>
        /// Converts a way into a projected path that includes a point for every elevation change on the path.
        /// </summary>
        /// <param name="way"></param>
        /// <param name="offset"></param>
        /// <param name="projection"></param>
        /// <param name="elevation"></param>
        /// <returns></returns>
        public static List<Vector3> ProjectWayWithLineElevation(CompleteWay way, Point offset,
            IProjection projection, Elevation elevation)
        {
            // get line points
            var geoPoints = elevation.GetWayElevation(way.Nodes).ToList();

            // convert to projected points
            var nodes = geoPoints.Select(point =>
            {
                // convert to X/Y
                var projPos = projection.Project(point.Latitude, point.Longitude);

                // apply offset
                projPos.X -= offset.X;
                projPos.Y -= offset.Y;

                // flip vertically because Z is down
                projPos.Y *= -1;

                return new Vector3((float)projPos.X, (float)point.Elevation, (float)projPos.Y);
            }).ToList();

            // remove points that are too close to each other to avoid "Curve item is too small" errors
            const float epsilon = 0.8f;
            const float epsilonSquared = epsilon * epsilon;
            var unique = new List<Vector3>(nodes.Count);
            unique.Add(nodes[0]);
            for (int i = 1; i < nodes.Count; i++)
            {
                if (Vector3.DistanceSquared(nodes[i - 1], nodes[i]) < epsilonSquared)
                    continue;
                else
                    unique.Add(nodes[i]);
            }

            return unique;
        }
Example #5
0
 public BuildingCreator(Map map, IProjection projection, Elevation elevation)
     : base(map, projection, elevation)
 {
 }
Example #6
0
 public RailwayCreator(Map map, IProjection projection, Elevation elevation)
     : base(map, projection, elevation)
 {
 }
Example #7
0
 public Creator(Map map, IProjection projection, Elevation elevation)
 {
     this.map        = map;
     this.projection = projection;
     this.elevation  = elevation;
 }