[Proj] dmstor return negative value

Eric Miller EMiller at dfg.ca.gov
Fri Jan 19 12:48:58 EST 2007


PROJ doesn't know about UTM grid zones.  So, the zone should just be "32."  However, the trailing letter is probably ignored during parsing.  You haven't provided a latitude for where you say the program fails.  If you provide a complete example, it will be easier to diagnose your error.  Below is a sample that may help you.

#include <stdio.h>
#include <stddef.h>
#include "projects.h"
#include "proj_api.h"

int main()
{
	char* params[] = {"proj=utm", "zone=32", "datum=WGS84"};
	const char *longitude = "8d29'30.74E";
	const char *latitude = "45N";
	projPJ utm32 = pj_init(sizeof(params)/ sizeof(params[0]), params);
	projLP lp;
	projXY xy;
	lp.u = dmstor(longitude, NULL);
	lp.v = dmstor(latitude, NULL);
	xy = pj_fwd(lp, utm32);
	printf("src: (%s, %s)\nradians: (%f, %f)\nutm: (%f, %f)",
		longitude, latitude, lp.u, lp.v, xy.u, xy.v);
	return 0;
}

>>> On 1/19/2007 at 12:10 AM, Lars Geldner <geldner.list.reg at gmx.net> wrote:

> Dear Jose,
> 
> you're right, the longitude is in zone 32. Thus, I changed my program to the
> following:
> 
> static char *parms[] = 
> {
> 	"proj=utm",
> 	"zone=32u",
> 	"datum=WGS84"
> };
> 
> My DMS longitude is 8d29'30.74. Starting from this longitude my task is to
> add an x distance in UTM projection. After that, the task is to re-transform
> the x value of UTM projection back to DMS (WGS84).
> 
> At first, I used dmstor function:
> data.u = dmstor(lPos, 0); // lpos is 8d29'30.74
> 
> Then I used the proj forward transform function:
> data = pj_fwd(data, ref);
> 
> Now, data.u is negative: data.u is -90178.546738 (Zone 32 used!)
> 
> For testing issues, I did not add an x distance in UTM projection but
> re-transformed data.u (x) back to DMS (WGS84). The result has to be
> 8d29'30.74:
> 
> in.u = data.u;
> in = pj_inv(in, ref); // re-transform
> char dms_x[20];
> rtodms(dms_x, in.u, 'E', 'W');
> printf("dms_x is: %s\n", dms_x);
> 
> OUTPUT: dms_x is: 0d0'0.001"
> 
> My question is: Why I'm getting 0d0'0.001" instead of 8d29'30.74? I can't
> face it!
> The same proceeding works fine with the latitude of 53d55'49.03! My problem
> is the longitude.
> 
> What is the correct proceeding to get the longitude 8d29'30.74?
> 
> Thanks,
> 
> Lars
> 
> 
> José Alberto Gonçalves wrote:
>> 
>> Your longitude (8d... East) is in Zone 32. Zone 33 goes from 12  to 18 
>> degrees East longitude, so it is likely that you get a negative X when 
>> you project your point in zone 33.
>> 
>> Regards
>> 
>> 
>> Jose Gonçalves
>> 
>> 
>> 
>> 
>> 
>> 
>> Lars Geldner wrote:
>> 
>>>Dear all,
>>>
>>>I'm transforming WGS84 coordinates into x/y coordinates of the UTM
>>>projection.
>>>
>>>The input WGS84 values have the following format, e.g. 8d29'30.74 as
>>>longitude.
>>>
>>>UTM Zone is 33.
>>>
>>>The first step is to transform the DMS data (8d29'30.74 as longitude) to
>>>radian data using dmstor function.
>>>The second step is to transform the radian data (returned by dmstor) to
> UTM
>>>using pj_fwd function.
>>>
>>>The result of the steps mentioned above is a negative value
> (-481324.644767)
>>>returned by pj_fwd.
>>>
>>>What indicates the UTM x-value -481324.644767 of the WGS84 longitude
>>>8d29'30.74?
>>>
>>>The inverse transformation of -481324.644767 returns a longitude of
>>>0d0'0.085"E but not 8d29'30.74.
>>>
>>>Any help is appreciated!
>>>
>>>TIA,
>>>
>>>Lars Geldner
>>>
>> 
>> _______________________________________________
>> Proj mailing list
>> Proj at lists.maptools.org 
>> http://lists.maptools.org/mailman/listinfo/proj 
>> 
>> 
> 
> -- 
> View this message in context: 
> http://www.nabble.com/dmstor-return-negative-value-tf3034418.html#a8445519 
> Sent from the PROJ.4 mailing list archive at Nabble.com.
> 
> 
> _______________________________________________
> Proj mailing list
> Proj at lists.maptools.org 
> http://lists.maptools.org/mailman/listinfo/proj




More information about the Proj mailing list