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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:50:25+00:00 2026-05-20T00:50:25+00:00

I have an application (cad like editor) in which the user may place a

  • 0

I have an application (cad like editor) in which the user may place a lot of positional nodes (defined by their latitude and longitude). The application needs to tell the user if these nodes are very close together – a common design error is to overlap them. What the app is doing is something rather like ReSharper or CodeRush does in the IDE – parses the project and reports problems. A project may have several thousand of these nodes so testing for overlap becomes exponetially more time consuming as the numbers go. At the moment I am using two for loops to get through the list.

for (int i = 0; i < count - 1; i++) {
     for (int j = i + 1; j < count; j++) {
         // check the distance between the i and j elements and if less than
         // a predetermined value report it
    }
}

I would like to get the process of identifying these into ‘real time’ so that the user is told at once in the event that an overlap occurs. The looping is expensive as is the testing of the distance between nodes. Most of the comparisons are wasted of course.

I just wonder if there is another way. I have thought about sorting the list by lat and lon and comparing adjacent elements but I suspect that will not work nor necessarily be faster.

My other thought is to move the activity to another thread (I really have no experience of using multiple threads) so that the values are being updated – for example storing a reference to nearby nodes in each object. However I can imagine needing to clone the object tree for the background thread so that there is no conflict with the foreground.

  • 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-05-20T00:50:26+00:00Added an answer on May 20, 2026 at 12:50 am

    Since the user is placing these locations, the ideal solution would be to assume all previously placed points are not nearby, and with each new point or moved point, check against the rest — this becomes a single for loop, which should be reasonable.

    Another, more ideal solution however:

    Let position of A be lat, lng.
    Convert both lat and lng to a fixed-length representation
        (truncating the degree of precision to a value below which 
        you are sure they will overlap)
    Let xa = lat . lng (concatenate both)
    Let ya = lng . lat
    
    Given some position B, find xb, yb.
    
    B is 'close' to A iff | xa - xb | < delta, | ya - yb | < delta.
    

    So what you can do is sort the values of xi, yi for all your input points. When you want to check for points that are too close, you need to traverse through the list of xi’s to find points that are too close together (linear time, since they will be adjacent) and then check if the same points in the list of yi’s are too close.

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

Sidebar

Related Questions

I have application which is for paranoic users who used to store their sensitive
I'm developing CAD like application in C# (Forms, no external framework). I have implemented
I have application with BroadcastReceiver which listens to SD card mount/unmount, like: public class
i have application with one form, which i developed in c#. I would like
I have application which uses Sherlock ActionBar package. The application uses platform-specific behavior for
I have application which needs to use a dll (also written by me) which
I have an application loading CAD data (Custom format), either from the local filesystem
We have application named Milekeeper , which relays users to send invitations to race
My C++ CAD application maintains logs of the user's modeling operations so that they
I have defined a method called ccy which takes in a number num ,

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.