In PHP, how do you calculate the sun's azimuth? [closed] - php

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I know how to use the sun info function to get some info about the sun, but it doesn't offer a way to get the azimuth for a given date/time/location. Specifically, I want to get the azimuth at sunset to display in a graph where I show the length of day and sunrise/sunset.
I've seen at least one answer that partially applies, but it's a long and complicated function that calculates a whole lot of things I don't need. Since I'll need to calculate the azimuth for 365 days, I think this will add a lot of processor load and time in generating the chart.
I'm hoping for a simpler formula that will provide just the azimuth for a lat/long and timestamp.

You can use a tiny PHP library called SunCalc. SunCalc is a tiny PHP library for calculating sun position, sunlight phases (times for sunrise, sunset, dusk, etc.)
Here you can find the lib and exemples : Source

Related

Unable to extract fuel prices from updated website [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 12 months ago.
Improve this question
I used to use a website from the RAC to gather todays fuel prices, but they've changed the format and now it's all javascripted. Anyone fancy having a look and see if they can extract just the price of diesel in a usable format? Here's the website.
https://datawrapper.dwcdn.net/oDTQ2/48/
Ideally something in php as the rest of my coding is already using that.
Massive thanks
In the end the data seem to come from:
https://static.dwcdn.net/data/oDTQ2.csv?v=1646751660000
The trick the is to discover what the number behind the v parameter stands for. This is a time, in milliseconds, since the Unix Epoch (January 1 1970 00:00:00 GMT). In this case it is "2022-03-08 07:01:00.000". I think you need to update that number to get the correct prices.
Oh, I simply used the developer tools of my browser to check what was downloaded for this page. And saw one file with this response:
Unleaded,Super unleaded,Diesel,LPG
156.37,167.75,162.28,80.08
pence per litre,pence per litre,pence per litre,pence per litre
↗ Likely to rise,↗ Likely to rise,↗ Likely to rise,
7 March 2022,,,

ZipCode Algorithm [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have to write a function that takes in an array of zipcodes and only returns the ones that do not produce super overlappy visualizations if a circle was drawn around the zipcode of a fixed radius. So basically my function takes in array of zipcodes and a radius variable.
What are some algorithms I can use to produce non overlappy maps?
Here is a messed up visualization:
Here is a correct one.
One algorithm that I came up was to basically loop through the zip code array one zip at a time and then determine the distance to other zipcodes in the array center using the provided lat / lon coordinates and then finding all the zips that are intersected. However As you can imagine that it is not a perfect implementation as some overlap is OK and also my algorithm would assume perfect circles.
Is there a common sense algorithm that I am missing? Just trying to learn.

Calculate distance between geopoints on parse with PHP [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm using Parse.com for my back-end, and in my table I have column named geopoint whose time type is GeoPoint. In another table I have the same. So I need to calculate distance between those two geopoints. Is there way to do that with parse? Or you can provide another solution. I'm using PHP
Without any code snippets it would be hard to give you the answer. I can point you in the right direction though.
As you are only using 2 points I assume you want Euclidean distance. (Straight line or 'as the crow flies')?
Wolfram has an excellent page on this here: http://mathworld.wolfram.com/Distance.html
It is (slightly) simplified here too: http://www.cut-the-knot.org/pythagoras/DistanceFormula.shtml
If you are still having trouble then post code snippets. Ideally something where you are already accessing these objects.

Geolocation to find nearest place [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have a database of national park names (Alcatraz Island, Death Valley, Biscayne, etc.) which all have coordinates.
What's the simplest way for me to match the closest park in my database to their current location whether on a mobile device or on a desktop?
You can definitely use Google's Geolocation API to get the user's current location, then with some Javascript, you can determine the closest park.
Don't know what database you're using, but you might look into PostGIS, an extension to Postgres designed to handle geographical data. You would be able to query the database for the closest locations to a certain point. The algorithms for doing so are built in to PostGIS. Otherwise, you might need an external library to do the calculations.

What is better - Mysql vs csv - [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Sorry if this has been ask but i can't find anything about this on the form,
I am making a shipping calculator and i get csv files from my courier with rate and place (the calculator is made in php),my question is - what is best to read the CSV file in as an array or import the CSV to Mysql database and read the data that way?
If anyone has some experience with this type of situation and won't mine telling me the best way to go about this that will be so great.
I have not tried anything because i would like to know what the best way is to go about this.
Thanks for reading.
Won't this depend upon how many times a day you need to access the data, and how often the shipping data is updated?
eg if the shipping data is updated daily, and you access it 10000 times per day, then yes it would be worth importing it into a db so you can do your lookups.
(this is the kind of job sqlite was designed for btw).
If the shipping data is updated every minute, then you'd be best grabbing it every time.
If the shipping data is updated daily, and you only access it 10 times, then I wouldn't worry too much - either grab it an cache the file then access it as a PHP array.
Sorry, but I am not familiar with the data feed in question.

Categories