Skip to content
Snippets Groups Projects
Commit fed84ec9 authored by s192327's avatar s192327
Browse files

added output of JSON file for each camera containing image name, original EXIF...

added output of JSON file for each camera containing image name, original EXIF metadata, homography and boundaries
parent 355c7456
Branches
No related tags found
No related merge requests found
// The lat / Lon is retrieved from the URL_params or by point dropped on map
let ortomosaic_Lat = 55.39478003;
let ortomosaic_Lon = 10.36819213;
// This matrix is project-wide and used for all images
let ortomosaic_matrix = [
[0.02058, 0, 422992.35133],
[0, -0.02058, 1141303.77145],
];
// Homographies - 1 pr. image
let homography_0318 = [
[18.1748008896691, 110.768040573102, -1073920.02739014],
[-93.5072721511896, 22.9184010773105, 1443133.71867263],
[0.00251773837644659, 0.00477261054405393, 13.1563804084711],
];
let homography_0319 = [
[91.1913681526212, 74.4954006235995, -2032705.65426289],
[-45.9491261079299, 91.0850627766938, 171874.03429197],
[0.00847800760620633, 0.00670916759943164, -107.707794052532],
];
let homography_0396 = [
[-95.2171306574051, -29.8646394213374, 2211180.11714658],
[35.8083803816194, -86.1842002662421, 401622.842075709],
[-0.000900957696478009, 0.00265330072368818, 90.1507734097704],
];
let homography_0397 = [
[-87.1783293678574, -45.230650433766, 2167669.31918901],
[50.6739871848908, -80.3042160587032, 171110.407022258],
[-0.000591511908147938, 0.00219435869720514, 87.7727832580621],
];
console.log('lat : ' + ortomosaic_Lat);
console.log('lon : ' + ortomosaic_Lon);
console.log('-------------------------------------');
picture_coordinates = CalculatePictureXYFromLatLon(
ortomosaic_Lat,
ortomosaic_Lon,
'DKTM2_4094',
ortomosaic_matrix,
homography_0318)
console.log('Picture : 0318');
console.log('x : ' + picture_coordinates[0]);
console.log('y : ' + picture_coordinates[1]);
console.log('-------------------------------------');
picture_coordinates = CalculatePictureXYFromLatLon(
ortomosaic_Lat,
ortomosaic_Lon,
'DKTM2_4094',
ortomosaic_matrix,
homography_0319
);
console.log('Picture : 0319');
console.log('x : ' + picture_coordinates[0]);
console.log('y : ' + picture_coordinates[1]);
console.log('-------------------------------------');
picture_coordinates = CalculatePictureXYFromLatLon(
ortomosaic_Lat,
ortomosaic_Lon,
'DKTM2_4094',
ortomosaic_matrix,
homography_0396
);
console.log('Picture : 0396');
console.log('x : ' + picture_coordinates[0]);
console.log('y : ' + picture_coordinates[1]);
console.log('-------------------------------------');
picture_coordinates = CalculatePictureXYFromLatLon(
ortomosaic_Lat,
ortomosaic_Lon,
'DKTM2_4094',
ortomosaic_matrix,
homography_0397
);
console.log('Picture : 0397');
console.log('x : ' + picture_coordinates[0]);
console.log('y : ' + picture_coordinates[1]);
console.log('-------------------------------------');
function CalculatePictureXYFromLatLon(
Lat,
Lon,
project_csr,
mosaic_matrix,
pic_homography
) {
switch (project_csr) {
case 'WGS84_4326':
csr =
'+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees';
break;
case 'DKTM1_4093':
csr =
'+proj=tmerc +lat_0=0 +lon_0=9 +k=0.99998 +x_0=200000 +y_0=-5000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs';
break;
case 'DKTM2_4094':
csr =
'+proj=tmerc +lat_0=0 +lon_0=10 +k=0.99998 +x_0=400000 +y_0=-5000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs';
break;
case 'DKTM3_4095':
csr =
'+proj=tmerc +lat_0=0 +lon_0=11.75 +k=0.99998 +x_0=600000 +y_0=-5000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs';
break;
case 'DKTM4_4096':
csr =
'+proj=tmerc +lat_0=0 +lon_0=15 +k=1 +x_0=800000 +y_0=-5000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs';
break;
case 'ETRS89_25832':
csr =
'+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs';
break;
default:
csr = '';
}
//
// Default 'from' crs is WGS84_4326
var projected_xy = proj4(csr, [Lon, Lat]);
var mosaic_coordinates_x =
(mosaic_matrix[1][1] * projected_xy[0] -
mosaic_matrix[0][1] * projected_xy[1] +
mosaic_matrix[0][1] * mosaic_matrix[1][2] -
mosaic_matrix[1][1] * mosaic_matrix[0][2]) /
(mosaic_matrix[0][0] * mosaic_matrix[1][1] -
mosaic_matrix[1][0] * mosaic_matrix[1][0]);
var mosaic_coordinates_y =
(-mosaic_matrix[0][1] * projected_xy[0] +
mosaic_matrix[0][0] * projected_xy[1] +
mosaic_matrix[0][1] * mosaic_matrix[0][2] -
mosaic_matrix[0][0] * mosaic_matrix[1][2]) /
(mosaic_matrix[0][0] * mosaic_matrix[1][1] -
mosaic_matrix[1][0] * mosaic_matrix[0][1]);
var calc_a =
pic_homography[0][0] * mosaic_coordinates_x +
pic_homography[0][1] * mosaic_coordinates_y +
pic_homography[0][2];
var calc_b =
pic_homography[1][0] * mosaic_coordinates_x +
pic_homography[1][1] * mosaic_coordinates_y +
pic_homography[1][2];
var calc_c =
pic_homography[2][0] * mosaic_coordinates_x +
pic_homography[2][1] * mosaic_coordinates_y +
pic_homography[2][2];
var pic_x = calc_a / calc_c;
var pic_y = calc_b / calc_c;
let pic_xy = [pic_x, pic_y];
return pic_xy;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment