{% extends "rgd/_base/detail.html" %}

{% block meta_table_body %}
  <tr>
    <td>Description</td>
    <td>{{ object.description }}</td>
  </tr>
  <tr>
    <td>VTP Data</td>
    <td>{{ object.data_link }}</td>
  </tr>
  <tr>
    <td>Source Data</td>
    <td>{{ object.source.data_link }}</td>
  </tr>

  {% if object.pointcloudspatial %}
    <tr>
      <td>Acquisition Date</td>
      <td>{{ object.pointcloudspatial.acquisition_date }}</td>
    </tr>
    <tr>
      <td>Area</td>
      <td>{{ object.pointcloudspatial.footprint.area | floatformat:-2 }}</td>
    </tr>
    <tr>
      <td>Instrumentation</td>
      <td>{{ object.pointcloudspatial.instrumentation }}</td>
    </tr>
  {% endif %}

{% endblock %}

{% block extra_meta %}
  {% if object.source.pointcloudspatial %}

    <br/>

    {% include 'rgd/_include/empty_viewer.html' %}

    <script>

      let reader = geo.createFileReader('geojsonReader', {
        'layer': layer
      });
      var footprint = '{{ object.source.pointcloudspatial.footprint.json|escapejs }}'
      reader.read(footprint, (features) => {
        features[0].style({
          strokeColor: '#FF0000',
          fill: true,
        })
        .draw();
      });

      let extent = JSON.parse('{{ object.source.pointcloudspatial.bounds_json|escapejs }}');
      setBounds(extent)

    </script>

  {% endif %}
{% endblock %}

{% block detail %}

    {% include 'rgd_3d/_include/vtkjs_viewer.html' %}

    <script>

      load(vtkContainer, `{% url 'point-cloud-entry-data' object.id %}`)

    </script>

{% endblock %}
