Re: GPS Coordinates to Map

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: GPS Coordinates to Map

Andy Czerwonka
I'm really stuck on this one - new to the whole geospatial space.  Any help
you be greatly appreciated.  I'm guessing that I should be looking around in
the GeoTools API somewhere for examples.  Somewhere there must be a
translation from a shapefile coordinate to a screen rendering - can anyone
help?

"Andy Czerwonka" <[hidden email]> wrote in message
news:eht3r7$f9k$[hidden email]...

> I'm wondering if someone can point me to sample where lat/long coordinates
> (in this case, NMEA GPS coordinates) are transformed to a pixel location
> on a map.
>
> The NMEA sentence format for geographic position looks like:
>
>        GLL - Geographic position, Latitude and Longitude
>        GLL,4916.45,N,12311.12,W,225444,A
>           4916.46,N    Latitude 49 deg. 16.45 min. North
>           12311.12,W   Longitude 123 deg. 11.12 min. West
>           225444       Fix taken at 22:54:44 UTC
>           A            Data valid
> Any pointers would be greatly appreciated.
>
> -andy
>
>



_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel
Reply | Threaded
Open this post in threaded view
|

Re: Re: GPS Coordinates to Map

Jesse Eichar-3
Hi,

So what exactly are you trying to do here?  Just transform from a  
point in world space to a coordinate on the screen?  If that is the  
case then you can use one of the context's worldToPoint() methods to  
make the transformation.  Look at the AbstractContext interface for  
the code if you don't want to use the context methods directly (you  
can create a ToolContext with the method:  
ApplicationGIS.createContext(map).  Also all MapGraphics have access  
to a MapGraphics context.  A final place to look is the layer's  
layerToMapTransform().


Jesse


On 31-Oct-06, at 7:51 AM, Andy Czerwonka wrote:

> I'm really stuck on this one - new to the whole geospatial space.  
> Any help
> you be greatly appreciated.  I'm guessing that I should be looking  
> around in
> the GeoTools API somewhere for examples.  Somewhere there must be a
> translation from a shapefile coordinate to a screen rendering - can  
> anyone
> help?
>
> "Andy Czerwonka" <[hidden email]> wrote in message
> news:eht3r7$f9k$[hidden email]...
>> I'm wondering if someone can point me to sample where lat/long  
>> coordinates
>> (in this case, NMEA GPS coordinates) are transformed to a pixel  
>> location
>> on a map.
>>
>> The NMEA sentence format for geographic position looks like:
>>
>>        GLL - Geographic position, Latitude and Longitude
>>        GLL,4916.45,N,12311.12,W,225444,A
>>           4916.46,N    Latitude 49 deg. 16.45 min. North
>>           12311.12,W   Longitude 123 deg. 11.12 min. West
>>           225444       Fix taken at 22:54:44 UTC
>>           A            Data valid
>> Any pointers would be greatly appreciated.
>>
>> -andy
>>
>>
>
>
>
> _______________________________________________
> User-friendly Desktop Internet GIS (uDig)
> http://udig.refractions.net
> http://lists.refractions.net/mailman/listinfo/udig-devel

_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel
Reply | Threaded
Open this post in threaded view
|

Re: Re: GPS Coordinates to Map

Andy Czerwonka
Thanks.  That perfect.  The only thing now is to deal with the coordinate
system I think.  GPS comes in in Lat/Long, but I see there a negative number
for the coordinate.  I have to get:

>>           4916.46,N    Latitude 49 deg. 16.45 min. North
>>           12311.12,W   Longitude 123 deg. 11.12 min. West

into a proper coordinate number.  For example, uDig shows diffent numbers
(negative numbers) and GPS coordinate need to be transformed first.  I
know - stup question - but for a geospatial newbie, relevent.  Apologies in
advance.

"Jesse Eichar" <[hidden email]> wrote in
message news:[hidden email]...

> Hi,
>
> So what exactly are you trying to do here?  Just transform from a  point
> in world space to a coordinate on the screen?  If that is the  case then
> you can use one of the context's worldToPoint() methods to  make the
> transformation.  Look at the AbstractContext interface for  the code if
> you don't want to use the context methods directly (you  can create a
> ToolContext with the method:   ApplicationGIS.createContext(map).  Also
> all MapGraphics have access  to a MapGraphics context.  A final place to
> look is the layer's  layerToMapTransform().
>
>
> Jesse
>



_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: GPS Coordinates to Map

Paul Ramsey-2
Right, you will have to convert your DDMM.MM numbers into DD.DDD numbers.

If the coordinates are West or South, they need to be multiplied by -1.

So, the formula is  (W?S? then -1) * (DD + (MM.MMM / 60)) = DD.DDD

P


Quoting Andy Czerwonka <[hidden email]>:

> Thanks.  That perfect.  The only thing now is to deal with the coordinate
> system I think.  GPS comes in in Lat/Long, but I see there a negative number
> for the coordinate.  I have to get:
>
> >>           4916.46,N    Latitude 49 deg. 16.45 min. North
> >>           12311.12,W   Longitude 123 deg. 11.12 min. West
>
> into a proper coordinate number.  For example, uDig shows diffent numbers
> (negative numbers) and GPS coordinate need to be transformed first.  I
> know - stup question - but for a geospatial newbie, relevent.  Apologies in
> advance.
>
> "Jesse Eichar" <[hidden email]> wrote in
> message news:[hidden email]...
> > Hi,
> >
> > So what exactly are you trying to do here?  Just transform from a  point
> > in world space to a coordinate on the screen?  If that is the  case then
> > you can use one of the context's worldToPoint() methods to  make the
> > transformation.  Look at the AbstractContext interface for  the code if
> > you don't want to use the context methods directly (you  can create a
> > ToolContext with the method:   ApplicationGIS.createContext(map).  Also
> > all MapGraphics have access  to a MapGraphics context.  A final place to
> > look is the layer's  layerToMapTransform().
> >
> >
> > Jesse
> >
>
>
>
> _______________________________________________
> User-friendly Desktop Internet GIS (uDig)
> http://udig.refractions.net
> http://lists.refractions.net/mailman/listinfo/udig-devel
>




