pgRouting

Changeset 107

Show
Ignore:
Timestamp:
02/21/08 11:37:36 (9 months ago)
Author:
Matthieu
Message:

Test version: debug

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/routingservice/.classpath

    r94 r107  
    1212        <classpathentry kind="lib" path="/home/matthieu/workspace/pgRouting_Webservice/lib/org.simpleframework.jar"/> 
    1313        <classpathentry kind="lib" path="/home/matthieu/workspace/pgRouting_Webservice/lib/postgresql-8.2-506.jdbc4.jar"/> 
     14        <classpathentry kind="lib" path="/home/matthieu/workspace/pgRouting_Webservice/lib/com.noelios.restlet.ext.jdbc_3.0.jar"/> 
     15        <classpathentry kind="lib" path="/home/matthieu/workspace/pgRouting_Webservice/lib/commons-pool-1.4.jar"/> 
     16        <classpathentry kind="lib" path="/home/matthieu/workspace/pgRouting_Webservice/lib/commons-dbcp-1.2.2.jar"/> 
    1417        <classpathentry kind="output" path="bin"/> 
    1518</classpath> 
  • branches/routingservice/src/jp/co/orkney/restlet/geo/ClosestEdge.java

    r102 r107  
    2929import org.antlr.stringtemplate.StringTemplate; 
    3030import org.json.JSONException; 
     31 
     32import com.noelios.restlet.ext.jdbc.RowSetRepresentation; 
    3133 
    3234/** 
     
    123125         */ 
    124126        public void start() throws SQLException, JSONException 
    125         { 
     127        {       
    126128                databaseConnection = new DatabaseConnection(configuration); 
     129                 
     130                StringTemplate query = ioHelper.getQuery(); 
     131                float bboxSize = Float.parseFloat(configuration.getService().getParameter("bbox").getValue()); 
     132 
     133                // Makes the SQL query 
     134                query.setAttribute("sonPx", point.getX()); 
     135                query.setAttribute("sonPy", point.getY()); 
     136                query.setAttribute("sonPxM", point.getX(-bboxSize)); 
     137                query.setAttribute("sonPxP", point.getX(bboxSize)); 
     138                query.setAttribute("sonPyM", point.getY(-bboxSize)); 
     139                query.setAttribute("sonPyP", point.getY(bboxSize)); 
     140                query.setAttribute("sridProvider", configuration.getService().getDataProjection()); 
     141                query.setAttribute("sridIn", configuration.getService().getParameter("sridInput").getValue()); 
     142                query.setAttribute("sridOut", configuration.getService().getParameter("sridOutput").getValue()); 
     143                 
     144                ResultSet rs = ((RowSetRepresentation)databaseConnection.makeRequest(query.toString()).getEntity()).getJdbcResult().getResultSet(); 
     145 
     146                 
     147                /*databaseConnection = new DatabaseConnection(configuration); 
    127148                databaseConnection.start(); 
    128149 
     
    145166                        //System.out.println(query.toString()); 
    146167                        log.write(query.toString(),1); 
    147                         ResultSet rs = databaseConnection.getResult(query.toString()); 
    148  
     168                        ResultSet rs = databaseConnection.getResult(query.toString());*/ 
     169                         
    149170                        // Converts the SQL Result in Geojson 
    150171                        if (configuration.getFormatOut().getName().equals("geojson")) 
     
    183204                        } 
    184205 
    185                         databaseConnection.close(); 
    186                 } 
     206                        /*databaseConnection.close(); 
     207                }*/ 
    187208        } 
    188209} 
  • branches/routingservice/src/jp/co/orkney/restlet/geo/DrivingDistance.java

    r102 r107  
    180180                        query.setAttribute("sridOut", configuration.getService().getParameter("sridOutput").getValue()); 
    181181                         
    182                         System.out.println(query.toString()); 
     182                        //System.out.println(query.toString()); 
    183183                        log.write(query.toString(),1); 
    184184                        ResultSet rs = databaseConnection.getResult(query.toString()); 
  • branches/routingservice/src/jp/co/orkney/restlet/geo/ShortestPath.java

    r102 r107  
    148148                        query.setAttribute("sridOut", configuration.getService().getParameter("sridOutput").getValue()); 
    149149 
    150                         System.out.println(query.toString()); 
     150                        //System.out.println(query.toString()); 
    151151                        log.write(query.toString(),1); 
    152152                        ResultSet rs = databaseConnection.getResult(query.toString()); 
  • branches/routingservice/src/jp/co/orkney/restlet/geo/TravelingSalesPerson.java

    r102 r107  
    8989                        } 
    9090                } 
    91                 /*// extract method for Gml format 
     91                // extract method for Gml format 
    9292                else if (this.configuration.getFormatIn().getName().equals("gml")) 
    9393                { 
    94                        
     94               
    9595                // extract method for lonlat format 
    9696                else if (this.configuration.getFormatIn().getName().equals("lonlat")) 
     
    104104                else if (this.configuration.getFormatIn().getName().equals("kml")) 
    105105                { 
    106                         startPoint = ioHelper.extractKMLPxPy(this.configuration.getService().getParameter("point_start").getValue()); 
    107                         endPoint = ioHelper.extractKMLPxPy(this.configuration.getService().getParameter("point_end").getValue()); 
    108                 }*/ 
     106                } 
    109107        } 
    110108         
     
    146144                        query.setAttribute("sridOut", configuration.getService().getParameter("sridOutput").getValue()); 
    147145 
    148                         System.out.println(query.toString()); 
     146                        //System.out.println(query.toString()); 
    149147                        log.write(query.toString(),1); 
    150148                        ResultSet rs = databaseConnection.getResult(query.toString()); 
     
    155153                                result = ioHelper.travelingSalesPersonGEOJSONResult(rs); 
    156154                        } 
    157                         /*// Converts the SQL Result in HTML 
     155                        // Converts the SQL Result in HTML 
    158156                        else if (configuration.getFormatOut().getName().equals("html")) 
    159157                        { 
    160                                 result = ioHelper.shortestPathHTMLResult(rs, startPoint, endPoint); 
     158                                result = ioHelper.travelingSalesPersonHTMLResult(rs, startPoint); 
    161159                        } 
    162160                        // Converts the SQL Result in XML 
    163161                        else if (configuration.getFormatOut().getName().equals("xml")) 
    164162                        { 
    165                                 result = ioHelper.shortestPathXMLResult(rs); 
     163                                result = ioHelper.travelingSalesPersonXMLResult(rs); 
    166164                        } 
    167165                        // Converts the SQL Result in GML 
    168166                        else if (configuration.getFormatOut().getName().equals("gml")) 
    169167                        { 
    170                                 result = ioHelper.shortestPathGMLResult(rs); 
     168                                result = ioHelper.travelingSalesPersonGMLResult(rs); 
    171169                        } 
    172170                        // Converts the SQL Result in WKT 
    173171                        else if (configuration.getFormatOut().getName().equals("wkt")) 
    174172                        { 
    175                                 result = ioHelper.shortestPathWKTResult(rs); 
     173                                result = ioHelper.travelingSalesPersonWKTResult(rs); 
    176174                        } 
    177175                        // Converts the SQL Result in KML 
    178176                        else if (configuration.getFormatOut().getName().equals("kml")) 
    179177                        { 
    180                                 result = ioHelper.shortestPathKMLResult(rs); 
    181                         }*/ 
     178                                result = ioHelper.travelingSalesPersonKMLResult(rs); 
     179                        } 
    182180                        databaseConnection.close(); 
    183181                } 
  • branches/routingservice/src/jp/co/orkney/restlet/util/Configuration.java

    r96 r107  
    2828import org.jdom.JDOMException; 
    2929import org.jdom.input.SAXBuilder; 
     30import org.jdom.output.XMLOutputter; 
    3031 
    3132/** 
     
    5859{ 
    5960        private String urlConfigurationFile = "./configuration.xml"; 
     61        private String urlXMLTemplateQuery = "./pool.xml"; 
     62        private String commandCapabilities = "capabilities"; 
    6063 
    6164        private String port; 
     
    6568        private String urlCss; 
    6669        public Vector<Provider> providers; 
     70        private int askCapabilities; // -1 by default, 0 host capabilities, 1 
     71        // provider "x" capabilities 
    6772 
    6873        private Provider provider; 
     
    7075        private Format formatIn; 
    7176        private Format formatOut; 
    72          
     77 
    7378        private int iProvider = 0; 
    7479        private int iService = 0; 
     
    8893                localhost = ""; 
    8994                urlCss = ""; 
     95                askCapabilities = -1; 
    9096                providers = new Vector<Provider>(); 
    9197                provider = new Provider(); 
     
    122128                localhost = root.getChild("localhost").getText(); 
    123129                urlCss = root.getChild("css").getText(); 
    124          
     130 
    125131                List<Element> listProviders = root.getChild("providers").getChildren("provider"); 
    126                 Iterator<Element> iProvider = listProviders.iterator(); 
    127  
    128                 while (iProvider.hasNext()) 
     132                Iterator<Element> itProvider = listProviders.iterator(); 
     133 
     134                while (itProvider.hasNext()) 
    129135                { 
    130136                        Provider provider = new Provider(); 
    131                         Element currentProvider = (Element) iProvider.next(); 
     137                        Element currentProvider = (Element) itProvider.next(); 
    132138                        provider.setName(currentProvider.getAttributeValue("name")); 
    133                         currentProvider.getChild("services").getChildren("service"); 
    134139                        List<Element> listServices = currentProvider.getChild("services").getChildren("service"); 
    135                         Iterator<Element> iService = listServices.iterator(); 
     140                        Iterator<Element> itService = listServices.iterator(); 
    136141                        Vector<Service> services = new Vector<Service>(); 
    137142 
    138                         while (iService.hasNext()) 
     143                        while (itService.hasNext()) 
    139144                        { 
    140145                                Service service = new Service(); 
    141                                 Element currentService = iService.next(); 
     146                                Element currentService = itService.next(); 
    142147                                service.setName(currentService.getAttributeValue("name")); 
    143148                                service.setEnable(new Boolean(currentService.getAttributeValue("enable"))); 
    144                                 service.setConfigurationConnexion(new DatabaseConfiguration(currentService.getChild("connection") 
    145                                                 .getAttributeValue("driver"), currentService.getChild("connection").getChildText("url"), currentService.getChild( 
    146                                                 "connection").getChildText("user"), currentService.getChild("connection").getChildText("password"))); 
     149                                service.setConfigurationConnexion(new DatabaseConfiguration(currentService.getChild("connection").getAttributeValue("driver"), 
     150                                                currentService.getChild("connection").getChildText("url"), currentService.getChild("connection").getChildText("user"), 
     151                                                currentService.getChild("connection").getChildText("password"))); 
    147152                                service.setDataProjection(currentService.getChild("projection").getAttributeValue("srid")); 
    148153 
    149154                                List<Element> listSQL = currentService.getChild("sql").getChildren("query"); 
    150                                 Iterator<Element> iQuery = listSQL.iterator(); 
    151                                 while (iQuery.hasNext()) 
     155                                Iterator<Element> itQuery = listSQL.iterator(); 
     156                                while (itQuery.hasNext()) 
    152157                                { 
    153                                         Element currentQuery = iQuery.next(); 
     158                                        Element currentQuery = itQuery.next(); 
    154159                                        if (currentQuery.getAttributeValue("transformProjectionIn").equals("false")) 
    155160                                        { 
     
    187192 
    188193                                List<Element> listParameters = currentService.getChild("parameters").getChildren("parameter"); 
    189                                 Iterator<Element> iParametre = listParameters.iterator(); 
     194                                Iterator<Element> itParametre = listParameters.iterator(); 
    190195                                Vector<Parameter> parameters = new Vector<Parameter>(); 
    191196 
    192                                 while (iParametre.hasNext()) 
     197                                while (itParametre.hasNext()) 
    193198                                { 
    194199                                        Parameter parameter = new Parameter(); 
    195                                         Element currentParameter = iParametre.next(); 
     200                                        Element currentParameter = itParametre.next(); 
    196201                                        parameter.setName(currentParameter.getAttributeValue("name")); 
    197202                                        parameter.setType(currentParameter.getAttributeValue("type")); 
     
    205210 
    206211                                List<Element> listFormat = currentService.getChild("formats").getChildren("format"); 
    207                                 Iterator<Element> iFormat = listFormat.iterator(); 
     212                                Iterator<Element> itFormat = listFormat.iterator(); 
    208213                                Vector<Format> formats = new Vector<Format>(); 
    209214 
    210                                 while (iFormat.hasNext()) 
     215                                while (itFormat.hasNext()) 
    211216                                { 
    212217                                        Format format = new Format(); 
    213                                         Element currentFormat = iFormat.next(); 
     218                                        Element currentFormat = itFormat.next(); 
    214219                                        format.setName(currentFormat.getAttributeValue("name")); 
    215220                                        format.setSrid(currentFormat.getAttributeValue("srid")); 
     
    242247                String urlSplit[] = url.split("/"); 
    243248 
     249                if (urlSplit[0].equals(commandCapabilities)) 
     250                { 
     251                        askCapabilities = 0; 
     252                        return; 
     253                } 
    244254                if ((iProvider = isProvider(urlSplit[0])) != -1) 
    245255                { 
    246256                        provider.setName(providers.get(iProvider).getName()); 
     257                        if (urlSplit[1].equals(commandCapabilities)) 
     258                        { 
     259                                askCapabilities = 1; 
     260                                return; 
     261                        } 
    247262                } 
    248263                else 
     
    252267                { 
    253268                        Service tmpService = providers.get(iProvider).getServices().get(iService); 
    254                         service = new Service(tmpService.getName(),tmpService.getDataProjection(),tmpService.getSQL(),tmpService.isEnable(),tmpService.getParameters(),null,tmpService.getDatabaseConfiguration()); 
     269                        service = new Service(tmpService.getName(), tmpService.getDataProjection(), tmpService.getSQL(), tmpService.isEnable(), tmpService 
     270                                        .getParameters(), null, tmpService.getDatabaseConfiguration()); 
    255271                } 
    256272                else 
     
    260276                { 
    261277                        Format tmpFormat = providers.get(iProvider).getServices().get(iService).getFormats().get(iFormat); 
    262                         formatIn = new Format(tmpFormat.getName(),tmpFormat.getSrid(),tmpFormat.isEnableInput(),tmpFormat.isEnableOutput()); 
     278                        formatIn = new Format(tmpFormat.getName(), tmpFormat.getSrid(), tmpFormat.isEnableInput(), tmpFormat.isEnableOutput()); 
    263279                } 
    264280                else 
     
    268284                { 
    269285                        Format tmpFormat = providers.get(iProvider).getServices().get(iService).getFormats().get(iFormat); 
    270                         formatOut = new Format(tmpFormat.getName(),tmpFormat.getSrid(),tmpFormat.isEnableInput(),tmpFormat.isEnableOutput()); 
    271                         if(formatOut.getSrid() != null && !formatOut.getSrid().equals("")) 
     286                        formatOut = new Format(tmpFormat.getName(), tmpFormat.getSrid(), tmpFormat.isEnableInput(), tmpFormat.isEnableOutput()); 
     287                        if (formatOut.getSrid() != null && !formatOut.getSrid().equals("")) 
    272288                        { 
    273289                                service.getParameter("sridOutput").setValue(formatOut.getSrid()); 
     
    285301        public Log createLog() 
    286302        { 
    287                 return new Log(urlLog,modeLog); 
     303                return new Log(urlLog, modeLog); 
    288304        } 
    289305 
     
    388404        /** 
    389405         * Gets the requested provider 
     406         *  
    390407         * @return the requested provider 
    391408         */ 
     
    397414        /** 
    398415         * Gets the requested service 
     416         *  
    399417         * @return the requested service 
    400418         */ 
     
    403421                return service; 
    404422        } 
     423 
     424        /** 
     425         * Gets the url of CSS file (for HTML output) 
     426         *  
     427         * @return the CSS File 
     428         */ 
     429        public String getCss() 
     430        { 
     431                return urlCss; 
     432        } 
     433 
     434        /** 
     435         * Gets the database configuration of the requested service 
     436         *  
     437         * @return the database configuration 
     438         */ 
     439        public DatabaseConfiguration getConfigurationConnexion() 
     440        { 
     441                return service.getDatabaseConfiguration(); 
     442        } 
     443 
     444        /** 
     445         * Gets the parameters of the requested service 
     446         *  
     447         * @return a vector<Parameter> 
     448         */ 
     449        public Vector<Parameter> getParameters() 
     450        { 
     451                return service.getParameters(); 
     452        } 
     453 
     454        /** 
     455         * Gets the requested input data format 
     456         *  
     457         * @return a format 
     458         */ 
     459        public Format getFormatIn() 
     460        { 
     461                return formatIn; 
     462        } 
     463 
     464        /** 
     465         * Gets the requested output data format 
     466         *  
     467         * @return a format 
     468         */ 
     469        public Format getFormatOut() 
     470        { 
     471                return formatOut; 
     472        } 
     473 
     474        public int askCapabilities() 
     475        { 
     476                return askCapabilities; 
     477        } 
     478 
     479        public String getCapabilities() 
     480        { 
     481                String res = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\n"; 
     482                SAXBuilder sxb = new SAXBuilder(); 
     483                Document document = null; 
     484                try 
     485                { 
     486                        document = sxb.build(new File(urlConfigurationFile)); 
     487                } 
     488                catch (JDOMException e) 
     489                { 
     490                        e.printStackTrace(); 
     491                } 
     492                catch (IOException e) 
     493                { 
     494                        e.printStackTrace(); 
     495                } 
     496                Element root = document.getRootElement(); 
     497                List<Element> listProviders = root.getChild("providers").getChildren("provider"); 
     498                Iterator<Element> itProvider = listProviders.iterator(); 
     499 
     500                while (itProvider.hasNext()) 
     501                { 
     502                        Element currentProvider = (Element) itProvider.next(); 
     503                        List<Element> listServices = currentProvider.getChild("services").getChildren("service"); 
     504                        Iterator<Element> itService = listServices.iterator(); 
     505                        while (itService.hasNext()) 
     506                        { 
     507                                Element currentService = itService.next(); 
     508                                currentService.removeChild("connection"); 
     509                                currentService.removeChild("sql"); 
     510                        } 
     511                } 
     512 
     513                switch (askCapabilities) { 
     514                case 0: 
     515                        res += new XMLOutputter().outputString(root.getChild("providers")); 
     516                        break; 
     517                case 1: 
     518                        res += new XMLOutputter().outputString(listProviders.get(iProvider)); 
     519                        break; 
     520                } 
     521                return res; 
     522        } 
    405523         
    406         /** 
    407          * Gets the url of CSS file (for HTML output) 
    408          * @return the CSS File 
    409          */ 
    410         public String getCss() 
    411         { 
    412                 return urlCss; 
    413         } 
    414  
    415         /** 
    416          * Gets the database configuration of the requested service 
    417          * @return the database configuration 
    418          */ 
    419         public DatabaseConfiguration getConfigurationConnexion() 
    420         { 
    421                 return service.getDatabaseConfiguration(); 
    422         } 
    423  
    424         /** 
    425          * Gets the parameters of the requested service 
    426          * @return a vector<Parameter> 
    427          */ 
    428         public Vector<Parameter> getParameters() 
    429         { 
    430                 return service.getParameters(); 
    431         } 
    432  
    433         /** 
    434          * Gets the requested input data format 
    435          * @return a format 
    436          */ 
    437         public Format getFormatIn() 
    438         { 
    439                 return formatIn; 
    440         } 
    441          
    442         /** 
    443          * Gets the requested output data format 
    444          * @return a format 
    445          */ 
    446         public Format getFormatOut() 
    447         { 
    448                 return formatOut; 
     524        public String getUrlXMLTemplateQuery () 
     525        { 
     526                return urlXMLTemplateQuery; 
    449527        } 
    450528} 
  • branches/routingservice/src/jp/co/orkney/restlet/util/DatabaseConnection.java

    r96 r107  
    1818package jp.co.orkney.restlet.util; 
    1919 
     20import java.io.File; 
    2021import java.sql.Connection; 
    2122import java.sql.DriverManager; 
     
    2324import java.sql.SQLException; 
    2425import java.sql.Statement; 
     26 
     27import org.antlr.stringtemplate.StringTemplate; 
     28import org.restlet.Client; 
     29import org.restlet.data.MediaType; 
     30import org.restlet.data.Protocol; 
     31import org.restlet.data.Request; 
     32import org.restlet.data.Response; 
     33import org.restlet.resource.Representation; 
     34import org.restlet.resource.StringRepresentation; 
     35 
     36import com.noelios.restlet.ext.jdbc.JdbcClientHelper; 
    2537 
    2638import jp.co.orkney.restlet.util.Log; 
     
    5163        private Statement statement; 
    5264        private boolean start; 
     65        private IOHelper ioHelper; 
    5366        private Log log; 
    5467        private DatabaseConfiguration databaseConfiguration; 
     68        private Configuration configuration; 
    5569 
    5670        /** 
     
    6680        public DatabaseConnection(Configuration configuration) 
    6781        { 
     82                this.configuration = configuration; 
    6883                start = false; 
    6984                log = configuration.createLog(); 
    7085                databaseConfiguration = configuration.getService().getDatabaseConfiguration(); 
     86                ioHelper = new IOHelper(configuration); 
    7187        } 
    7288 
     
    7692        public void start() 
    7793        { 
    78                 log.write("Database connection started",1); 
     94                log.write("Database connection started", 1); 
    7995                try 
    8096                { 
     
    89105                { 
    90106                        start = false; 
    91                         log.write("--ERROR: unkown driver",0); 
     107                        log.write("--ERROR: unkown driver", 0); 
    92108                } 
    93109                catch (SQLException e) 
    94110                { 
    95111                        start = false; 
    96                         log.write("--ERROR: Can not connect to the database",0); 
     112                        log.write("--ERROR: Can not connect to the database", 0); 
    97113                } 
    98114                start = true; 
     
    116132         * @return This query's result 
    117133         */ 
    118         public ResultSet getResult(String sql
     134        public ResultSet getResult(String query
    119135        { 
    120136                try 
    121137                { 
    122                         return statement.executeQuery(sql); 
     138                        return statement.executeQuery(query); 
    123139                } 
    124140                catch (SQLException e1) 
    125141                { 
    126                         log.write("--ERROR: query execution failed",0); 
     142                        log.write("--ERROR: query execution failed", 0); 
    127143                        log.getStackTrace(e1); 
    128144                } 
     
    140156                        statement.close(); 
    141157                        connection.close(); 
    142                         log.write("Database connection finished",1); 
     158                        log.write("Database connection finished", 1); 
    143159                } 
    144160                catch (SQLException e) 
    145161                { 
    146                         log.write("--ERROR: Can not close the connection",0); 
     162                        log.write("--ERROR: Can not close the connection", 0); 
    147163                } 
    148164        } 
     165         
     166        public Response makeRequest(String query) 
     167        { 
     168                StringTemplate queryTemplate = new StringTemplate(ioHelper.loadFile(new File(configuration.getUrlXMLTemplateQuery()))); 
    149169 
     170                // Makes the SQL query 
     171                queryTemplate.setAttribute("user",databaseConfiguration.getUser()); 
     172                queryTemplate.setAttribute("password", databaseConfiguration.getPassword()); 
     173                queryTemplate.setAttribute("query", query); 
     174                 
     175                Client client = new Client(Protocol.JDBC); 
     176                JdbcClientHelper helper = new JdbcClientHelper(client); 
     177                try 
     178                { 
     179                        Class.forName(databaseConfiguration.getDriver()); 
     180                } 
     181                catch (ClassNotFoundException e) 
     182                { 
     183                        e.printStackTrace(); 
     184                } 
     185                System.out.println(queryTemplate.toString()); 
     186                Representation req = new StringRepresentation(queryTemplate.toString().replace("&", "&amp;"),MediaType.TEXT_XML) ; 
     187                Request request = JdbcClientHelper.create("jdbc:postgresql://192.168.20.177:5432/geobase",req); 
     188                Response response = new Response(request); 
     189                helper.handle(request, response); 
     190                return response; 
     191        } 
    150192} 
  • branches/routingservice/src/jp/co/orkney/restlet/util/IOHelper.java

    r102 r107  
    1818package jp.co.orkney.restlet.util; 
    1919 
     20import java.io.BufferedInputStream; 
     21import java.io.File; 
     22import java.io.FileInputStream; 
     23import java.io.IOException; 
     24import java.io.StringWriter; 
    2025import java.math.BigDecimal; 
    2126import java.sql.ResultSet; 
     
    569574                int i = 0; 
    570575                result = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\n"; 
    571                 result += "<road>\n"; 
     576                result += "<route>\n"; 
    572577                while (resultSet != null && resultSet.next()) 
    573578                { 
     
    582587                        i++; 
    583588                } 
    584                 result += "</road>\n"; 
     589                result += "</route>\n"; 
    585590                return result; 
    586591        } 
     
    825830                String result = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<kml xmlns=\"http://earth.google.com/kml/2.1\">" 
    826831                                + "<Document><name>WebRouting Service</name><Style id=\"PolyStyle\"><PolyStyle><color>7f0000ff</color><width>4</width>" 
    827                                 + "<fill>1</fill><outline>1</outline></PolyStyle></Style><Placemark>" 
    828                                 + "<description>No+description+available</description>" + "<name>Isoline</name><styleUrl>#PolyStyle</styleUrl>" 
     832                                + "<fill>1</fill><outline>1</outline></PolyStyle></Style><Placemark>" + "<description>No+description+available</description>" 
     833                                + "<name>Isoline</name><styleUrl>#PolyStyle</styleUrl>" 
    829834                                + "<Polygon><extrude>1</extrude><altitudeMode>clampToGround</altitudeMode><outerBoundaryIs>" + "<LinearRing><coordinates>"; 
    830835 
     
    901906        } 
    902907 
     908         
     909        public String travelingSalesPersonHTMLResult(ResultSet resultSet, Point point) throws SQLException 
     910        { 
     911                int i = 0; 
     912                String result = "<html><head>" + "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + configuration.getCss() + "\" />" 
     913                                + "</head><body><table class=\"table\"><tr>"; 
     914 
     915                result += "<td colspan=\"3\">The travel sale person result is: </td></tr>"; 
     916                while (resultSet != null && resultSet.next()) 
     917                { 
     918                        result += "<tr class=\"line\"><td rowspan=\"2\" class=\"case_id\">" + i + "</td><td>Gid:</td><td>" + +resultSet.getInt("gid") 
     919                                        + "</td></tr>"; 
     920                        result += "<tr class=\"line\"><td>Geom:</td><td class=\"case_desc\">" + resultSet.getString("wkt") + "</td></tr>"; 
     921                        i++; 
     922                } 
     923                if (resultSet == null) 
     924                { 
     925                        result += "<tr class=\"line\"><td rowspan=\"2\" class=\"case_id\">" + i + "</td><td>Gid:</td><td>0</td></tr>"; 
     926                        result += "<tr class=\"line\"><td>Geom:</td><td class=\"case_desc\">unkown_road</td></tr>"; 
     927                } 
     928                result += "</body></html>"; 
     929                return result; 
     930        } 
     931         
     932        public String travelingSalesPersonXMLResult(ResultSet resultSet) throws SQLException 
     933        { 
     934                String result = ""; 
     935                int i = 0; 
     936                result = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\n"; 
     937                result += "<route>\n"; 
     938                while (resultSet != null && resultSet.next()) 
     939                { 
     940                        result += "<edge id=\"" + i + "\">\n"; 
     941                        result += "\t<gid>" + resultSet.getInt("gid") + "</gid>\n"; 
     942                        result += "\t<name>" + null + "</name>\n"; 
     943 
     944                        String wkt = resultSet.getString("wkt"); 
     945                        wkt = wkt.split("MULTILINESTRING\\(\\(")[1].split("\\)\\)")[0]; 
     946                        result += "\t<wkt>" + wkt + "</wkt>\n"; 
     947                        result += "</edge>\n"; 
     948                        i++; 
     949                } 
     950                result += "</route>\n"; 
     951                return result; 
     952        } 
     953         
    903954        public String travelingSalesPersonGEOJSONResult(ResultSet resultSet) throws SQLException, JSONException 
    904955        { 
     
    9531004 
    9541005                result = joRes.toString(); 
     1006                return result; 
     1007        } 
     1008         
     1009        public String travelingSalesPersonGMLResult(ResultSet resultSet) throws SQLException 
     1010        { 
     1011                String result = "<wfs:FeatureCollection xmlns:wfs=\"http://www.opengis.net/wfs\">"; 
     1012                int k = 0; 
     1013 
     1014                while (resultSet != null && resultSet.next()) 
     1015                { 
     1016                        result += "<gml:featureMember xmlns:gml=\"http://www.opengis.net/gml\">" 
     1017                                        + "<feature:features xmlns:feature=\"http://mapserver.gis.umn.edu/mapserver\" " + "fid=\"id" + k + "\">" + "<feature:geometry>" 
     1018                                        + "<gml:MultiLineString>"; 
     1019 
     1020                        String tmpSplit = resultSet.getString("wkt"); 
     1021                        tmpSplit = tmpSplit.split("MULTILINESTRING\\(\\(")[1].split("\\)\\)")[0]; 
     1022                        String wkt[] = tmpSplit.split("\\)\\("); 
     1023                        for (int i = 0; i < wkt.length; i++) 
     1024                        { 
     1025                                result += "<gml:lineStringMember>" + "<gml:LineString>" + "<gml:coordinates decimal=\".\" cs=\",\" ts=\"+\">"; 
     1026                                String wkt2[] = wkt[i].split(","); 
     1027                                for (int j = 0; j < wkt2.length; j++) 
     1028                                { 
     1029                                        result += new BigDecimal(wkt2[j].split(" ")[0]) + "," + new BigDecimal(wkt2[j].split(" ")[1]) + " "; 
     1030                                } 
     1031                                result += "</gml:coordinates>" + "</gml:LineString>" + "</gml:lineStringMember>"; 
     1032                        } 
     1033                        k++;