Using PHP, we have an array of GPS coordinates that create a specific route.
I need to allow the user to give an input width. Using this input we need to create a polygon around the line.
In the image found under the link below:
https://drive.google.com/file/d/1DmVdKAh6advlcQYiDZQPsKYisjxmPu5I/view?usp=sharing
We are given the latitude and longitude of the points A,B,C. I need a way to get the coordinates of the points D,E,F,G,H. Note that these are GPS locations and not 2d formulas
Related
I am using Google Maps to display locations stored in a MySQL database containing name, latitude and longitude information. An AJAX request is sent and the map is updated with all the locations. So far, so good.
Users have the ability to filter the locations by drawing polylines on the map to create a bounding box. The idea is that only locations within this bounding box are returned and they can draw whatever shape they want.
All the points used to draw the shape are returned a list of coordinates. Where I am struggling is taking the list of coordinates and finding everything within them. Can I achieve this with an SQL query? Is it even possible?
I have seen examples of returning locations within x radius from one set of coordinates and also a square box, but I have no idea how to take that further and get everything within a potentially infinite set of coordinates.
You should transform the shape the user enters into a polygon. Then you transform all locations within a square around this polygon into the same coordinate system.
Using a solution describe in the wikipedia page for point-in-polygon problems you will be able to find all locations within this shape and remap them to coordinates in your sql database and then into locations.
There are however similar question which might help you find a proper solution to your problem. See:
How can I determine whether a 2D Point is within a Polygon?
Point in Polygon Algorithm
I need to get programmatically polygon points coordinates from image.
Here is an example: http://imgur.com/gbs96tt
Is there any libraries or any solutions for this? Desirable written in php.
I have a dataset that has four types of files with the following file extensions -
.DBF,.PRJ,SHP,SHX
My goal is to get all the polygon coordinates for each neighborhood and draw the boundary outline on the google map when a user is on a specific Neighborhood page. Currently the datasource for the site is a MySQL Database.
I have tried converting the shp file to Geojson but then parsing that file is time taking.
I have also tried using tools such as QGIS and shp2sql etc.
I would like to know what is the best way to get the main attributes from the dataset along with each neighborhood's Polygon coordinates.
please advise
I have managed to accomplish this using the ogr2ogr command line tool -
ogr2ogr -f "MySQL" MYSQL:"mydb,host=myhost,user=mylogin,password=mypassword,port=3306" -nln "world" -a_srs "EPSG:4326" path/to/world_adm0.shp
I have the polygon coordinates in a geometry field in the table attached to its corresponding neighborhood id.
I did Select ASTEXT(Shape) as POLYGON from world to get the array of coordinates and now I can convert that to json and send it to Javascript so that it can be mapped
I have a set of adresses / coordinates. In my software the user should be able to search for a specific adress or coordinate and find the surrounding places of the set of coordinates in a specific radius. The results should be shown on a map.
(Mostly like Google Places for Restaurants just with my own set of places)
Displaying the places on a static map is not the problem, but handling the set of addresses (~5000) and calculating the distances to the place searched for.
How can I establish a function like this using Google's APIs?
Thanks!
You can use the harvesine formula and a bounding box. Or you can use a spatial index and a bounding box. The harvesine formula is used for spheres. Most likely you use straight distance (like the crow flies).
I'm working on a PHP application that needs to obtain data from a topographical map (different elevations denoted by different colors). I need to do two things:
Using this map (800x600), find a way to determine the exact pixel location of a particular city. For example, San Francisco is located at precisely 121x585.
Using the location from (1) above, I need to read the exact color at that location.
Note: The map provider does not provide location-based data, only a colored map. I suspect multiple libraries would be needed to map coordinates to locations on the map (via a ratio?) and then use OCR to read the color.
Are there any PHP libraries/tools that do this? How would you pull this off?
Once you know the pixel-coordinates, you can use PHP's built-in GD library to sample the color of an arbitrary pixel quite easily.
The tricky bit will be determining the pixel to sample, which can get pretty darned tricky. The earth being sphere-like, maps use various projections to produce a 2-d representation. If you know how the colored map image is projected, and you know the latitude/longitude of the pixel at (0,0), you should be able to write a function to convert lat/long to a pixel coordinate.
I may not have understood the problem entirely, but you should map the locations you want into an array (of objects?)
$city_mapping = array(new City("San Francisco", 121, 585), new City....); //Map your cities to an array.
Where City should be defined as a class to contain those variables.
Then use imagecolorat() to check for the color.