<commit_before><!DOCTYPE html>
<html>
<head>
    <title>arc.js</title>
    <meta charset="utf-8" />
    <link rel="stylesheet" href="http://leaflet.cloudmade.com/dist/leaflet.css" />
    <!--[if lte IE 8]><link rel="stylesheet" href="../dist/leaflet.ie.css" /><![endif]-->

<!--
    <script src="http://leaflet.cloudmade.com/dist/leaflet.js"></script>
--> 
    <script src="https://raw.github.com/CloudMade/Leaflet/master/dist/leaflet.js"></script>
    <script src="./arc.js"></script>
    <style>

      body {
        margin:10px auto;
        width:90%;
        font:14px/20px 'Helvetica';
      }

      #map {
        border: 1px solid;
        width:  100%;
        height: 420px;
        margin: 10px auto;
      }

      #json-dump {
        width: 100%;
        height: 100px;
      }

    </style>
</head>
<body>

    <div>
      <h3>Arc.js with Leaflet</h3> 
      <p>Single clicks on the map will plot points. Once you have drawn two points a great circle arc (curved path) should automatically be drawn between the first point and the second. Nearby clicks will be snapped to existing start/end points. Click on the lines to get details. All drawn lines are collected as GeoJSON below the map.</p>
      <p><a href="https://github.com/springmeyer/arc.js">source code on github</a></p>
    </div>

    <div id="map"></div>

    <div id="geojson">
    <textarea id="json-dump"></textarea>
    </div>

    <script>
        var map = new L.Map('map');
        var idx = 1;
        var features = [];
        
        var url = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
        var attribution = 'Map data &copy; 2011 OpenStreetMap contributors';
        var osm = new L.TileLayer(url, {maxZoom: 18, attribution: attribution});
        
        map.setView(new L.LatLng(30, -50), 2).addLayer(osm);
        
        // number of intermediate arc points
        var npoints = 50;
        var coords = [];
        var points = [];
        var snap_tolerance = 1000000;
        
        map.on('click', onMapClick);

        var start;
        var end;
        function draw(coords) {
            var len = coords.length;
            if (len == 1) {
                var hit = false;
                start = coords[0];
                for (var i=0;i<points.length;++i) {
                    var distance = points[i].distanceTo(start);
                    if (distance<snap_tolerance) {
                        console.log('hit previous point, re-using location')
                        start = points[i];
                        hit = true;
                    } else {
                        console.log(distance);
                    }
                }
                if (!hit) {
                    points.push(start);
                }
                var circleOptions = {color: '#f03', opacity: 0.5, clickable:false};
                var circle = new L.CircleMarker(start, circleOptions);
                map.addLayer(circle);

            } else if (len == 2) {
                var hit = false;
                end = coords[1];
                for (var i=0;i<points.length;++i) {
                    var distance = points[i].distanceTo(end);
                    if (distance<snap_tolerance) {
                        console.log('hit previous point, re-using location')
                        end = points[i];
                        hit = true;
                    } else {
                        console.log(distance);
                    }
                }
                if (!hit) {
                    points.push(end);
                }
                var circleOptions = {color: '#f03', opacity: 0.5, clickable:false};
                var circle = new L.CircleMarker(end, circleOptions);
                map.addLayer(circle);

                try {
                    var from = new arc.Coord(start.lng,start.lat);
                    var to = new arc.Coord(end.lng,end.lat);
                    var properties = {
                        arc:idx++,
                        start:''+from.lon+','+from.lat,
                        end:''+to.lon+','+to.lat
                    };
                    var greatCircle = new arc.GreatCircle(from,to,properties);
                } catch (e) {<commit_msg>avoid end point snapping to start point<commit_after><!DOCTYPE html>
<html>
<head>
    <title>arc.js</title>
    <meta charset="utf-8" />
    <link rel="stylesheet" href="http://leaflet.cloudmade.com/dist/leaflet.css" />
    <!--[if lte IE 8]><link rel="stylesheet" href="../dist/leaflet.ie.css" /><![endif]-->

<!--
    <script src="http://leaflet.cloudmade.com/dist/leaflet.js"></script>
--> 
    <script src="https://raw.github.com/CloudMade/Leaflet/master/dist/leaflet.js"></script>
    <script src="./arc.js"></script>
    <style>

      body {
        margin:10px auto;
        width:90%;
        font:14px/20px 'Helvetica';
      }

      #map {
        border: 1px solid;
        width:  100%;
        height: 420px;
        margin: 10px auto;
      }

      #json-dump {
        width: 100%;
        height: 100px;
      }

    </style>
</head>
<body>

    <div>
      <h3>Arc.js with Leaflet</h3> 
      <p>Single clicks on the map will plot points. Once you have drawn two points a great circle arc (curved path) should automatically be drawn between the first point and the second. Nearby clicks will be snapped to existing start/end points. Click on the lines to get details. All drawn lines are collected as GeoJSON below the map.</p>
      <p><a href="https://github.com/springmeyer/arc.js">source code on github</a></p>
    </div>

    <div id="map"></div>

    <div id="geojson">
    <textarea id="json-dump"></textarea>
    </div>

    <script>
        var map = new L.Map('map');
        var idx = 1;
        var features = [];
        
        var url = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
        var attribution = 'Map data &copy; 2011 OpenStreetMap contributors';
        var osm = new L.TileLayer(url, {maxZoom: 18, attribution: attribution});
        
        map.setView(new L.LatLng(30, -50), 2).addLayer(osm);
        
        // number of intermediate arc points
        var npoints = 50;
        var coords = [];
        var points = [];
        var snap_tolerance = 500000;
        
        map.on('click', onMapClick);

        var start;
        var end;
        function draw(coords) {
            var len = coords.length;
            if (len == 1) {
                var hit = false;
                start = coords[0];
                for (var i=0;i<points.length;++i) {
                    var distance = points[i].distanceTo(start);
                    if (distance<snap_tolerance) {
                        console.log('hit previous point, re-using location')
                        start = points[i];
                        hit = true;
                    } else {
                        console.log(distance);
                    }
                }
                if (!hit) {
                    points.push(start);
                }
                var circleOptions = {color: '#f03', opacity: 0.5, clickable:false};
                var circle = new L.CircleMarker(start, circleOptions);
                map.addLayer(circle);

            } else if (len == 2) {
                var hit = false;
                end = coords[1];
                for (var i=0;i<points.length;++i) {
                    var distance = points[i].distanceTo(end);
                    if (distance<snap_tolerance && (points[i].lng !== start.lng)) {
                        console.log('hit previous point, re-using location')
                        end = points[i];
                        hit = true;
                    } else {
                        console.log(distance);
                    }
                }
                if (!hit) {
                    points.push(end);
                }
                var circleOptions = {color: '#f03', opacity: 0.5, clickable:false};
                var circle = new L.CircleMarker(end, circleOptions);
                map.addLayer(circle);

                try {
                    var from = new arc.Coord(start.lng,start.lat);
                    var to = new arc.Coord(end.lng,end.lat);
                    var properties = {
                        arc:idx++,
                        start:''+from.lon+','+from.lat,
                        end:''+to.lon+','+to.lat
                    };
                    var greatCircle = new arc.GreatCircle(from,to,properties);
                } catch (e) {
{'fraction_non_alphanumeric': 0.13259085580304805, 'fraction_numerical': 0.014419695193434936, 'mean_word_length': 1.39971870604782, 'pattern_counts': {'":': 0, '<': 87, '<?xml version=': 0, '>': 79, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1290923', 'n_tokens_mistral': 2601, 'n_tokens_neox': 2355, 'n_words': 586}