Hey, Congrats on the hard work. It would be interesting to hear what you mean by testing your geotools code live from openjump since I've always thought those were very different projects. How does openjump deal with gps data, in plate-carre space?
Sunburned Surveyor wrote: > - Right now my code uses doubles to represent lat and long values. I'd > like to create a convenient wrapper class to represent a lat/long > coordinate (possible with an elevation). I noted that GeoTools has a > latitude and longitude classes: > > http://javadoc.geotools.fr/2.5/org/geotools/measure/Latitude.html > http://javadoc.geotools.fr/2.5/org/geotools/measure/Longitude.html > > Is there a class GeoTools uses to represent a Lat/Long pair? If there > isn't, what interface or class might I extend/implement to do so? I > don't want to roll my own lat/long wrapper if I don't have to. > The geotools way to define a coordinate tuple is through an array of doubles; the way to define a series of tuples is through an array of doubles. This is because of the way we can then operate on those coordinates if we want to transform them---we follow a Java convention of working on a single long array containing all the ordinates. That also gives us access to the very nice System.array* types of functions including their improved versions in Java 6. The OGC/ISO way to reference a single coordinate tuple of geographic ordinates is with a "direct position," a tuple plus a defining CRS to give it meaning (i.e. which ordinate is lat and which is long and how that coordinate system relates to the globe). You can find the classes you want in the referencing module's org.geotools.geometry package where you'll want to look at the GeneralDirectPosition, or DirectPosition2D classes. (Note this is *not* a Point, which for ISO is a very different data structure.) For the CRS, you could use the static org.geotools.referencing.crs.WGS84 if you keep in mind that its in long,lat order (it exists to provide a flipped alternative to the ubiquitous EPSG:4326 CRS without asking users to learn how to flip axes with a trivial affine). I'm angling for us to have a few more default CRS's going forward so we can skip the epsg database plugins in these simple cases. For now, you will have to find the EPSG code for the CRS you want to use and pull it out of one of the utility CRS.decode(.) methods. > - I want to create some utility methods that work with lat/long > coordinates on the ellipsoid. I only need a simple sphere, nothing > fancier. Find the epsg code; I bet you can google it. Warning, they may be several with different radii. The epsg website has a lookup tool and geotools has some class that you can use from the command line to do the lookup. (Martin has recently greatly improved this by bringing all his mini-apps together into a single, powerful, sexy, colourized, localized, covered in whipped cream and with a cherry on top command line app. A goody in the pipeline for us.) > I'm dealing with positional accuracies of several feet (if > not tens of feet), so I'm not going to get exceited about the > differences between a shpere and an ellipsoid at this point. I know > that GeoTools offers the DefaultEllipsoid class: > > http://javadoc.geotools.fr/2.5/org/geotools/referencing/datum/DefaultEllipsoid.html > > Would there be objections to adding some methods to this class to > perform the calculations I need, or should I whip up my own > implementation of the Ellipsoid interface? > Wow! Your asking this question means either you have not understood what geotools is trying to do or you are distracted and so are not thinking. So let's back up a second. Geotools is a *library*. It is not some random accumulation of code built to satisfy the particular need of whomever was writing it. Geotools is a library built along a *design*. The OGC and ISO design has been vetted through the two standards bodies, implemented in lots of different ways and refined over the years. It's not perfect by any means but it is designed systematically to satisfy the broadest range of needs. Furthermore, in the particular case of referencing, the module is one of the best written, best documented, and most stable parts of the project. So there is *no* chance whatsoever you could add any methods to that class---it doesn't make any sense to ask. Happily, you might not even need to add anything. Chances are high that what you want to do already exists you just need to learn how. (Yes, reading code is much harder than writing code; the benefit comes from learning better approaches and from discovering standard ways to do things which often gets repeated elsewhere.) For your needs, there's a geodetic calculator class around to do simple operations in geographic space which may be helpful. There's a lot of other code around as well, so you ought to browse the GeoAPI javadoc first and then poke around Geotools to find the helper classes. If you are still stuck after that, ask specific questions if you have them. all the best, --adrian ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Geotools-devel mailing list Geotools-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-devel