Changeset 27491 in osm for applications/viewer/jmapviewer


Ignore:
Timestamp:
2012-01-19T18:48:10+01:00 (13 years ago)
Author:
simon04
Message:

jmapviewer: fix encoding bug (under Windows) introduced in r27483.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java

    r27483 r27491  
    44
    55import java.awt.Image;
    6 import java.io.BufferedReader;
    7 import java.io.ByteArrayInputStream;
    86import java.io.IOException;
    9 import java.io.InputStreamReader;
     7import java.io.StringReader;
    108import java.net.URL;
    119import java.util.ArrayList;
    1210import java.util.List;
    1311import java.util.Locale;
     12import java.util.Scanner;
    1413import java.util.concurrent.Callable;
    1514import java.util.concurrent.Executors;
     
    6362            URL u = new URL("http://dev.virtualearth.net/REST/v1/Imagery/Metadata/Aerial?include=ImageryProviders&output=xml&key="
    6463                    + API_KEY);
    65             BufferedReader in = new BufferedReader(new InputStreamReader(u.openStream()));
    66             StringBuilder content = new StringBuilder(1<<15 /* represents 32k */);
    67             String line;
    68             while ((line = in.readLine()) != null) {
    69                 content.append(line);
    70             }
    71             in.close();
     64            UTFInputStreamReader in = UTFInputStreamReader.create(u.openStream(), "utf-8");
     65            String r = new Scanner(in).useDelimiter("\\A").next();
    7266            System.out.println("Successfully loaded Bing attribution data.");
    73             return content.toString().getBytes();
     67            return r.getBytes("utf-8");
    7468        }
    7569    }
     
    9993            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    10094            DocumentBuilder builder = factory.newDocumentBuilder();
    101             Document document = builder.parse(new InputSource(
    102                     UTFInputStreamReader.create(new ByteArrayInputStream(xml.getBytes()), "UTF-8")));
     95            Document document = builder.parse(new InputSource(new StringReader(xml)));
    10396
    10497            XPathFactory xPathFactory = XPathFactory.newInstance();
     
    228221                            Thread.sleep(waitTimeSec * 1000L);
    229222                            waitTimeSec *= 2;
     223                            ex.printStackTrace();
    230224                        }
    231225                    }
     
    236230            final List<Attribution> data;
    237231            try {
    238                 data = attributions.get(100, TimeUnit.MILLISECONDS);
     232                data = attributions.get(1000, TimeUnit.MILLISECONDS);
    239233            } catch (TimeoutException ex) {
    240234                return "Loading Bing attribution data...";
Note: See TracChangeset for help on using the changeset viewer.