I'm using the code below:
I want to get the nearest place from google (only need nearest result).
To do this, I changed radius but then result is wrong.
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=6.384314,81.324417&radius=1000&types=accounting|airport|amusement_park|aquarium|art_gallery|atm|bakery|bank|bar|beauty_salon|bicycle_store|book_store|bowling_alley|bus_station|cafe|campground|car_dealer|car_rental|car_repair|car_wash|casino|cemetery|church|city_hall|clothing_store|convenience_store|courthouse|dentist|department_store|doctor|electrician|electronics_store|embassy|establishment|finance|fire_station|florist|food|funeral_home|furniture_store|gas_station|general_contractor|grocery_or_supermarket|gym|hair_care|hardware_store|health|hindu_temple|home_goods_store|hospital|insurance_agency|jewelry_store|laundry|lawyer|library|liquor_store|local_government_office|locksmith|lodging|meal_delivery|meal_takeaway|mosque|movie_rental|movie_theater|moving_company|museum|night_club|painter|park|parking|pet_store|pharmacy|physiotherapist|place_of_worship|plumber|police|post_office|real_estate_agency|restaurant|roofing_contractor|rv_park|school|shoe_store|shopping_mall|spa|stadium|storage|store|subway_station|synagogue|taxi_stand|train_station|trave_agency|university|veterinary_care|zoo&sensor=false&key=AIzaSyA0JD_Z2Uo2AfnDTejQFWHAXOIaRRpjF8c
Order the results by distance(by using the rankby-parameter):
https://maps.googleapis.com/maps/api/place/nearbysearch/json?rankby=distance&location=6.384314,81.324417&types=accounting|airport|......&sensor=false&key=AIzaSyA0JD_Z2Uo2AfnDTejQFWHAXOIaRRpjF8c
Note:
you must ommit the radius in this case
there is no way to limit the number of results to a specific value
Related
I am trying to save polygon area when a new polygon has been created by the user. I found that there is a function for this purpose - ST_AREA, but when I check if it is calculating correct I find some discrepancies. Here is one example:
This is one polygon which area according to geojson.io is 31.85:
But when I run ST_AREA for the same polygon:
SELECT ST_Area(CONCAT(a.polygon, 'SRID=4326'))*10000 AS area FROM kt_polygons a where polygon_id = 180;
The result is 34.93261884737489. Something more, I am not quite sure why I multiply the result area by 10000.. I just do that because the result seems to be more realistic in that way.
I check some other polygons and the difference is not more than 5, but why this can happen? Any ideas what I do wrong?
I found a solution which helps for my case. When I get the result from ST_Area I multiply it by 9090,91. This coefficient maybe is propriate only for my problem, but you can find if there is dependency between the real areas and the one from ST_Area. If so, you can find your coefficient.
I want to use:
st_join(polygon_A, polygon_B, join=st_intersects)
to get the same output as of the current version with an extra column that specifies the proportion of the area captured from polygon_A by polygon_B? Ideally this would work with largest=TRUE (returning unique records of polygon_A with only one match from polygon_B) or with largest=FALSE (returning all matches from polygon_B with the proportions of captured areas by polygon_A).
My workaround was to use st_intersection(polygon_A, polygon_B), calculate the area of the new shapes (the result of the intersection) using st_area, and then divide it by the area of the original shape of polygon_A. Is there a better way of achieving this? Or maybe plans to add this as a feature to st_join.
For the record and to avoid the XY problem, my objective is to identify cases where the proportions are close to 0.50/0.50 or 0.70/0.30 and take a closer look to decide if largest=TRUE is meaningful. I am not very interested in cases where the proportions are 0.99/0.01 - largest=TRUE is good enough for these cases.
A short introduction:
I have a body that is expressed by the outer-surface, given in STL form (set of triangular elements and their outside-pointing normal vector).
I'm trying to detect if a point given by coordinates is inside or outside the body.
The problem:
How do I find the nearest element to a given point?
More specifically, say you have found the nearest vertex to the point and this vertex is shared by two (or more) elements. Which is is the "nearest" one?
Note that the end result is determining if the point is inside or outside the body. A simple normal distance (dot product with the normal) does not solve the problem and can lead to ambiguous result based on which of the elements, sharing the node is selected.
Using the centroid of the element is also problematic.
Any suggestions, ideas (especially from people who have been involved in this issue before) are most welcomed!
EDIT:
I'll make the issue slightly harder. Say there's an open surface (but it covers the whole domain so that every point is on one of two sides of the surface, either in or out, based on the direction relative to the normal.
This also needs to be answered using the same approach.
EDIT2:
Answer was found!
Hope this helps!
The problem was answered with a variation of the ray-intersection method. 1. Find the nearest vertex, using the L2 norm (squared). 2. Consider the elements which share the vertex. It is recommended to have a connectivity list and not map them every time. 3. Cast a ray is cast from the interest point to the centroid of the first element. 4. Check among the elements in <2> which intersect the ray and select the one with the shortest intersection distance 5. Use the dot product of the intersection vector with the element normal (negative sign = outside, else inside)
(This was added to the question post itself)
I use the Google Maps Javascript API v3 for calculating the directions from my current position to my end destination in an iPad PhoneGap Application.
Now I want to make a function which automatically recalculates the directions, if you take the wrong lane. That means, I will make a marker for the current position on the map and then should check if it's near the directions-polygon, if not recalculate the route.
The directions are printed out in a canvas-element and I couldn't find anything how to compare it with my markers…
Any idea?
The following line works. Just set the tolerance as desired.
google.maps.geometry.poly.isLocationOnEdge (point, polyline, tolerance)
It will return true if point is located in the polyline/ polygen. Let me know if tyhis doesn't work.
axs
Apologies if this is considered a repeat question, but the answers I've seen on here are too complex for my needs.
I simply need to find out if a line segment intersects a circle. I don't need to find the distance to the line from the circle center, I don't need to solve for the points of intersection.
The reason I need something simple is that I have to code this in SQL and am unable to call out to external libraries, and need to write this formula in a WHERE clause... basicaly it has to be done in a single statement that I can plug values in to.
Assuming 2 points A (Ax,Ay) and B (Bx,By) to describe the line segment, and a circle with center point C (Cx,Cy) and radius R, the formula I am currently using is:
( RR ( (Ax-Bx)(Ax-Bx) + (Ay-By)(Ay-By) ) )
-( ((Ax-Cx)(By-Cy))-((Bx-Cx)(Ay-Cy)) ) > 0
This formula is taken from link text, and is based on a 0,0 centered circle.
The reason I am posting is that I am getting weird results and I wondered if I did something stupid. :(
although this doesn't exactly answer your question: Do you really have to calculate this on the fly on a SQL-Select? This means that the DB-system has to calculate the formula for every single row in the table (or every single row for which the remaining where conditions hold, respectively) which might result in bad performance.
Instead, you might consider creating a separate boolean column and calculate its value in an on-insert/on-update trigger. There, in turn, you wouldn't even need to put the test in a single line formula. Using a separate column has another advantage: You can create an index on that column which allows you to get your set of intersecting/non-intersecting records very fast.