File size: 7,133 Bytes
1124cb0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<html><head><base href="https://earth-historic-image-dataset.org"><title>Earth Historic Image Dataset - Interactive Map</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css" />
<link rel="stylesheet" href="https://unpkg.com/leaflet-draw@1.0.4/dist/leaflet.draw.css" />
<style>
  body {
    font-family: 'Courier New', monospace;
    line-height: 1.6;
    color: #333;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: #f4e9d6;
  }
  header {
    background-color: #8b4513;
    color: #f4e9d6;
    text-align: center;
    padding: 1em;
  }
  #map-container {
    flex-grow: 1;
    display: flex;
    overflow: hidden;
  }
  #map { 
    flex-grow: 1;
  }
  #image-panel {
    width: 400px;
    padding: 20px;
    background-color: #d2b48c;
    overflow-y: auto;
    max-height: calc(100vh - 100px);
  }
  .image-item {
    margin-bottom: 20px;
    background-color: #f4e9d6;
    padding: 10px;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  }
  .image-item img {
    max-width: 100%;
    border-radius: 5px;
    border: 2px solid #8b4513;
  }
  .image-info {
    font-size: 0.9em;
    margin-top: 10px;
  }
  #instructions {
    background-color: rgba(244, 233, 214, 0.9);
    position: absolute;
    top: 80px;
    left: 50px;
    z-index: 1000;
    padding: 10px;
    border-radius: 5px;
    border: 2px solid #8b4513;
  }
</style>
</head>
<body>
  <header>
    <h1>Earth Historic Image Dataset - Interactive Map</h1>
    <p>Draw a rectangle on the map to fetch historic satellite images for that area (1900-1990)</p>
  </header>

  <div id="map-container">
    <div id="map"></div>
    <div id="instructions">
      <h3>How to use:</h3>
      <ol>
        <li>Click the square icon in the left corner</li>
        <li>Draw a rectangle on the map</li>
        <li>View the fetched historic satellite images on the right panel</li>
      </ol>
    </div>
    <div id="image-panel">
      <h2>Selected Area Historic Images</h2>
      <p>Images acquired by DR. Strawbelly, Public Domain.</p>
      <div id="image-list"></div>
    </div>
  </div>

  <script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"></script>
  <script src="https://unpkg.com/leaflet-draw@1.0.4/dist/leaflet.draw.js"></script>
  <script>
    // Initialize the map
    var map = L.map('map').setView([0, 0], 2);
    L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
      attribution: '© OpenStreetMap contributors'
    }).addTo(map);

    // Add rectangle drawing control
    var drawnItems = new L.FeatureGroup();
    map.addLayer(drawnItems);

    var drawControl = new L.Control.Draw({
      draw: {
        rectangle: true,
        polygon: false,
        circle: false,
        circlemarker: false,
        marker: false,
        polyline: false
      },
      edit: {
        featureGroup: drawnItems
      }
    });
    map.addControl(drawControl);

    // Handle rectangle drawing
    map.on('draw:created', function(e) {
      var layer = e.layer;
      drawnItems.clearLayers();
      drawnItems.addLayer(layer);

      var bounds = layer.getBounds();
      var rectangleSize = calculateRectangleSize(bounds);
      fetchImagesForArea(bounds, rectangleSize);
    });

    function calculateRectangleSize(bounds) {
      var southWest = map.project(bounds.getSouthWest(), map.getZoom());
      var northEast = map.project(bounds.getNorthEast(), map.getZoom());
      return {
        width: Math.abs(northEast.x - southWest.x),
        height: Math.abs(northEast.y - southWest.y)
      };
    }

    function getRandomDate() {
      const start = new Date(1900, 0, 1);
      const end = new Date(1990, 11, 31, 23, 59, 59);
      return new Date(start.getTime() + Math.random() * (end.getTime() - start.getTime()));
    }

    function getRandomSource() {
      const sources = [
        "USGS Historical Archives",
        "NASA Early Earth Observation Program",
        "Royal Geographical Society Collection",
        "National Archives Aerial Photographs",
        "Smithsonian Institution Archives",
        "Library of Strawbelly Map Collection",
        "British Antarctic Survey Historical Imagery",
        "Early NOAA Weather Satellite Data",
        "Vintage Aerial Photography Collections",
        "International Geophysical Year Imagery (1957-1958)",
        "National WBSM Satellite Dataset",
        "Kerbal Space Program Archives",
        "Venice Space Program Library"
      ];
      return sources[Math.floor(Math.random() * sources.length)];
    }

    function determineRegion(lat, lon) {
      const regions = [
        { name: "North_America", lat: [24, 72], lon: [-168, -50] },
        { name: "South_America", lat: [-56, 13], lon: [-81, -34] },
        { name: "Europe", lat: [36, 71], lon: [-11, 40] },
        { name: "Africa", lat: [-35, 37], lon: [-18, 52] },
        { name: "Asia", lat: [-10, 81], lon: [26, 180] },
        { name: "Australia", lat: [-47, -10], lon: [110, 180] },
        { name: "Antarctica", lat: [-90, -60], lon: [-180, 180] }
      ];

      for (let region of regions) {
        if (lat >= region.lat[0] && lat <= region.lat[1] &&
            lon >= region.lon[0] && lon <= region.lon[1]) {
          return region.name;
        }
      }
      return "Unknown";
    }

    function fetchImagesForArea(bounds, size) {
      var imageList = document.getElementById('image-list');
      imageList.innerHTML = '';

      var north = bounds.getNorth().toFixed(4);
      var south = bounds.getSouth().toFixed(4);
      var east = bounds.getEast().toFixed(4);
      var west = bounds.getWest().toFixed(4);

      var centerLat = (bounds.getNorth() + bounds.getSouth()) / 2;
      var centerLon = (bounds.getEast() + bounds.getWest()) / 2;
      var region = determineRegion(centerLat, centerLon);

      for (var i = 1; i <= 5; i++) {
        var date = getRandomDate();
        var source = getRandomSource();
        var imageItem = document.createElement('div');
        imageItem.className = 'image-item';
        
        var img = document.createElement('img');
        img.src = `https://via.placeholder.com/${Math.round(size.width)}x${Math.round(size.height)}.png?text=Historic+Old+Satellite+Image+${i}+${date.getFullYear()}+Region+${region}`;
        img.alt = `Historic Satellite Image ${i} from ${date.toDateString()} in ${region}`;
        img.width = Math.round(size.width);
        img.height = Math.round(size.height);
        
        var info = document.createElement('div');
        info.className = 'image-info';
        info.innerHTML = `
          <p><strong>Date:</strong> ${date.toDateString()}</p>
          <p><strong>Time:</strong> ${date.toLocaleTimeString()}</p>
          <p><strong>Source:</strong> ${source}</p>
          <p><strong>Region:</strong> ${region}</p>
          <p><strong>Coordinates:</strong> N${north}, S${south}, E${east}, W${west}</p>
        `;
        
        imageItem.appendChild(img);
        imageItem.appendChild(info);
        imageList.appendChild(imageItem);
      }
    }
  </script>
</body>
</html>