Package org.openstreetmap.josm.data.coor

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


        public void visit(IWay w) {
            geomObj.add("type", "LineString");
            if (w instanceof Way) {
                JsonArrayBuilder array = Json.createArrayBuilder();
                for (Node n : ((Way)w).getNodes()) {
                    LatLon ll = n.getCoor();
                    if (ll != null) {
                        array.add(getCoorArray(ll));
                    }
                }
                geomObj.add("coordinates", array);
View Full Code Here


    }

    public double getDist100Pixel() {
        int w = getWidth()/2;
        int h = getHeight()/2;
        LatLon ll1 = getLatLon(w-50,h);
        LatLon ll2 = getLatLon(w+50,h);
        return ll1.greatCircleDistance(ll2);
    }
View Full Code Here

     * @param newCenter The center x-value (easting) to zoom to.
     * @param newScale The scale to use.
     */
    public void zoomTo(EastNorth newCenter, double newScale) {
        Bounds b = getProjection().getWorldBoundsLatLon();
        LatLon cl = Projections.inverseProject(newCenter);
        boolean changed = false;
        double lat = cl.lat();
        double lon = cl.lon();
        if(lat < b.getMinLat()) {changed = true; lat = b.getMinLat(); }
        else if(lat > b.getMaxLat()) {changed = true; lat = b.getMaxLat(); }
        if(lon < b.getMinLon()) {changed = true; lon = b.getMinLon(); }
        else if(lon > b.getMaxLon()) {changed = true; lon = b.getMaxLon(); }
        if(changed) {
            newCenter = Projections.project(new LatLon(lat,lon));
        }
        int width = getWidth()/2;
        int height = getHeight()/2;
        LatLon l1 = new LatLon(b.getMinLat(), lon);
        LatLon l2 = new LatLon(b.getMaxLat(), lon);
        EastNorth e1 = getProjection().latlon2eastNorth(l1);
        EastNorth e2 = getProjection().latlon2eastNorth(l2);
        double d = e2.north() - e1.north();
        if (height > 0 && d < height*newScale) {
            double newScaleH = d/height;
            e1 = getProjection().latlon2eastNorth(new LatLon(lat, b.getMinLon()));
            e2 = getProjection().latlon2eastNorth(new LatLon(lat, b.getMaxLon()));
            d = e2.east() - e1.east();
            if (width > 0 && d < width*newScale) {
                newScale = Math.max(newScaleH, d/width);
            }
        } else if (height > 0) {
View Full Code Here

            return new Node(new EastNorth(east1 / size, north1 / size));
        case 2:
            final double[] weights = new double[size];

            for (int i = 0; i < size; i++) {
                final LatLon c1 = candidates.get(i).getCoor();
                for (int j = i + 1; j < size; j++) {
                    final LatLon c2 = candidates.get(j).getCoor();
                    final double d = c1.distance(c2);
                    weights[i] += d;
                    weights[j] += d;
                }
            }
View Full Code Here

            cmds.addAll(wayFixCommands);

            // build the commands
            //
            if (targetNode != targetLocationNode) {
                LatLon targetLocationCoor = targetLocationNode.getCoor();
                if (!targetNode.getCoor().equals(targetLocationCoor)) {
                    Node newTargetNode = new Node(targetNode);
                    newTargetNode.setCoor(targetLocationCoor);
                    cmds.add(new ChangeCommand(targetNode, newTargetNode));
                }
View Full Code Here

        double area2 = 0.;
        int nodesCount = w.getNodesCount();

        for (int node = 1; node <= /*sic! consider last-first as well*/ nodesCount; node++) {
            LatLon coorPrev = w.getNode(node - 1).getCoor();
            LatLon coorCurr = w.getNode(node % nodesCount).getCoor();
            area2 += coorPrev.lon() * coorCurr.lat();
            area2 -= coorCurr.lon() * coorPrev.lat();
        }
        return area2 < 0;
    }
View Full Code Here

    }

    public static LatLon getLatLonOfTile(double x, double y, double zoom) {
        double lon = x / Math.pow(2.0, zoom) * 360.0 - 180;
        double lat = Math.toDegrees(Math.atan(Math.sinh(Math.PI - (2.0 * Math.PI * y) / Math.pow(2.0, zoom))));
        return new LatLon(lat, lon);
    }
View Full Code Here

        return !Double.isNaN(lat) && !Double.isNaN(lon);
    }

    @Override
    public LatLon getCoor() {
        return isLatLonKnown() ? new LatLon(lat,lon) : null;
    }
View Full Code Here

        return Projections.project(getCoor());
    }

    @Override
    public void setEastNorth(EastNorth eastNorth) {
        LatLon ll = Projections.inverseProject(eastNorth);
        setCoor(ll);
    }
View Full Code Here

    protected URL getURL(double w, double s,double e,double n,
            int wi, int ht) throws MalformedURLException {
        String myProj = Main.getProjection().toCode();
        if (!info.getServerProjections().contains(myProj) && "EPSG:3857".equals(Main.getProjection().toCode())) {
            LatLon sw = Main.getProjection().eastNorth2latlon(new EastNorth(w, s));
            LatLon ne = Main.getProjection().eastNorth2latlon(new EastNorth(e, n));
            myProj = "EPSG:4326";
            s = sw.lat();
            w = sw.lon();
            n = ne.lat();
            e = ne.lon();
        }
        if ("EPSG:4326".equals(myProj) && !info.getServerProjections().contains(myProj) && info.getServerProjections().contains("CRS:84")) {
            myProj = "CRS:84";
        }
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.