Re: [OpenMap Users] UTMPoint outside a zone

From: Tore Halset <halset_at_pvv.ntnu.no>
Date: Mon, 7 May 2007 11:14:19 +0200

Hello.

Any news on this? I have some more patches I want to send in, but
this one should be agreed on and perhaps committed first.

Regards,
  - Tore.

On Mar 20, 2007, at 21:02 , Don Dietrick wrote:

> Hi Tore,
>
> Thanks for sending this class and the UTM projection in, I'll take
> a look at them this week.
>
> Best Regards,
>
> Don
>
>
>
> On Mar 16, 2007, at 10:57 AM, Tore Halset wrote:
>
>> Hello.
>>
>> I am build support for UTM projections into the WMS-part of
>> OpenMap. I am using UTMPoint for the calculation, but would like
>> to be able to convert a LatLonPoint to a UTMPoint for a specified
>> UTM zone that may not include the given LatLonPoint. This is
>> normal practice in the WMS context.
>>
>> Does this seem to be a good idea? I have attached a patch to
>> UTMPoint that works for me.
>>
>> Regards,
>> - Tore.
>> ### Eclipse Workspace Patch 1.0
>> #P openmap
>> Index: src/openmap/com/bbn/openmap/proj/coords/UTMPoint.java
>> ===================================================================
>> RCS file: /cvs/openmap/openmap/src/openmap/com/bbn/openmap/proj/
>> coords/UTMPoint.java,v
>> retrieving revision 1.10
>> diff -u -r1.10 UTMPoint.java
>> --- src/openmap/com/bbn/openmap/proj/coords/UTMPoint.java 24 Oct
>> 2005 14:39:14 -0000 1.10
>> +++ src/openmap/com/bbn/openmap/proj/coords/UTMPoint.java 16 Mar
>> 2007 14:26:23 -0000
>> _at_@ -197,8 +197,31 @@
>> public static UTMPoint LLtoUTM(LatLonPoint llpoint, Ellipsoid
>> ellip,
>> UTMPoint utmpoint) {
>> - double Lat = llpoint.getLatitude();
>> - double Long = llpoint.getLongitude();
>> + // find the native zone for the given llpoint
>> + int zoneNumber = zoneNumber(llpoint.getLatitude(),
>> llpoint.getLongitude());
>> + boolean isnorthern = (llpoint.getLatitude() >= 0f);
>> +
>> + return LLtoUTM(llpoint, ellip, utmpoint, zoneNumber,
>> isnorthern);
>> + }
>> +
>> + /**
>> + * Converts a set of Longitude and Latitude co-ordinates to UTM
>> + * given an ellipsoid and the UTM zone to use.
>> + *
>> + * _at_param ellip an ellipsoid definition.
>> + * _at_param llpoint the coordinate to be converted
>> + * _at_param utmpoint A UTMPoint instance to put the results in. If
>> + * null, a new UTMPoint will be allocated.
>> + * _at_param ZoneNumber the number of the zone
>> + * _at_param isnorthern true if zone is in norhering hemispehere
>> + * _at_return A UTM class instance containing the value of
>> + * <code>null</code> if conversion failed. If you pass
>> + * in a UTMPoint, it will be returned as well if
>> + * successful.
>> + */
>> + public static UTMPoint LLtoUTM(LatLonPoint llpoint, Ellipsoid
>> ellip,
>> + UTMPoint utmpoint, int
>> ZoneNumber, boolean isnorthern) {
>> +
>> double a = ellip.radius;
>> double eccSquared = ellip.eccsq;
>> double k0 = 0.9996;
>> _at_@ -210,31 +233,7 @@
>> double LatRad = llpoint.radlat_;
>> double LongRad = llpoint.radlon_;
>> double LongOriginRad;
>> - int ZoneNumber;
>> -
>> - ZoneNumber = (int) ((Long + 180) / 6) + 1;
>> - //Make sure the longitude 180.00 is in Zone 60
>> - if (Long == 180) {
>> - ZoneNumber = 60;
>> - }
>> -
>> - // Special zone for Norway
>> - if (Lat >= 56.0f && Lat < 64.0f && Long >= 3.0f && Long <
>> 12.0f) {
>> - ZoneNumber = 32;
>> - }
>> -
>> - // Special zones for Svalbard
>> - if (Lat >= 72.0f && Lat < 84.0f) {
>> - if (Long >= 0.0f && Long < 9.0f)
>> - ZoneNumber = 31;
>> - else if (Long >= 9.0f && Long < 21.0f)
>> - ZoneNumber = 33;
>> - else if (Long >= 21.0f && Long < 33.0f)
>> - ZoneNumber = 35;
>> - else if (Long >= 33.0f && Long < 42.0f)
>> - ZoneNumber = 37;
>> - }
>> LongOrigin = (ZoneNumber - 1) * 6 - 180 + 3; //+3 puts
>> origin
>> // in middle of
>> // zone
>> _at_@ -272,7 +271,7 @@
>> * (A * A / 2 + (5 - T + 9 * C + 4 * C * C) * A *
>> A * A * A
>> / 24.0d + (61 - 58 * T + T * T + 600 * C
>> - 330 * eccPrimeSquared)
>> * A * A * A * A * A * A / 720.0d)));
>> - if (Lat < 0.0f) {
>> + if (!isnorthern) {
>> UTMNorthing += 10000000.0f; //10000000 meter offset for
>> // southern hemisphere
>> }
>> _at_@ -284,11 +283,11 @@
>> utmpoint.northing = (float) Math.rint(UTMNorthing);
>> utmpoint.easting = (float) Math.rint(UTMEasting);
>> utmpoint.zone_number = ZoneNumber;
>> - utmpoint.zone_letter = utmpoint.getLetterDesignator(Lat);
>> + utmpoint.zone_letter = isnorthern ? 'N' : 'S';
>> return utmpoint;
>> }
>> -
>> +
>> /**
>> * Returns 'N' if the latitude is equal to or above the equator,
>> * 'S' if it's below.
>> _at_@ -538,5 +537,44 @@
>> return new LatLonPoint((float) Lat, (float) Long);
>> }
>> }
>> +
>> + /**
>> + * Find zone number based on the given latitude and longitude
>> in *degrees*.
>> + *
>> + * _at_param Lat
>> + * _at_param Long
>> + * _at_return
>> + */
>> + public static int zoneNumber(double Lat, double Long) {
>> + int ZoneNumber;
>> +
>> + ZoneNumber = (int) ((Long + 180) / 6) + 1;
>> +
>> + //Make sure the longitude 180.00 is in Zone 60
>> + if (Long == 180) {
>> + ZoneNumber = 60;
>> + }
>> +
>> + // Special zone for Norway
>> + if (Lat >= 56.0f && Lat < 64.0f && Long >= 3.0f && Long <
>> 12.0f) {
>> + ZoneNumber = 32;
>> + }
>> +
>> + // Special zones for Svalbard
>> + if (Lat >= 72.0f && Lat < 84.0f) {
>> + if (Long >= 0.0f && Long < 9.0f)
>> + ZoneNumber = 31;
>> + else if (Long >= 9.0f && Long < 21.0f)
>> + ZoneNumber = 33;
>> + else if (Long >= 21.0f && Long < 33.0f)
>> + ZoneNumber = 35;
>> + else if (Long >= 33.0f && Long < 42.0f)
>> + ZoneNumber = 37;
>> + }
>> +
>> + return ZoneNumber;
>> + }
>> +
>> +
>> }
>>
>> --
>> [To unsubscribe to this list send an email to "majdart_at_bbn.com"
>> with the following text in the BODY of the message "unsubscribe
>> openmap-users"]
>
>
>
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> Don Dietrick, dietrick_at_bbn.com
> BBN Technologies, Cambridge, MA
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>
>
> --
> [To unsubscribe to this list send an email to "majdart_at_bbn.com"
> with the following text in the BODY of the message "unsubscribe
> openmap-users"]
>

--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Mon May 07 2007 - 05:46:35 EDT

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:08 EDT