_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: GPS Coordinates to Map

Andy Czerwonka
That's what I was looking for - thanks Paul.

"Paul Ramsey" <[hidden email]> wrote in
message news:[hidden email]...

> Right, you will have to convert your DDMM.MM numbers into DD.DDD numbers.
>
> If the coordinates are West or South, they need to be multiplied by -1.
>
> So, the formula is  (W?S? then -1) * (DD + (MM.MMM / 60)) = DD.DDD
>
> P
>
>
> Quoting Andy Czerwonka <[hidden email]>:
>
>> Thanks.  That perfect.  The only thing now is to deal with the coordinate
>> system I think.  GPS comes in in Lat/Long, but I see there a negative
>> number
>> for the coordinate.  I have to get:
>>
>> >>           4916.46,N    Latitude 49 deg. 16.45 min. North
>> >>           12311.12,W   Longitude 123 deg. 11.12 min. West
>>
>> into a proper coordinate number.  For example, uDig shows diffent numbers
>> (negative numbers) and GPS coordinate need to be transformed first.  I
>> know - stup question - but for a geospatial newbie, relevent.  Apologies
>> in
>> advance.
>>
>> "Jesse Eichar" <[hidden email]> wrote in
>> message
>> news:[hidden email]...
>> > Hi,
>> >
>> > So what exactly are you trying to do here?  Just transform from a
>> > point
>> > in world space to a coordinate on the screen?  If that is the  case
>> > then
>> > you can use one of the context's worldToPoint() methods to  make the
>> > transformation.  Look at the AbstractContext interface for  the code if
>> > you don't want to use the context methods directly (you  can create a
>> > ToolContext with the method:   ApplicationGIS.createContext(map).  Also
>> > all MapGraphics have access  to a MapGraphics context.  A final place
>> > to
>> > look is the layer's  layerToMapTransform().
>> >
>> >
>> > Jesse
>> >
>>
>>
>>
>> _______________________________________________
>> User-friendly Desktop Internet GIS (uDig)
>> http://udig.refractions.net
>> http://lists.refractions.net/mailman/listinfo/udig-devel
>>
>
>
>
>



_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel
Reply | Threaded
Open this post in threaded view
|

Re: Re: GPS Coordinates to Map

Andy Czerwonka-2
In reply to this post by Jesse Eichar-3

"Jesse Eichar" <[hidden email]> wrote in
message news:[hidden email]...

> Hi,
>
> So what exactly are you trying to do here?  Just transform from a  point
> in world space to a coordinate on the screen?  If that is the  case then
> you can use one of the context's worldToPoint() methods to  make the
> transformation.  Look at the AbstractContext interface for  the code if
> you don't want to use the context methods directly (you  can create a
> ToolContext with the method:   ApplicationGIS.createContext(map).  Also
> all MapGraphics have access  to a MapGraphics context.  A final place to
> look is the layer's  layerToMapTransform().
>
[snip]

I've got code that is correctly giving me the coordinates:

        double lat = getLatValue(location);
        double lon = getLonValue(location);
        Coordinate coordinate = new Coordinate(lat, lon);

But, when I do this...

MapGraphicContext context... (geeting it from the MapGraphic)
Point point = context.worldToPixel(coordinate);

I get a very large point - way off the screen.  When I render it...

            point = buildPoint(context, location);
            int x = (int) point.getX();
            int y = (int) point.getY();
            graphics.fillRect(x - 3, y - 3, 5, 5);

It's nowhere to be found...

Help???



_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel
Reply | Threaded
Open this post in threaded view
|

Re: Re: GPS Coordinates to Map

Andy Czerwonka-2
Sorry - long and lat we're reversed.

"Andy Czerwonka" <[hidden email]> wrote
in message news:eiagas$bn6$[hidden email]...

>
> "Jesse Eichar" <[hidden email]> wrote in
> message
> news:[hidden email]...
>> Hi,
>>
>> So what exactly are you trying to do here?  Just transform from a  point
>> in world space to a coordinate on the screen?  If that is the  case then
>> you can use one of the context's worldToPoint() methods to  make the
>> transformation.  Look at the AbstractContext interface for  the code if
>> you don't want to use the context methods directly (you  can create a
>> ToolContext with the method:   ApplicationGIS.createContext(map).  Also
>> all MapGraphics have access  to a MapGraphics context.  A final place to
>> look is the layer's  layerToMapTransform().
>>
> [snip]
>
> I've got code that is correctly giving me the coordinates:
>
>        double lat = getLatValue(location);
>        double lon = getLonValue(location);
>        Coordinate coordinate = new Coordinate(lat, lon);
>
> But, when I do this...
>
> MapGraphicContext context... (geeting it from the MapGraphic)
> Point point = context.worldToPixel(coordinate);
>
> I get a very large point - way off the screen.  When I render it...
>
>            point = buildPoint(context, location);
>            int x = (int) point.getX();
>            int y = (int) point.getY();
>            graphics.fillRect(x - 3, y - 3, 5, 5);
>
> It's nowhere to be found...
>
> Help???
>
>



_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel