示例#1
0
        public static UTMCoord FromLatLon(Angle latitude, Angle longitude, string datum)
        {
            if (latitude == null || longitude == null)
            {
                throw new ArgumentException("Latitude Or Longitude Is Null");
            }

            UTMCoordConverter converter;
            if (datum != null && datum.Equals("NAD27"))
            {
                converter = new UTMCoordConverter(UTMCoordConverter.CLARKE_A, UTMCoordConverter.CLARKE_F);
                LatLon llNAD27 = UTMCoordConverter.ConvertWGS84ToNAD27(latitude, longitude);
                latitude = llNAD27.Latitude;
                longitude = llNAD27.Longitude;
            }
            else
            {
                converter = new UTMCoordConverter(UTMCoordConverter.WGS84_A, UTMCoordConverter.WGS84_F);
            }

            long err = converter.ConvertGeodeticToUTM(latitude.radians, longitude.radians);

            if (err != UTMCoordConverter.UTM_NO_ERROR)
            {
                throw new ArgumentException("UTM Conversion Error");
            }

            return new UTMCoord(latitude, longitude, converter.Zone, converter.Hemisphere,
                                converter.Easting, converter.Northing, Angle.FromRadians(converter.CentralMeridian));
        }
示例#2
0
        /**
         * Create a set of UTM coordinates for the given <code>Globe</code>.
         *
         * @param zone       the UTM zone - 1 to 60.
         * @param hemisphere the hemisphere, either {@link gov.nasa.worldwind.avlist.AVKey#NORTH} or {@link
         *                   gov.nasa.worldwind.avlist.AVKey#SOUTH}.
         * @param easting    the easting distance in meters
         * @param northing   the northing distance in meters.
         * @param globe      the <code>Globe</code> - can be null (will use WGS84).
         *
         * @return the corresponding <code>UTMCoord</code>.
         *
         * @throws ArgumentException if the conversion to UTM coordinates fails.
         */
        public static UTMCoord FromUTM(int zone, String hemisphere, double easting, double northing)
        {
            UTMCoordConverter converter = new UTMCoordConverter();
            long err = converter.ConvertUTMToGeodetic(zone, hemisphere, easting, northing);

            if (err != UTMCoordConverter.UTM_NO_ERROR)
            {
                throw new ArgumentException("UTM Conversion Error");
            }

            return new UTMCoord(Angle.FromRadians(converter.Latitude),
                                Angle.FromRadians(converter.Longitude),
                                zone, hemisphere, easting, northing, Angle.FromRadians(converter.CentralMeridian));
        }
示例#3
0
        /**
         * Create a set of UTM coordinates from a pair of latitude and longitude for the given <code>Globe</code>.
         *
         * @param latitude  the latitude <code>Angle</code>.
         * @param longitude the longitude <code>Angle</code>.
         * @param globe     the <code>Globe</code> - can be null (will use WGS84).
         *
         * @return the corresponding <code>UTMCoord</code>.
         *
         * @throws IllegalArgumentException if <code>latitude</code> or <code>longitude</code> is null, or the conversion to
         *                                  UTM coordinates fails.
         */
        public static UTMCoord FromLatLon(Angle latitude, Angle longitude)
        {
            if (latitude == null || longitude == null)
            {
                throw new ArgumentException("Latitude Or Longitude Is Null");
            }

            UTMCoordConverter converter = new UTMCoordConverter();
            long err = converter.ConvertGeodeticToUTM(latitude.radians, longitude.radians);

            if (err != UTMCoordConverter.UTM_NO_ERROR)
            {
                throw new ArgumentException("UTM Conversion Error");
            }

            return new UTMCoord(latitude, longitude, converter.Zone, converter.Hemisphere,
                                converter.Easting, converter.Northing, Angle.FromRadians(converter.CentralMeridian));
        }