Examples of GpsFormat


Examples of net.sourceforge.gpstools.utils.GpsFormat

        xw.endElement("Placemark");
    }

    private String formatCoordinates(Trkseg seg){
        StringBuilder sb = new StringBuilder();
        GpsFormat gpsFormat = GpsFormat.getInstance();
        for(Trkpt pt : seg.getTrkpt()){
            sb.append(gpsFormat.asLatLon(pt.getLon(), pt.getLat()));
            Number ele = pt.getEle();
            if(ele != null && ele.doubleValue() >= 0.01){
                sb.append(',');
                sb.append(gpsFormat.asAltitude(ele));
            }
            sb.append(' ');
        }
        sb.deleteCharAt(sb.length() - 1);
        return sb.toString();
View Full Code Here

Examples of net.sourceforge.gpstools.utils.GpsFormat

        processTemplate("/net/sourceforge/gpstools/res/OpenLayers.js.template",
                out);
    }

    private void drawWaypoints(Appendable mapjs) throws IOException {
        GpsFormat format = GpsFormat.getInstance();
        Wpt[] points = getGpx().getWpt();
        if (points != null) {
            for (Wpt wpt : points) {
                String desc = wpt.getDesc();
                String name = wpt.getName();
                name = (name == null) ? "Wpt" : name.trim();
                mapjs.append("gpxmap.addWpt({lon:");
                mapjs.append(format.asLatLon(wpt.getLon()));
                mapjs.append(",lat:").append(format.asLatLon(wpt.getLat()));
                mapjs.append(",desc:'<div class=\"wpt-name\">")
                        .append(name.replace('\'', ' ')).append("</div>");
                if (desc != null && desc.length() != 0
                        && !desc.trim().equals(name)) {
                    mapjs.append("<div class=\"wpt-desc\">").append(
View Full Code Here

Examples of net.sourceforge.gpstools.utils.GpsFormat

    }

    private void setBounds(Appendable mapjs) throws IOException {
        Rectangle2D.Double bd = getBounds();
        float padding = getPadding();
        GpsFormat format = GpsFormat.getInstance();
        mapjs.append("W:").append(format.asLatLon(bd.y - bd.height * padding));
        mapjs.append(",S:").append(format.asLatLon(bd.x - bd.width * padding));
        mapjs.append(",E:").append(
                format.asLatLon(bd.y + bd.height * (1.0f + padding)));
        mapjs.append(",N:").append(
                format.asLatLon(bd.x + bd.width * (1.0f + padding)));
    }
View Full Code Here

Examples of net.sourceforge.gpstools.utils.GpsFormat

    private static CharSequence trksegToLine(Trkpt[] pts, String color,
            String name) {
        CharSequence result = "//less than two trkpts";
        if (pts.length > 1) {
            GpsFormat format = GpsFormat.getInstance();
            StringBuilder sb = new StringBuilder("points = [\n");
            for (Trkpt pt : pts) {
                sb.append("{lon:");
                sb.append(format.asLatLon(pt.getLon())).append(",lat:");
                sb.append(format.asLatLon(pt.getLat())).append("},\n");
            }
            sb.deleteCharAt(sb.length() - 2);
            sb.append("];\n");
            sb.append("gpxmap.addTrkSeg({trkpt: points, color: '");
            sb.append(color).append("'}");
View Full Code Here

Examples of net.sourceforge.gpstools.utils.GpsFormat

        processTemplate("/net/sourceforge/gpstools/res/GoogleMap.js.template",
                out);
    }

    private void wptsToGMarkers(Appendable mapjs) throws IOException {
        GpsFormat format = GpsFormat.getInstance();
        for (Wpt wpt : getGpx().getWpt()) {
            String desc = wpt.getDesc();
            desc = (desc == null) ? "" : desc.trim();
            String name = wpt.getName();
            name = (name == null) ? "Wpt" : name.trim();
            int linkstart = desc.indexOf("http://");
            if (linkstart >= 0) {
                String link = desc.substring(linkstart);
                link = link.replaceFirst("\\s.*", "");
                mapjs.append("map.addOverlay(createUrlMarker(new GLatLng(");
                mapjs.append(format.asLatLon(wpt.getLat(), wpt.getLon()));
                mapjs.append("), {clickable: true, title: \"");
                mapjs.append(name).append("\"}, \"").append(link)
                        .append("\"));");
            } else {
                mapjs.append("map.addOverlay(createMarker(new GLatLng(");
                mapjs.append(format.asLatLon(wpt.getLat(), wpt.getLon()));
                mapjs.append("), {clickable: false, title: \"");
                mapjs.append(name).append("\"}));\n");
            }
        }
    }
View Full Code Here

Examples of net.sourceforge.gpstools.utils.GpsFormat

        return builder;
    }

    private static void trksegToUnencodedGPolyline(Trkpt[] pts, String color,
            Appendable mapjs) throws IOException {
        GpsFormat format = GpsFormat.getInstance();
        mapjs.append("points = [];\n");
        for (Trkpt pt : pts) {
            mapjs.append("points.push(new GLatLng(");
            mapjs.append(format.asLatLon(pt.getLat(), pt.getLon()));
            mapjs.append("));\n");
        }
        mapjs.append("map.addOverlay(new GPolyline(points, \"");
        mapjs.append(color).append("\", 2));\n");
    }
View Full Code Here

Examples of net.sourceforge.gpstools.utils.GpsFormat

        mapjs.append(color).append("\", 2));\n");
    }

    private static void trksegToEncodedGPolyline(Trkpt[] pts, String color,
            Appendable mapjs) throws IOException {
        GpsFormat format = GpsFormat.getInstance();
        final int len = pts.length;
        int[] ilevels = new int[len];
        mapjs.append("//new segment\n");

        /*
         * we encode at most 100 points simultaneously to avoid big rounding
         * errors and overlong strings
         */
        for (int start = 0, stop = 100; stop != len; start = stop - 1) {
            mapjs.append("map.addOverlay(GPolyline.fromEncoded({\n");
            mapjs.append("  color: \"").append(color).append("\",\n");
            mapjs.append("  weight: 2,\n");
            mapjs.append("  opacity: 0.5,\n");

            /* encode first point */
            mapjs.append("  points: \"");
            Trkpt previous;
            Trkpt current = pts[start];
            format.asGPolylineCoordinate(current.getLat(), null, mapjs);
            format.asGPolylineCoordinate(current.getLon(), null, mapjs);

            stop = start + 100;
            if (len <= stop) {
                stop = len;
            }

            /* encode other points */
            for (int i = start + 1; i < stop; i++) {
                previous = current;
                current = pts[i];
                format.asGPolylineCoordinate(current.getLat(),
                        previous.getLat(), mapjs);
                format.asGPolylineCoordinate(current.getLon(),
                        previous.getLon(), mapjs);
            }

            mapjs.append("\",\n");

            /* calculate and encode levels */
            mapjs.append("  levels: \"");
            calculateLevels(pts, start, stop, ilevels);

            for (int i = start; i < stop; i++) {
                format.gEncodeUnsignedInt(ilevels[i], mapjs);
            }

            mapjs.append("\",\n");
            mapjs.append("  zoomFactor: 2,\n");
            mapjs.append("  numLevels: 18\n");
View Full Code Here

Examples of net.sourceforge.gpstools.utils.GpsFormat

    }

    private void zoomMap(Appendable mapjs) throws IOException {
        Rectangle2D.Double bd = getBounds();
        float padding = getPadding();
        GpsFormat format = GpsFormat.getInstance();
        mapjs.append("map.setZoom(\n");
        mapjs.append("    map.getBoundsZoomLevel(\n");
        mapjs.append("        new GLatLngBounds(\n");
        mapjs.append("            new GLatLng(");
        mapjs.append(
                format.asLatLon(bd.x - bd.width * padding, bd.y - bd.height
                        * padding)).append("),\n");
        mapjs.append("            new GLatLng(");
        mapjs.append(format.asLatLon(bd.x + bd.width * (1.0f + padding), bd.y
                + bd.height * (1.0f + padding)));
        mapjs.append(")\n");
        mapjs.append("        )\n");
        mapjs.append("    )\n");
        mapjs.append(");\n");
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.