Nearest place within the latitude and longitude [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 8 years ago.
Improve this question
I create simple API for IOS devices. In my project there is a table with the parties the latitude and longitude where they registered. The device gives me the latitude and longitude where it is and I have him return The list of parties that are closer to it within such km. How best to do this, please help and thanks.
I use clean PHP and mysql.

Write a user defined function in mysql [e.g. distance(x1,y1,x2,y2)] which returns the distance of two points. Then you can query for other locations within a given radius of a given point, like in
select parties from mytable where distance(latitude,longitude,x,y) < 10
Do the processing in the database, not in the PHP client, for performance reasons.

Related

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.

PHP & Google Maps Postcode Checker [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 not asking for anybody to build the application for me. I'm just looking for some direction. Plugins, Tutorials, etc.
How would I go around making a small application to check if a custom is within our operating radius?
So when a customer starts the ordering process, they will be asked to give us their postcode and they enter their their postcode so that we can check it. So if it is outwith our operating boundaries of 50 miles from another postcode then we will display a static error message and tell them to check back later.
By the way this is UK postcodes.
Use this to get all US Zipcodes or UK Postcodes within whatever radius use this tool...
For US:
http://www.freemaptools.com/find-zip-codes-inside-radius.htm
For
UK: http://www.freemaptools.com/find-uk-postcodes-inside-radius.htm
For any other tools you can try and check this site

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.

Converting coördinates into addresses [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 8 years ago.
Improve this question
I created a database, which contains many locations expressed in longitude and latitude. How can I convert them automitcally into addresses? (Reverse Geocoding)For this task I want to use PHP and SQL, because I am building a webapplication.
The Google Map API can do this.
Example:
$response = json_decode(file_get_contents("https://maps.googleapis.com/maps/api/geocode/json?latlng=".$latitude.",".$longitude."&sensor=false&key=".$API_KEY));
You can see the kind of response you'll get on the page about reverse geocoding. In the above example, I parsed the JSON response string into an appropriate php object.

Categories