|
click: | |
|
console.log("click on coordinates detected"); |
|
var inputField = el; |
|
var form = inputField.closest(".modal-body"); |
|
var epsgField = form.find(".-fn-active-epsgCode> .form-control"); |
|
window.liveReprSourceEpsg = epsgField.val(); |
|
change: | |
|
function ConvertDDToDMS(D, lng){ |
|
return { |
|
dir : D<0?lng?'W':'S':lng?'E':'N', |
|
deg : 0|(D<0?D=-D:D), |
|
min : 0|D%1*60, |
|
sec :(0|D*60%1*6000)/100 |
|
}; |
|
} |
|
console.log("change on coordinates"); |
|
var inputField = el; |
|
var form = inputField.closest(".modal-body"); |
|
var epsgField = form.find(".-fn-active-epsgCode> .form-control"); |
|
var xField = form.find("[name='x']"); |
|
var yField = form.find("[name='y']"); |
|
var desiredEpsg = epsgField.val(); |
|
if (desiredEpsg != window.liveReprSourceEpsg) { |
|
if (window.liveReprSourceEpsg = "EPSG:4326") { |
|
var splitreprpointx = xField.val().split(/\'|°/); |
|
var splitreprpointy = yField.val().split(/\'|°/); |
|
console.log(splitreprpointx); |
|
console.log(splitreprpointy); |
|
var reprpoint = new Proj4js.Point( xField.val() , yField.val() ); |
|
} else { |
|
var reprpoint = new Proj4js.Point( xField.val() , yField.val() ); |
|
} |
|
console.log(window.liveReprSourceEpsg + " -> \n" + desiredEpsg ); |
|
Proj4js.defs["EPSG:31255"]='+proj=tmerc +lat_0=0 +lon_0=13.33333333333333 +k=1 +x_0=0 +y_0=-5000000 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m +no_defs'; |
|
var toCRS = new Proj4js.Proj(desiredEpsg); |
|
var fromCRS = new Proj4js.Proj(window.liveReprSourceEpsg); |
|
var reprCoords = Proj4js.transform(fromCRS ,toCRS ,reprpoint); |
|
if (desiredEpsg == "EPSG:4326") { |
|
var ccordx = ConvertDDToDMS(reprCoords.x); |
|
var ccordy = ConvertDDToDMS(reprCoords.y); |
|
xField.val( ccordx.deg + "°" + ccordx.min + "'" + ccordx.sec + "''" ); |
|
yField.val( ccordy.deg + "°" + ccordy.min + "'" + ccordy.sec + "''" ); |
|
} else { |
|
xField.val(reprCoords.x); |
|
yField.val(reprCoords.y); |
|
} |
|
} |