Skip to content

Commit

Permalink
Added server with out viirs night tiles
Browse files Browse the repository at this point in the history
  • Loading branch information
frasanz committed Sep 23, 2024
1 parent daf7a42 commit 433c9f2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
25 changes: 19 additions & 6 deletions frontend/templates/task2.html
Original file line number Diff line number Diff line change
Expand Up @@ -619,25 +619,38 @@ <h3>Lost at night</h3>

const latLng = parseCoordinates(response.photo_center_by_machine_learning);

map = L.map('map').setView(latLng, 10);


const viirs = L.tileLayer('http://development.ibercivis.es:8001/{z}/{x}/{y}.png', {
maxZoom: 12,
transparent: true,
tms: 1,
attribution: 'The Earth Observation Group (EOG)',
opacity: 0.7,
});
const osmLayer = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 17,
maxZoom: 12,
attribution: '© OpenStreetMap contributors'
});

const googleSat = L.tileLayer('http://{s}.google.com/vt/lyrs=s&x={x}&y={y}&z={z}', {
maxZoom: 20,
subdomains: ['mt0', 'mt1', 'mt2', 'mt3']
maxZoom: 12,
subdomains: ['mt0', 'mt1', 'mt2', 'mt3'],
transparent: true,
});
googleSat.addTo(map);
map = L.map('map' , { layers: [viirs] }).setView(latLng, 10);
osmLayer.addTo(map);



// Add layer control to switch between layers
baseLayers = {
"OpenStreetMap": osmLayer,
"Satellite": googleSat
};
var overlaymaps = {"VIIRS": viirs}

layersControl = L.control.layers(baseLayers).addTo(map);
layersControl = L.control.layers(baseLayers, overlaymaps, { collapsed: false}).addTo(map);

function addIconToMap(lat, lon) {
// Create a custom icon using Leaflet's divIcon and Font Awesome
Expand Down
3 changes: 2 additions & 1 deletion georeferencing/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def patch(self, request, pk=None):
os.makedirs('georeferenced')

# First command: gdal_translate
command = 'gdpal_translate -of GTiff'
command = 'gdal_translate -of GTiff'
for item in request.data['control_points']:
command += ' -gcp ' + str(item['actualPx']) + ' ' + str(item['actualPy'])
command += ' ' + str(item['lon']) + ' ' + str(item['lat'])
Expand All @@ -194,6 +194,7 @@ def patch(self, request, pk=None):
return Response({"error": f"gdal_translate failed: {e.stderr}"}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)

# Second command: gdalwarp
# Check the # of points before enable tps (-order n to pylynomial)
command = 'gdalwarp -r bilinear -tps -t_srs EPSG:4326'
command += ' georeferenced/' + geoattemp.image.name + geoattemp.hash + '.tif'
command += ' georeferenced/' + geoattemp.image.name + geoattemp.hash + '.tif'
Expand Down

0 comments on commit 433c9f2

Please sign in to comment.