|
Калькулятор расстояния (гео. координаты А и Б) | ☑ | ||
---|---|---|---|---|
0
kuromanlich
17.06.12
✎
13:50
|
У кого нидь есть алгоритм готовый? поделитесь?
|
|||
1
kuromanlich
17.06.12
✎
13:50
|
т.е. вычислить расстояние между точками имея их координаты
|
|||
2
kuromanlich
17.06.12
✎
13:51
|
планируемые расстояния - не более 30 метров, так что о дугообразности отрезка можно забыть, только прямые
|
|||
3
Mikeware
17.06.12
✎
13:52
|
математику прогуливал? :-)
|
|||
4
kuromanlich
17.06.12
✎
13:53
|
(3) по широтам км в градусе разные
|
|||
5
kuromanlich
17.06.12
✎
13:54
|
(3) + не прогуливал, "гипотенузу" уже осталось правильно в метры перевести
|
|||
6
zak555
17.06.12
✎
13:54
|
(1) расстояние считает иначе
|
|||
7
Mikeware
17.06.12
✎
13:54
|
(4) прими поверхность как шар, и посчитай :-)
а расз ты аппроксимируешь сектор шара плоскостью - то и вообще пофиг |
|||
8
Hans
17.06.12
✎
13:57
|
Это называется обратная геодезическая задача.
|
|||
9
Мизантроп
17.06.12
✎
13:58
|
http://planetcalc.ru/73/
Онлайн калькулятор: Расстояние между двумя координатами |
|||
10
zak555
17.06.12
✎
13:59
|
(7) ты предлагаешь считать сектор не учитывая, что
это сфера ? |
|||
11
kuromanlich
17.06.12
✎
14:01
|
(10) это я допустил такое. потому что планируется проверять погрешность не больше чем 30 метров. учитывая наш "шарик" - это допущение не повлияет на решение моей задачи
|
|||
12
zak555
17.06.12
✎
14:03
|
(11) данные откуда ?
|
|||
13
kuromanlich
17.06.12
✎
14:05
|
(12) с GPS, в виде долготы и широты. фактически "пишу" чтото вродеь "функции принадлежности". готовой пока не нашел.
|
|||
14
kuromanlich
17.06.12
✎
14:07
|
формулой из вики приведенной в (9) вроде как можно пользоваться... хорошо в 1С все функции есть )
|
|||
15
Мизантроп
17.06.12
✎
14:07
|
(13) чем тебя (9) не устраивает?
|
|||
16
Злопчинский
17.06.12
✎
14:07
|
гораздо лучшее в уме рассчитывать дальность горизонта. для невысоких объектов...
|
|||
17
Мизантроп
17.06.12
✎
14:07
|
там готовый js код
|
|||
18
kuromanlich
17.06.12
✎
14:09
|
(17) не вижу
|
|||
19
kuromanlich
17.06.12
✎
14:10
|
(17) говорят (там же) что это точнее http://planetcalc.ru/722/
|
|||
20
zak555
17.06.12
✎
14:13
|
(13) по данным координаат ты не знаешь как считать расстояние ?
|
|||
21
kuromanlich
17.06.12
✎
14:16
|
(20) знаю, хочу точно перевести в метры, а скока метров в градусах "широтах" непостоянное. вот поэтому и ищу формулу учитывающую это
|
|||
22
kuromanlich
17.06.12
✎
14:21
|
или забить и считать от 40000 км?..
|
|||
23
kuromanlich
17.06.12
✎
14:27
|
(17) правильно копирнул?
<script type="text/javascript"> BSAdviseEvent( document.getElementById('dialogv4e8d63a1cd9f7_calculate'), 'click', onclick_v4e8d63a1cd9f7calculate, 'form');</script></div></li><li><fieldset id="dialogv4e8d63a1cd9f7_outputs0" class="calc_outputs"><ol><li><span class="textoutput_label" >Расстояние:</span><span class="textoutput" id="dialogv4e8d63a1cd9f7_distance" > </span></li></ol></fieldset></li><li><span class="offer14"><a href="http://planetcalc.ru/jme?id=177">Установить на ваш мобильный телефон</a></span></li></ol></fieldset></div><div><script type="text/javascript"><!-- var dialogv4e8d63a1cd9f7 = new Dialogv4e8d63a1cd9f7(); var dialoghandlerv4e8d63a1cd9f7 = new function ( ) {this.Dialog = null;this.CalculatorID = 72;this.initdialog = function ( dlg ) { this.Dialog = dlg;if ( !window.CurrentPageCalculators ) { window.CurrentPageCalculators = []; }window.CurrentPageCalculators[window.CurrentPageCalculators.length]=this;this.Dialog.distance.formatter =new FormatterNumber( 3 );if ( window.CalculatorData && window.CalculatorData.id72) { var savedProp = window.CalculatorData.id72.lat1; if (typeof(savedProp)!='undefined') { this.Dialog.lat1.SetValue( savedProp ); } } else { if ( this.Dialog.lat1 ) { this.Dialog.lat1.Load( this.HTTPParams.Parameters );} };if ( window.CalculatorData && window.CalculatorData.id72) { var savedProp = window.CalculatorData.id72.lon1; if (typeof(savedProp)!='undefined') { this.Dialog.lon1.SetValue( savedProp ); } } else { if ( this.Dialog.lon1 ) { this.Dialog.lon1.Load( this.HTTPParams.Parameters );} };if ( window.CalculatorData && window.CalculatorData.id72) { var savedProp = window.CalculatorData.id72.lat2; if (typeof(savedProp)!='undefined') { this.Dialog.lat2.SetValue( savedProp ); } } else { if ( this.Dialog.lat2 ) { this.Dialog.lat2.Load( this.HTTPParams.Parameters );} };if ( window.CalculatorData && window.CalculatorData.id72) { var savedProp = window.CalculatorData.id72.lon2; if (typeof(savedProp)!='undefined') { this.Dialog.lon2.SetValue( savedProp ); } } else { if ( this.Dialog.lon2 ) { this.Dialog.lon2.Load( this.HTTPParams.Parameters );} };this.setTimerIcon( true );this.notInitializedDataCount=0; this.refresh();};this.showControlError = function ( e ) {if ( typeof(e)=="object" && e.source && e.message && this.Dialog[e.source] && this.Dialog[e.source].ShowError ) {this.Dialog[e.source].ShowError( e.message );return true; };return false; };this.GetInputValues = function ( ) { var vals ={};vals['lat1'] = this.Dialog.lat1.GetValue();vals['lon1'] = this.Dialog.lon1.GetValue();vals['lat2'] = this.Dialog.lat2.GetValue();vals['lon2'] = this.Dialog.lon2.GetValue(); return vals; };this.OnDataSource = function ( name, obj ) { this[ "dataSource_" + name ] = obj; this.notInitializedDataCount-=1; if ( 0==this.notInitializedDataCount) this.refresh(); };this.setTimerIcon = function ( enable ) { var timerplace = document.getElementById("dialogv4e8d63a1cd9f7_timerplace"); if ( timerplace ) timerplace.className=(enable?"timer":"notimer"); this.enableOutputs(!enable);};this.enableOutputs = function( enable ) {this.Dialog.distance.GetElement().style.visibility=(enable?"visible":"hidden");};this.onkeypressed = function ( controlid, evt ) { return true;};this.refreshTimer= 0;this.onchanged = function ( controlid ) {var control = this.Dialog[ controlid ];if ( control.ValidateCurrent() && this.Dialog.Validate() ) { this.recalculate(1500);}};this.recalculate= function ( timeout ) {if (this.progressControl.isInProgress()) { this.progressControl.stop(); return;}if (this.refreshTimer) { clearTimeout(this.refreshTimer); } dialoghandlerv4e8d63a1cd9f7.setTimerIcon(true); this.refreshTimer=setTimeout('dialoghandlerv4e8d63a1cd9f7.refresh()',timeout);}; function CalcProgressControl( calcHandler ) { var me=this; var shouldContinue=false; var shouldStop=false; me.context = null; me.isInProgress=function( ){ return me.context!=null;} function setButtonLabel( lbl ){ document.getElementById("dialogv4e8d63a1cd9f7_timerplace").innerHTML=lbl; }this.stop=function(){};this.clear=function(){};this.repeat=function(){};this.shouldRepeat=function(){ return false;};}; this.progressControl = new CalcProgressControl( this );this.repeat = function() { this.refresh(true); }; this.refresh = function ( repeat ) {if ( !repeat ) { this.progressControl.context = null;}if ( this.notInitializedDataCount>0 ) return;clearTimeout(this.refreshTimer); this.refreshTimer=0;this.setTimerIcon(true);try {this.calculate(this.Dialog.lat1.GetValue(), this.Dialog.lon1.GetValue(), this.Dialog.lat2.GetValue(), this.Dialog.lon2.GetValue(), this.Dialog.distance);} catch( e ) { if ( !this.showControlError( e )) {alert( e.message ); }}if ( this.progressControl.shouldRepeat() ) { if (this.refreshTimer) { clearTimeout(this.refreshTimer); } this.refreshTimer=setTimeout('dialoghandlerv4e8d63a1cd9f7.repeat()',200);this.enableOutputs(true);} else {this.setTimerIcon(false);this.progressControl.clear(); }};this.calculate = function ( lat1, lon1, lat2, lon2, distance ) { var radLat1 = lat1 * (Math.PI/180); var radLon1 = lon1 * (Math.PI/180); var radLat2 = lat2 * (Math.PI/180); var radLon2 = lon2 * (Math.PI/180); var earthRadius = 6372.795; var radLonDif = radLon2 - radLon1; var atan2top = Math.sqrt( Math.pow( Math.cos(radLat2) * Math.sin(radLonDif), 2 ) + Math.pow( Math.cos(radLat1)*Math.sin(radLat2) - Math.sin(radLat1) * Math.cos(radLat2) * Math.cos(radLonDif), 2 ) ); var atan2bottom = Math.sin(radLat1)*Math.sin(radLat2)+Math.cos(radLat1)*Math.cos(radLat2)*Math.cos(radLonDif); var deltaAngle = Math.atan2(atan2top, atan2bottom); distance.SetValue(earthRadius*deltaAngle); };this.HTTPParams = new HTTPParameters();}; dialoghandlerv4e8d63a1cd9f7.initdialog(dialogv4e8d63a1cd9f7); //--></script> |
|||
24
kuromanlich
17.06.12
✎
14:29
|
(23) вот, ели быть точным
var radLat1 = lat1 * (Math.PI/180); var radLon1 = lon1 * (Math.PI/180); var radLat2 = lat2 * (Math.PI/180); var radLon2 = lon2 * (Math.PI/180); var earthRadius = 6372.795; var radLonDif = radLon2 - radLon1; var atan2top = Math.sqrt( Math.pow( Math.cos(radLat2) * Math.sin(radLonDif), 2 ) + Math.pow( Math.cos(radLat1)*Math.sin(radLat2) - Math.sin(radLat1) * Math.cos(radLat2) * Math.cos(radLonDif), 2 ) ); var atan2bottom = Math.sin(radLat1)*Math.sin(radLat2)+Math.cos(radLat1)*Math.cos(radLat2)*Math.cos(radLonDif); var deltaAngle = Math.atan2(atan2top, atan2bottom); distance.SetValue(earthRadius*deltaAngle) |
|||
25
Мизантроп
17.06.12
✎
14:30
|
LOL!
Откуда мне знать, разбирайся. Функции там все видно. |
|||
26
Grobik
17.06.12
✎
14:30
|
||||
27
Grobik
17.06.12
✎
14:32
|
(24) О! Уже сам нашел!
|
|||
28
kuromanlich
17.06.12
✎
16:07
|
написано по мотивам скрипта http://planetcalc.ru/722/ (аналогичное приведено в http://kobzarev.com/programming/calculation-of-distances-between-cities-on-their-coordinates.html )
при вычислении испольуется формула Формула гаверсинусов (Модификация для антиподов): http://upload.wikimedia.org/wikipedia/en/math/a/a/2/aa208c2f065a3c9311bb785ffed93763.png Функция ВычислитьРасстояние(Широта1,Долгота1,Широта2,Долгота2) РадиусЗемли = 6372795; Пи=3.1415926535; Широта1_Рад = Широта1 * Пи / 180; Широта2_Рад = Широта2 * Пи / 180; Долгота1_Рад = Долгота1 * Пи / 180; Долгота2_Рад = Долгота2 * Пи / 180; cl1 = cos(Широта1_Рад); cl2 = cos(Широта2_Рад); sl1 = sin(Широта1_Рад); sl2 = sin(Широта2_Рад); delta = Долгота2_Рад - Долгота1_Рад; cdelta = cos(delta); sdelta = sin(delta); y = sqrt((cl2 * sdelta)*(cl2 * sdelta)+ (cl1 * sl2 - sl1 * cl2 * cdelta)*(cl1 * sl2 - sl1 * cl2 * cdelta)); x = sl1 * sl2 + cl1 * cl2 * cdelta; ad = atan(y/x); Расстояние = ad * РадиусЗемли; Возврат Расстояние; КонецФункции |
|||
29
MaxS
17.06.12
✎
16:19
|
Представил голос из навигатора, если нужно ехать на другой материк. "Полезайте в колодец, где это возможно!"
|
|||
30
kuromanlich
17.06.12
✎
16:24
|
(29) в (20) уже с учетом шаровидности земли )
|
|||
31
Азазелло
17.06.12
✎
16:24
|
Pi = 3.1415926535897932;
R = 6371; phi_1 = 55.7522 * Pi / 180; psi_1 = 37.6156 * Pi / 180; phi_2 = 52.9658 * Pi / 180; psi_2 = 36.0803 * Pi / 180; x_11 = Cos(phi_1) * Sin(psi_1); x_21 = Cos(phi_1) * Cos(psi_1); x_31 = Sin(psi_1); x_12 = Cos(phi_2) * Sin(psi_2); x_22 = Cos(phi_2) * Cos(psi_2); x_32 = Sin(psi_2); hi = R * Sqrt(Pow((x_11 - x_12), 2) + Pow((x_21 - x_22), 2) + Pow((x_31 - x_32), 2)); Сообщить(hi); Сообщить(R * 2 * ASin(hi / (2 * R))); |
|||
32
kuromanlich
17.06.12
✎
16:42
|
(31) у меня наверное точнее... есть 2 точки. у меня 30 метров расстояние между ними, у тебя 37
|
|||
33
kuromanlich
17.06.12
✎
16:48
|
(31) протестировал на большом каменном мосту
координата 1 - 55.749543,37.624095 координата 2 - 55.748637,37.624202 у меня получилос - 100,993356086163398715 у тебя получилос - 84,094209039067324812 оф данные о длине пролета моста с wiki:Большой_Каменный_мост 105 м |
|||
34
kuromanlich
17.06.12
✎
16:50
|
(33) но я радиус земли взял не 6371, а 6372795
|
|||
35
Grobik
17.06.12
✎
17:16
|
(34) Разница три сотые процента, у тебя просто формула точнее.
|
Форум | Правила | Описание | Объявления | Секции | Поиск | Книга знаний | Вики-миста |