chetanspeed511987
chetanspeed511987

Reputation: 2025

How to check (in php or cakephp) particular latitude/longitude of a suburb lies in particular state?

I have

  1. latitude/longitude of particular state
  2. latitude/longitude of particular suburb

What I want :

I want to know

  1. Area of particular state
  2. particular suburb lie in which state

What I already tried :

  1. How do I check if a longitude/latitude point is within a range of coordinates? -> But unfortunately not getting in php
  2. https://developers.google.com/maps/documentation/geocoding/#ReverseGeocoding

Upvotes: 0

Views: 979

Answers (1)

mark
mark

Reputation: 21743

you can use my Lib class and behavior to geocode the two things: http://www.dereuromark.de/2012/06/12/geocoding-with-cakephp/

then you got coordinates for both of them and you can use this information to get your results.

so

  • add lat/lng fields to your tables (states and suburbs)
  • run a save() for each of them to geocode the address field (name probably here)
  • use the now stored lat/lng fields to determine distances etc

PS: you will most likely get geocoding results that will already tell you which state the suburb is located in. so you might want to extract this information along the way. this will be more accurate then trying to use distances, especially in smaller states the distance can get you a wrong result.

Upvotes: 1

Related Questions