Esempio n. 1
0
        public static UTMCoord fromLatLon(Angle latitude, Angle longitude, string datum)
        {
            if (latitude == null || longitude == null)
            {
                string message = Logging.getMessage("nullValue.LatitudeOrLongitudeIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            UTMCoordConverter converter;

            if (!WWUtil.isEmpty(datum) && datum.Equals("NAD27"))
            {
                converter = new UTMCoordConverter(UTMCoordConverter.CLARKE_A, UTMCoordConverter.CLARKE_F);
                LatLon llNAD27 = UTMCoordConverter.convertWGS84ToNAD27(latitude, longitude);
                latitude  = llNAD27.getLatitude();
                longitude = llNAD27.getLongitude();
            }
            else
            {
                converter = new UTMCoordConverter(UTMCoordConverter.WGS84_A, UTMCoordConverter.WGS84_F);
            }

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

            if (err != UTMCoordConverter.UTM_NO_ERROR)
            {
                string message = Logging.getMessage("Coord.UTMConversionError");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            return(new UTMCoord(latitude, longitude, converter.getZone(), converter.getHemisphere(),
                                converter.getEasting(), converter.getNorthing(), Angle.fromRadians(converter.getCentralMeridian())));
        }
Esempio n. 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 SharpEarth.avlist.AVKey#NORTH} or {@link
         *                   SharpEarth.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, Globe globe)
        {
            UTMCoordConverter converter = new UTMCoordConverter(globe);
            long err = converter.convertUTMToGeodetic(zone, hemisphere, easting, northing);

            if (err != UTMCoordConverter.UTM_NO_ERROR)
            {
                string message = Logging.getMessage("Coord.UTMConversionError");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            return(new UTMCoord(Angle.fromRadians(converter.getLatitude()),
                                Angle.fromRadians(converter.getLongitude()),
                                zone, hemisphere, easting, northing, Angle.fromRadians(converter.getCentralMeridian())));
        }
Esempio n. 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 ArgumentException 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, Globe globe)
        {
            if (latitude == null || longitude == null)
            {
                string message = Logging.getMessage("nullValue.LatitudeOrLongitudeIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

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

            if (err != UTMCoordConverter.UTM_NO_ERROR)
            {
                string message = Logging.getMessage("Coord.UTMConversionError");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            return(new UTMCoord(latitude, longitude, converter.getZone(), converter.getHemisphere(),
                                converter.getEasting(), converter.getNorthing(), Angle.fromRadians(converter.getCentralMeridian())));
        }