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 8624155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:27:17+00:00 2026-06-12T07:27:17+00:00

I would like to know your opinion. I created an application, where users create

  • 0

I would like to know your opinion. I created an application, where users create routes and we track this route and save all the way points in the database. Then, the application does comparisons of users way points.

Currently, I use a MSSQL Server, using two tables, one for Routes and the other for storing way points (with spatial data type). The comparisons are made in a stored procedure using SQL Server geographic functions such as st_distance…

I have investigated other options. One that I implemented is with Oracle 11g using objects. I store all data in only one Object Table, and the way points are stored in a Varray of a type with Latitude and Longitude attributes. This way is very efficient saving and retrieving data, but gets some complicated when comparing.

I’m looking for a NoSQL solution, some algorithm or method to do this efficiently. What do you think?

  • 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-12T07:27:18+00:00Added an answer on June 12, 2026 at 7:27 am

    Using database functions like STDistance for all n records is suboptimal. Your CPU overhead will increase exponentially.

    What you should do is check for the amount of points within a rectangle around the current epicenter you are searching. Here’s an example (in MySQL):

    SELECT * FROM `points`
        WHERE `latitude` >= X1 AND `latitude` <= X2
        AND `longitude` >= Y1 AND `longitude` <= Y2
    

    This provides a reduced superset of points that should then be further reduced by calculating the orthodromic distance (with respect to the curvature of the Earth) using the Haversine formula.

    Don’t forget to set up a composite index on latitude and longitude.

    Orthodromic distance

    Here it is in PHP:

    <?php
    function haversine($latitude1, $longitude1,
                       $latitude2, $longitude2, $unit = 'Mi') {
        $theta = $longitude1 - $longitude2;
        $distance = (sin(deg2rad($latitude1)) * sin(deg2rad($latitude2))) +
        (cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * cos(deg2rad($theta)));
        $distance = acos($distance);
        $distance = rad2deg($distance);
        $distance = $distance * 60 * 1.1515;
        switch ($unit) {
        case 'Mi':
            break;
        case 'Km':
            $distance = $distance * 1.609344;
        }
        return (round($distance, 2));
    }
    ?>
    

    To recap:

    Here’s an example image illustrating what to do:

    Example with CN Tower

    The first search would involve a bounding box collision search (MySQL example) to determine the superset, excluding the red points. The second verification process would involve calculating if the points are within an appropriate orthodromic distance with the Haversine formula (PHP example) and taking a subset (composed of the black points).

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

Sidebar

Related Questions

This is probably a subjective question, but I would like to know your opinion.
I would like to know your opinion about using Cassandra to implement a RBAC-like
I would like to know your opinions on how to handle this. I need
I would like to know your opinion on disadvantages of using ACL on Honeycomb
I would like to know your opinion on developing a .html web pages site
I would like to know your opinion about javascript template engine, which one you
I would like to know what in your opinion should be included in approach
I would like to know what is in your opinion the best way of
I would like to know your opinion of a good jQuery and JavaScript book.
I would like to know your opinion on whether it is a good idea

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.