Commit 827d0e58 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

1. +basepath 2. work when kml is missing

parent ba0dc914
...@@ -93,6 +93,7 @@ function parseURL(){ ...@@ -93,6 +93,7 @@ function parseURL(){
case "slidingdrag": SETTINGS.slidingdrag = true; break; case "slidingdrag": SETTINGS.slidingdrag = true; break;
case "shiftspeed": SETTINGS.shiftspeed = parseFloat(parameters[i][1]); break; case "shiftspeed": SETTINGS.shiftspeed = parseFloat(parameters[i][1]); break;
case "markersize": SETTINGS.markersize = parseFloat(parameters[i][1]); break; case "markersize": SETTINGS.markersize = parseFloat(parameters[i][1]); break;
case "basepath": SETTINGS.basepath = parameters[i][1]; break;
case "path": SETTINGS.path = parameters[i][1]; break; case "path": SETTINGS.path = parameters[i][1]; break;
case "ver": SETTINGS.version = parameters[i][1]; break; case "ver": SETTINGS.version = parameters[i][1]; break;
...@@ -209,56 +210,58 @@ function light_init(){ ...@@ -209,56 +210,58 @@ function light_init(){
$.ajax({ $.ajax({
url: SETTINGS.files.kml+"?"+Date.now(), url: SETTINGS.files.kml+"?"+Date.now(),
success: function(response){ success: function(response){
parse_light_init_response(response); parse_light_init_response(response,"init");
}, },
error: function(response){ error: function(response){
console.log("KML not found. Using defaults"); console.log("Init: KML not found. Using defaults");
parse_light_init_response(response); parse_light_init_response(response,"init");
} }
}); });
} }
function parse_light_init_response(response){ function parse_light_init_response(response,state){
var longitude = parseFloat($(response).find("Camera").find("longitude").text()); var latitude = parseFloat($(response).find("Camera").find("latitude").text()) || 40.7233861;
var latitude = parseFloat($(response).find("Camera").find("latitude").text()); var longitude = parseFloat($(response).find("Camera").find("longitude").text()) || -111.9328843;
var altitude = parseFloat($(response).find("Camera").find("altitude").text()); var altitude = parseFloat($(response).find("Camera").find("altitude").text()) || 1305.1;
var heading = parseFloat($(response).find("Camera").find("heading").text()); var heading = parseFloat($(response).find("Camera").find("heading").text()) || 0.0001;
var tilt = parseFloat($(response).find("Camera").find("tilt").text()); var tilt = parseFloat($(response).find("Camera").find("tilt").text()) || 90;
var roll = parseFloat($(response).find("Camera").find("roll").text()); var roll = parseFloat($(response).find("Camera").find("roll").text()) || 0;
var fov = parseFloat($(response).find("Camera").find("fov").text()); var fov = parseFloat($(response).find("Camera").find("fov").text()) || 0;
Data.camera = new X3L({ Data.camera = new X3L({
x: 0, x: 0,
y: 0, y: 0,
z: 0, z: 0,
latitude: latitude || 40.7233861, latitude: latitude,
longitude: longitude || -111.9328843, longitude: longitude,
altitude: altitude || 1305.1, altitude: altitude,
heading: heading || 0, heading: heading,
tilt: tilt || 90, tilt: tilt,
roll: roll || 0, roll: roll ,
fov: fov || 0, fov: fov,
}); });
// store kml // store kml
// this data changes only in leaflet's edit location mode // this data changes only in leaflet's edit location mode
Data.camera.kml = { Data.camera.kml = {
latitude: latitude || 40.7233861, latitude: latitude,
longitude: longitude || -111.9328843, longitude: longitude,
altitude: altitude || 1305.1, altitude: altitude,
heading: heading || 0, heading: heading,
tilt: tilt || 90, tilt: tilt,
roll: roll || 0, roll: roll,
name : $(response).find("name").text(), name : $(response).find("name").text(),
description : $(response).find("Camera").find("description").text(), description : $(response).find("Camera").find("description").text(),
visibility : $(response).find("visibility").text(), visibility : $(response).find("visibility").text(),
href : $(response).find("Icon").find("href").text() href : $(response).find("Icon").find("href").text()
}; };
if (state=="init"){
var element = document.getElementById('x3d_id'); var element = document.getElementById('x3d_id');
Scene = new X3DOMObject(element,Data,{}); Scene = new X3DOMObject(element,Data,{});
...@@ -281,50 +284,7 @@ function parse_light_init_response(response){ ...@@ -281,50 +284,7 @@ function parse_light_init_response(response){
}; };
}); });
} }else{
function reset_to_initial_position(){
$.ajax({
url: SETTINGS.files.kml+"?"+Date.now(),
success: function(response){
var longitude = parseFloat($(response).find("Camera").find("longitude").text());
var latitude = parseFloat($(response).find("Camera").find("latitude").text());
var altitude = parseFloat($(response).find("Camera").find("altitude").text());
var heading = parseFloat($(response).find("Camera").find("heading").text());
var tilt = parseFloat($(response).find("Camera").find("tilt").text());
var roll = parseFloat($(response).find("Camera").find("roll").text());
var fov = parseFloat($(response).find("Camera").find("fov").text());
Data.camera = new X3L({
x: 0,
y: 0,
z: 0,
latitude: latitude || 0,
longitude: longitude || 0,
altitude: altitude || 0,
heading: heading || 0,
tilt: tilt || 0,
roll: roll || 0,
fov: fov || 0,
});
// store kml
Data.camera.kml = {
latitude: latitude || 0,
longitude: longitude || 0,
altitude: altitude || 0,
heading: heading || 0,
tilt: tilt || 0,
roll: roll || 0,
name : $(response).find("name").text(),
description : $(response).find("Camera").find("description").text(),
visibility : $(response).find("visibility").text(),
href : $(response).find("Icon").find("href").text()
};
Map.marker.setHeading(heading); Map.marker.setHeading(heading);
Map.marker.setBasePoint(new L.LatLng(latitude,longitude)); Map.marker.setBasePoint(new L.LatLng(latitude,longitude));
...@@ -337,6 +297,20 @@ function reset_to_initial_position(){ ...@@ -337,6 +297,20 @@ function reset_to_initial_position(){
reportKmlReloaded(); reportKmlReloaded();
} }
}
function reset_to_initial_position(){
$.ajax({
url: SETTINGS.files.kml+"?"+Date.now(),
success: function(response){
parse_light_init_response(response,"reset");
},
error: function(response){
console.log("Reset: KML not found. Using defaults");
parse_light_init_response(response,"reset");
}
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment