Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome General
 PowerHome Messageboard : PowerHome General
Subject Topic: Calculate distance with ph Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
krommetje
Super User
Super User
Avatar

Joined: December 29 2004
Location: Netherlands
Online Status: Offline
Posts: 695
Posted: November 19 2014 at 12:02 | IP Logged Quote krommetje

dhoward wrote:
Peter,

In the PH multi-editor, what do you get when you run the following functions:
Code:
ph_latlongdist(ph_number("51.4567405"),ph_number("5.6372489" ),ph_number("51.4589887"),ph_number("5.6342066"))

and
Code:
ph_latlongdist(ph_number("51,4567405"),ph_number("5,6372489" ),ph_number("51,4589887"),ph_number("5,6342066"))


Dave.


SQLSTATE = 37000
[Sybase][ODBC Driver][SQL Anywhere]Syntax error near '(' on line 1


However: running it as part of the macro (code1)
Execution time: 0,004 seconds.
The formula evaluates to: 9789,460432694224

(code2)
Execution time: 0,002 seconds.
The formula evaluates to: 0,3269925583113723



Edited by krommetje - November 19 2014 at 12:11
Back to Top View krommetje's Profile Search for other posts by krommetje Visit krommetje's Homepage
 
krommetje
Super User
Super User
Avatar

Joined: December 29 2004
Location: Netherlands
Online Status: Offline
Posts: 695
Posted: November 19 2014 at 12:03 | IP Logged Quote krommetje

I made a small page which takes the original Lat/Lon and transfers it to google maps, this works OK....

Edited by krommetje - November 19 2014 at 12:04
Back to Top View krommetje's Profile Search for other posts by krommetje Visit krommetje's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: November 19 2014 at 12:28 | IP Logged Quote dhoward

Peter,

Your multi-editor error is because the editor was in SQL mode (shift-F5) instead of PH Formula mode (shift-F6).

