Ejemplo n.º 1
0
        private geoHelper.GeoLocation[] generateCoords(VTMap map, int mapSize, bool startBottomLeft, float latOffset = 0, float lonOffset = 0)
        {
            support.WriteLog("Generating Coordinates from bottom corner");
            geoHelper.GeoLocation[] geoLocations = new geoHelper.GeoLocation[4];

            if (startBottomLeft)
            {
                geoHelper.GeoLocation bottomLeft = new geoHelper.GeoLocation();
                bottomLeft.Latitude  = map.mapLatitude;
                bottomLeft.Longitude = map.mapLongitude;

                geoHelper.GeoLocation bottomRight = geoHelper.FindPointAtDistanceFrom2(bottomLeft, 90, mapSize);

                geoHelper.GeoLocation topLeft = geoHelper.FindPointAtDistanceFrom2(bottomLeft, 0, mapSize);

                geoHelper.GeoLocation topRight = geoHelper.FindPointAtDistanceFrom2(topLeft, 90, mapSize);

                geoLocations[0] = bottomLeft;
                geoLocations[1] = bottomRight;
                geoLocations[2] = topRight;
                geoLocations[3] = topLeft;
            }
            else
            {
                geoHelper.GeoLocation bottomRight = new geoHelper.GeoLocation();
                bottomRight.Latitude  = map.mapLatitude;
                bottomRight.Longitude = map.mapLongitude;

                geoHelper.GeoLocation bottomLeft = geoHelper.FindPointAtDistanceFrom2(bottomRight, 270, mapSize);

                geoHelper.GeoLocation topLeft = geoHelper.FindPointAtDistanceFrom2(bottomLeft, 0, mapSize);

                geoHelper.GeoLocation topRight = geoHelper.FindPointAtDistanceFrom2(topLeft, 90, mapSize);
                geoLocations[0] = bottomLeft;
                geoLocations[1] = bottomRight;
                geoLocations[2] = topRight;
                geoLocations[3] = topLeft;
            }

            return(geoLocations);
        }
Ejemplo n.º 2
0
        private void generateMapXML(Texture2D texture, VTMap map, bool customMap, string TacViewFolder)
        {
            support.WriteLog("Generating custom XML");

            geoHelper.GeoLocation[] geoLocations = new geoHelper.GeoLocation[4];

            if (customMap)
            {
                geoLocations = generateCoords(map, map.mapSize * 3, true);
            }
            else
            {
                geoHelper.GeoLocation bottomLeft = new geoHelper.GeoLocation
                {
                    Latitude  = 53.94148616349887,
                    Longitude = -166.40063465537224
                };

                geoHelper.GeoLocation bottomRight = new geoHelper.GeoLocation
                {
                    Latitude  = 53.94544,
                    Longitude = -165.426
                };

                geoHelper.GeoLocation topRight = new geoHelper.GeoLocation
                {
                    Latitude  = 54.5124234999398,
                    Longitude = -165.41245674515972
                };

                geoHelper.GeoLocation topLeft = new geoHelper.GeoLocation
                {
                    Latitude  = 54.51646078127723,
                    Longitude = -166.40063465537224
                };

                geoLocations[0] = bottomLeft;
                geoLocations[1] = bottomRight;
                geoLocations[2] = topRight;
                geoLocations[3] = topLeft;
            }

            string file   = $"heightmap_{genMapNameFile(map)}.data";
            int    endian = 1;
            int    width  = texture.width;
            int    height = texture.height;

            float altFactor = 0.04f;
            float altOffset = -235f;

            string projection = "Quad";

            XDocument doc = new XDocument(new XElement("CustomHeightmap",
                                                       new XElement("File", file),
                                                       new XElement("BigEndian", endian.ToString()),
                                                       new XElement("Width", width.ToString()),
                                                       new XElement("Height", height.ToString()),
                                                       new XElement("AltitudeFactor", altFactor.ToString()),
                                                       new XElement("AltitudeOffset", altOffset.ToString()),
                                                       new XElement("Projection", projection.ToString()),
                                                       new XElement("BottomLeft",
                                                                    new XElement("Longitude", geoLocations[0].Longitude),
                                                                    new XElement("Latitude", geoLocations[0].Latitude)),
                                                       new XElement("BottomRight",
                                                                    new XElement("Longitude", geoLocations[1].Longitude),
                                                                    new XElement("Latitude", geoLocations[1].Latitude)),
                                                       new XElement("TopRight",
                                                                    new XElement("Longitude", geoLocations[2].Longitude),
                                                                    new XElement("Latitude", geoLocations[2].Latitude)),
                                                       new XElement("TopLeft",
                                                                    new XElement("Longitude", geoLocations[3].Longitude),
                                                                    new XElement("Latitude", geoLocations[3].Latitude))
                                                       ));

            support.WriteLog($"Saving custom tacview custom XML to {TacViewFolder + "customHeightMapXML.txt"}");
            doc.Save(TacViewFolder + "customHeightMapXML.txt");
        }