Examples of Geonames


Examples of slash.navigation.geonames.binding.Geonames

    private Geonames getGeonamesFor(String uri, double longitude, double latitude) throws IOException {
        return getGeonamesFor(uri + "?lat=" + latitude + "&lng=" + longitude);
    }

    private String getNearByFor(String uri, double longitude, double latitude) throws IOException {
        Geonames geonames = getGeonamesFor(uri, longitude, latitude);
        if (geonames == null || geonames.getGeoname() == null)
            return null;
        if (geonames.getStatus() != null)
            throw new IOException(geonames.getStatus().getMessage());
        List<String> result = new ArrayList<String>();
        for (Geonames.Geoname geoname : geonames.getGeoname()) {
            result.add(geoname.getName());
        }
        return result.size() > 0 ? result.get(0) : null;
    }
View Full Code Here

Examples of slash.navigation.geonames.binding.Geonames

            description = getNearByToponymFor(longitude, latitude);
        return description;
    }

    public PostalCode getNearByPostalCodeFor(double longitude, double latitude) throws IOException {
        Geonames geonames = getGeonamesFor("findNearbyPostalCodes", longitude, latitude);
        if (geonames == null || geonames.getCode() == null)
            return null;
        List<PostalCode> result = new ArrayList<PostalCode>();
        for (Geonames.Code code : geonames.getCode()) {
            result.add(new PostalCode(code.getCountryCode(), code.getPostalcode(), code.getName()));
        }
        return result.size() > 0 ? result.get(0) : null;
    }
View Full Code Here

Examples of slash.navigation.geonames.binding.Geonames

        }
        return result.size() > 0 ? result.get(0) : null;
    }

    public String getPlaceNameFor(String countryCode, String postalCode) throws IOException {
        Geonames geonames = getGeonamesFor("postalCodeSearch?postalcode=" + postalCode + "&country=" + countryCode);
        if (geonames == null || geonames.getCode() == null)
            return null;
        List<PostalCode> result = new ArrayList<PostalCode>();
        for (Geonames.Code code : geonames.getCode()) {
            result.add(new PostalCode(code.getCountryCode(), code.getPostalcode(), code.getName()));
        }
        return result.size() > 0 ? result.get(0).placeName : null;
    }
View Full Code Here

Examples of slash.navigation.geonames.binding.Geonames

     * @param postalCode  the postal code to search a position for
     * @return the longitude and latitude for the given country and postal code
     * @throws IOException if an error occurs while accessing geonames.org
     */
    public double[] getPositionFor(String countryCode, String postalCode) throws IOException {
        Geonames geonames = getGeonamesFor("postalCodeSearch?postalcode=" + postalCode + "&country=" + countryCode);
        if (geonames == null || geonames.getCode() == null)
            return null;
        List<Double> result = new ArrayList<Double>();
        for (Geonames.Code code : geonames.getCode()) {
            result.add(code.getLng().doubleValue());
            result.add(code.getLat().doubleValue());
        }
        return result.size() > 1 ? new double[]{result.get(0), result.get(1)} : null;
    }
View Full Code Here

Examples of slash.navigation.geonames.binding.Geonames

    private static Unmarshaller newUnmarshaller() {
        return JAXBHelper.newUnmarshaller(newContext(ObjectFactory.class));
    }

    private static Geonames unmarshal(StringReader reader) throws JAXBException {
        Geonames result = null;
        try {
            result = (Geonames) newUnmarshaller().unmarshal(reader);
        } catch (ClassCastException e) {
            throw new JAXBException("Parse error: " + e, e);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.