However, your macro runs gives me the info I need. Code2 with an answer of 0,3269925583113723 is the correct value so you would use this format if you still want to do it within PowerHome (using the ph_number function to convert the lat/long with comma's instead of decimals for ALL the values).

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
krommetje
Super User
Super User
Avatar

Joined: December 29 2004
Location: Netherlands
Online Status: Offline
Posts: 695
Posted: November 19 2014 at 12:33 | IP Logged Quote krommetje

So all values should be with a comma in my case. In case of US users, all values should be with a decimal point....
Back to Top View krommetje's Profile Search for other posts by krommetje Visit krommetje's Homepage
 
krommetje
Super User
Super User
Avatar

Joined: December 29 2004
Location: Netherlands
Online Status: Offline
Posts: 695
Posted: November 19 2014 at 12:41 | IP Logged Quote krommetje

ph_latlongdist(ph_number("51,4567405"),ph_number("5,6372489" ),ph_number(ph_getglobal_s("PLAT")),ph_number(ph_getglobal_s ("PLONG")))

gives Formula Evaluation
     Execution time: 0,006 seconds.
     The formula evaluates to: 7160,365178893712




PLAT and PLONG are the original GV's as sent by my droid... with decimal point. How do I substitue a decimal for a comma?

Edited by krommetje - November 19 2014 at 13:07
Back to Top View krommetje's Profile Search for other posts by krommetje Visit krommetje's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: November 19 2014 at 13:24 | IP Logged Quote dhoward

Peter,

Quote:
So all values should be with a comma in my case. In case of US users, all values should be with a decimal point....


Correct. Unless you want to change your Windows regional settings to match the US so you can use a decimal point.

Quote:
ph_latlongdist(ph_number("51,4567405"),ph_number("5,6372489" ),ph_number(ph_getglobal_s("PLAT")),ph_number(ph_getglobal_s ("PLONG")))

gives Formula Evaluation
     Execution time: 0,006 seconds.
     The formula evaluates to: 7160,365178893712


Mixing the commas and decimals will give you the wrong values always. To substitute, use the ph_replaceall function. Your function above would look like this:

Code:
ph_latlongdist(ph_number("51,4567405"),ph_number("5,6372489" ),ph_number(ph_replaceall(ph_getglobal_s("PLAT"),".",",")),p h_number(ph_replaceall(ph_getglobal_s ("PLONG"),".",",")))


Dave.



Edited by dhoward - November 19 2014 at 13:24
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
krommetje
Super User
Super User
Avatar

Joined: December 29 2004
Location: Netherlands
Online Status: Offline
Posts: 695
Posted: November 28 2014 at 07:42 | IP Logged Quote krommetje

Dave (and others)

I've got it up and running for several days now but I've still got a problem with authenicating. I've got auth in web set to basic. Restarted (not reinit) PH but after some time, PH no longer accepts authenication....what can be the cause of this?

Edited by krommetje - November 28 2014 at 07:43
Back to Top View krommetje's Profile Search for other posts by krommetje Visit krommetje's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: December 06 2014 at 19:46 | IP Logged Quote dhoward

Peter,

Not sure. When it stops accepting authentication, can you still hit the webserver from a browser and navigate through the PowerHome webpages? Also, what does the eventlog show for each failed attempt?

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
krommetje
Super User
Super User
Avatar

Joined: December 29 2004
Location: Netherlands
Online Status: Offline
Posts: 695
Posted: December 07 2014 at 02:39 | IP Logged Quote krommetje

Dave,

I still can logon even with the http://username:password@... format. PH just stops changing the GV's

Peter
Back to Top View krommetje's Profile Search for other posts by krommetje Visit krommetje's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: December 07 2014 at 11:24 | IP Logged Quote dhoward

Peter,

What does the eventlog say for the web event and the entries after? If the web entry is ok and the GV does not update, Im suspecting a syntax error or some other problem.

Let me know,

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
krommetje
Super User
Super User
Avatar

Joined: December 29 2004
Location: Netherlands
Online Status: Offline
Posts: 695
Posted: December 10 2014 at 09:10 | IP Logged Quote krommetje

Dave,

I can send you my database or send me the sql to export the eventlog so i can send that. Whatever you see fit....
Back to Top View krommetje's Profile Search for other posts by krommetje Visit krommetje's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: December 10 2014 at 19:40 | IP Logged Quote dhoward

Peter,

Probably not necessary to send the whole database. A screenshot of the eventlog showing the web access entry and some of the before and after should be sufficient.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
krommetje
Super User
Super User
Avatar

Joined: December 29 2004
Location: Netherlands
Online Status: Offline
Posts: 695
Posted: December 15 2014 at 04:06 | IP Logged Quote krommetje

Dave,

(took a little longer due to 2 deaths in the family)

Here is a screenshot of the log:


I still think this is an auth. problem however can't think what to do next: IP's whitelisted and auth set to basic...
Back to Top View krommetje's Profile Search for other posts by krommetje Visit krommetje's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: December 15 2014 at 16:35 | IP Logged Quote dhoward

Peter,

Very sorry to hear about your family. Its terrible anytime but even more so this time of year.

Looking at your screenshot, the request doesnt have an "Authorization: Basic" section that would normally be included if you had supplied credentials on the URL line. This would put the issue with whatever http client you're using to access PowerHome with. If you compare this log entry to one that works, you should see the difference.

However, you say that you've got the IP in the trusted IP section of the webserver configuration. If you could send a screenshot of the Trusted IP section or just copy/paste the data there I can verify that its formatted properly. With 92.69.213.73 set as trusted, you shouldnt need to include any authorization and it should just work.

Let me know,

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
krommetje
Super User
Super User
Avatar

Joined: December 29 2004
Location: Netherlands
Online Status: Offline
Posts: 695
Posted: December 16 2014 at 01:55 | IP Logged Quote krommetje

Dave,

Due to securityissues I will send the trusted IP-section in a PM on the board.

Peter
Back to Top View krommetje's Profile Search for other posts by krommetje Visit krommetje's Homepage
 
krommetje
Super User
Super User
Avatar

Joined: December 29 2004
Location: Netherlands
Online Status: Offline
Posts: 695
Posted: August 09 2015 at 05:43 | IP Logged Quote krommetje

Dave,

got a new phone yesterday and now all of a sudden PH says the formula is a syntax error...

here is the log-entry:

Code:

Aug 09 2015       12:16:58       Formula Error      Syntax Error in Formula: ph_setglobal_s(~"plat~",~"51.45676~")+ph_setglobal_s
Aug 09 2015       12:16:58       Trusted Web Access      From: 95.96.108.241 GET /ph-cgi/eval?formula=ph_setglobal_s("plat","51.45676")%2bph_ setglobal_s("plong","5.637223") HTTP/1.1 User-Agent: Dalvik/2.1.0 (Linux; U; Android 5.0.1; SM-N910F Build/LRX22C) Host: powerhome.krommetje.nl:9600 Connection: Keep-Alive Accept-Encoding: gzip


can you tell here what seems wrong? the formula and settings are the same...

note: the boardbug has struck again!

Edited by krommetje - August 09 2015 at 05:44
Back to Top View krommetje's Profile Search for other posts by krommetje Visit krommetje's Homepage
 
krommetje
Super User
Super User
Avatar

Joined: December 29 2004
Location: Netherlands
Online Status: Offline
Posts: 695
Posted: August 09 2015 at 07:12 | IP Logged Quote krommetje

Update in this matter:

I Changed the " into ' and all worked again.
Back to Top View krommetje's Profile Search for other posts by krommetje Visit krommetje's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: August 12 2015 at 19:39 | IP Logged Quote dhoward

Peter,

Glad to hear you got it going.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

<< Prev Page of 2
  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum