Package org.openstreetmap.josm.data.coor

Examples of org.openstreetmap.josm.data.coor.LatLon


                try {
                    zoom = Integer.parseInt(v);
                } catch(NumberFormatException e) {
                    throw new XmlParsingException(tr("Illegal value for attribute ''{0}'' on XML tag ''{1}''. Got {2}.", "zoom", "home", v));
                }
                userInfo.setHome(new LatLon(lat,lon));
                userInfo.setHomeZoom(zoom);
            }

            // -- language list
            NodeList xmlNodeList = (NodeList)xpath.compile("/osm/user[1]/languages[1]/lang/text()").evaluate(document, XPathConstants.NODESET);
View Full Code Here


     */
    public static LatLon readLatLon(GpsDirectory dirGps) throws MetadataException {
        if (dirGps != null) {
            double lat = readAxis(dirGps, GpsDirectory.TAG_GPS_LATITUDE, GpsDirectory.TAG_GPS_LATITUDE_REF, 'S');
            double lon = readAxis(dirGps, GpsDirectory.TAG_GPS_LONGITUDE, GpsDirectory.TAG_GPS_LONGITUDE_REF, 'W');
            return new LatLon(lat, lon);
        }
        return null;
    }
View Full Code Here

        if (!LatLon.isValidLat(minLat))
            throw new IllegalArgumentException(tr("Illegal latitude value for parameter ''{0}'', got {1}", "minLat", minLat));
        if (!LatLon.isValidLat(maxLat))
            throw new IllegalArgumentException(tr("Illegal longitude value for parameter ''{0}'', got {1}", "maxLat", maxLat));

        return inBbox(new LatLon(minLon, minLat), new LatLon(maxLon, maxLat));
    }
View Full Code Here

        if (viewportEl != null) {
            EastNorth center = null;
            Element centerEl = getElementByTagName(viewportEl, "center");
            if (centerEl != null && centerEl.hasAttribute("lat") && centerEl.hasAttribute("lon")) {
                try {
                    LatLon centerLL = new LatLon(Double.parseDouble(centerEl.getAttribute("lat")), Double.parseDouble(centerEl.getAttribute("lon")));
                    center = Projections.project(centerLL);
                } catch (NumberFormatException ex) {
                    Main.warn(ex);
                }
            }
            if (center != null) {
                Element scaleEl = getElementByTagName(viewportEl, "scale");
                if (scaleEl != null && scaleEl.hasAttribute("meter-per-pixel")) {
                    try {
                        double meterPerPixel = Double.parseDouble(scaleEl.getAttribute("meter-per-pixel"));
                        Projection proj = Main.getProjection();
                        // Get a "typical" distance in east/north units that
                        // corresponds to a couple of pixels. Shouldn't be too
                        // large, to keep it within projection bounds and
                        // not too small to avoid rounding errors.
                        double dist = 0.01 * proj.getDefaultZoomInPPD();
                        LatLon ll1 = proj.eastNorth2latlon(new EastNorth(center.east() - dist, center.north()));
                        LatLon ll2 = proj.eastNorth2latlon(new EastNorth(center.east() + dist, center.north()));
                        double meterPerEasting = ll1.greatCircleDistance(ll2) / dist / 2;
                        double scale = meterPerPixel / meterPerEasting; // unit: easting per pixel
                        viewport = new ViewportData(center, scale);
                    } catch (NumberFormatException ex) {
                        Main.warn(ex);
View Full Code Here

                                    entry.setFile(new File(attrElem.getTextContent()));
                                    break;
                                case "position":
                                    double lat = Double.parseDouble(attrElem.getAttribute("lat"));
                                    double lon = Double.parseDouble(attrElem.getAttribute("lon"));
                                    entry.setPos(new LatLon(lat, lon));
                                    break;
                                case "speed":
                                    entry.setSpeed(Double.parseDouble(attrElem.getTextContent()));
                                    break;
                                case "elevation":
                                    entry.setElevation(Double.parseDouble(attrElem.getTextContent()));
                                    break;
                                case "gps-time":
                                    entry.setGpsTime(new Date(Long.parseLong(attrElem.getTextContent())));
                                    break;
                                case "exif-orientation":
                                    entry.setExifOrientation(Integer.parseInt(attrElem.getTextContent()));
                                    break;
                                case "exif-time":
                                    entry.setExifTime(new Date(Long.parseLong(attrElem.getTextContent())));
                                    break;
                                case "exif-gps-time":
                                    entry.setExifGpsTime(new Date(Long.parseLong(attrElem.getTextContent())));
                                    break;
                                case "exif-coordinates":
                                    entry.setExifCoor(new LatLon(
                                            Double.parseDouble(attrElem.getAttribute("lat")),
                                            Double.parseDouble(attrElem.getAttribute("lon"))));
                                    break;
                                case "exif-image-direction":
                                    entry.setExifImgDir(Double.parseDouble(attrElem.getTextContent()));
View Full Code Here

                    noSnapNow();
                }
            }

            // find out the distance, in metres, between the base point and projected point
            LatLon mouseLatLon = Main.map.mapView.getProjection().eastNorth2latlon(snapPoint);
            double distance = currentBaseNode.getCoor().greatCircleDistance(mouseLatLon);
            double hdg = Math.toDegrees(p0.heading(snapPoint));
            // heading of segment from current to calculated point, not to mouse position

            if (baseHeading >=0 ) { // there is previous line segment with some heading
View Full Code Here

        return tabs.getModel().getSelectedIndex() == 0;
    }

    public void setCoordinates(LatLon ll) {
        if (ll == null) {
            ll = new LatLon(0,0);
        }
        this.latLonCoordinates = ll;
        tfLatLon.setText(ll.latToString(CoordinateFormat.getDefaultFormat()) + " " + ll.lonToString(CoordinateFormat.getDefaultFormat()));
        EastNorth en = Main.getProjection().latlon2eastNorth(ll);
        tfEastNorth.setText(en.east()+" "+en.north());
View Full Code Here

        }
        return n== null ? null : n.doubleValue();
    }

    protected void parseLatLonUserInput() {
        LatLon latLon;
        try {
            latLon = parseLatLon(tfLatLon.getText());
            if (!LatLon.isValidLat(latLon.lat()) || !LatLon.isValidLon(latLon.lon())) {
                latLon = null;
            }
        } catch (IllegalArgumentException e) {
            latLon = null;
        }
View Full Code Here

                    params[3], params[4], params[5], "E");
        } else {
            throw new IllegalArgumentException("invalid format: " + pattern);
        }

        return new LatLon(latLon.lat, latLon.lon);
    }
View Full Code Here

        Element viewportEl = doc.createElement("viewport");
        root.appendChild(viewportEl);
        Element centerEl = doc.createElement("center");
        viewportEl.appendChild(centerEl);
        EastNorth center = Main.map.mapView.getCenter();
        LatLon centerLL = Projections.inverseProject(center);
        centerEl.setAttribute("lat", Double.toString(centerLL.lat()));
        centerEl.setAttribute("lon", Double.toString(centerLL.lon()));
        Element scale = doc.createElement("scale");
        viewportEl.appendChild(scale);
        double dist100px = Main.map.mapView.getDist100Pixel();
        scale.setAttribute("meter-per-pixel", Double.toString(dist100px / 100));
View Full Code Here

TOP

Related Classes of org.openstreetmap.josm.data.coor.LatLon

Copyright © 2018 www.massapicom. 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.