<commit_before><?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="robots" content="index, all" />
  <title>WebGL Earth API - Polygon Example</title>

  <script src="../Cesium/Build/Cesium/Cesium.js"></script>
  <script src="http://localhost:9810/compile?id=api-debug"></script>

  <script>    
    var app, poly;
    function startWE() {
    
      var options = {
        altitude: 360,
        position: [47.192, 8.523],
        map: WebGLEarth.Maps.OSM,
        proxyHost: 'http://srtm.webglearth.com/cgi-bin/corsproxy.fcgi?url='
      };

      app = new WebGLEarth('webglearthdiv', options);
      app.showMiniGlobe('../deploy/world512.jpg', 128);
      app.setTilt(45);
      
      var defaultPoly = new WebGLEarth.Polygon(app);
      defaultPoly.setFillColor('#00ffff', 0.3);
      defaultPoly.addPoint(47.1966945, 8.52359601);
      defaultPoly.addPoint(47.1963864, 8.52475703);
      var cornerPoint =
      defaultPoly.addPoint(47.1954063, 8.52230885);
      defaultPoly.addPoint(47.1966242, 8.52120111);
      defaultPoly.addPoint(47.1967805, 8.52164874);
      defaultPoly.addPoint(47.1972796, 8.52242167);
      defaultPoly.addPoint(47.1972434, 8.52277868);
      defaultPoly.disableClickToAdd();
      defaultPoly.showDraggers(false);
      defaultPoly.onClick(reopenPoly);
      
      var defaultPoly2 = new WebGLEarth.Polygon(app);
      defaultPoly2.setFillColor('#00ff00', 0.3);
      defaultPoly2.addPoint(47.1965465487, 8.5211790565);
      defaultPoly2.addPoint(47.1953526123, 8.5222943548);
      defaultPoly2.addPoint(47.1942354599, 8.5196876980);
      defaultPoly2.addPoint(47.1958763746, 8.5188098538);
      defaultPoly2.disableClickToAdd();
      defaultPoly2.showDraggers(false);
      defaultPoly2.onClick(reopenPoly);
      
      // let the corner point animate in circle
      //   not very useful way of demonstrating the movePoint() method
      setInterval(function() {
        var alpha = 2 * Math.PI * (+new Date())/1000;
        var x_ = Math.cos(alpha)/8000;
        var y_ = Math.sin(alpha)/8000;
        defaultPoly.movePoint(cornerPoint, 47.1954063 + x_, 8.52230885 + y_);
        document.getElementById('info3div').innerHTML = "The two default polygons " + (defaultPoly.intersects(defaultPoly2) ? "DO" : "DO NOT") + " intersect.";
      }, 50);
    }

    function reopenPoly(pol_) {
      if (poly) {
        // disable old active polygon
        poly.disableClickToAdd();
        poly.showDraggers(false);
      }
      poly = pol_;
      poly.showDraggers(true);
      poly.setOnChange(onchange);
    }
    
    function startPoly() {
      if (poly) {
        closePoly();
      }
      poly = new WebGLEarth.Polygon(app);
      poly.enableClickToAdd();
      poly.setOnChange(onchange);
      setBorder('#000000', 0.9);
      poly.setFillColor('#eedd00', 0.6);
      poly.onClick(reopenPoly);
      document.getElementById('infodiv').innerHTML = 'Create polygon by clicking on the ground, Alt-click on polygon node to remove it.';
    }

    function closePoly() {
      if (!poly) return;
      poly.disableClickToAdd();
      poly.showDraggers(false);
      poly = null;
      document.getElementById('infodiv').innerHTML = '';
      document.getElementById('info2div').innerHTML = '';
    }

    function removePoly() {
      if (!poly) return;
      poly.destroy();
      poly = null;
    }
    
    var borderHex = '#000000', borderAlpha = 1; //remember the color so we can visualize invalid polygons
    function onchange() {
      if (poly) {
        document.getElementById('info2div').innerHTML =
            poly.isValid() ? poly.getRoughArea().toFixed(2) + ' m2' :
            'Invalid polygon (self-intersecting or  < 3 vertices)';
        if (poly.isValid()) {
          poly.setStrokeColor(borderHex, borderAlpha);
        } else {
          poly.setStrokeColor('#ff0000', 1);
        }

        // when the user has already defined already at least 4 points,
        //   disable the "click-to-add" feature
        if (poly.getPoints().length >= 4) {
          poly.disableClickToAdd();
        } else {
          poly.enableClickToAdd();
        }
      }
    }

    function setBorder(hex, opt_a) {
      if (poly) {
        borderHex = hex;
        borderAlpha = opt_a;
        poly.setStrokeColor(hex, opt_a);
      }
    }
    
    function randomIcon() {
      if (poly) {
        var icons = [1, 10, 14, 15, 17, 20, 23, 25, 26, 31, 34, 36, 40, 42, 43, 45, 47, 48, 49, 50, 52, 53, 54];
        var random = icons[Math.floor(Math.random() * icons.length)];
        
        // (src, reference height in pixels, minimal height in pixels, maximal height in pixels)
        poly.setIcon('icons/' + random + '.png', 50, 30, 250);
      }
    }
  </script>
  
 </head>
 <body onload="javascript:startWE()">
   <div id="webglearthdiv" style="width:600px;height:400px;"></div>
   <div id="infodiv" style="width:600px;height:20px;"></div>
   <div id="info2div" style="width:600px;height:20px;"></div>
   <div id="info3div" style="width:600px;height:20px;"></div>
   <br />
   <input type="button" id="start" value="Start new polygon" onclick="javascript:startPoly()"/>
   <input type="button" id="close" value="Close polygon" onclick="javascript:closePoly()"/>
   <input type="button" value="Remove polygon" onclick="javascript:removePoly()"/>
   <br />
   <input type="button" value="Make green" onclick="javascript:if(poly)poly.setFillColor('#00aa00', 0.7);"/>
   <input type="button" value="Make blue" onclick="javascript:if(poly)poly.setFillColor('#0000ff', 0.4);"/><commit_msg>Use proper set of icons in the polygon demo<commit_after><?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="robots" content="index, all" />
  <title>WebGL Earth API - Polygon Example</title>

  <script src="../Cesium/Build/Cesium/Cesium.js"></script>
  <script src="http://localhost:9810/compile?id=api-debug"></script>

  <script>    
    var app, poly;
    function startWE() {
    
      var options = {
        altitude: 360,
        position: [47.192, 8.523],
        map: WebGLEarth.Maps.OSM,
        proxyHost: 'http://srtm.webglearth.com/cgi-bin/corsproxy.fcgi?url='
      };

      app = new WebGLEarth('webglearthdiv', options);
      app.showMiniGlobe('../deploy/world512.jpg', 128);
      app.setTilt(45);
      
      var defaultPoly = new WebGLEarth.Polygon(app);
      defaultPoly.setFillColor('#00ffff', 0.3);
      defaultPoly.addPoint(47.1966945, 8.52359601);
      defaultPoly.addPoint(47.1963864, 8.52475703);
      var cornerPoint =
      defaultPoly.addPoint(47.1954063, 8.52230885);
      defaultPoly.addPoint(47.1966242, 8.52120111);
      defaultPoly.addPoint(47.1967805, 8.52164874);
      defaultPoly.addPoint(47.1972796, 8.52242167);
      defaultPoly.addPoint(47.1972434, 8.52277868);
      defaultPoly.disableClickToAdd();
      defaultPoly.showDraggers(false);
      defaultPoly.onClick(reopenPoly);
      
      var defaultPoly2 = new WebGLEarth.Polygon(app);
      defaultPoly2.setFillColor('#00ff00', 0.3);
      defaultPoly2.addPoint(47.1965465487, 8.5211790565);
      defaultPoly2.addPoint(47.1953526123, 8.5222943548);
      defaultPoly2.addPoint(47.1942354599, 8.5196876980);
      defaultPoly2.addPoint(47.1958763746, 8.5188098538);
      defaultPoly2.disableClickToAdd();
      defaultPoly2.showDraggers(false);
      defaultPoly2.onClick(reopenPoly);
      
      // let the corner point animate in circle
      //   not very useful way of demonstrating the movePoint() method
      setInterval(function() {
        var alpha = 2 * Math.PI * (+new Date())/1000;
        var x_ = Math.cos(alpha)/8000;
        var y_ = Math.sin(alpha)/8000;
        defaultPoly.movePoint(cornerPoint, 47.1954063 + x_, 8.52230885 + y_);
        document.getElementById('info3div').innerHTML = "The two default polygons " + (defaultPoly.intersects(defaultPoly2) ? "DO" : "DO NOT") + " intersect.";
      }, 50);
    }

    function reopenPoly(pol_) {
      if (poly) {
        // disable old active polygon
        poly.disableClickToAdd();
        poly.showDraggers(false);
      }
      poly = pol_;
      poly.showDraggers(true);
      poly.setOnChange(onchange);
    }
    
    function startPoly() {
      if (poly) {
        closePoly();
      }
      poly = new WebGLEarth.Polygon(app);
      poly.enableClickToAdd();
      poly.setOnChange(onchange);
      setBorder('#000000', 0.9);
      poly.setFillColor('#eedd00', 0.6);
      poly.onClick(reopenPoly);
      document.getElementById('infodiv').innerHTML = 'Create polygon by clicking on the ground, Alt-click on polygon node to remove it.';
    }

    function closePoly() {
      if (!poly) return;
      poly.disableClickToAdd();
      poly.showDraggers(false);
      poly = null;
      document.getElementById('infodiv').innerHTML = '';
      document.getElementById('info2div').innerHTML = '';
    }

    function removePoly() {
      if (!poly) return;
      poly.destroy();
      poly = null;
    }
    
    var borderHex = '#000000', borderAlpha = 1; //remember the color so we can visualize invalid polygons
    function onchange() {
      if (poly) {
        document.getElementById('info2div').innerHTML =
            poly.isValid() ? poly.getRoughArea().toFixed(2) + ' m2' :
            'Invalid polygon (self-intersecting or  < 3 vertices)';
        if (poly.isValid()) {
          poly.setStrokeColor(borderHex, borderAlpha);
        } else {
          poly.setStrokeColor('#ff0000', 1);
        }

        // when the user has already defined already at least 4 points,
        //   disable the "click-to-add" feature
        if (poly.getPoints().length >= 4) {
          poly.disableClickToAdd();
        } else {
          poly.enableClickToAdd();
        }
      }
    }

    function setBorder(hex, opt_a) {
      if (poly) {
        borderHex = hex;
        borderAlpha = opt_a;
        poly.setStrokeColor(hex, opt_a);
      }
    }
    
    function randomIcon() {
      if (poly) {
        var icons = [1, 2, 3, 4, 5, 6];//1, 10, 14, 15, 17, 20, 23, 25, 26, 31, 34, 36, 40, 42, 43, 45, 47, 48, 49, 50, 52, 53, 54];
        var random = icons[Math.floor(Math.random() * icons.length)];
        
        // (src, reference height in pixels, minimal height in pixels, maximal height in pixels)
        poly.setIcon('icons/' + random + '.png', 50, 30, 250);
      }
    }
  </script>
  
 </head>
 <body onload="javascript:startWE()">
   <div id="webglearthdiv" style="width:600px;height:400px;"></div>
   <div id="infodiv" style="width:600px;height:20px;"></div>
   <div id="info2div" style="width:600px;height:20px;"></div>
   <div id="info3div" style="width:600px;height:20px;"></div>
   <br />
   <input type="button" id="start" value="Start new polygon" onclick="javascript:startPoly()"/>
   <input type="button" id="close" value="Close polygon" onclick="javascript:closePoly()"/>
   <input type="button" value="Remove polygon" onclick="javascript:removePoly()"/>
   <br />
   <input type="button" value="Make green" onclick="javascript:if(poly)poly.setFillColor('#00aa00', 0.7);"/>
   <input type="button" value="Make blue" onclick="javascript:if(poly)poly.setFillColor('#0000ff', 0.4);"/>
{'fraction_non_alphanumeric': 0.15156004880599616, 'fraction_numerical': 0.07425483702283424, 'mean_word_length': 2.8326653306613228, 'pattern_counts': {'":': 0, '<': 67, '<?xml version=': 2, '>': 67, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5476529', 'n_tokens_mistral': 4345, 'n_tokens_neox': 3697, 'n_words': 748}