Ignore:
Timestamp:
2015-07-12T14:51:36+02:00 (9 years ago)
Author:
belecker
Message:

Change code for new Server response.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/tracer2/src/org/openstreetmap/josm/plugins/tracer2/server/GetTrace.java

    r30737 r31369  
    4444    */
    4545    public void run() {
     46        m_listLatLon = new ArrayList<>();
     47       
    4648        try {
    4749            String strResponse = callServer("traceOrder=GetTrace"
     
    6668            }
    6769           
    68             if (!strResponse.startsWith("(") || !strResponse.endsWith(")")){
     70            if (strResponse.startsWith("(")) {
     71                GetPoints(strResponse);
    6972                return;
    7073            }
    71             strResponse = strResponse.substring(1, strResponse.length()-1);
    72            
    73             ArrayList<LatLon> nodelist = new ArrayList<>();
    74            
    75             String[] astrPoints = strResponse.split("\\)\\(");
    76             for (String strPoint : astrPoints) {
    77                 String[] astrParts = strPoint.split(":");
    78                 double x = Double.parseDouble(astrParts[0]);
    79                 double y = Double.parseDouble(astrParts[1]);
    80                 nodelist.add(new LatLon(x, y));
     74            String[] astrParts = strResponse.split("&");
     75
     76            for (String strPart : astrParts) {
     77                if (strPart.contains("tracePoints="))
     78                {
     79                        String strPoints = strPart.replace("tracePoints=", "");
     80                        GetPoints(strPoints);
     81                        return;
     82                }
    8183            }
    82             m_listLatLon = nodelist;
    8384        } catch (Exception e) {
    84                 m_listLatLon = new ArrayList<>();
     85                //m_listLatLon = new ArrayList<>();
    8586        }
    8687    }
    8788   
     89   
     90    /**
     91     * Get points from string
     92     */
     93     public void GetPoints(String strResponse) {
     94         try {
     95             if (!strResponse.startsWith("(") || !strResponse.endsWith(")")){
     96                return;
     97             }
     98             strResponse = strResponse.substring(1, strResponse.length()-1);
     99             
     100             ArrayList<LatLon> nodelist = new ArrayList<>();
     101             
     102             String[] astrPoints = strResponse.split("\\)\\(");
     103             for (String strPoint : astrPoints) {
     104                 String[] astrParts = strPoint.split(":");
     105                 double x = Double.parseDouble(astrParts[0]);
     106                 double y = Double.parseDouble(astrParts[1]);
     107                 nodelist.add(new LatLon(x, y));
     108             }
     109             m_listLatLon = nodelist;
     110         } catch (Exception e) {
     111                //m_listLatLon = new ArrayList<>();
     112         }
     113     }
     114   
    88115}
Note: See TracChangeset for help on using the changeset viewer.