Angular
- 20 ответов
- 0 вопросов
15
Вклад в тег
public static function distance($_y1, $_x1, $_y2, $_x2)
{
$pi = pi();
$c_A = 6378137;
$c_a = 1 / 298.257223563;
$c_e2 = 2 * $c_a - $c_a * $c_a;
$fSinB1 = sin($_y1 * $pi / 180);
$fCosB1 = cos($_y1 * $pi / 180);
$fSinL1 = sin($_x1 * $pi / 180);
$fCosL1 = cos($_x1 * $pi / 180);
$fSinB2 = sin($_y2 * $pi / 180);
$fCosB2 = cos($_y2 * $pi / 180);
$fSinL2 = sin($_x2 * $pi / 180);
$fCosL2 = cos($_x2 * $pi / 180);
$N1 = $c_A / sqrt( 1 - $c_e2 * $fSinB1 * $fSinB1 );
$X1 = $N1 * $fCosB1 * $fCosL1;
$Y1 = $N1 * $fCosB1 * $fSinL1;
$Z1 = ( 1 - $c_e2 ) * $N1 * $fSinB1;
$N2 = $c_A / sqrt( 1 - $c_e2 * $fSinB2 * $fSinB2 );
$X2 = $N2 * $fCosB2 * $fCosL2;
$Y2 = $N2 * $fCosB2 * $fSinL2;
$Z2 = ( 1 - $c_e2 ) * $N2 * $fSinB2;
$D = sqrt( ( $X1 - $X2 ) * ( $X1 - $X2 ) + ( $Y1 - $Y2 ) * ( $Y1 - $Y2 ) + ( $Z1 - $Z2 ) * ( $Z1 - $Z2 ) );
$R = $N1;
return 2 * $R * asin( 0.5 * $D / $R );
}
function myfunc() {
results = [];
return fetch(URL)
.then((response) => response.json())
.then((hitsJSON) => {
return hitsJSON.hits.map(item => {
return {
id: item.id,
url: item.previewURL,
tags: item.tags
};
}));
});
}
// и использование
myfunc()
.then((results) => {
// do something
})
var myApp = angular.module('myApp', []);
// make a factory to share data between controllers
myApp.factory('Data', function(){
var data = {
firstName: ''
};
return {
getFirstName: function () {
return data.firstName;
},
setFirstName: function (firstName) {
data.firstName = firstName;
}
};
});