Subrato, Thats y you no need to calculate it. Calculate costly in CPU resource and traffic for query, rather than you already have predefine answer, it would consume a little CPU resource by just to lookup the answer. However it also got cons like it require more spaces.
If you higlight on time, your calculation should be minimized. In moderate, you can combine both to optimize CPU, space and time. Based on your situation, I dont know what is you input or existing data. Since the state location is fixed and possibility the state would change location is nearly imposible, retrieving the adjacent state is good by loading the the predefined answer from your db. No need to calc each time you want to retrieve it unless you create the app for GPS app/map provider. If you got no data about it, you need it one time only. So you need to convert from raw, lon, lat etc... to your lookup table. To convert it you need to know the "algorithm" to perform. Finding near place by straight line is very simple vs by road is too much complicated. On May 14, 8:05 pm, Subrato Mukherjee <[email protected]> wrote: > Technically yes. But then you have to run through a db to scan for each > latitude/ longitude and calculate the distance. What I am trying to do is to > avoid this. If I know what latitudes/longitudes I have to scan for say > 10001, it would be nice to know that I would search in direction of Jersey > city rather than searching for places in Upstate NY. That way I am already > avoiding a query on so many rows. > I know most would argue that searching through db these days doesnt take a > lot of time with the computing power we have, but I was still looking for > something optimized rather than check all. > > I have DB of all zip codes and I am using that to calculate it but as I > said, I would want to avoid searching 30 odd thousand records every time > > On Thu, May 14, 2009 at 12:37 AM, Hari haran <[email protected]>wrote: > > > I dont know if it could help, but can you not achieve the same by having > > latitutes and longitudes as a basic paramater to compute? > > > Coz to compute we need to have some base data to work on... > > > Let me know if this can work or give me inputs... > > > -Hari > > On Thu, May 14, 2009 at 9:12 AM, Subrato Mukherjee < > > [email protected]> wrote: > > >> Yes I believe I could use enum or anything. But I really would like to > >> compute it. > >> Subrato > > >> On Wed, May 13, 2009 at 11:21 PM, Vivek SHANTHARAM > >> <[email protected]>wrote: > > >>> Since I the know the data beforehand and it is fixed , say 50 states, i > >>> would put it in an enum and access it. > > >>> And of course, computing it would be brilliant. > > >>> On Thu, May 14, 2009 at 7:00 AM, S <[email protected]> wrote: > > >>>> I am developing this small application in which I need to find states > >>>> adjacent to the one I am looking up. Say for example, if I am looking > >>>> up Connecticut, adjacent ones are NY, MA. Now I could potentially > >>>> store it but I would want to rather compute it and do it very > >>>> efficiently. > > >>>> Any ideas anyone can throw on this ? > > >>>> Thanks > >>>> S
