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 |
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 |
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 |
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 |
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 |
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(). > 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 |
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 |
Free forum by Nabble | Edit this page |