On Tue, Apr 26, 2011 at 4:13 PM, elephant2001
<[email protected]> wrote:
> Hi all,
> I'm newbie on GIS and on GeoTools ( and I'm not very good in math)....
>
>
> I need to do this:
> - I have a position in geo coordinates WGS84 (for example: 45.4644, 9.1908);
> - I have a "distance" in meters (i.e. 200 m)
>
> I would like to move my position about 200 m to East. So my destination
> point should be 45.4644, (9.1908 + 200m).
>
> How I can do this?
>
> I try to see the class GeodeticCalculator but I am not be able to use it.
>
> I defined a point as :
> GeometryFactory geometryFactory =
> JTSFactoryFinder.getGeometryFactory(null);
> Point createPoint = geometryFactory.createPoint(new Coordinate( 9.1908,
> 45.4644));
>
>
> Could you provide me some examples?
Here we go:
import java.awt.geom.Point2D;
import org.geotools.referencing.GeodeticCalculator;
public class MovePoint {
public static void main(String[] args) {
GeodeticCalculator calc = new GeodeticCalculator();
// mind, this is lon/lat
calc.setStartingGeographicPoint(45.4644, 9.1908);
calc.setDirection(90, 200);
Point2D dest = calc.getDestinationGeographicPoint();
System.out.println("Longitude: " + dest.getX() + " Latitude: "
+ dest.getY());
}
}
Reference for the azimuth value: http://en.wikipedia.org/wiki/Azimuth
Also mind GeodeticCalculator works in lon/lat order (as most data
source do as well).
Cheers
Andrea
--
-------------------------------------------------------
Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 962313
http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf
-------------------------------------------------------
------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network
management toolset available today. Delivers lowest initial
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users