Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8354003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:25:36+00:00 2026-06-09T09:25:36+00:00

I need to implement a locality based search feature where users would be able

  • 0

I need to implement a locality based search feature where users would be able to choose a city and locality(within the city) , proceed to mention a keyword and click on search . So say we have 10 cities with an average of 100 localities in each . The results are to be displayed considering the user provided locality as the starting point and ordering other results further away from the user’s locality (in this way the cities results for the particular keyword would be constant only the ordering would change ) .What would be the best approach in php ?

1) Calculate the distance between various localities , pre store them in the mySqldatabase . This would mean a 100X100 matrix for the localities (each localities distance from the others).Also as many tables as the cities in the db . So 10 such tables + possibility of adding more . This is to be used only for ordering.

2) Put all the data in an XML instead of mysql database.

3) Use bitmaps and compressed images ?

Considering performance and scalability as a main criteria .

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T09:25:38+00:00Added an answer on June 9, 2026 at 9:25 am

    You’re first filtering your data by city and tag, and then want to order the result by distance, but not filter by distance. I.e. even the farthest points should be retrieved from the database. In that case, there shoulnd’t be too much of a penalty if you compute the distance from the given location when you execute the request. After all, it’s just one formula evaluation per line, and then sorting the result by that value.

    If your data is given using latitude and longitude coordinates, then theoretically this would mean computating lengths of geodesics on the sphere using a complicated formula. But within a single city, the georgraphical grid can reasonably be assumed to be rectangular (not square!). So if you store the ratio between one degree of latitude and one degree of longitude for each city, then you can convert all coordinates to a square grid, compute difference from the entered location in x and y direction, square and add those. No need to take the square root, as ordering by squares works just as well.

    Something along these lines:

      SELECT location.name, location.lat, location.lon, …
        FROM locations, cities
       WHERE location.city = city.id
         AND city.name = ?
         AND location.tag = ?
    ORDER BY POW((location.lat - ?), 2) + POW((location.lon - ?)*city.geoaspect, 2)
    

    where parameters are the city name, the selected tag and the entered latitude and longitude.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to implement AI for game based on fuzzy logic. I need to
I need to implement a one-to-one videoconferencing solution server-based, runnable by browser, free (or
Need to implement the delivery of public messages for all users and personal messages.
I need implement simple search in small content table: id, name, description, content. Results
Need to implement Application Role Management feature.. Looked at AZMan , I guess it
I need to implement an in-memory tuple-of-strings matching feature in C. There will be
I need to implement Minesweeper solver. I have started to implement rule based agent.
I need to implement string.IndexOf functionality without using any c# string search related built
I need to implement facebook's share feature into my android app. My scenario is
I need to implement a search in mysql table for a certain word to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.