From: vincent L. <vin...@gm...> - 2006-09-06 13:58:12
|
Hello, I am trying to use the geotools2.2 library to compute distance between two points within a servlet (I am working on a SVG-XUL GIS web-application that interacts with a bunch of servlets for data manipulation) I have first tried to use the library in a simple java application and it worked fine now, when I put the piece of code into my doGet method in my servlet, I get the following error message which apparently comes from the creation of the DefaultGeographicCRS object Here is the ERROR MESSAGE : 6 sept. 2006 15:53:11 org.apache.catalina.core.StandardWrapperValve invoke GRAVE: "Servlet.service()" pour la servlet Distance a généré une exception java.lang.NoSuchFieldError: RADIAN at org.geotools.referencing.AbstractIdentifiedObject.ensureAngularUnit(AbstractIdentifiedObject.java:1034) at org.geotools.referencing.datum.DefaultPrimeMeridian.<init>(DefaultPrimeMeridian.java:124) at org.geotools.referencing.datum.DefaultPrimeMeridian.<init>(DefaultPrimeMeridian.java:108) at org.geotools.referencing.datum.DefaultPrimeMeridian.<clinit>(DefaultPrimeMeridian.java:61) at org.geotools.referencing.datum.DefaultGeodeticDatum.<clinit>(DefaultGeodeticDatum.java:85) at org.geotools.referencing.crs.DefaultGeographicCRS.<clinit>(DefaultGeographicCRS.java:95) at com.helmet.gis.DistanceServlet.doGet(DistanceServlet.java:36) at javax.servlet.http.HttpServlet.service(HttpServlet.java:689) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) at java.lang.Thread.run(Thread.java:595) Here is MY CODE : /** * */ package com.helmet.gis; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.Servlet; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.geotools.geometry.jts.JTS; import org.geotools.referencing.crs.DefaultGeographicCRS; import org.opengis.referencing.operation.TransformException; import com.vividsolutions.jts.geom.Coordinate; /** * @author Vincent Laugier * */ public class DistanceServlet extends HttpServlet implements Servlet { protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { // create 2 points Coordinate coord1 = new Coordinate(4.47, 51.92); Coordinate coord2 = new Coordinate(4.86, 52.38); // create a WGS CRS DefaultGeographicCRS crs = new DefaultGeographicCRS(DefaultGeographicCRS.WGS84); // compute distance try{ double distance = JTS.orthodromicDistance(coord1,coord2,crs); PrintWriter writer = res.getWriter(); writer.println("la distance est de : " + distance); } catch (TransformException e) {System.err.println(e);} } } Thanks in advance for your help -- Vincent Laugier |